mirror of https://github.com/CGAL/cgal
store/retrieve selection and features of an OM
This commit is contained in:
parent
65b7c09c1f
commit
0c8e489f46
|
|
@ -9,17 +9,20 @@
|
|||
#include <CGAL/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
|
||||
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Mesh;
|
||||
|
||||
typedef CGAL::Surface_mesh<Kernel::Point_3> SM;
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<SM>::vertex_descriptor sm_vertex_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<SM>::halfedge_descriptor sm_halfedge_descriptor;
|
||||
typedef boost::graph_traits<SM>::edge_descriptor sm_edge_descriptor;
|
||||
|
||||
int main(int argc, char** argv )
|
||||
{
|
||||
|
|
@ -30,6 +33,7 @@ int main(int argc, char** argv )
|
|||
CGAL::IO::read_polygon_mesh(filename, mesh);
|
||||
|
||||
mesh.request_vertex_status();
|
||||
mesh.request_edge_status();
|
||||
|
||||
int i = 0;
|
||||
for(auto v : vertices(mesh)){
|
||||
|
|
@ -37,21 +41,60 @@ int main(int argc, char** argv )
|
|||
++i;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for(auto e : edges(mesh)){
|
||||
mesh.status(e).set_feature(i > 2);
|
||||
++i;
|
||||
}
|
||||
|
||||
OpenMesh::IO::write_mesh(mesh, outname, OpenMesh::IO::Options::Status);
|
||||
|
||||
Mesh mesh2;
|
||||
OpenMesh::IO::Options options = OpenMesh::IO::Options::Status;
|
||||
bool read = OpenMesh::IO::read_mesh(mesh2, outname, options);
|
||||
std::cout << num_vertices(mesh2) << std::endl;
|
||||
assert(read);
|
||||
|
||||
SM sm;
|
||||
std::map<vertex_descriptor,sm_vertex_descriptor> v2v;
|
||||
auto v2vpmap = boost::make_assoc_property_map(v2v);
|
||||
|
||||
std::map<halfedge_descriptor,sm_halfedge_descriptor> h2h;
|
||||
auto h2hpmap = boost::make_assoc_property_map(h2h);
|
||||
|
||||
CGAL::copy_face_graph<Mesh,SM>(mesh, sm, CGAL::parameters::vertex_to_vertex_map(v2vpmap).halfedge_to_halfedge_map(h2hpmap));
|
||||
|
||||
std::map<sm_vertex_descriptor,bool> sm_selected_map;
|
||||
auto sm_selected_pmap = boost::make_assoc_property_map(sm_selected_map);
|
||||
if(options.vertex_has_status()){
|
||||
for(auto v : vertices(mesh2)){
|
||||
put(sm_selected_pmap, v2v[v], mesh2.status(v).selected());
|
||||
std::cout << std::boolalpha << mesh2.status(v).selected() << std::endl;
|
||||
}
|
||||
}else{
|
||||
std::cout << "no vertex status" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
std::map<sm_edge_descriptor,bool> sm_feature_map;
|
||||
auto sm_feature_pmap = boost::make_assoc_property_map(sm_feature_map);
|
||||
if(options.edge_has_status()){
|
||||
for(auto e : edges(mesh2)){
|
||||
auto sme = edge(h2h[halfedge(e,mesh2)], sm);
|
||||
put(sm_feature_pmap, sme , mesh2.status(e).feature());
|
||||
std::cout << std::boolalpha << mesh2.status(e).feature() << std::endl;
|
||||
}
|
||||
}else{
|
||||
std::cout << "no edge status" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "vertex selection values:\n";
|
||||
for(auto v : vertices(sm)){
|
||||
std::cout << std::boolalpha << get(sm_selected_pmap, v) << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "edge feature values:\n";
|
||||
for(auto e : edges(sm)){
|
||||
std::cout << std::boolalpha << get(sm_feature_pmap, e) << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue