mirror of https://github.com/CGAL/cgal
Update examples (tabs vs spaces)
This commit is contained in:
parent
fcfc79dfc7
commit
f08b0bd1fb
|
|
@ -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\n";
|
||||
return 1;
|
||||
std::cerr << "Usage: " << argv[0] << " input.off\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
|
|
@ -23,8 +23,8 @@ 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.\n";
|
||||
return 1;
|
||||
std::cerr << argv[1] << " is not a valid off file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a property-map (it is an adaptor for this case)
|
||||
|
|
@ -34,8 +34,8 @@ int main(int argc, char **argv)
|
|||
|
||||
// compute sdf values using default parameters for number of rays, and cone angle
|
||||
std::pair<double, double> min_max_sdf = CGAL::sdf_values_computation(mesh, sdf_property_map);
|
||||
// print minimum & maximum sdf values
|
||||
std::cout << "minimum sdf: " << pair.first << " maximum sdf: " << pair.second << std::endl;
|
||||
// print minimum & maximum sdf values
|
||||
std::cout << "minimum sdf: " << pair.first << " maximum sdf: " << pair.second << std::endl;
|
||||
// print sdf values
|
||||
for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin();
|
||||
facet_it != mesh.facets_end(); ++facet_it)
|
||||
|
|
|
|||
|
|
@ -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\n";
|
||||
return 1;
|
||||
std::cerr << "Usage: " << argv[0] << " input.off\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
|
|
@ -23,8 +23,8 @@ 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.\n";
|
||||
return 1;
|
||||
std::cerr << argv[1] << " is not a valid off file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a property-map for segment-ids (it is an adaptor for this case)
|
||||
|
|
@ -33,8 +33,9 @@ int main(int argc, char **argv)
|
|||
boost::associative_property_map<Facet_int_map> segment_property_map(internal_segment_map);
|
||||
|
||||
// calculate SDF values and segment the mesh using default parameters.
|
||||
CGAL::surface_mesh_segmentation(mesh, segment_property_map);
|
||||
int number_of_segments = CGAL::surface_mesh_segmentation(mesh, 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)
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ int main(int argc, char **argv)
|
|||
// segment the mesh using default parameters for number of levels, and smoothing lambda
|
||||
int number_of_segments = CGAL::surface_mesh_segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map);
|
||||
|
||||
std::cout << "Number of segments: " << number_of_segments << std::endl;
|
||||
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)
|
||||
{
|
||||
// ids are between [0, number_of_segments -1]
|
||||
// ids are between [0, number_of_segments -1]
|
||||
std::cout << segment_property_map[facet_it] << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,33 +50,36 @@ int main(int argc, char **argv)
|
|||
std::cerr << argv[1] << " is not a valid off file.\n";
|
||||
return 1;
|
||||
}
|
||||
// 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)
|
||||
|
||||
// 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)
|
||||
{
|
||||
facet_it->id() = facet_id;
|
||||
}
|
||||
|
||||
// create a property-map for sdf values
|
||||
std::vector<double> sdf_values(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, double> sdf_property_map(&sdf_values);
|
||||
std::vector<double> sdf_values(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, double> sdf_property_map(&sdf_values);
|
||||
|
||||
CGAL::sdf_values_computation(mesh, 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)
|
||||
// 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] == sdf_values[facet_it->id()]) << std::endl;
|
||||
}
|
||||
std::cout << (sdf_property_map[facet_it] == sdf_values[facet_it->id()]) << std::endl;
|
||||
}
|
||||
|
||||
// create a property-map for segment-ids
|
||||
std::vector<double> segment_ids(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, double> segment_property_map(&segment_ids);
|
||||
std::vector<double> segment_ids(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, double> segment_property_map(&segment_ids);
|
||||
|
||||
CGAL::surface_mesh_segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map);
|
||||
|
||||
// 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)
|
||||
facet_it != mesh.facets_end(); ++facet_it)
|
||||
{
|
||||
std::cout << (segment_property_map[facet_it] == segment_ids[facet_it->id()]) << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue