mirror of
				https://gitlab.com/Trygve/contour-creator.git
				synced 2025-10-31 00:40:46 +00:00 
			
		
		
		
	tried to implement finding contour lines
This commit is contained in:
		
							parent
							
								
									d046e18c43
								
							
						
					
					
						commit
						228945a767
					
				
							
								
								
									
										41
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -36,6 +36,8 @@ std::vector<Point> produce_cellmap(HeightMap* heightmap, float z) | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interval) | ||||
| { | ||||
|     int num_contours = (heightmap->max - heightmap->min)/interval; | ||||
| @ -48,9 +50,44 @@ std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interva | ||||
|         #pragma omp for | ||||
|         for (int i = 1; i <= num_contours; i++)  | ||||
|         { | ||||
|             vec_private.push_back(produce_cellmap(heightmap, heightmap->min + interval*i)); | ||||
|             auto points = produce_cellmap(heightmap, heightmap->min + interval*i) ; | ||||
|             std::vector<Point> line; | ||||
|             line.push_back(points.back()); | ||||
|             points.pop_back(); | ||||
| 
 | ||||
|             while (points.size() != 0){ | ||||
|                 Point current_point = points.back(); | ||||
|                 for (int j=0; j < points.size(); j++){ | ||||
|                     Point next = points[j]; | ||||
|                     if (&next != &points.back()) { | ||||
|                         if (next.x +1 == current_point.x) { | ||||
|                             line.push_back(next); | ||||
|                             points.erase(points.begin()+j); | ||||
|                         } | ||||
|                         else if (next.x -1 == current_point.x) { | ||||
|                             line.push_back(next); | ||||
|                             points.erase(points.begin()+j); | ||||
|                         } | ||||
|                         else if (next.y +1 == current_point.y) { | ||||
|                             line.push_back(next); | ||||
|                             points.erase(points.begin()+j); | ||||
|                         } | ||||
|                         else if (next.y -1 == current_point.y) { | ||||
|                             line.push_back(next); | ||||
|                             points.erase(points.begin()+j); | ||||
|                         } | ||||
|                         else { | ||||
|                             vec_private.push_back(line); | ||||
|                             std::vector<Point> line; | ||||
|                             line.push_back(points.back()); | ||||
|                             points.pop_back(); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         #pragma omp critical | ||||
| 
 | ||||
|         vector_contours.insert(vector_contours.end(), vec_private.begin(), vec_private.end()); | ||||
| 
 | ||||
|     } | ||||
| @ -184,5 +221,5 @@ int main(int argc, const char* argv[]) | ||||
|     auto cellmap = produce_cellmap(&map, 40); | ||||
|      | ||||
|     auto cellmaps = vector_cellmap(&map, 5); | ||||
|     //write_output_file(cellmaps, "out.geojson");
 | ||||
|     write_output_file(cellmaps, "out.geojson"); | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 esther
						esther