Debugging without omp

This commit is contained in:
Trygve 2024-05-06 11:37:10 +02:00
parent 4f709d3b07
commit c535eec958
1 changed files with 41 additions and 43 deletions

View File

@ -54,47 +54,60 @@ std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interva
for (int i = 1; i <= num_contours; i++) for (int i = 1; i <= num_contours; i++)
{ {
auto points = produce_cellmap(heightmap, heightmap->min + interval*i); auto points = produce_cellmap(heightmap, heightmap->min + interval*i);
std::vector<Point> line;
int x;
int y;
for (int j = 0; j < points.size(); j++){ for (int j = 0; j < points.size(); j++){
Point* current = &points[j]; Point* current = &points[j];
current->allocated=true;
line.push_back(points[j]);
x = points[j].x;
y = points[j].y;
//std::cout << points_allocated << " " << points.size() << "\n"; //std::cout << points_allocated << " " << points.size() << "\n";
for (int k = 0; k < points.size(); k++){ for (int k = 0; k < points.size(); k++){
Point* candidate = &points[k]; Point* candidate = &points[k];
if (candidate->previous == nullptr and candidate != current->previous) { if (!candidate->allocated) {
if (candidate->x == x +1 && candidate->y == y) {
if (candidate->x +1 == current->x && candidate->y == current->y) { candidate->allocated = true;
current->next = candidate; x = candidate->x;
candidate->previous = current; y = candidate->y;
line.push_back(*candidate);
break; break;
} }
else if (candidate->x -1 == current->x && candidate->y == current->y) { else if (candidate->x == x -1&& candidate->y == y) {
current->next = candidate; x = candidate->x;
candidate->previous = current; y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break; break;
} }
else if (candidate->y +1 == current->y && candidate->x == current->x) { else if (candidate->y == y +1&& candidate->x == x) {
current->next = candidate; x = candidate->x;
candidate->previous = current; y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break; break;
} }
else if (candidate->y -1 == current->y && candidate->x == current->x) { else if (candidate->y == y -1&& candidate->x == x) {
current->next = candidate; x = candidate->x;
candidate->previous = current; y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break; break;
} }
} }
} }
if (current->next == nullptr) if (x == points[j].x && y == points[j].y)
{ {
current->endpoint = true; vector_contours.push_back(line);
std::cout << "🤕";std::cout.flush(); std::vector<Point> line;
} }
} }
//vec_private.push_back(points); //vec_private.push_back(points);
vector_contours.push_back(points); //vector_contours.push_back(points);
std::cout << vector_contours.size(); //std::cout << vector_contours.size();
} }
//#pragma omp critical //#pragma omp critical
@ -187,18 +200,14 @@ void write_output_file(std::vector<std::vector<Point>> all_points, const char *f
feature->SetField( "Name", j ); feature->SetField( "Name", j );
std::vector<Point>* points = &all_points[j]; std::vector<Point> points = all_points[j];
for (int k = 0; k < points.size(); k++)
Point* current = &points->at(0);
int points_allocated = 0;
while (true)
{ {
//int x_raw = i%width; //int x_raw = i%width;
//int y_raw = i/height; //int y_raw = i/height;
int x_raw = current->x; int x_raw = points[k].x;
int y_raw = current->y; int y_raw = points[k].y;
/* /*
if (x_raw > 500 || y_raw > 400) if (x_raw > 500 || y_raw > 400)
{ {
@ -211,21 +220,10 @@ void write_output_file(std::vector<std::vector<Point>> all_points, const char *f
//std::cout << x_raw << ", " << y_raw << " ";std::cout.flush(); //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_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+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????? //current sometimes becomes random pointer?????
if (current == nullptr or current->allocated)
{
for (int k = 0; k<points->size(); k++)
{
if (points->at(k).endpoint and !points->at(k).allocated)
{
current = &points->at(k);
}
}
if (current == nullptr){std::cout << "🫠";std::cout.flush(); break; }
}
} }
if ( feature->SetGeometry(geometry) != OGRERR_NONE) if ( feature->SetGeometry(geometry) != OGRERR_NONE)