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 853ceb5d99b..c267e986fa5 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 @@ -14,8 +14,8 @@ typedef CGAL::Polyhedron_3 Polyhedron; int main(int argc, char **argv) { if (argc !=2){ - std::cerr << "Usage: " << argv[0] << " input.off" << std::endl; - return 1; + std::cerr << "Usage: " << argv[0] << " input.off" << std::endl; + return 1; } // create and read Polyhedron @@ -23,42 +23,29 @@ int main(int argc, char **argv) std::ifstream input(argv[1]); if ( !input || !(input >> mesh) || mesh.empty() ){ - std::cerr << argv[1] << " is not a valid off file." << std::endl; - return 1; + std::cerr << argv[1] << " is 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 - // create a property-map (it is an adaptor for this case) - typedef std::map Facet_double_map; + // create a property-map + typedef std::map Facet_double_map; Facet_double_map internal_map; boost::associative_property_map sdf_property_map(internal_map); - // compute sdf values using default parameters for number of rays, and cone angle - std::pair min_max_sdf = CGAL::compute_sdf_values(mesh, sdf_property_map); + // use custom parameters for number of rays, and cone angle. + 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 + // 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; } - - const int number_of_rays = 30; // cast 30 rays per facet - const double cone_angle = (1.0 / 2.0) * CGAL_PI; // use 90 degrees for cone opening-angle - - // create another property-map - Facet_double_map internal_map_2; - boost::associative_property_map sdf_property_map_2(internal_map_2); - - // use custom parameters for number of rays, and cone angle. - CGAL::compute_sdf_values(mesh, sdf_property_map_2, cone_angle, number_of_rays); - - // print differences - for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) - { - std::cout << sdf_property_map[facet_it] - sdf_property_map_2[facet_it] << std::endl; - } } \ No newline at end of file