mirror of https://github.com/CGAL/cgal
Shorten the example, now default call is placed inside a comment.
This commit is contained in:
parent
e440cb2c1d
commit
cb5e7b0edb
|
|
@ -14,8 +14,8 @@ typedef CGAL::Polyhedron_3<Kernel> 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<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
||||
// create a property-map
|
||||
typedef std::map<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
||||
Facet_double_map internal_map;
|
||||
boost::associative_property_map<Facet_double_map> sdf_property_map(internal_map);
|
||||
|
||||
// compute sdf values using default parameters for number of rays, and cone angle
|
||||
std::pair<double, double> min_max_sdf = CGAL::compute_sdf_values(mesh, sdf_property_map);
|
||||
// use custom parameters for number of rays, and cone angle.
|
||||
std::pair<double, double> 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<Facet_double_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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue