35 # include <netpbm/pgm.h>
50 for (
int i=-
CS/2; i<
CS/2; i++)
53 for (
int j=-
CS/2; j<
CS/2; j++)
57 for (
int i=-
CS/2; i<
CS/2; i++)
60 for (
int j=-
CS/2; j<
CS/2; j++)
70 #define unknown_gray 0xCC // seems to be the value of "unknown" in maps
73 readPGM(
const char *fname,
int *width,
int *height,
bool raw)
75 pm_init(
"navfn_tests",0);
78 pgmfile = fopen(fname,
"r");
81 printf(
"readPGM() Can't find file %s\n", fname);
85 printf(
"readPGM() Reading costmap file %s\n", fname);
89 pgm_readpgminit(pgmfile, &ncols, &nrows, &maxval, &format);
90 printf(
"readPGM() Size: %d x %d\n", ncols, nrows);
95 for (
int i=0; i<ncols*nrows; i++)
98 gray * row(pgm_allocrow(ncols));
102 for (
int ii = 0; ii < nrows; ii++) {
103 pgm_readpgmrow(pgmfile, row, ncols, maxval, format);
106 for (
int jj(ncols - 1); jj >= 0; --jj)
109 cmap[ii*ncols+jj] = v;
119 for (
int jj(ncols - 1); jj >= 0; --jj)
136 printf(
"readPGM() Found %d obstacle cells, %d free cells, %d unknown cells\n", otot, ftot, utot);