diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp index 7fd6f4777b6..9b160b35a47 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp @@ -16,12 +16,12 @@ int main(int argc, char **argv) // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() ){ + if ( !input || !(input >> mesh) || mesh.empty() ) { std::cerr << "Not a valid off file." << std::endl; return 1; } - // create a property-map for segment-ids (it is an adaptor for this case) + // create a property-map for segment-ids typedef std::map Facet_int_map; Facet_int_map internal_segment_map; boost::associative_property_map segment_property_map(internal_segment_map); @@ -33,8 +33,7 @@ int main(int argc, char **argv) // print segment-ids for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { - std::cout << segment_property_map[facet_it] << std::endl; + facet_it != mesh.facets_end(); ++facet_it) { + std::cout << segment_property_map[facet_it] << std::endl; } } \ No newline at end of file diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp index df14186a6ec..a15b96c49e6 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp @@ -39,30 +39,28 @@ int main(int argc, char **argv) // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() ){ + if ( !input || !(input >> mesh) || mesh.empty() ) { std::cerr << "Not a valid off file." << std::endl; return 1; } - // assign id field for each facet + // assign id field for each facet int facet_id = 0; - for(Polyhedron::Facet_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it, ++facet_id) - { + for(Polyhedron::Facet_iterator facet_it = mesh.facets_begin(); + facet_it != mesh.facets_end(); ++facet_it, ++facet_id) { facet_it->id() = facet_id; } - // create a property-map for sdf values + // create a property-map for SDF values std::vector sdf_values(mesh.size_of_facets()); Polyhedron_with_id_to_vector_property_map sdf_property_map(&sdf_values); CGAL::compute_sdf_values(mesh, sdf_property_map); - // access sdf values (with constant-complexity) either via sdf_values or sdf_property_map + // access SDF values (with constant-complexity) either via sdf_values or sdf_property_map for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { - std::cout << sdf_property_map[facet_it] << std::endl; // or segment_ids[facet_it->id()] + facet_it != mesh.facets_end(); ++facet_it) { + std::cout << sdf_property_map[facet_it] << std::endl; } // create a property-map for segment-ids @@ -73,8 +71,7 @@ int main(int argc, char **argv) // access segment-ids (with constant-complexity) either via segment_ids or segment_property_map for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { - std::cout << segment_property_map[facet_it] << std::endl; // or segment_ids[facet_it->id()] + facet_it != mesh.facets_end(); ++facet_it) { + std::cout << segment_property_map[facet_it] << std::endl; } } \ No newline at end of file diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp index 5a100e23db9..01be0c52985 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp @@ -16,13 +16,13 @@ int main(int argc, char **argv) // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() ){ + if ( !input || !(input >> mesh) || mesh.empty() ) { std::cerr << "Not a valid off file." << std::endl; return 1; } - const int number_of_rays = 20; // cast 30 rays per facet - const double cone_angle = (1.0 / 2.0) * CGAL_PI; // use 90 degrees for cone opening-angle + const int number_of_rays = 20; // cast 20 rays per facet + const double cone_angle = CGAL_PI / 2.0; // use 90 degrees for cone opening-angle // create a property-map typedef std::map Facet_double_map; @@ -33,13 +33,12 @@ int main(int argc, char **argv) std::pair min_max_sdf = CGAL::compute_sdf_values(mesh, sdf_property_map, cone_angle, number_of_rays); // for using default parameters: CGAL::compute_sdf_values(mesh, sdf_property_map); - // print minimum & maximum sdf values - std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl; + // print minimum & maximum SDF values + std::cout << "minimum SDF: " << min_max_sdf.first << " maximum SDF: " << min_max_sdf.second << std::endl; - // print sdf values + // print SDF values for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { - std::cout << sdf_property_map[facet_it] << std::endl; + facet_it != mesh.facets_end(); ++facet_it) { + std::cout << sdf_property_map[facet_it] << std::endl; } } \ No newline at end of file diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp index 04ee18ae21e..c8200b68a91 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp @@ -16,41 +16,40 @@ int main(int argc, char **argv) // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() ){ + if ( !input || !(input >> mesh) || mesh.empty() ) { std::cerr << "Not a valid off file." << std::endl; return 1; } - // create a property-map for sdf values (it is an adaptor for this case) + // create a property-map for SDF values typedef std::map Facet_double_map; Facet_double_map internal_sdf_map; boost::associative_property_map sdf_property_map(internal_sdf_map); - // compute sdf values using default parameters for number of rays, and cone angle + // compute SDF values using default parameters for number of rays, and cone angle CGAL::compute_sdf_values(mesh, sdf_property_map); - // create a property-map for segment-ids (it is an adaptor for this case) + // create a property-map for segment-ids typedef std::map Facet_int_map; Facet_int_map internal_segment_map; boost::associative_property_map segment_property_map(internal_segment_map); // segment the mesh using default parameters for number of levels, and smoothing lambda - // Note that you can use your own scalar value, instead of using SDF calculation computed using the CGAL function + // Note that you can use your own scalar values, instead of using SDF values computed using the CGAL function int number_of_segments = CGAL::segment_from_sdf_values(mesh, sdf_property_map, segment_property_map); std::cout << "Number of segments: " << number_of_segments << std::endl; // print segment-ids for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { + facet_it != mesh.facets_end(); ++facet_it) { // ids are between [0, number_of_segments -1] - std::cout << segment_property_map[facet_it] << std::endl; + std::cout << segment_property_map[facet_it] << std::endl; } const int number_of_levels = 4; // use 4 clusters in soft clustering - const double smoothing_lambda = 0.3; // importance of surface features, between [0,1] + const double smoothing_lambda = 0.3; // importance of surface features, suggested to be in-between [0,1] - // Note that we can use same sdf values (sdf_property_map) over and over again for segmentation. + // Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation. // This feature becomes important when we want to segment the mesh several times with different parameters. CGAL::segment_from_sdf_values( mesh, sdf_property_map, segment_property_map, number_of_levels, smoothing_lambda);