Merge pull request #2888 from sloriot/PMP-autorefine_bugfixes

Autorefine bugfixes
This commit is contained in:
Laurent Rineau 2018-03-06 16:23:08 +01:00
commit 81a7e2d737
4 changed files with 58 additions and 6 deletions

View File

@ -801,7 +801,7 @@ public:
// parts of a mesh (ex: a square in crossing the interior
// of a larger). In practice, we could say this is not an
// issue if anyway the whole patch would be dropped.
// Note that this remark is value for all cases where
// Note that this remark is valid for all cases where
// all_fixed is set to false.
if (patch_id_p1==patch_id_p2 || patch_id_q1==patch_id_q2)
{

View File

@ -339,7 +339,10 @@ public:
Node_id node_id,
TriangleMesh& tm)
{
mesh_to_vertex_to_node_id[&tm].insert(std::make_pair(target(h,tm),node_id));
CGAL_assertion_code(bool insert_ok = )
mesh_to_vertex_to_node_id[&tm].insert(std::make_pair(target(h,tm),node_id))
CGAL_assertion_code(.second);
CGAL_assertion(insert_ok || mesh_to_vertex_to_node_id[&tm][target(h,tm)]==node_id);
}
void new_node_added_triple_face(std::size_t node_id,

View File

@ -163,6 +163,7 @@ class Intersection_of_triangle_meshes
typedef typename graph_traits::face_descriptor face_descriptor;
typedef typename graph_traits::edge_descriptor edge_descriptor;
typedef typename graph_traits::halfedge_descriptor halfedge_descriptor;
typedef typename graph_traits::vertex_descriptor vertex_descriptor;
typedef typename CGAL::Box_intersection_d::Box_with_info_d<double, 3, halfedge_descriptor> Box;
@ -194,6 +195,7 @@ class Intersection_of_triangle_meshes
Node_vector nodes;
Node_visitor visitor;
Faces_to_nodes_map f_to_node; //Associate a pair of triangles to their intersection points
std::vector<Node_id> extra_terminal_nodes; //used only for autorefinement
CGAL_assertion_code(bool doing_autorefinement;)
// member functions
void filter_intersections(const TriangleMesh& tm_f,
@ -1050,6 +1052,13 @@ class Intersection_of_triangle_meshes
}
}
CGAL_assertion(extra_terminal_nodes.empty() || doing_autorefinement);
// these nodes are created by pinchements along an edge of the surface.
// the node ids being the same for the two edges, the degree of the node
// in the graph is two while it should be 3
BOOST_FOREACH(Node_id id, extra_terminal_nodes)
graph[id].make_terminal();
//visitor call
visitor.annotate_graph(graph);
@ -1163,6 +1172,7 @@ class Intersection_of_triangle_meshes
{
const TriangleMesh& tm = nodes.tm1;
CGAL_assertion(doing_autorefinement);
std::map<vertex_descriptor, Node_id> vertex_to_node_id;
for (typename Faces_to_nodes_map::iterator it=f_to_node.begin();
it!=f_to_node.end(); ++it)
{
@ -1177,9 +1187,18 @@ class Intersection_of_triangle_meshes
{
if ( target(h1, tm)==target(h2,tm) )
{
Node_id node_id=++current_node;
Node_id node_id = current_node+1;
std::pair< typename std::map<vertex_descriptor, Node_id>::iterator, bool>
insert_res = vertex_to_node_id.insert(std::make_pair(target(h1,tm), node_id));
if (insert_res.second)
{
++current_node;
nodes.add_new_node(get(nodes.vpm1, target(h1,tm)));
visitor.new_node_added(node_id,ON_VERTEX,h1,h2,tm,tm,true,false);
extra_terminal_nodes.push_back(node_id);
}
else
node_id = insert_res.first->second;
it->second.insert(node_id);
break;
}
@ -1320,11 +1339,12 @@ public:
/// TODO AUTOREF_TAG does this happen in coplanar cases only? + shall we do it have new edge splitting?
remove_duplicated_intersecting_edges();
detect_intersections_in_the_graph(tm, vpm, current_node);
// If a pair of faces defines an isolated node, check if they share a common
// vertex and create a new node in that case.
add_common_vertices_for_pairs_of_faces_with_isolated_node(current_node);
detect_intersections_in_the_graph(tm, vpm, current_node);
#if 0
//collect connectivity infos and create polylines
if ( Node_visitor::do_need_vertex_graph )

View File

@ -320,6 +320,7 @@ class Intersection_nodes<TriangleMesh,VertexPointMap,Predicates_on_constructions
//members
Nodes_vector nodes;
Input_kernel k;
typename Input_kernel::Intersect_3 intersection;
public:
typedef Input_kernel Exact_kernel;
@ -344,6 +345,34 @@ public:
size_t size() const {return nodes.size();}
const Point_3& exact_node(std::size_t i) const {return nodes[i];}
void add_new_node(halfedge_descriptor h1,
halfedge_descriptor h2,
halfedge_descriptor h3,
const TriangleMesh& tm,
const VertexPointMap& vpm)
{
// TODO Far from optimal!
typedef typename Exact_kernel::Plane_3 Plane_3;
Plane_3 p1( get(vpm, source(h1,tm)),
get(vpm, target(h1,tm)),
get(vpm, target(next(h1,tm),tm))),
p2(get(vpm, source(h2,tm)),
get(vpm, target(h2,tm)),
get(vpm, target(next(h2,tm),tm))),
p3(get(vpm, source(h3,tm)),
get(vpm, target(h3,tm)),
get(vpm, target(next(h3,tm),tm)));
typename cpp11::result_of<
typename Exact_kernel::Intersect_3(Plane_3, Plane_3, Plane_3)
>::type inter_res = intersection(p1, p2, p3);
CGAL_assertion(inter_res != boost::none);
const Point_3* pt =
boost::get<Point_3>(&(*inter_res));
CGAL_assertion(pt!=NULL);
add_new_node(*pt);
}
//add a new node in the final graph.
//it is the intersection of the triangle with the segment
void add_new_node(halfedge_descriptor h_a,