Add trace

This commit is contained in:
Guillaume Damiand 2018-12-17 10:42:14 +01:00
parent 5fc6387061
commit a3fcbc4afa
3 changed files with 52 additions and 6 deletions

View File

@ -10,6 +10,8 @@ if(CGAL_Qt5_FOUND)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS) add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif() endif()
# add_definitions(-DCGAL_TRACE_PATH_TESTS)
if ( CGAL_FOUND ) if ( CGAL_FOUND )
# create a target per cppfile # create a target per cppfile

View File

@ -126,6 +126,10 @@ int main(int argc, char** argv)
for (unsigned int i=0; i<N; ++i) for (unsigned int i=0; i<N; ++i)
{ {
// TEMPO POUR DEBUG
//random=CGAL::Random(461974893);
// END TEMPO POUR DEBUG
if (i!=0) if (i!=0)
{ {
random=CGAL::Random(random.get_int(0, std::numeric_limits<int>::max())); random=CGAL::Random(random.get_int(0, std::numeric_limits<int>::max()));
@ -150,8 +154,7 @@ int main(int argc, char** argv)
CGAL::Path_on_surface<LCC_3_cmap> path1(lcc); CGAL::Path_on_surface<LCC_3_cmap> path1(lcc);
path1.generate_random_closed_path(F, random); path1.generate_random_closed_path(F, random);
//if (path1.length()<100000) // TEMPO FOR DEBUG //if (path1.length()<100000) { // TEMPO FOR DEBUG
{
std::cout<<"Path1 size: "<<path1.length()<<" (from "<<F<<" darts); "; std::cout<<"Path1 size: "<<path1.length()<<" (from "<<F<<" darts); ";
paths.push_back(path1); paths.push_back(path1);
@ -164,7 +167,8 @@ int main(int argc, char** argv)
if (smct.is_contractible(path1, time)) if (smct.is_contractible(path1, time))
{ ++nbcontractible; } { ++nbcontractible; }
if (!smct.are_freely_homotopic(path1, path2, time)) bool res=smct.are_freely_homotopic(path1, path2, time);
if (!res)
{ {
/* std::cout<<"ERROR: paths are not homotopic while they should be." /* std::cout<<"ERROR: paths are not homotopic while they should be."
<<std::endl; */ <<std::endl; */
@ -177,8 +181,9 @@ int main(int argc, char** argv)
if (draw) if (draw)
{ CGAL::draw(lcc, paths); } { CGAL::draw(lcc, paths); }
#endif #endif
} // END TEMPO POUR DEBUG}
// else { --i; } // TEMPO POUR DEBUG
// { if (!res) { i=0; errors_seeds.clear();} } // TEMPO POUR DEBUG
} }
if (errors_seeds.empty()) if (errors_seeds.empty())

View File

@ -328,6 +328,12 @@ public:
return dhend==flat->end; return dhend==flat->end;
} }
void display_flat(std::ostream& os, const List_iterator& flat)
{
os<<"["<<m_map.darts().index(flat->begin)<<", "
<<m_map.darts().index(flat->end)<<" (l="<<flat->length<<")]";
}
/// @return true iff the path is valid; i.e. a sequence of flats two by /// @return true iff the path is valid; i.e. a sequence of flats two by
/// two adjacent. /// two adjacent.
/// if test_minimal is true, test that there is no two consecutive flats /// if test_minimal is true, test that there is no two consecutive flats
@ -977,6 +983,12 @@ public:
if (!can_merge_with_next_flat(it, positive2, negative2)) if (!can_merge_with_next_flat(it, positive2, negative2))
{ return false; } { return false; }
#ifdef CGAL_TRACE_PATH_TESTS
std::cout<<"Merge with next flat: ";
display_flat(std::cout, it); std::cout<<" and ";
display_flat(std::cout, next_iterator(it)); std::cout<<std::endl;
#endif
List_iterator it2=next_iterator(it); List_iterator it2=next_iterator(it);
set_flat_length(it, flat_length(it)+flat_length(it2)+ set_flat_length(it, flat_length(it)+flat_length(it2)+
(positive2?1:-1)); (positive2?1:-1));
@ -1005,6 +1017,12 @@ public:
/// ('it' will be equal to m_path.end() if the path becomes empty). /// ('it' will be equal to m_path.end() if the path becomes empty).
void remove_spur(List_iterator& it) void remove_spur(List_iterator& it)
{ {
#ifdef CGAL_TRACE_PATH_TESTS
std::cout<<"Remove spur between flats: ";
display_flat(std::cout, it); std::cout<<" and ";
display_flat(std::cout, next_iterator(it)); std::cout<<std::endl;
#endif
CGAL_assertion(is_spur(it)); CGAL_assertion(is_spur(it));
Set_of_it modified_flats; Set_of_it modified_flats;
@ -1145,6 +1163,13 @@ public:
/// of the bracket; it3 is the flat end of the bracket. /// of the bracket; it3 is the flat end of the bracket.
void remove_negative_bracket(List_iterator& it1, List_iterator& it3) void remove_negative_bracket(List_iterator& it1, List_iterator& it3)
{ {
#ifdef CGAL_TRACE_PATH_TESTS
std::cout<<"Remove negative bracket: ";
display_flat(std::cout, it1); std::cout<<", ";
display_flat(std::cout, next_iterator(it1)); std::cout<<" and ";
display_flat(std::cout, it3); std::cout<<std::endl;
#endif
Set_of_it modified_flats; Set_of_it modified_flats;
List_iterator it2; List_iterator it2;
CGAL_assertion(is_negative_bracket(it1, it2)); // Here it2 is unused CGAL_assertion(is_negative_bracket(it1, it2)); // Here it2 is unused
@ -1192,6 +1217,13 @@ public:
void remove_positive_bracket(List_iterator& it1, void remove_positive_bracket(List_iterator& it1,
List_iterator& it3) List_iterator& it3)
{ {
#ifdef CGAL_TRACE_PATH_TESTS
std::cout<<"Remove positive bracket: ";
display_flat(std::cout, it1); std::cout<<", ";
display_flat(std::cout, next_iterator(it1)); std::cout<<" and ";
display_flat(std::cout, it3); std::cout<<std::endl;
#endif
Set_of_it modified_flats; Set_of_it modified_flats;
List_iterator it2; List_iterator it2;
CGAL_assertion(is_positive_bracket(it1, it2)); // Here it2 is unused CGAL_assertion(is_positive_bracket(it1, it2)); // Here it2 is unused
@ -1401,7 +1433,14 @@ public:
/// Right push the given l-shape. /// Right push the given l-shape.
void right_push_l_shape(List_iterator& it1) void right_push_l_shape(List_iterator& it1)
{ // it is the beginning of a flat {
#ifdef CGAL_TRACE_PATH_TESTS
std::cout<<"Right push l-shape: ";
display_flat(std::cout, it1); std::cout<<" and ";
display_flat(std::cout, next_iterator(it1)); std::cout<<std::endl;
#endif
// it is the beginning of a flat
CGAL_assertion(is_l_shape(it1)); CGAL_assertion(is_l_shape(it1));
// CGAL_assertion(is_valid()); // CGAL_assertion(is_valid());
Set_of_it modified_flats; Set_of_it modified_flats;