mirror of https://github.com/CGAL/cgal
improve formatting
This commit is contained in:
parent
41d59aae2b
commit
2996be191f
|
|
@ -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<Polyhedron::Facet_const_handle, int> Facet_int_map;
|
||||
Facet_int_map internal_segment_map;
|
||||
boost::associative_property_map<Facet_int_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)
|
||||
{
|
||||
facet_it != mesh.facets_end(); ++facet_it) {
|
||||
std::cout << segment_property_map[facet_it] << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ 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;
|
||||
}
|
||||
|
|
@ -47,22 +47,20 @@ int main(int argc, char **argv)
|
|||
// 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 != 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<double> sdf_values(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, double> 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
||||
|
|
@ -33,13 +33,12 @@ int main(int argc, char **argv)
|
|||
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
|
||||
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)
|
||||
{
|
||||
facet_it != mesh.facets_end(); ++facet_it) {
|
||||
std::cout << sdf_property_map[facet_it] << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Polyhedron::Facet_const_handle, double> Facet_double_map;
|
||||
Facet_double_map internal_sdf_map;
|
||||
boost::associative_property_map<Facet_double_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<Polyhedron::Facet_const_handle, int> Facet_int_map;
|
||||
Facet_int_map internal_segment_map;
|
||||
boost::associative_property_map<Facet_int_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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue