mirror of https://github.com/CGAL/cgal
introduce the point property map
This commit is contained in:
parent
8b88547955
commit
aec7e99e6a
|
|
@ -26,7 +26,7 @@ typedef Hidden_type FT;
|
|||
/// @{
|
||||
|
||||
/*!
|
||||
The vector type.
|
||||
The point type.
|
||||
*/
|
||||
typedef Hidden_type Point_3;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ template <bool Fast_sdf_calculation_mode, class Polyhedron,
|
|||
class SDFPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename boost::property_map<Polyhedron, boost::vertex_point_t>::type
|
||||
#endif
|
||||
>
|
||||
std::pair<double, double>
|
||||
|
|
@ -40,12 +44,12 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
std::size_t number_of_rays = 25,
|
||||
bool postprocess = true,
|
||||
GeomTraits traits = GeomTraits())
|
||||
GeomTraits traits = GeomTraits(),
|
||||
PointPropertyMap ppmap = PointPropertyMap())
|
||||
{
|
||||
typedef typename boost::property_map<Polyhedron, vertex_point_t>::type VPMap;
|
||||
VPMap vpm = get(vertex_point,const_cast<Polyhedron&>(polyhedron));
|
||||
internal::Surface_mesh_segmentation<Polyhedron, GeomTraits, VPMap,Fast_sdf_calculation_mode>
|
||||
algorithm(polyhedron, traits,vpm);
|
||||
typedef PointPropertyMap VPMap;
|
||||
internal::Surface_mesh_segmentation<Polyhedron, GeomTraits, VPMap, Fast_sdf_calculation_mode>
|
||||
algorithm(polyhedron, traits, ppmap);
|
||||
return algorithm.calculate_sdf_values(cone_angle, number_of_rays,
|
||||
sdf_values_map, postprocess);
|
||||
}
|
||||
|
|
@ -62,8 +66,9 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
* @pre @a polyhedron.is_pure_triangle()
|
||||
*
|
||||
* @tparam Polyhedron a %CGAL polyhedron
|
||||
* @tparam SDFPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::face_handle` as key and `double` as value type
|
||||
* @tparam SDFPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::%face_descriptor` as key and `double` as value type
|
||||
* @tparam GeomTraits a model of SegmentationGeomTraits
|
||||
* @tparam PointPropertyMap a `ReadablePropertyMap` with `boost::graph_traits<Polyhedron>::%vertex_descriptor` as key and `GeomTraits::Point_3` as value type.
|
||||
*
|
||||
* @param polyhedron surface mesh on which SDF values are computed
|
||||
* @param[out] sdf_values_map the SDF value of each facet
|
||||
|
|
@ -71,12 +76,17 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
* @param number_of_rays number of rays picked in the cone of each facet. In our experiments, we observe that increasing the number of rays beyond the default has little effect on the quality of the segmentation result
|
||||
* @param postprocess if `true`, `CGAL::sdf_values_postprocessing` is called on raw SDF value computed.
|
||||
* @param traits traits class
|
||||
* @param ppmap point property map. An overload is provided with `get(boost::vertex_point,polyhedron)` as default.
|
||||
*
|
||||
* @return minimum and maximum raw SDF values if @a postprocess is `true`, otherwise minimum and maximum SDF values (before linear normalization)
|
||||
*/
|
||||
template <class Polyhedron, class SDFPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename boost::property_map<Polyhedron, boost::vertex_point_t>::type
|
||||
#endif
|
||||
>
|
||||
std::pair<double, double>
|
||||
|
|
@ -85,10 +95,11 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
double cone_angle = 2.0 / 3.0 * CGAL_PI,
|
||||
std::size_t number_of_rays = 25,
|
||||
bool postprocess = true,
|
||||
GeomTraits traits = GeomTraits())
|
||||
GeomTraits traits = GeomTraits(),
|
||||
PointPropertyMap ppmap = PointPropertyMap())
|
||||
{
|
||||
return sdf_values<true, Polyhedron, SDFPropertyMap, GeomTraits>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits);
|
||||
return sdf_values<true, Polyhedron, SDFPropertyMap, GeomTraits, PointPropertyMap>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits, ppmap);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -109,7 +120,7 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
* @pre Raw values should be greater or equal to 0. -1 indicates when no value could be computed
|
||||
*
|
||||
* @tparam Polyhedron a %CGAL polyhedron
|
||||
* @tparam SDFPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::face_handle` as key and `double` as value type
|
||||
* @tparam SDFPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::%face_descriptor` as key and `double` as value type
|
||||
*
|
||||
* @param polyhedron surface mesh on which SDF values are computed
|
||||
* @param[in, out] sdf_values_map the SDF value of each facet
|
||||
|
|
@ -147,9 +158,10 @@ sdf_values_postprocessing(const Polyhedron& polyhedron,
|
|||
* @pre @a number_of_clusters > 0
|
||||
*
|
||||
* @tparam Polyhedron a %CGAL polyhedron
|
||||
* @tparam SDFPropertyMap a `ReadablePropertyMap` with `boost::graph_traits<Polyhedron>::face_handle` as key and `double` as value type
|
||||
* @tparam SegmentPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::face_handle` as key and `std::size_t` as value type
|
||||
* @tparam SDFPropertyMap a `ReadablePropertyMap` with `boost::graph_traits<Polyhedron>::%face_descriptor` as key and `double` as value type
|
||||
* @tparam SegmentPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::%face_descriptor` as key and `std::size_t` as value type
|
||||
* @tparam GeomTraits a model of SegmentationGeomTraits
|
||||
* @tparam PointPropertyMap a `ReadablePropertyMap` with `boost::graph_traits<Polyhedron>::%vertex_descriptor` as key and `GeomTraits::Point_3` as value type.
|
||||
*
|
||||
* @param polyhedron surface mesh corresponding to the SDF values
|
||||
* @param sdf_values_map the SDF value of each facet between [0-1]
|
||||
|
|
@ -158,6 +170,7 @@ sdf_values_postprocessing(const Polyhedron& polyhedron,
|
|||
* @param smoothing_lambda factor which indicates the importance of the surface features for the energy minimization. It is recommended to choose a value in the interval [0,1]. See the section \ref Surface_mesh_segmentationGraphCut for more details.
|
||||
* @param output_cluster_ids if `false` fill `segment_ids` with segment-ids, and with cluster-ids otherwise (see \cgalFigureRef{Cluster_vs_segment})
|
||||
* @param traits traits class
|
||||
* @param ppmap point property map. An overload is provided with `get(boost::vertex_point,polyhedron)` as default.
|
||||
*
|
||||
* @return number of segments if `output_cluster_ids` is set to `false` and `number_of_clusters` otherwise
|
||||
*/
|
||||
|
|
@ -165,6 +178,10 @@ template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap,
|
|||
class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename boost::property_map<Polyhedron, boost::vertex_point_t>::type
|
||||
#endif
|
||||
>
|
||||
std::size_t
|
||||
|
|
@ -174,11 +191,11 @@ segmentation_from_sdf_values( const Polyhedron& polyhedron,
|
|||
std::size_t number_of_clusters = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
bool output_cluster_ids = false,
|
||||
GeomTraits traits = GeomTraits())
|
||||
GeomTraits traits=GeomTraits(),
|
||||
PointPropertyMap ppmap=PointPropertyMap())
|
||||
{
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type VPMap;
|
||||
internal::Surface_mesh_segmentation<Polyhedron, GeomTraits, VPMap> algorithm(
|
||||
polyhedron, traits, get(vertex_point,const_cast<Polyhedron&>(polyhedron)));
|
||||
internal::Surface_mesh_segmentation<Polyhedron, GeomTraits, VPMap> algorithm(polyhedron, traits, ppmap);
|
||||
return algorithm.partition(number_of_clusters, smoothing_lambda, sdf_values_map,
|
||||
segment_ids, !output_cluster_ids);
|
||||
}
|
||||
|
|
@ -189,7 +206,11 @@ template < bool Fast_sdf_calculation_mode, class Polyhedron,
|
|||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
#endif
|
||||
>
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename boost::property_map<Polyhedron, boost::vertex_point_t>::type
|
||||
#endif
|
||||
>
|
||||
std::size_t
|
||||
segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
||||
SegmentPropertyMap segment_ids,
|
||||
|
|
@ -198,7 +219,8 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
std::size_t number_of_clusters = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
bool output_cluster_ids = false,
|
||||
GeomTraits traits = GeomTraits())
|
||||
GeomTraits traits=GeomTraits(),
|
||||
PointPropertyMap ppmap=PointPropertyMap())
|
||||
{
|
||||
typedef typename boost::graph_traits<Polyhedron>::face_descriptor face_descriptor;
|
||||
typedef std::map<face_descriptor, double>
|
||||
|
|
@ -208,10 +230,10 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
internal_sdf_map);
|
||||
|
||||
sdf_values<Fast_sdf_calculation_mode, Polyhedron, boost::associative_property_map<Facet_double_map>, GeomTraits>
|
||||
(polyhedron, sdf_property_map, cone_angle, number_of_rays, true, traits);
|
||||
return segmentation_from_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, SegmentPropertyMap, GeomTraits>
|
||||
(polyhedron, sdf_property_map, cone_angle, number_of_rays, true, traits, ppmap);
|
||||
return segmentation_from_sdf_values<Polyhedron, boost::associative_property_map<Facet_double_map>, SegmentPropertyMap, GeomTraits, PointPropertyMap>
|
||||
(polyhedron, sdf_property_map, segment_ids, number_of_clusters,
|
||||
smoothing_lambda, output_cluster_ids, traits);
|
||||
smoothing_lambda, output_cluster_ids, traits, ppmap);
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
|
|
@ -233,8 +255,9 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
* @pre @a number_of_clusters > 0
|
||||
*
|
||||
* @tparam Polyhedron a %CGAL polyhedron
|
||||
* @tparam SegmentPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::face_handle` as key and `std::size_t` as value type
|
||||
* @tparam SegmentPropertyMap a `ReadWritePropertyMap` with `boost::graph_traits<Polyhedron>::%face_descriptor` as key and `std::size_t` as value type
|
||||
* @tparam GeomTraits a model of SegmentationGeomTraits
|
||||
* @tparam PointPropertyMap a `ReadablePropertyMap` with `boost::graph_traits<Polyhedron>::%vertex_descriptor` as key and `GeomTraits::Point_3` as value type.
|
||||
*
|
||||
* @param polyhedron surface mesh on which SDF values are computed
|
||||
* @param[out] segment_ids the segment or cluster id of each facet
|
||||
|
|
@ -244,12 +267,17 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
* @param smoothing_lambda factor which indicates the importance of the surface features for the energy minimization. It is recommended to choose a value in the interval [0,1]. See the section \ref Surface_mesh_segmentationGraphCut for more details.
|
||||
* @param output_cluster_ids if `false` fill `segment_ids` with segment-ids, and with cluster-ids otherwise (see \cgalFigureRef{Cluster_vs_segment})
|
||||
* @param traits traits class
|
||||
* @param ppmap point property map. An overload is provided with `get(boost::vertex_point,polyhedron)` as default.
|
||||
*
|
||||
* @return number of segments if `output_cluster_ids` is set to `false` and `number_of_clusters` otherwise
|
||||
*/
|
||||
template < class Polyhedron, class SegmentPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename boost::property_map<Polyhedron, boost::vertex_point_t>::type
|
||||
#endif
|
||||
>
|
||||
std::size_t
|
||||
|
|
@ -260,15 +288,18 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
std::size_t number_of_clusters = 5,
|
||||
double smoothing_lambda = 0.26,
|
||||
bool output_cluster_ids = false,
|
||||
GeomTraits traits = GeomTraits())
|
||||
GeomTraits traits=GeomTraits(),
|
||||
PointPropertyMap ppmap=PointPropertyMap())
|
||||
{
|
||||
return segmentation_via_sdf_values<true, Polyhedron, SegmentPropertyMap, GeomTraits>
|
||||
return segmentation_via_sdf_values<true, Polyhedron, SegmentPropertyMap, GeomTraits, PointPropertyMap>
|
||||
(polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters,
|
||||
smoothing_lambda, output_cluster_ids, traits);
|
||||
smoothing_lambda, output_cluster_ids, traits, ppmap);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// Even if CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES is not defined,
|
||||
// we need these overloads for the default of the point property map
|
||||
template <bool Fast_sdf_calculation_mode, class Polyhedron, class SDFPropertyMap>
|
||||
std::pair<double, double>
|
||||
sdf_values(const Polyhedron& polyhedron,
|
||||
|
|
@ -278,8 +309,10 @@ sdf_values(const Polyhedron& polyhedron,
|
|||
bool postprocess = true,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return sdf_values<Fast_sdf_calculation_mode, Polyhedron, SDFPropertyMap, typename Polyhedron::Traits>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits);
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type Ppmap;
|
||||
Ppmap ppmap = get(boost::vertex_point, const_cast<Polyhedron&>(polyhedron));
|
||||
return sdf_values<Fast_sdf_calculation_mode, Polyhedron, SDFPropertyMap, typename Polyhedron::Traits, Ppmap>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits, ppmap);
|
||||
}
|
||||
|
||||
template < class Polyhedron, class SDFPropertyMap>
|
||||
|
|
@ -291,8 +324,10 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
bool postprocess = true,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return sdf_values<true, Polyhedron, SDFPropertyMap, typename Polyhedron::Traits>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits);
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type Ppmap;
|
||||
Ppmap ppmap = get(boost::vertex_point, const_cast<Polyhedron&>(polyhedron));
|
||||
return sdf_values<true, Polyhedron, SDFPropertyMap, typename Polyhedron::Traits, Ppmap>
|
||||
(polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits, ppmap);
|
||||
}
|
||||
|
||||
template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap>
|
||||
|
|
@ -305,9 +340,11 @@ segmentation_from_sdf_values(const Polyhedron& polyhedron,
|
|||
bool output_cluster_ids = false,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return segmentation_from_sdf_values<Polyhedron, SDFPropertyMap, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type Ppmap;
|
||||
Ppmap ppmap = get(boost::vertex_point, const_cast<Polyhedron&>(polyhedron));
|
||||
return segmentation_from_sdf_values<Polyhedron, SDFPropertyMap, SegmentPropertyMap, typename Polyhedron::Traits, Ppmap>
|
||||
(polyhedron, sdf_values_map, segment_ids, number_of_clusters, smoothing_lambda,
|
||||
output_cluster_ids, traits);
|
||||
output_cluster_ids, traits, ppmap);
|
||||
}
|
||||
|
||||
template <bool Fast_sdf_calculation_mode, class Polyhedron, class SegmentPropertyMap>
|
||||
|
|
@ -321,9 +358,11 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
bool output_cluster_ids = false,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return segmentation_via_sdf_values< Fast_sdf_calculation_mode, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type Ppmap;
|
||||
Ppmap ppmap = get(boost::vertex_point, const_cast<Polyhedron&>(polyhedron));
|
||||
return segmentation_via_sdf_values< Fast_sdf_calculation_mode, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits, Ppmap>
|
||||
(polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters,
|
||||
smoothing_lambda, output_cluster_ids, traits);
|
||||
smoothing_lambda, output_cluster_ids, traits, ppmap);
|
||||
}
|
||||
|
||||
template <class Polyhedron, class SegmentPropertyMap>
|
||||
|
|
@ -337,13 +376,13 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
bool output_cluster_ids = false,
|
||||
typename Polyhedron::Traits traits = typename Polyhedron::Traits())
|
||||
{
|
||||
return segmentation_via_sdf_values<true, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits>
|
||||
typedef typename boost::property_map<Polyhedron, boost::vertex_point_t>::type Ppmap;
|
||||
Ppmap ppmap = get(boost::vertex_point, const_cast<Polyhedron&>(polyhedron));
|
||||
return segmentation_via_sdf_values<true, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits, Ppmap>
|
||||
(polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters,
|
||||
smoothing_lambda, output_cluster_ids, traits);
|
||||
smoothing_lambda, output_cluster_ids, traits, ppmap);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
/// \endcond
|
||||
|
||||
}//namespace CGAL
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue