mirror of https://github.com/CGAL/cgal
The OpenMesh example shows at the same time how to wrap the OpenMesh properties
This commit is contained in:
parent
071a273ce5
commit
2425bba8a5
|
|
@ -1004,8 +1004,8 @@ collapse_edge(typename boost::graph_traits<Graph>::edge_descriptor v0v1,
|
||||||
if (!(internal::is_border(edges_to_erase[0],g)))
|
if (!(internal::is_border(edges_to_erase[0],g)))
|
||||||
join_face(edges_to_erase[0],g);
|
join_face(edges_to_erase[0],g);
|
||||||
else
|
else
|
||||||
g.erase_facet(edges_to_erase[0]->opposite());
|
remove_face(opposite(edges_to_erase[0],g),g);
|
||||||
if (!edges_to_erase[1]->is_border())
|
if (!internal::is_border(edges_to_erase[1],g))
|
||||||
join_face(edges_to_erase[1],g);
|
join_face(edges_to_erase[1],g);
|
||||||
else
|
else
|
||||||
remove_face(opposite(edges_to_erase[1],g),g);
|
remove_face(opposite(edges_to_erase[1],g),g);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,37 @@
|
||||||
|
|
||||||
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;
|
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;
|
||||||
|
|
||||||
|
typedef boost::graph_traits<Surface_mesh>::edge_descriptor edge_descriptor;
|
||||||
|
typedef boost::graph_traits<Surface_mesh>::edge_iterator edge_iterator;
|
||||||
|
|
||||||
|
class Constrained_edge_map
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef boost::read_write_property_map_tag category;
|
||||||
|
typedef bool value_type;
|
||||||
|
typedef bool reference;
|
||||||
|
typedef edge_descriptor key_type;
|
||||||
|
|
||||||
|
Constrained_edge_map(Surface_mesh& sm)
|
||||||
|
: sm_(sm)
|
||||||
|
{
|
||||||
|
sm_.add_property(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend reference get(const Constrained_edge_map& em, key_type e)
|
||||||
|
{
|
||||||
|
return em.sm_.property(em.constraint,em.sm_.edge_handle(e.idx()));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend void put(const Constrained_edge_map& em, key_type e, value_type b)
|
||||||
|
{
|
||||||
|
em.sm_.property(em.constraint,em.sm_.edge_handle(e.idx())) = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Surface_mesh& sm_;
|
||||||
|
OpenMesh::EPropHandleT<bool> constraint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class OM_vertex_CGAL_point_pmap
|
class OM_vertex_CGAL_point_pmap
|
||||||
|
|
@ -61,9 +92,15 @@ namespace SMS = CGAL::Surface_mesh_simplification ;
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
Surface_mesh surface_mesh;
|
Surface_mesh surface_mesh;
|
||||||
|
Constrained_edge_map constraints_map(surface_mesh);
|
||||||
OpenMesh::IO::read_mesh(surface_mesh, argv[1]);
|
OpenMesh::IO::read_mesh(surface_mesh, argv[1]);
|
||||||
|
|
||||||
|
// For the pupose of the example we mark 10 edges as constrained edges
|
||||||
|
edge_iterator b,e;
|
||||||
|
int count=0;
|
||||||
|
for(boost::tie(b,e); b!= e; ++b){
|
||||||
|
put(constraints_map,*b,(count++ <10));
|
||||||
|
}
|
||||||
// This is a stop predicate (defines when the algorithm terminates).
|
// This is a stop predicate (defines when the algorithm terminates).
|
||||||
// In this example, the simplification stops when the number of undirected edges
|
// In this example, the simplification stops when the number of undirected edges
|
||||||
// left in the surface mesh drops below the specified number (1000)
|
// left in the surface mesh drops below the specified number (1000)
|
||||||
|
|
@ -77,6 +114,7 @@ int main( int argc, char** argv )
|
||||||
,stop
|
,stop
|
||||||
,CGAL::halfedge_index_map (get(CGAL::halfedge_index ,surface_mesh))
|
,CGAL::halfedge_index_map (get(CGAL::halfedge_index ,surface_mesh))
|
||||||
.vertex_point_map(OM_vertex_CGAL_point_pmap(surface_mesh))
|
.vertex_point_map(OM_vertex_CGAL_point_pmap(surface_mesh))
|
||||||
|
.edge_is_constrained_map(constraints_map)
|
||||||
);
|
);
|
||||||
|
|
||||||
surface_mesh.garbage_collection();
|
surface_mesh.garbage_collection();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue