From a4cb1c2a97c882ba28f6f773c608cc51eeebdba1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 16 Mar 2016 18:09:55 +0100 Subject: [PATCH] Add protection of identical edges in different polyhedra. WIP: with an #undef and std::cerr --- .../PMP/Isotropic_remeshing_plugin.cpp | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index e2549ee3fcf..cdbe028a8a5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -30,7 +30,7 @@ #include #include #include - +#undef CGAL_LINKED_WITH_TBB #ifdef CGAL_LINKED_WITH_TBB #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" @@ -300,7 +300,36 @@ public Q_SLOTS: selection, edges_only, target_length, nb_iter, protect, smooth_features)); total_time = time.elapsed(); + #else + typedef boost::graph_traits::edge_descriptor edge_descriptor; + std::map > edges_to_protect; + + if(selection.size()>1){ + typedef Polyhedron::Point_3 Point_3; + typedef std::pair Segment_3; + + std::map > duplicates; + + BOOST_FOREACH(Scene_polyhedron_item* poly_item, selection){ + const Polyhedron& pmesh = *poly_item->polyhedron(); + BOOST_FOREACH(edge_descriptor ed, edges(pmesh)){ + Point_3 p = source(ed,pmesh)->point(), q = target(ed,pmesh)->point(); + Segment_3 s = (p < q)? std::make_pair(p,q): std::make_pair(q,p); + + std::map >::iterator + it = duplicates.find(s); + if(it == duplicates.end()){ + duplicates[s] = std::make_pair(poly_item,ed); + }else{ + std::cerr << p << " "<< q << std::endl; + edges_to_protect[it->second.first].insert(it->second.second); + edges_to_protect[poly_item].insert(ed); + } + } + } + } + Remesh_polyhedron_item remesher(edges_only, target_length, nb_iter, protect, smooth_features); BOOST_FOREACH(Scene_polyhedron_item* poly_item, selection) @@ -308,7 +337,7 @@ public Q_SLOTS: QTime time; time.start(); - remesher(poly_item); + remesher(poly_item, edges_to_protect[poly_item]); total_time += time.elapsed(); std::cout << "Remeshing of " << poly_item->name().data() @@ -342,7 +371,8 @@ private: bool smooth_features_; protected: - void remesh(Scene_polyhedron_item* poly_item) const + void remesh(Scene_polyhedron_item* poly_item, + std::set& edges_to_protect) const { //fill face_index property map boost::property_map::type fim @@ -369,12 +399,15 @@ private: } else { + std::cerr << edges_to_protect.size() << " edges to protect" < > ecm(edges_to_protect); CGAL::Polygon_mesh_processing::isotropic_remeshing( faces(*poly_item->polyhedron()) , target_length_ , *poly_item->polyhedron() , CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iter_) .protect_constraints(protect_) + .edge_is_constrained_map(ecm) .smooth_along_features(smooth_features_)); } } @@ -401,9 +434,10 @@ private: , smooth_features_(remesh.smooth_features_) {} - void operator()(Scene_polyhedron_item* poly_item) const + void operator()(Scene_polyhedron_item* poly_item, + std::set& edges_to_protect) const { - remesh(poly_item); + remesh(poly_item, edges_to_protect); } };