#include #include #include using namespace std; #define SCALE_MAP 2 #define GRID_ROWS 1000 #define GRID_COLS 1000 // You can change this to use dynamic memory, if you like. float gridMap[GRID_ROWS][GRID_COLS]; /************************************************************************* * * * Function inputMap converts the input map information into an * * initial occupancy grid, which is stored in gridMap. * * * (Here, the "output" parameter says whether to print out the scaled * * map; output = 1 ==> yes, print; output = 0 ==> no, don't print.) * *************************************************************************/ void inputMap(int output) { int i, j, m, n; char inputLine1[80], nextChar; int width, height, maxVal; ifstream inFile("hospital_section.pnm"); /* Initialize map to 0's, meaning all free space */ for (m=0; m> width >> height >> maxVal; cout << "Width = " << width << ", Height = " << height << endl; /* Read in map; */ for (i=0; i> nextChar; if (!nextChar) gridMap[i/SCALE_MAP][j/SCALE_MAP] = 1.0; } cout << "Map input complete.\n"; if (output) { ofstream outFile("scaled_hospital_section.pnm"); outFile << inputLine1 << endl; outFile << width/SCALE_MAP << " " << height/SCALE_MAP << endl << maxVal << endl; for (i=0; i