mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-11-21 14:50:18 +00:00
Started on continus line drawing
This commit is contained in:
parent
77467594bd
commit
9d8df3256d
@ -45,6 +45,8 @@ class Point
|
||||
int mscase;
|
||||
Point * next;
|
||||
Point * previous;
|
||||
bool endpoint = false;
|
||||
bool allocated = false;
|
||||
Point(int x, int y, int mscase){
|
||||
this -> x = x;
|
||||
this -> y = y;
|
||||
|
70
src/main.cpp
70
src/main.cpp
@ -53,29 +53,37 @@ std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interva
|
||||
{
|
||||
auto points = produce_cellmap(heightmap, heightmap->min + interval*i);
|
||||
|
||||
|
||||
for (int j = 0; j < points.size(); j++){
|
||||
Point current = points[j];
|
||||
Point* current = &points[j];
|
||||
//std::cout << points_allocated << " " << points.size() << "\n";
|
||||
for (int k = 0; k < points.size(); k++){
|
||||
Point candidate = points[k];
|
||||
if (candidate.next != nullptr) {
|
||||
if (candidate.x +1 == current.x) {
|
||||
current.next = &candidate;
|
||||
Point* candidate = &points[k];
|
||||
if (candidate->previous == nullptr and candidate != current->previous) {
|
||||
|
||||
if (candidate->x +1 == current->x && candidate->y == current->y) {
|
||||
current->next = candidate;
|
||||
candidate->previous = current;
|
||||
}
|
||||
else if (candidate.x -1 == current.x) {
|
||||
current.next = &candidate;
|
||||
else if (candidate->x -1 == current->x && candidate->y == current->y) {
|
||||
current->next = candidate;
|
||||
candidate->previous = current;
|
||||
}
|
||||
else if (candidate->y +1 == current->y && candidate->x == current->x) {
|
||||
current->next = candidate;
|
||||
candidate->previous = current;
|
||||
}
|
||||
else if (candidate->y -1 == current->y && candidate->x == current->x) {
|
||||
current->next = candidate;
|
||||
candidate->previous = current;
|
||||
}
|
||||
else {
|
||||
current->endpoint = true;
|
||||
}
|
||||
else if (candidate.y +1 == current.x) {
|
||||
current.next = &candidate;
|
||||
}
|
||||
else if (candidate.y -1 == current.x) {
|
||||
current.next = &candidate;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
vec_private.push_back(points);
|
||||
}
|
||||
#pragma omp critical
|
||||
|
||||
@ -169,24 +177,33 @@ void write_output_file(std::vector<std::vector<Point>> all_points, const char *f
|
||||
|
||||
|
||||
std::vector<Point> points = all_points[j];
|
||||
|
||||
for (int i = 0; i < points.size(); i++)
|
||||
Point* current = &points[0];
|
||||
while (true)
|
||||
{
|
||||
|
||||
//int x_raw = i%width;
|
||||
//int y_raw = i/height;
|
||||
int x_raw = points[i].x;
|
||||
int y_raw = points[i].y;
|
||||
int x_raw = current->x;
|
||||
int y_raw = current->y;
|
||||
auto [x, y] = local_to_projected(heightmap->geotransform, x_raw, y_raw);
|
||||
//auto [x_bl, y_bl, x_tr, y_tr] = marching_squares_lookup(*(cellmap->cells + i) );
|
||||
//std::cout << x << ", " << y << " ";
|
||||
//std::cout << x_raw << ", " << y_raw << " ";std::cout.flush();
|
||||
//geometry->setPoint( geometry->getNumPoints(), x+x_tr*0.25, y+y_tr*0.25 );
|
||||
//geometry->setPoint( geometry->getNumPoints(), x+x_bl*0.25, y+y_bl*0.25 );
|
||||
geometry->setPoint(geometry->getNumPoints(),x ,y );
|
||||
|
||||
|
||||
|
||||
|
||||
geometry->setPoint(geometry->getNumPoints(),x_raw ,y_raw );
|
||||
current->allocated = true;
|
||||
current = current->previous;
|
||||
//current sometimes becomes random pointer?????
|
||||
if (current == nullptr)
|
||||
{
|
||||
for (int k = 0; k<points.size(); k++)
|
||||
{
|
||||
if (points[k].endpoint and !points[k].allocated)
|
||||
{
|
||||
current = &points[k];
|
||||
}
|
||||
}
|
||||
if (current == nullptr){std::cout << "🫠"; break; }
|
||||
}
|
||||
}
|
||||
|
||||
if ( feature->SetGeometry(geometry) != OGRERR_NONE)
|
||||
@ -201,8 +218,7 @@ void write_output_file(std::vector<std::vector<Point>> all_points, const char *f
|
||||
exit( 1 );
|
||||
}
|
||||
OGRFeature::DestroyFeature( feature );
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
GDALClose( poDS );
|
||||
|
Loading…
Reference in New Issue
Block a user