Loading [MathJax]/extensions/tex2jax.js
Surface Mesh Segmentation
All Classes Namespaces Files Functions Typedefs Pages
mesh_segmentation.h
Go to the documentation of this file.
1 #ifndef CGAL_SURFACE_MESH_SEGMENTATION_MESH_SEGMENTATION_H
2 #define CGAL_SURFACE_MESH_SEGMENTATION_MESH_SEGMENTATION_H
3 
8 #include <CGAL/internal/Surface_mesh_segmentation/Surface_mesh_segmentation.h>
9 #include <boost/config.hpp>
10 
12 namespace CGAL {
13 
14 
36 template <class Polyhedron, class SDFPropertyMap, class GeomTraits
37 #ifndef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
38  = typename Polyhedron::Traits
39 #endif
40 >
41 std::pair<double, double>
42 compute_sdf_values(const Polyhedron& polyhedron,
43  SDFPropertyMap sdf_values,
44  double cone_angle = 2.0 / 3.0 * CGAL_PI,
45  int number_of_rays = 25,
46  GeomTraits traits = GeomTraits())
47 {
48  internal::Surface_mesh_segmentation<Polyhedron, GeomTraits> algorithm(polyhedron, traits);
49  return algorithm.calculate_sdf_values(cone_angle, number_of_rays, sdf_values);
50 }
51 
52 
75 template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap, class GeomTraits
76 #ifndef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
77  = typename Polyhedron::Traits
78 #endif
79 >
80 int
81 segment_from_sdf_values(const Polyhedron& polyhedron,
82  SDFPropertyMap sdf_values,
83  SegmentPropertyMap segment_ids,
84  int number_of_levels = 5,
85  double smoothing_lambda = 0.26,
86  GeomTraits traits = GeomTraits())
87 {
88  smoothing_lambda = (std::max)(0.0, (std::min)(1.0, smoothing_lambda)); // clip into [0-1]
89 
90  internal::Surface_mesh_segmentation<Polyhedron, GeomTraits> algorithm(polyhedron, traits);
91  return algorithm.partition(number_of_levels, smoothing_lambda, sdf_values, segment_ids);
92 }
93 
94 
118 template < class Polyhedron, class SegmentPropertyMap, class GeomTraits
119 #ifndef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
120  = typename Polyhedron::Traits
121 #endif
122 >
123 int
124 compute_sdf_values_and_segment(const Polyhedron& polyhedron,
125  SegmentPropertyMap segment_ids,
126  double cone_angle = 2.0 / 3.0 * CGAL_PI,
127  int number_of_rays = 25,
128  int number_of_levels = 5,
129  double smoothing_lambda = 0.26,
130  GeomTraits traits = GeomTraits())
131 {
132  smoothing_lambda = (std::max)(0.0, (std::min)(1.0, smoothing_lambda)); // clip into [0-1]
133 
134  typedef std::map< typename Polyhedron::Facet_const_handle, double> Facet_double_map;
135  Facet_double_map internal_sdf_map;
136  boost::associative_property_map<Facet_double_map> sdf_property_map(internal_sdf_map);
137 
138  compute_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, GeomTraits>
139  (polyhedron, sdf_property_map, cone_angle, number_of_rays, traits);
140  return segment_from_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, SegmentPropertyMap, GeomTraits>
141  (polyhedron, sdf_property_map, segment_ids, number_of_levels, smoothing_lambda, traits);
142 }
143 
144 
145 #ifdef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
146 template <class Polyhedron, class SDFPropertyMap>
147 std::pair<double, double>
148 compute_sdf_values(const Polyhedron& polyhedron,
149  SDFPropertyMap sdf_values,
150  double cone_angle = 2.0 / 3.0 * CGAL_PI,
151  int number_of_rays = 25,
152  typename Polyhedron::Traits traits = typename Polyhedron::Traits())
153 {
154  return compute_sdf_values<Polyhedron, SDFPropertyMap, typename Polyhedron::Traits>
155  (polyhedron, sdf_values, cone_angle, number_of_rays, traits);
156 }
157 
158 template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap>
159 int
160 segment_from_sdf_values(const Polyhedron& polyhedron,
161  SDFPropertyMap sdf_values,
162  SegmentPropertyMap segment_ids,
163  int number_of_levels = 5,
164  double smoothing_lambda = 0.26,
165  typename Polyhedron::Traits traits = typename Polyhedron::Traits())
166 {
167  return segment_from_sdf_values<Polyhedron, SDFPropertyMap, SegmentPropertyMap, typename Polyhedron::Traits>
168  (polyhedron, sdf_values, segment_ids, number_of_levels, smoothing_lambda, traits);
169 }
170 
171 template <class Polyhedron, class SegmentPropertyMap>
172 int
173 compute_sdf_values_and_segment(const Polyhedron& polyhedron,
174  SegmentPropertyMap segment_ids,
175  double cone_angle = 2.0 / 3.0 * CGAL_PI,
176  int number_of_rays = 25,
177  int number_of_levels = 5,
178  double smoothing_lambda = 0.26,
179  typename Polyhedron::Traits traits = typename Polyhedron::Traits())
180 {
181  return compute_sdf_values_and_segment<Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits>
182  (polyhedron, segment_ids, cone_angle, number_of_rays, number_of_levels, smoothing_lambda, traits);
183 }
184 #endif
185 
186 }//namespace CGAL
187 
188 #endif // CGAL_SURFACE_MESH_SEGMENTATION_MESH_SEGMENTATION_H //