Debugging without omp

This commit is contained in:
Trygve 2024-05-06 11:37:10 +02:00
parent 4f709d3b07
commit c535eec958

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++)
{
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++){
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";
for (int k = 0; k < points.size(); k++){
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;
if (!candidate->allocated) {
if (candidate->x == x +1 && candidate->y == y) {
candidate->allocated = true;
x = candidate->x;
y = candidate->y;
line.push_back(*candidate);
break;
}
else if (candidate->x -1 == current->x && candidate->y == current->y) {
current->next = candidate;
candidate->previous = current;
else if (candidate->x == x -1&& candidate->y == y) {
x = candidate->x;
y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break;
}
else if (candidate->y +1 == current->y && candidate->x == current->x) {
current->next = candidate;
candidate->previous = current;
else if (candidate->y == y +1&& candidate->x == x) {
x = candidate->x;
y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break;
}
else if (candidate->y -1 == current->y && candidate->x == current->x) {
current->next = candidate;
candidate->previous = current;
else if (candidate->y == y -1&& candidate->x == x) {
x = candidate->x;
y = candidate->y;
candidate->allocated = true;
line.push_back(*candidate);
break;
}
}
}
if (current->next == nullptr)
if (x == points[j].x && y == points[j].y)
{
current->endpoint = true;
std::cout << "🤕";std::cout.flush();
vector_contours.push_back(line);
std::vector<Point> line;
}
}
//vec_private.push_back(points);
vector_contours.push_back(points);
std::cout << vector_contours.size();
//vector_contours.push_back(points);
//std::cout << vector_contours.size();
}
//#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 );
std::vector<Point>* points = &all_points[j];
std::vector<Point> points = all_points[j];
Point* current = &points->at(0);
int points_allocated = 0;
while (true)
for (int k = 0; k < points.size(); k++)
{
//int x_raw = i%width;
//int y_raw = i/height;
int x_raw = current->x;
int y_raw = current->y;
int x_raw = points[k].x;
int y_raw = points[k].y;
/*
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();
//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 );
current->allocated = true;
current = current->previous;
geometry->setPoint(geometry->getNumPoints(),x_raw ,y_raw );
//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)