mirror of https://github.com/CGAL/cgal
Use CGAL points even for OpenMesh
This commit is contained in:
parent
db346b1ad3
commit
d92d0cef84
|
|
@ -187,6 +187,7 @@ public:
|
|||
typedef vertices_size_type faces_size_type;
|
||||
|
||||
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
|
||||
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
|
||||
static face_descriptor null_face() { return face_descriptor(); }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -99,17 +99,17 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template<typename K>
|
||||
template<typename K, typename P>
|
||||
class OM_point_pmap //: public boost::put_get_helper<bool, OM_point_pmap<K> >
|
||||
{
|
||||
public:
|
||||
typedef boost::read_write_property_map_tag category;
|
||||
#if !defined(CGAL_BGL_TESTSUITE)
|
||||
#if defined(CGAL_USE_OM_POINTS)
|
||||
typedef typename OpenMesh::PolyMesh_ArrayKernelT<K>::Point value_type;
|
||||
typedef typename const OpenMesh::PolyMesh_ArrayKernelT<K>::Point& reference;
|
||||
#else
|
||||
typedef typename CGAL::Exact_predicates_inexact_constructions_kernel::Point_3 value_type;
|
||||
typedef typename CGAL::Exact_predicates_inexact_constructions_kernel::Point_3 reference;
|
||||
typedef P value_type;
|
||||
typedef P reference;
|
||||
#endif
|
||||
typedef typename boost::graph_traits< OpenMesh::PolyMesh_ArrayKernelT<K> >::vertex_descriptor key_type;
|
||||
|
||||
|
|
@ -125,9 +125,9 @@ public:
|
|||
: sm_(pm.sm_)
|
||||
{}
|
||||
|
||||
inline friend reference get(const OM_point_pmap<K>& pm, key_type v)
|
||||
inline friend reference get(const OM_point_pmap<K,P>& pm, key_type v)
|
||||
{
|
||||
#if !defined(CGAL_BGL_TESTSUITE)
|
||||
#if defined(CGAL_USE_OM_POINTS)
|
||||
return pm.sm->.point(v);
|
||||
#else
|
||||
typename OpenMesh::PolyMesh_ArrayKernelT<K>::Point const& omp = pm.sm_->point(v);
|
||||
|
|
@ -135,12 +135,12 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
inline friend void put(const OM_point_pmap<K>& pm, key_type v, const value_type& p)
|
||||
inline friend void put(const OM_point_pmap<K,P>& pm, key_type v, const value_type& p)
|
||||
{
|
||||
#if !defined(CGAL_BGL_TESTSUITE)
|
||||
const_cast<OpenMesh::PolyMesh_ArrayKernelT<K>&>(*pm.sm_)->set_point(v,p);
|
||||
#if defined(CGAL_USE_OM_POINTS)
|
||||
const_cast<OpenMesh::PolyMesh_ArrayKernelT<K>&>(*pm.sm_).set_point(v,p);
|
||||
#else
|
||||
const_cast<OpenMesh::PolyMesh_ArrayKernelT<K>&>(*pm.sm_)->set_point
|
||||
const_cast<OpenMesh::PolyMesh_ArrayKernelT<K>&>(*pm.sm_).set_point
|
||||
(v, typename OpenMesh::PolyMesh_ArrayKernelT<K>::Point(p[0], p[1], p[2]));
|
||||
#endif
|
||||
}
|
||||
|
|
@ -218,7 +218,8 @@ struct property_map<OpenMesh::PolyMesh_ArrayKernelT<K>, boost::halfedge_index_t
|
|||
template<typename K>
|
||||
struct property_map<OpenMesh::PolyMesh_ArrayKernelT<K>, boost::vertex_point_t >
|
||||
{
|
||||
typedef CGAL::OM_point_pmap<K> type;
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel::Point_3 P;
|
||||
typedef CGAL::OM_point_pmap<K,P> type;
|
||||
typedef type const_type;
|
||||
};
|
||||
|
||||
|
|
@ -297,10 +298,11 @@ get(const boost::halfedge_index_t&, const OpenMesh::PolyMesh_ArrayKernelT<K>&)
|
|||
}
|
||||
|
||||
template<typename K>
|
||||
CGAL::OM_point_pmap<K>
|
||||
CGAL::OM_point_pmap<K,typename CGAL::Exact_predicates_inexact_constructions_kernel::Point_3>
|
||||
get(boost::vertex_point_t, const OpenMesh::PolyMesh_ArrayKernelT<K>& g)
|
||||
{
|
||||
return CGAL::OM_point_pmap<K>(g);
|
||||
typedef typename CGAL::Exact_predicates_inexact_constructions_kernel::Point_3 P;
|
||||
return CGAL::OM_point_pmap<K,P>(g);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,11 @@ int main( int argc, char** argv )
|
|||
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(mesh, sdf_property_map, 2.0 / 3.0 * CGAL_PI, 25,true, Kernel());
|
||||
|
||||
// compute SDF values
|
||||
// We can't use default parameters for number of rays, and cone angle
|
||||
// and the postprocessing
|
||||
CGAL::sdf_values(mesh, sdf_property_map);
|
||||
|
||||
// create a property-map for segment-ids
|
||||
typedef std::map<face_descriptor, std::size_t> Facet_int_map;
|
||||
|
|
@ -43,7 +46,7 @@ int main( int argc, char** argv )
|
|||
|
||||
// segment the mesh using default parameters for number of levels, and smoothing lambda
|
||||
// Any other scalar values can be used instead of using SDF values computed using the CGAL function
|
||||
std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map, 5, 0.26, false, Kernel());
|
||||
std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map);
|
||||
|
||||
std::cout << "Number of segments: " << number_of_segments << std::endl;
|
||||
// print segment-ids
|
||||
|
|
@ -60,6 +63,5 @@ int main( int argc, char** argv )
|
|||
|
||||
// Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation.
|
||||
// This feature is relevant for segmenting the mesh several times with different parameters.
|
||||
//CGAL::segmentation_from_sdf_values(
|
||||
// mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda);
|
||||
CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace CGAL
|
|||
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
|
||||
= typename Kernel_traits<boost::property_traits<PointPropertyMap>::value_type>::Kernel
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
|
|
@ -82,7 +82,7 @@ sdf_values( const Polyhedron& polyhedron,
|
|||
*/
|
||||
template <class Polyhedron, class SDFPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
= typename Kernel_traits<boost::property_traits<PointPropertyMap>::value_type>::Kernel
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
|
|
@ -177,7 +177,7 @@ sdf_values_postprocessing(const Polyhedron& polyhedron,
|
|||
template <class Polyhedron, class SDFPropertyMap, class SegmentPropertyMap,
|
||||
class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
= typename Kernel_traits<boost::property_traits<PointPropertyMap>::value_type>::Kernel
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
|
|
@ -204,7 +204,7 @@ segmentation_from_sdf_values( const Polyhedron& polyhedron,
|
|||
template < bool Fast_sdf_calculation_mode, class Polyhedron,
|
||||
class SegmentPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
= typename Kernel_traits<boost::property_traits<PointPropertyMap>::value_type>::Kernel
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
|
|
@ -273,7 +273,7 @@ segmentation_via_sdf_values(const Polyhedron& polyhedron,
|
|||
*/
|
||||
template < class Polyhedron, class SegmentPropertyMap, class GeomTraits
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
= typename Polyhedron::Traits
|
||||
= typename Kernel_traits<boost::property_traits<PointPropertyMap>::value_type>::Kernel
|
||||
#endif
|
||||
, class PointPropertyMap
|
||||
#ifndef CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;
|
||||
|
||||
typedef boost::graph_traits<Surface_mesh>::edge_descriptor edge_descriptor;
|
||||
|
|
@ -51,41 +53,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class OM_vertex_CGAL_point_pmap
|
||||
{
|
||||
public:
|
||||
typedef boost::read_write_property_map_tag category;
|
||||
|
||||
typedef CGAL::Simple_cartesian<double>::Point_3 value_type;
|
||||
typedef CGAL::Simple_cartesian<double>::Point_3 reference;
|
||||
|
||||
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor key_type;
|
||||
|
||||
OM_vertex_CGAL_point_pmap(const Surface_mesh& sm)
|
||||
: sm_(sm)
|
||||
{}
|
||||
|
||||
OM_vertex_CGAL_point_pmap(const OM_vertex_CGAL_point_pmap& pm)
|
||||
: sm_(pm.sm_)
|
||||
{}
|
||||
|
||||
inline friend reference get(const OM_vertex_CGAL_point_pmap& pm, key_type v)
|
||||
{
|
||||
Surface_mesh::Point const& omp = pm.sm_.point(v);
|
||||
return value_type(omp[0], omp[1], omp[2]);
|
||||
}
|
||||
|
||||
inline friend void put(const OM_vertex_CGAL_point_pmap& pm, key_type v, const value_type& p)
|
||||
{
|
||||
const_cast<Surface_mesh&>(pm.sm_).set_point
|
||||
(v, Surface_mesh::Point(p[0], p[1], p[2]));
|
||||
}
|
||||
|
||||
private:
|
||||
const Surface_mesh& sm_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
namespace SMS = CGAL::Surface_mesh_simplification ;
|
||||
|
||||
|
|
@ -113,7 +80,7 @@ int main( int argc, char** argv )
|
|||
(surface_mesh
|
||||
,stop
|
||||
,CGAL::halfedge_index_map (get(CGAL::halfedge_index ,surface_mesh))
|
||||
.vertex_point_map(OM_vertex_CGAL_point_pmap(surface_mesh))
|
||||
.vertex_point_map(get(boost::vertex_point, surface_mesh))
|
||||
.edge_is_constrained_map(constraints_map)
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue