diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index 369ed0d0e3c..80be34a152d 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -48,7 +48,7 @@ namespace internal { int n; Indentation_level() : n(0) {} friend std::ostream& operator<<(std::ostream& os, Indentation_level level) { - return os << std::string(2*level.n, ' '); + return os << std::setw(2) << level.n << ": " << std::string(2*level.n, ' '); } Indentation_level& operator++() { ++n; return *this; } Indentation_level& operator--() { --n; return *this; } @@ -754,11 +754,11 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb) if (vi != vaa && vi != vbb) { #ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS std::cerr << CGAL::internal::cdt_2_indent_level - << "CT_2::insert_constraint stask push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point() + << "CT_2::insert_constraint stack push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point() << " , #" << vi->time_stamp() << "= " << vi->point() << " )\n"; std::cerr << CGAL::internal::cdt_2_indent_level - << "CT_2::insert_constraint stask push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point() + << "CT_2::insert_constraint stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point() << " , #" << vbb->time_stamp() << "= " << vbb->point() << " )\n"; #endif // CGAL_CDT_2_DEBUG_INTERSECTIONS @@ -768,7 +768,7 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb) else{ #ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS std::cerr << CGAL::internal::cdt_2_indent_level - << "CT_2::insert_constraint stask push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point() + << "CT_2::insert_constraint stack push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point() << " , #" << vbb->time_stamp() << "= " << vbb->point() << " )\n"; #endif // CGAL_CDT_2_DEBUG_INTERSECTIONS diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 78b66f39e8e..b899fd042b0 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -272,6 +272,12 @@ public: Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb) { +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint( #" << va->time_stamp() << "= " << va->point() + << " , #" << vb->time_stamp() << "= " << vb->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS // protects against inserting a zero length constraint if(va == vb){ return Constraint_id(nullptr); @@ -854,6 +860,17 @@ insert_subconstraint(Vertex_handle vaa, // insert the subconstraint [vaa vbb] // it will eventually be splitted into several subconstraints { +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_subconstraint( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " )\n"; + internal::Indentation_level::Exit_guard exit_guard = CGAL::internal::cdt_2_indent_level.open_new_scope(); + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint stack push [va, vb] ( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS std::stack > stack; stack.push(std::make_pair(vaa,vbb)); @@ -861,15 +878,36 @@ insert_subconstraint(Vertex_handle vaa, boost::tie(vaa,vbb) = stack.top(); stack.pop(); CGAL_triangulation_precondition( vaa != vbb); - +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_subconstraint, stack pop=( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " ) remaining stack size: " + << stack.size() << '\n'; + CGAL_assertion(this->is_valid()); +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS Vertex_handle vi; Face_handle fr; int i; if(this->includes_edge(vaa,vbb,vi,fr,i)) { +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_subconstraint, the segment ( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " ) is an edge with #" + << vi->time_stamp() << "= " << vi->point() + << '\n'; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS this->mark_constraint(fr,i); if (vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint (includes_edge) stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS stack.push(std::make_pair(vi,vbb)); } continue; @@ -888,10 +926,28 @@ insert_subconstraint(Vertex_handle vaa, if ( intersection) { if (vi != vaa && vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint stack push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vi->time_stamp() << "= " << vi->point() + << " )\n"; + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS stack.push(std::make_pair(vaa,vi)); stack.push(std::make_pair(vi,vbb)); } - else stack.push(std::make_pair(vaa,vbb)); + else { +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::insert_constraint stack push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS + stack.push(std::make_pair(vaa,vbb)); + } continue; } @@ -1026,6 +1082,14 @@ insert(const Point& a, Locate_type lt, Face_handle loc, int li) Vertex_handle va = Triangulation::insert(a,lt,loc,li); // update the hierarchy if (insert_in_constrained_edge) { +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << " CT_plus_2::insert(" << a << ") = #" + << va->time_stamp() + << " insert in constrained edge: #" << v1->time_stamp() << "= " << v1->point() + << " , #" << v2->time_stamp() << "= " << v2->point() + << std::endl; +#endif hierarchy.split_constraint(v1,v2,va); } return va; @@ -1085,6 +1149,14 @@ intersect(Face_handle f, int i, const Point& pb = vb->point(); const Point& pc = vc->point(); const Point& pd = vd->point(); +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::intersect segment ( #" << va->time_stamp() << "= " << va->point() + << " , #" << vb->time_stamp() << "= " << vb->point() + << " ) with edge ( #"<< vc->time_stamp() << "= " << vc->point() + << " , #" << vd->time_stamp() << "= " << vd->point() + << " , Exact_intersections_tag)\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS Point pi; Intersection_tag itag = Intersection_tag(); CGAL_triangulation_assertion_code( bool ok = ) @@ -1092,6 +1164,11 @@ intersect(Face_handle f, int i, CGAL_triangulation_assertion(ok); Vertex_handle vi = insert(pi, Triangulation::EDGE, f, i); +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::intersect, `vi` is ( #" << vi->time_stamp() << "= " << vi->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS return vi; } @@ -1111,6 +1188,14 @@ intersect(Face_handle f, int i, const Point& pb = vbb->point(); const Point& pc = vcc->point(); const Point& pd = vdd->point(); +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::intersect segment ( #" << vaa->time_stamp() << "= " << vaa->point() + << " , #" << vbb->time_stamp() << "= " << vbb->point() + << " ) with edge ( #"<< vcc->time_stamp() << "= " << vcc->point() + << " , #" << vdd->time_stamp() << "= " << vdd->point() + << " , Exact_predicates_tag)\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS Point pi; //creator for point is required here Intersection_tag itag = Intersection_tag(); @@ -1133,6 +1218,11 @@ intersect(Face_handle f, int i, Triangulation::remove_constrained_edge(f, i); vi = insert(pi, f); } +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "CT_plus_2::intersect, `vi` is ( #" << vi->time_stamp() << "= " << vi->point() + << " )\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS // vi == vc or vi == vd may happen even if intersection==true // due to approximate construction of the intersection diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index 168fc2fc4e8..3713469fc55 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -845,6 +845,14 @@ insert_constraint(T va, T vb){ Vertex_list* children = new Vertex_list; Context_list* fathers; +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "C_hierachy.insert_constraint( #" + << va->time_stamp() + << ", #" + << vb->time_stamp() + << ")\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); if(scit == sc_to_c_map.end()){ fathers = new Context_list; @@ -874,6 +882,14 @@ insert_constraint_old_API(T va, T vb){ Vertex_list* children = new Vertex_list; Context_list* fathers; +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "C_hierachy.insert_constraint_old_API( #" + << va->time_stamp() + << ", #" + << vb->time_stamp() + << ")\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); if(scit == sc_to_c_map.end()){ fathers = new Context_list; @@ -901,6 +917,14 @@ append_constraint(Constraint_id cid, T va, T vb){ Edge he = make_edge(va, vb); Context_list* fathers; +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "C_hierachy.append_constraint( ..., #" + << va->time_stamp() + << ", #" + << vb->time_stamp() + << ")\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); if(scit == sc_to_c_map.end()){ fathers = new Context_list; @@ -1012,6 +1036,16 @@ template void Polyline_constraint_hierarchy_2:: add_Steiner(T va, T vb, T vc){ +#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS + std::cerr << CGAL::internal::cdt_2_indent_level + << "C_hierachy.add_Steinter( #" + << va->time_stamp() + << ", #" + << vb->time_stamp() + << ", #" + << vc->time_stamp() + << ")\n"; +#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS Context_list* hcl=nullptr; if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false);