mirror of https://github.com/CGAL/cgal
API function names are changed:
old name -> new name sdf_values_computation -> compute_sdf_values surface_mesh_segmentation_from_sdf_values -> segment_from_sdf_values surface_mesh_segmentation -> compute_sdf_values_and_segment Also example code files are changed accordingly.
This commit is contained in:
parent
d0305753de
commit
c6cc177bfa
|
|
@ -1,45 +1,46 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
std::ifstream input(argv[1]);
|
||||
|
||||
if ( !input || !(input >> mesh) || mesh.empty() ){
|
||||
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)
|
||||
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);
|
||||
|
||||
// calculate SDF values and segment the mesh using default parameters.
|
||||
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)
|
||||
{
|
||||
std::cout << segment_property_map[facet_it] << std::endl;
|
||||
}
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
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;
|
||||
}
|
||||
|
||||
// create a property-map for segment-ids (it is an adaptor for this case)
|
||||
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);
|
||||
|
||||
// calculate SDF values and segment the mesh using default parameters.
|
||||
int number_of_segments = CGAL::compute_sdf_values_and_segment(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)
|
||||
{
|
||||
std::cout << segment_property_map[facet_it] << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +1,86 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron;
|
||||
|
||||
// Property map using the fact that each facet is assigned an integer
|
||||
// to store associated information into a vector
|
||||
template<class PolyhedronWithId, class ValueType>
|
||||
struct Polyhedron_with_id_to_vector_property_map
|
||||
: public boost::put_get_helper<ValueType&,
|
||||
Polyhedron_with_id_to_vector_property_map<PolyhedronWithId, ValueType> >
|
||||
{
|
||||
public:
|
||||
typedef typename PolyhedronWithId::Facet_const_handle key_type;
|
||||
typedef ValueType value_type;
|
||||
typedef value_type& reference;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
|
||||
Polyhedron_with_id_to_vector_property_map() : internal_vector(NULL) { }
|
||||
Polyhedron_with_id_to_vector_property_map(std::vector<ValueType>* internal_vector)
|
||||
: internal_vector(internal_vector) { }
|
||||
|
||||
reference operator[](key_type key) const { return (*internal_vector)[key->id()]; }
|
||||
private:
|
||||
std::vector<ValueType>* internal_vector;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc !=2){
|
||||
std::cerr << "Usage: " << argv[0] << " input.off\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
std::ifstream input(argv[1]);
|
||||
|
||||
if ( !input || !(input >> mesh) || mesh.empty() ){
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
std::cout << (sdf_property_map[facet_it] == sdf_values[facet_it->id()]) << std::endl;
|
||||
}
|
||||
|
||||
// create a property-map for segment-ids
|
||||
std::vector<unsigned> segment_ids(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, unsigned> 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)
|
||||
{
|
||||
std::cout << (segment_property_map[facet_it] == segment_ids[facet_it->id()]) << std::endl;
|
||||
}
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron;
|
||||
|
||||
// Property map using the fact that each facet is assigned an integer
|
||||
// to store associated information into a vector
|
||||
template<class PolyhedronWithId, class ValueType>
|
||||
struct Polyhedron_with_id_to_vector_property_map
|
||||
: public boost::put_get_helper<ValueType&,
|
||||
Polyhedron_with_id_to_vector_property_map<PolyhedronWithId, ValueType> >
|
||||
{
|
||||
public:
|
||||
typedef typename PolyhedronWithId::Facet_const_handle key_type;
|
||||
typedef ValueType value_type;
|
||||
typedef value_type& reference;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
|
||||
Polyhedron_with_id_to_vector_property_map() : internal_vector(NULL) { }
|
||||
Polyhedron_with_id_to_vector_property_map(std::vector<ValueType>* internal_vector)
|
||||
: internal_vector(internal_vector) { }
|
||||
|
||||
reference operator[](key_type key) const { return (*internal_vector)[key->id()]; }
|
||||
private:
|
||||
std::vector<ValueType>* internal_vector;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc !=2){
|
||||
std::cerr << "Usage: " << argv[0] << " input.OFF" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
CGAL::compute_sdf_values(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)
|
||||
{
|
||||
std::cout << sdf_property_map[facet_it] << std::endl; // or segment_ids[facet_it->id()]
|
||||
}
|
||||
|
||||
// create a property-map for segment-ids
|
||||
std::vector<unsigned> segment_ids(mesh.size_of_facets());
|
||||
Polyhedron_with_id_to_vector_property_map<Polyhedron, unsigned> segment_property_map(&segment_ids);
|
||||
|
||||
CGAL::segment_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)
|
||||
{
|
||||
std::cout << segment_property_map[facet_it] << std::endl; // or segment_ids[facet_it->id()]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +1,64 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
std::ifstream input(argv[1]);
|
||||
|
||||
if ( !input || !(input >> mesh) || mesh.empty() ){
|
||||
std::cerr << argv[1] << " is not a valid off file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a property-map (it is an adaptor for this case)
|
||||
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::sdf_values_computation(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 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;
|
||||
}
|
||||
|
||||
int number_of_rays = 30; // cast 30 rays per facet
|
||||
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::sdf_values_computation(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;
|
||||
}
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
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;
|
||||
}
|
||||
|
||||
// create a property-map (it is an adaptor for this case)
|
||||
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);
|
||||
|
||||
// print minimum & maximum sdf values
|
||||
std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +1,62 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
std::ifstream input(argv[1]);
|
||||
|
||||
if ( !input || !(input >> mesh) || mesh.empty() ){
|
||||
std::cerr << argv[1] << " is not a valid off file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a property-map for sdf values (it is an adaptor for this case)
|
||||
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
|
||||
CGAL::sdf_values_computation(mesh, sdf_property_map);
|
||||
|
||||
// create a property-map for segment-ids (it is an adaptor for this case)
|
||||
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
|
||||
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;
|
||||
// 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]
|
||||
std::cout << segment_property_map[facet_it] << std::endl;
|
||||
}
|
||||
|
||||
int number_of_levels = 4; // use 4 clusters in soft clustering
|
||||
double smoothing_lambda = 0.3; // importance of surface features, between [0,1]
|
||||
|
||||
// Note that we can use 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::surface_mesh_segmentation_from_sdf_values(
|
||||
mesh, sdf_property_map, segment_property_map, number_of_levels, smoothing_lambda);
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
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;
|
||||
}
|
||||
|
||||
// create and read Polyhedron
|
||||
Polyhedron mesh;
|
||||
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;
|
||||
}
|
||||
|
||||
// create a property-map for sdf values (it is an adaptor for this case)
|
||||
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
|
||||
CGAL::compute_sdf_values(mesh, sdf_property_map);
|
||||
|
||||
// create a property-map for segment-ids (it is an adaptor for this case)
|
||||
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
|
||||
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)
|
||||
{
|
||||
// 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]
|
||||
|
||||
// Note that we can use 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);
|
||||
}
|
||||
|
|
@ -40,11 +40,11 @@ template <class Polyhedron, class SDFPropertyMap, class GeomTraits
|
|||
#endif
|
||||
>
|
||||
std::pair<double, double>
|
||||
sdf_values_computation(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
GeomTraits traits = GeomTraits())
|
||||
compute_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
GeomTraits traits = GeomTraits())
|
||||
{
|
||||
internal::Surface_mesh_segmentation<Polyhedron, GeomTraits> algorithm(
|
||||
polyhedron, traits);
|
||||
|
|
@ -81,12 +81,12 @@ template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap,
|
|||
#endif
|
||||
>
|
||||
int
|
||||
surface_mesh_segmentation_from_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
SegmentPropertyMap segment_ids,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
GeomTraits traits = GeomTraits())
|
||||
segment_from_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
SegmentPropertyMap segment_ids,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
GeomTraits traits = GeomTraits())
|
||||
{
|
||||
smoothing_lambda = (std::max)(0.0, (std::min)(1.0,
|
||||
smoothing_lambda)); // clip into [0-1]
|
||||
|
|
@ -126,13 +126,13 @@ template < class Polyhedron, class SegmentPropertyMap, class GeomTraits
|
|||
#endif
|
||||
>
|
||||
int
|
||||
surface_mesh_segmentation(const Polyhedron& polyhedron,
|
||||
SegmentPropertyMap segment_ids,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
GeomTraits traits = GeomTraits())
|
||||
compute_sdf_values_and_segment(const Polyhedron& polyhedron,
|
||||
SegmentPropertyMap segment_ids,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
GeomTraits traits = GeomTraits())
|
||||
{
|
||||
smoothing_lambda = (std::max)(0.0, (std::min)(1.0,
|
||||
smoothing_lambda)); // clip into [0-1]
|
||||
|
|
@ -143,9 +143,9 @@ surface_mesh_segmentation(const Polyhedron& polyhedron,
|
|||
boost::associative_property_map<Facet_double_map> sdf_property_map(
|
||||
internal_sdf_map);
|
||||
|
||||
sdf_values_computation<Polyhedron, boost::associative_property_map<Facet_double_map>, GeomTraits>
|
||||
compute_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, GeomTraits>
|
||||
(polyhedron, sdf_property_map, cone_angle, number_of_rays, traits);
|
||||
return surface_mesh_segmentation_from_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, SegmentPropertyMap, GeomTraits>
|
||||
return segment_from_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, SegmentPropertyMap, GeomTraits>
|
||||
(polyhedron, sdf_property_map, segment_ids, number_of_levels, smoothing_lambda,
|
||||
traits);
|
||||
}
|
||||
|
|
@ -154,41 +154,41 @@ surface_mesh_segmentation(const Polyhedron& polyhedron,
|
|||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
|
||||
template <class Polyhedron, class SDFPropertyMap>
|
||||
std::pair<double, double>
|
||||
sdf_values_computation(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
compute_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return sdf_values_computation<Polyhedron, SDFPropertyMap, typename Polyhedron::Traits>
|
||||
return compute_sdf_values<Polyhedron, SDFPropertyMap, typename Polyhedron::Traits>
|
||||
(polyhedron, sdf_values, cone_angle, number_of_rays, traits);
|
||||
}
|
||||
|
||||
template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap>
|
||||
int
|
||||
surface_mesh_segmentation_from_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
SegmentPropertyMap segment_ids,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
segment_from_sdf_values(const Polyhedron& polyhedron,
|
||||
SDFPropertyMap sdf_values,
|
||||
SegmentPropertyMap segment_ids,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return surface_mesh_segmentation_from_sdf_values<Polyhedron, SDFPropertyMap, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
return segment_from_sdf_values<Polyhedron, SDFPropertyMap, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
(polyhedron, sdf_values, segment_ids, number_of_levels, smoothing_lambda,
|
||||
traits);
|
||||
}
|
||||
|
||||
template <class Polyhedron, class SegmentPropertyMap>
|
||||
int
|
||||
surface_mesh_segmentation(const Polyhedron& polyhedron,
|
||||
SegmentPropertyMap segment_ids,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
compute_sdf_values_and_segment(const Polyhedron& polyhedron,
|
||||
SegmentPropertyMap segment_ids,
|
||||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
int number_of_rays = 25,
|
||||
int number_of_levels = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return surface_mesh_segmentation<Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
return compute_sdf_values_and_segment<Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
(polyhedron, segment_ids, cone_angle, number_of_rays, number_of_levels,
|
||||
smoothing_lambda, traits);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue