mirror of https://github.com/CGAL/cgal
Add protection of identical edges in different polyhedra. WIP: with an #undef and std::cerr
This commit is contained in:
parent
25c87c75a6
commit
a4cb1c2a97
|
|
@ -30,7 +30,7 @@
|
|||
#include <algorithm>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
#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<Polyhedron>::edge_descriptor edge_descriptor;
|
||||
std::map<Scene_polyhedron_item*,std::set<edge_descriptor> > edges_to_protect;
|
||||
|
||||
if(selection.size()>1){
|
||||
typedef Polyhedron::Point_3 Point_3;
|
||||
typedef std::pair<Point_3,Point_3> Segment_3;
|
||||
|
||||
std::map<Segment_3 ,std::pair<Scene_polyhedron_item*, edge_descriptor> > 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<Segment_3 ,std::pair<Scene_polyhedron_item*, edge_descriptor> >::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<edge_descriptor>& edges_to_protect) const
|
||||
{
|
||||
//fill face_index property map
|
||||
boost::property_map<Polyhedron, CGAL::face_index_t>::type fim
|
||||
|
|
@ -369,12 +399,15 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cerr << edges_to_protect.size() << " edges to protect" <<std::endl;
|
||||
Scene_polyhedron_selection_item::Is_constrained_map<std::set<edge_descriptor> > 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<edge_descriptor>& edges_to_protect) const
|
||||
{
|
||||
remesh(poly_item);
|
||||
remesh(poly_item, edges_to_protect);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue