diff --git a/src/CaseMap.cpp b/src/CaseMap.cpp index f06b4fe..0de6d8b 100644 --- a/src/CaseMap.cpp +++ b/src/CaseMap.cpp @@ -1,6 +1,7 @@ +#include #include "CaseMap.hh" -CaseMap::CaseMap(int width, int height, int* cases) +CaseMap::CaseMap(int width, int height, uint8_t* cases) { this->width = width; this->height = height; diff --git a/src/CaseMap.hh b/src/CaseMap.hh index 78715b4..454202d 100644 --- a/src/CaseMap.hh +++ b/src/CaseMap.hh @@ -1,13 +1,14 @@ /** @brief stores the cases from marching squars for one elevation level */ +#include class CaseMap { public: - int* cases; + uint8_t* cases; //!< pointer to the first case in the array. uint8_t is a 8 bit unsigned integer int width; //!< width of image in cases int height; //!< height of image in cases - CaseMap(int width, int height, int* cases); + CaseMap(int width, int height, uint8_t* cases); int get_case(int x,int y); }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f552ddf..8fd656d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,17 +3,18 @@ #include #include #include +#include #include #include "gdal/gdal_priv.h" #include CaseMap produce_casemap(HeightMap* heightmap, float z) { - int *cases = (int *) CPLMalloc(sizeof(int)*(heightmap->width-1)*(heightmap->height-1)); + uint8_t *cases = (uint8_t *) CPLMalloc(sizeof(uint8_t)*(heightmap->width-1)*(heightmap->height-1)); for (int i = 0; i<(heightmap->width-1)*(heightmap->height-1); i++) { int y = i/(heightmap->width-1); int x = i%(heightmap->width-1); - int result = (heightmap->get_pixel(x,y+1)>z) + + uint8_t result = (heightmap->get_pixel(x,y+1)>z) + (heightmap->get_pixel(x+1,y+1)>z)*2 + (heightmap->get_pixel(x+1,y)>z)*4 + (heightmap->get_pixel(x,y)>z)*8; @@ -43,6 +44,6 @@ int main(int argc, const char* argv[]) std::cout << x << ","<< y << "=" << casemap.get_case(x, y) << " "; } } - std::cout << "\n"; + //std::cout << "\n"; } } \ No newline at end of file