mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-11-24 16:10:18 +00:00
Calculated cases for casemap
This commit is contained in:
parent
1a10f0df33
commit
fe2a369225
49
src/main.cpp
49
src/main.cpp
@ -7,14 +7,24 @@
|
|||||||
#include "gdal/gdal_priv.h"
|
#include "gdal/gdal_priv.h"
|
||||||
#include <gdal/gdal_frmts.h>
|
#include <gdal/gdal_frmts.h>
|
||||||
|
|
||||||
std::vector<CaseMap> produce_casemap(HeightMap* heightmap)
|
|
||||||
|
|
||||||
|
|
||||||
|
CaseMap produce_casemap(HeightMap* heightmap, float height)
|
||||||
{
|
{
|
||||||
std::vector<CaseMap> output;
|
|
||||||
int* test = (int *) CPLMalloc(sizeof(int)*heightmap->width*heightmap->height);
|
int* test = (int *) CPLMalloc(sizeof(int)*heightmap->width*heightmap->height);
|
||||||
*(test + 4) = 13;
|
for (int i; i<(heightmap->width-1)*(heightmap->height-1); i++) {
|
||||||
CaseMap casemap1(heightmap->width-1, heightmap->height-1, test);
|
int y = i/(heightmap->width-1);
|
||||||
output.push_back(casemap1);
|
int x = i%(heightmap->width-1);
|
||||||
return output;
|
*(test + i) = heightmap->get_pixel(x,y+1)*(heightmap->get_pixel(x,y+1)>heightmap->height) +
|
||||||
|
heightmap->get_pixel(x+1,y+1)*(heightmap->get_pixel(x+1,y+1)>heightmap->height)*2 +
|
||||||
|
heightmap->get_pixel(x+1,y)*(heightmap->get_pixel(x+1,y)>heightmap->height)*4 +
|
||||||
|
heightmap->get_pixel(x,y)*(heightmap->get_pixel(x,y)>heightmap->height)*8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CaseMap(heightmap->width-1, heightmap->height-1, test);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//(int a, int b, )
|
//(int a, int b, )
|
||||||
|
|
||||||
@ -26,17 +36,20 @@ int main(int argc, const char* argv[])
|
|||||||
|
|
||||||
std::cout << "x: " << map.width << " y: " << map.height << "\n";
|
std::cout << "x: " << map.width << " y: " << map.height << "\n";
|
||||||
std::cout << "max: " << map.max << " min: " << map.min << "\n";
|
std::cout << "max: " << map.max << " min: " << map.min << "\n";
|
||||||
/*
|
|
||||||
for (int y = 0; y < map.height; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < map.width; x++)
|
|
||||||
{
|
|
||||||
std::cout << map.get_pixel(x, y) << " ";
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
std::cout << "\nend🤡\n";
|
std::cout << "\nend🤡\n";
|
||||||
auto casemap = produce_casemap(&map);
|
auto casemap = produce_casemap(&map, 40.0);
|
||||||
std::cout << casemap[0].get_case( 4, 0);
|
|
||||||
|
for (int y = 0; y < casemap.height; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < casemap.width; x++)
|
||||||
|
{
|
||||||
|
if (casemap.get_case(x, y)) {
|
||||||
|
std::cout << casemap.get_case(x, y) << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// std::cout << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user