Better debug messages

This commit is contained in:
Laurent Rineau 2020-10-14 10:01:59 +02:00
parent 772d059f00
commit e37c290841
3 changed files with 130 additions and 6 deletions

View File

@ -48,7 +48,7 @@ namespace internal {
int n; int n;
Indentation_level() : n(0) {} Indentation_level() : n(0) {}
friend std::ostream& operator<<(std::ostream& os, Indentation_level level) { 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; }
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) { if (vi != vaa && vi != vbb) {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS #ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level 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() << " , #" << vi->time_stamp() << "= " << vi->point()
<< " )\n"; << " )\n";
std::cerr << CGAL::internal::cdt_2_indent_level 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() << " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n"; << " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS #endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
@ -768,7 +768,7 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb)
else{ else{
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS #ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level 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() << " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n"; << " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS #endif // CGAL_CDT_2_DEBUG_INTERSECTIONS

View File

@ -272,6 +272,12 @@ public:
Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb) 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 // protects against inserting a zero length constraint
if(va == vb){ if(va == vb){
return Constraint_id(nullptr); return Constraint_id(nullptr);
@ -854,6 +860,17 @@ insert_subconstraint(Vertex_handle vaa,
// insert the subconstraint [vaa vbb] // insert the subconstraint [vaa vbb]
// it will eventually be splitted into several subconstraints // 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<std::pair<Vertex_handle, Vertex_handle> > stack; std::stack<std::pair<Vertex_handle, Vertex_handle> > stack;
stack.push(std::make_pair(vaa,vbb)); stack.push(std::make_pair(vaa,vbb));
@ -861,15 +878,36 @@ insert_subconstraint(Vertex_handle vaa,
boost::tie(vaa,vbb) = stack.top(); boost::tie(vaa,vbb) = stack.top();
stack.pop(); stack.pop();
CGAL_triangulation_precondition( vaa != vbb); 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; Vertex_handle vi;
Face_handle fr; Face_handle fr;
int i; int i;
if(this->includes_edge(vaa,vbb,vi,fr,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); this->mark_constraint(fr,i);
if (vi != vbb) { if (vi != vbb) {
hierarchy.split_constraint(vaa,vbb,vi); 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)); stack.push(std::make_pair(vi,vbb));
} }
continue; continue;
@ -888,10 +926,28 @@ insert_subconstraint(Vertex_handle vaa,
if ( intersection) { if ( intersection) {
if (vi != vaa && vi != vbb) { if (vi != vaa && vi != vbb) {
hierarchy.split_constraint(vaa,vbb,vi); 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(vaa,vi));
stack.push(std::make_pair(vi,vbb)); 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; 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); Vertex_handle va = Triangulation::insert(a,lt,loc,li);
// update the hierarchy // update the hierarchy
if (insert_in_constrained_edge) { 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); hierarchy.split_constraint(v1,v2,va);
} }
return va; return va;
@ -1085,6 +1149,14 @@ intersect(Face_handle f, int i,
const Point& pb = vb->point(); const Point& pb = vb->point();
const Point& pc = vc->point(); const Point& pc = vc->point();
const Point& pd = vd->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; Point pi;
Intersection_tag itag = Intersection_tag(); Intersection_tag itag = Intersection_tag();
CGAL_triangulation_assertion_code( bool ok = ) CGAL_triangulation_assertion_code( bool ok = )
@ -1092,6 +1164,11 @@ intersect(Face_handle f, int i,
CGAL_triangulation_assertion(ok); CGAL_triangulation_assertion(ok);
Vertex_handle vi = insert(pi, Triangulation::EDGE, f, i); 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; return vi;
} }
@ -1111,6 +1188,14 @@ intersect(Face_handle f, int i,
const Point& pb = vbb->point(); const Point& pb = vbb->point();
const Point& pc = vcc->point(); const Point& pc = vcc->point();
const Point& pd = vdd->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 Point pi; //creator for point is required here
Intersection_tag itag = Intersection_tag(); Intersection_tag itag = Intersection_tag();
@ -1133,6 +1218,11 @@ intersect(Face_handle f, int i,
Triangulation::remove_constrained_edge(f, i); Triangulation::remove_constrained_edge(f, i);
vi = insert(pi, f); 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 // vi == vc or vi == vd may happen even if intersection==true
// due to approximate construction of the intersection // due to approximate construction of the intersection

View File

@ -845,6 +845,14 @@ insert_constraint(T va, T vb){
Vertex_list* children = new Vertex_list; Vertex_list* children = new Vertex_list;
Context_list* fathers; 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); typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){ if(scit == sc_to_c_map.end()){
fathers = new Context_list; fathers = new Context_list;
@ -874,6 +882,14 @@ insert_constraint_old_API(T va, T vb){
Vertex_list* children = new Vertex_list; Vertex_list* children = new Vertex_list;
Context_list* fathers; 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); typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){ if(scit == sc_to_c_map.end()){
fathers = new Context_list; fathers = new Context_list;
@ -901,6 +917,14 @@ append_constraint(Constraint_id cid, T va, T vb){
Edge he = make_edge(va, vb); Edge he = make_edge(va, vb);
Context_list* fathers; 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); typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){ if(scit == sc_to_c_map.end()){
fathers = new Context_list; fathers = new Context_list;
@ -1012,6 +1036,16 @@ template <class T, class Compare, class Data>
void void
Polyline_constraint_hierarchy_2<T,Compare,Data>:: Polyline_constraint_hierarchy_2<T,Compare,Data>::
add_Steiner(T va, T vb, T vc){ 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; Context_list* hcl=nullptr;
if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false); if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false);