From 14c8e8dd18dbac7f6cbb6d65242c8b88dd40b717 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 14 Apr 2020 09:21:06 +0200 Subject: [PATCH] Add input file for gis_tutorial example --- .../Classification/gis_tutorial_example.cmd | 1 + .../Classification/gis_tutorial_example.cpp | 55 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 Classification/examples/Classification/gis_tutorial_example.cmd diff --git a/Classification/examples/Classification/gis_tutorial_example.cmd b/Classification/examples/Classification/gis_tutorial_example.cmd new file mode 100644 index 00000000000..3ee28617055 --- /dev/null +++ b/Classification/examples/Classification/gis_tutorial_example.cmd @@ -0,0 +1 @@ +data/b9_training.ply diff --git a/Classification/examples/Classification/gis_tutorial_example.cpp b/Classification/examples/Classification/gis_tutorial_example.cpp index d9936c9f54d..319c55cff69 100644 --- a/Classification/examples/Classification/gis_tutorial_example.cpp +++ b/Classification/examples/Classification/gis_tutorial_example.cpp @@ -120,7 +120,7 @@ Segment_3 isocontour_in_face (TIN::Face_handle fh, double isovalue) // Compute position of segment vertex double ratio = (isovalue - zbottom) / (ztop - zbottom); Point_3 p = CGAL::barycenter (p0, (1 - ratio), p1,ratio); - + if (source_found) target = p; else @@ -151,17 +151,17 @@ public: Polylines_visitor (Graph& graph, std::vector >& polylines) : polylines (polylines), graph(graph) { } - + void start_new_polyline() { polylines.push_back (std::vector()); } - + void add_node (typename Graph::vertex_descriptor vd) { polylines.back().push_back (graph[vd]); } - + void end_polyline() { // filter small polylines @@ -213,7 +213,7 @@ int main (int argc, char** argv) //! [Save DSM] using Mesh = CGAL::Surface_mesh; - + Mesh dsm_mesh; CGAL::copy_face_graph (dsm, dsm_mesh); std::ofstream dsm_ofile ("dsm.ply", std::ios_base::binary); @@ -236,7 +236,7 @@ int main (int argc, char** argv) TIN_with_info tin_with_info (boost::make_transform_iterator (points.begin(), idx_to_point_with_info), boost::make_transform_iterator (points.end(), idx_to_point_with_info)); - + //! [TIN_with_info] /////////////////////////////////////////////////////////////////// @@ -282,7 +282,7 @@ int main (int argc, char** argv) continue; current->info() = component_size.size(); ++ size; - + for (int i = 0; i < 3; ++ i) todo.push (current->neighbor(i)); } @@ -299,10 +299,10 @@ int main (int argc, char** argv) //! [Save TIN with info] Mesh tin_colored_mesh; - + Mesh::Property_map color_map = tin_colored_mesh.add_property_map("f:color").first; - + CGAL::copy_face_graph (tin_with_info, tin_colored_mesh, CGAL::parameters::face_to_face_output_iterator (boost::make_function_output_iterator @@ -320,7 +320,7 @@ int main (int argc, char** argv) r.get_int(64, 192)); } }))); - + std::ofstream tin_colored_ofile ("colored_tin.ply", std::ios_base::binary); CGAL::set_binary_mode (tin_colored_ofile); CGAL::write_ply (tin_colored_ofile, tin_colored_mesh); @@ -332,7 +332,7 @@ int main (int argc, char** argv) /////////////////////////////////////////////////////////////////// //! [Filtering] - int min_size = 100000; + int min_size = points.size() / 2; std::vector to_remove; for (TIN_with_info::Vertex_handle vh : tin_with_info.finite_vertex_handles()) @@ -359,7 +359,7 @@ int main (int argc, char** argv) std::cerr << to_remove.size() << " vertices(s) will be removed after filtering" << std::endl; for (TIN_with_info::Vertex_handle vh : to_remove) tin_with_info.remove (vh); - + //! [Filtering] /////////////////////////////////////////////////////////////////// @@ -368,7 +368,7 @@ int main (int argc, char** argv) // Copy and keep track of overly large faces Mesh dtm_mesh; - + std::vector face_selection; Mesh::Property_map face_selection_map = dtm_mesh.add_property_map("is_selected", false).first; @@ -429,7 +429,7 @@ int main (int argc, char** argv) face_selection.push_back(fi); std::cerr << face_selection.size() << " face(s) are selected for removal after expansion" << std::endl; - + for (Mesh::Face_index fi : face_selection) CGAL::Euler::remove_face (halfedge(fi, dtm_mesh), dtm_mesh); dtm_mesh.collect_garbage(); @@ -474,7 +474,7 @@ int main (int argc, char** argv) if (hi != outer_hull) CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (dtm_mesh, hi, CGAL::Emptyset_iterator(), CGAL::Emptyset_iterator()); - + // Save DTM with holes filled std::ofstream dtm_filled_ofile ("dtm_filled.ply", std::ios_base::binary); CGAL::set_binary_mode (dtm_filled_ofile); @@ -493,7 +493,7 @@ int main (int argc, char** argv) CGAL::set_binary_mode (dtm_remeshed_ofile); CGAL::write_ply (dtm_remeshed_ofile, dtm_mesh); dtm_remeshed_ofile.close(); - + //! [Remeshing] /////////////////////////////////////////////////////////////////// @@ -503,7 +503,7 @@ int main (int argc, char** argv) //! [Rastering] CGAL::Bbox_3 bbox = CGAL::bbox_3 (points.points().begin(), points.points().end()); - + // Generate raster image 1920-pixels large std::size_t width = 1920; std::size_t height = std::size_t((bbox.ymax() - bbox.ymin()) * 1920 / (bbox.xmax() - bbox.xmin())); @@ -532,7 +532,7 @@ int main (int argc, char** argv) Point_3 query (bbox.xmin() + x * (bbox.xmax() - bbox.xmin()) / double(width), bbox.ymin() + (height-y) * (bbox.ymax() - bbox.ymin()) / double(height), 0); // not relevant for location in 2D - + location = dtm_clean.locate (query, location); // Points outside the convex hull will be colored black @@ -560,7 +560,7 @@ int main (int argc, char** argv) } raster_ofile.close(); - + //! [Rastering] /////////////////////////////////////////////////////////////////// @@ -591,7 +591,7 @@ int main (int argc, char** argv) vh->point() = Point_3 (vh->point().x(), vh->point().y(), z); } - + /////////////////////////////////////////////////////////////////// //! [Contouring extraction] @@ -647,7 +647,7 @@ int main (int argc, char** argv) //! [Contouring split] /////////////////////////////////////////////////////////////////// - + /////////////////////////////////////////////////////////////////// //! [Contouring simplify] @@ -676,7 +676,7 @@ int main (int argc, char** argv) std::cerr << nb_vertices << " vertices remaining after simplification (" << 100. * (nb_vertices / double(map_p2v.size())) << "%)" << std::endl; - + // Output to WKT file std::ofstream simplified_ofile ("simplified.wkt"); simplified_ofile.precision(18); @@ -693,11 +693,11 @@ int main (int argc, char** argv) Point_set::Property_map training_map; bool training_found; std::tie (training_map, training_found) = points.property_map("training"); - + if (training_found) { std::cerr << "Classifying ground/vegetation/building" << std::endl; - + // Create labels Classification::Label_set labels ({ "ground", "vegetation", "building" }); @@ -705,7 +705,7 @@ int main (int argc, char** argv) Classification::Feature_set features; Classification::Point_set_feature_generator generator (points, points.point_map(), 5); // 5 scales - + #ifdef CGAL_LINKED_WITH_TBB // If TBB is used, features can be computed in parallel features.begin_parallel_additions(); @@ -740,11 +740,10 @@ int main (int argc, char** argv) classified_ofile << points; classified_ofile.close(); } - + //! [Classification] /////////////////////////////////////////////////////////////////// - + return EXIT_SUCCESS; } -