Compare commits

..

3 Commits

Author SHA1 Message Date
25354cc115 Remove build dir first 2024-04-11 15:25:30 +02:00
Esther Zijerveld
666987ca1e Merge branch 'main' of gitlab.com:Trygve/contour-creator 2024-04-11 15:24:12 +02:00
Esther Zijerveld
ec8ee8d056 Started on case map class 2024-04-11 15:23:44 +02:00
4 changed files with 52 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#! /bin/sh #! /bin/sh
rm -rf build
mkdir build mkdir build
cmake -DCMAKE_BUILD_TYPE=Debug -B build cmake -DCMAKE_BUILD_TYPE=Debug -B build
cmake --build build --parallel cmake --build build --parallel

22
src/casemap.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <gdal/gdal.h>
#include "gdal/gdal_priv.h"
#include <iostream>
#include <stdfloat>
#include "CaseMap.hh"
#include "HeightMap.hh"
CaseMap::CaseMap(int width, int height, int* cases)
{
this->width = width;
this->height = height;
this->cases = cases;
}
int CaseMap::get_case(int x, int y)
{
// all the pixels are in an array of floats from left to right, top to bottom
int offset = ((this->width * y) + x);
return *(this->cases + offset);
}

13
src/casemap.hh Normal file
View File

@ -0,0 +1,13 @@
/**
@brief stores the cases produced from image
*/
class CaseMap
{
public:
float* data;
int width; //!< width of image in cases
int height; //!< height of image in cases
CaseMap(int width, int height, int* cases);
float get_case(int x,int y);
};

View File

@ -1,6 +1,20 @@
#include "HeightMap.hh" #include "HeightMap.hh"
#include "CaseMap.hh"
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include <vector>
#include <gdal/gdal.h>
std::vector<CaseMap> produce_casemap(HeightMap* heightmap)
{
std::vector<CaseMap> output;
int* test = (int *) CPLMalloc(sizeof(int)*heightmap->width*heightmap->height);
CaseMap casemap1(heightmap->width-1, heightmap->height-1, test);
output.push_back(casemap1);
return output
}
//(int a, int b, )
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
@ -19,4 +33,6 @@ int main(int argc, const char* argv[])
std::cout << "\n"; std::cout << "\n";
} }
std::cout << "\nend🤡\n"; std::cout << "\nend🤡\n";
casemap = produce_casemap(map);
std::cout << casemap.get_case( 2, 2)
} }