Tried to fix check for if cases can connect

This commit is contained in:
Trygve 2024-05-07 16:18:42 +02:00
parent 47d0e29868
commit 5845ae6693

View File

@ -45,6 +45,11 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
int num_contours = (heightmap->max - heightmap->min)/interval; int num_contours = (heightmap->max - heightmap->min)/interval;
std::vector<std::vector<Point>> vector_contours; std::vector<std::vector<Point>> vector_contours;
std::array<int,8> north{4, 5,6,7,8,9,10,11};
std::array<int,8> south{1,2,5,6,9,10,13,14};
std::array<int,8> east{2,3,4,5,10,11,12,13};
std::array<int,8> west{1,3,5,7,8,10,12,14};
#pragma omp parallel #pragma omp parallel
{ {
std::vector<std::vector<Point>> vec_private; std::vector<std::vector<Point>> vec_private;
@ -64,46 +69,10 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
for (int j = 0; j < points.size(); j++){ for (int j = 0; j < points.size(); j++){
for (int k = 0; k < points.size(); k++){ for (int k = 0; k < points.size(); k++){
Point* candidate = &points[k]; Point* candidate = &points[k];
std::array<int,8> north{4, 5,6,7,8,9,10,11};
std::array<int,8> south{1,2,5,6,9,10,13,14};
std::array<int,8> east{2,3,4,5,10,11,12,13};
std::array<int,8> west{1,3,5,7,8,10,12,14};
std::vector<int> possible_connections;
switch (candidate->mscase) {
case 1:
case 14:
possible_connections.insert(possible_connections.end(), east.begin(), east.end());
possible_connections.insert(possible_connections.end(), north.begin(), north.end());
case 2:
case 13:
possible_connections.insert(possible_connections.end(), west.begin(), west.end());
possible_connections.insert(possible_connections.end(), south.begin(), south.end());
case 3:
case 12:
possible_connections.insert(possible_connections.end(), west.begin(), west.end());
possible_connections.insert(possible_connections.end(), east.begin(), east.end());
case 4:
case 11:
possible_connections.insert(possible_connections.end(), west.begin(), west.end());
possible_connections.insert(possible_connections.end(), north.begin(), north.end());
case 5:
case 10:
possible_connections.insert(possible_connections.end(), north.begin(), south.end());
possible_connections.insert(possible_connections.end(), south.begin(), south.end());
possible_connections.insert(possible_connections.end(), west.begin(), west.end());
possible_connections.insert(possible_connections.end(), east.begin(), east.end());
case 6:
case 9:
possible_connections.insert(possible_connections.end(), north.begin(), south.end());
possible_connections.insert(possible_connections.end(), south.begin(), south.end());
case 7:
case 8:
possible_connections.insert(possible_connections.end(), north.begin(), south.end());
possible_connections.insert(possible_connections.end(), east.begin(), east.end());
}
if (!candidate->allocated) { if (!candidate->allocated) {
if (candidate->x == x +1 && candidate->y == y && is_in(candidate->mscase, west) && is_in(current_case, east)) { if (candidate->x == x +1 && candidate->y == y && is_in(current_case, east)) {
candidate->allocated = true; candidate->allocated = true;
x = candidate->x; x = candidate->x;
y = candidate->y; y = candidate->y;
@ -112,7 +81,7 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
points_allocated++; points_allocated++;
break; break;
} }
else if (candidate->x == x -1 && candidate->y == y && is_in(candidate->mscase, east ) && is_in(current_case, west)) { else if (candidate->x == x -1 && candidate->y == y && is_in(current_case, west)) {
x = candidate->x; x = candidate->x;
y = candidate->y; y = candidate->y;
current_case = candidate->mscase; current_case = candidate->mscase;
@ -121,7 +90,7 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
points_allocated++; points_allocated++;
break; break;
} }
else if (candidate->x == x && candidate->y == y + 1 && is_in(candidate->mscase, south) && is_in(current_case, north)) { else if (candidate->x == x && candidate->y == y + 1 && is_in(current_case, north)) {
x = candidate->x; x = candidate->x;
y = candidate->y; y = candidate->y;
current_case = candidate->mscase; current_case = candidate->mscase;
@ -130,7 +99,7 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
points_allocated++; points_allocated++;
break; break;
} }
else if (candidate->x == x && candidate->y == y - 1 && is_in(candidate->mscase, north) && is_in(current_case, south)) { else if (candidate->x == x && candidate->y == y - 1 && is_in(current_case, south)) {
x = candidate->x; x = candidate->x;
y = candidate->y; y = candidate->y;
current_case = candidate->mscase; current_case = candidate->mscase;
@ -153,6 +122,7 @@ std::vector<std::vector<Point>> create_lines(HeightMap* heightmap, int interval)
line.push_back(*candidate); line.push_back(*candidate);
x = candidate->x; x = candidate->x;
y = candidate->y; y = candidate->y;
current_case = candidate->mscase;
points_allocated++; points_allocated++;
break; break;
} }