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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc !=2){
|
if (argc !=2){
|
||||||
std::cerr << "Usage: " << argv[0] << " input.off" << std::endl;
|
std::cerr << "Usage: " << argv[0] << " input.off" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and read Polyhedron
|
// create and read Polyhedron
|
||||||
|
|
@ -23,19 +23,23 @@ int main(int argc, char **argv)
|
||||||
std::ifstream input(argv[1]);
|
std::ifstream input(argv[1]);
|
||||||
|
|
||||||
if ( !input || !(input >> mesh) || mesh.empty() ){
|
if ( !input || !(input >> mesh) || mesh.empty() ){
|
||||||
std::cerr << argv[1] << " is not a valid off file." << std::endl;
|
std::cerr << argv[1] << " is not a valid off file." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a property-map (it is an adaptor for this case)
|
const int number_of_rays = 20; // cast 30 rays per facet
|
||||||
typedef std::map<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
const double cone_angle = (1.0 / 2.0) * CGAL_PI; // use 90 degrees for cone opening-angle
|
||||||
|
|
||||||
|
// create a property-map
|
||||||
|
typedef std::map<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
||||||
Facet_double_map internal_map;
|
Facet_double_map internal_map;
|
||||||
boost::associative_property_map<Facet_double_map> sdf_property_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
|
// 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);
|
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;
|
std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl;
|
||||||
|
|
||||||
// print sdf values
|
// print sdf values
|
||||||
|
|
@ -44,21 +48,4 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::cout << sdf_property_map[facet_it] << std::endl;
|
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