Continue isotopy test.

This commit is contained in:
Guillaume Damiand 2018-09-18 15:16:40 +02:00
parent ed81c8491c
commit f52676769f
4 changed files with 73 additions and 31 deletions

View File

@ -152,6 +152,10 @@ namespace CGAL {
m_map.free_mark(marktemp); m_map.free_mark(marktemp);
m_map.display_darts(std::cout); m_map.display_darts(std::cout);
#endif #endif
m_map.display_darts(std::cout);
assert(are_paths_valid());
} }
~Combinatorial_map_tools() ~Combinatorial_map_tools()
@ -168,10 +172,12 @@ namespace CGAL {
{ {
if (!m_original_map.is_marked(path[i], m_mark_T)) if (!m_original_map.is_marked(path[i], m_mark_T))
{ {
res.push_back(get_first_dart_of_the_path(path[i])); res.push_back(get_first_dart_of_the_path(path[i]), false);
res.push_back(get_second_dart_of_the_path(path[i])); res.push_back(get_second_dart_of_the_path(path[i]), false);
} }
} }
res.update_is_closed();
assert(res.is_closed());
assert(res.is_valid()); assert(res.is_valid());
return res; return res;
} }
@ -402,20 +408,20 @@ namespace CGAL {
// <<m_map.darts().index(p.second)<<": "<<std::flush; // <<m_map.darts().index(p.second)<<": "<<std::flush;
//std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush; //std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush;
p.first=m_map.template beta<0>(p.first); // p.first=m_map.template beta<0>(p.first);
Dart_const_handle initdart=p.first; Dart_const_handle initdart=p.first;
while (m_map.is_marked(p.first, toremove)) while (m_map.is_marked(p.first, toremove))
{ {
p.first=m_map.template beta<2, 0>(p.first); p.first=m_map.template beta<2, 1>(p.first);
//std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush; //std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush;
assert(p.first!=initdart); assert(p.first!=initdart);
} }
//std::cout<<std::endl; //std::cout<<std::endl;
p.second=m_map.template beta<0>(p.second); // p.second=m_map.template beta<0>(p.second);
initdart=p.second; initdart=p.second;
while (m_map.is_marked(p.second, toremove)) while (m_map.is_marked(p.second, toremove))
{ {
p.second=m_map.template beta<2, 0>(p.second); p.second=m_map.template beta<2, 1>(p.second);
//std::cout<<m_map.darts().index(p.second)<<"; "<<std::flush; //std::cout<<m_map.darts().index(p.second)<<"; "<<std::flush;
assert(p.second!=initdart); assert(p.second!=initdart);
} }
@ -465,8 +471,8 @@ namespace CGAL {
std::pair<Dart_const_handle, Dart_const_handle>& p=itp->second; std::pair<Dart_const_handle, Dart_const_handle>& p=itp->second;
//std::cout<<"Pair: "<<m_map.darts().index(p.first)<<", " //std::cout<<"Pair: "<<m_map.darts().index(p.first)<<", "
// <<m_map.darts().index(p.second)<<std::flush; // <<m_map.darts().index(p.second)<<std::flush;
p.first=m_map.template beta<1>(p.first); p.first=m_map.template beta<0, 2>(p.first);
p.second=m_map.template beta<1,2>(p.second); p.second=m_map.template beta<0>(p.second);
//std::cout<<" -> "<<m_map.darts().index(p.first)<<", " //std::cout<<" -> "<<m_map.darts().index(p.first)<<", "
// <<m_map.darts().index(p.second)<<std::endl; // <<m_map.darts().index(p.second)<<std::endl;
// WRONG ASSERTS assert(p.first!=p.second); // WRONG ASSERTS assert(p.first!=p.second);

View File

@ -475,6 +475,9 @@ void generate_random_closed_path(Path& p, std::size_t nb,
{ CGAL::unmark_cell<typename Path::Map, 2>(p.get_map(), *it, amark); } { CGAL::unmark_cell<typename Path::Map, 2>(p.get_map(), *it, amark); }
p.get_map().free_mark(amark); p.get_map().free_mark(amark);
p.update_is_closed(); // TODO we can avoid that because we know that we generated a closed path (to do so, we need a method that put p.is_closed to true)
assert(p.is_closed());
} }
} // namespace CGAL } // namespace CGAL

View File

@ -439,6 +439,10 @@ public:
{ {
if (is_empty()) return false; if (is_empty()) return false;
#ifndef NDEBUG
bool is_even=length()%2;
#endif // NDEBUG
Self new_path(m_map); Self new_path(m_map);
bool positive=false; bool positive=false;
std::size_t begin, end; std::size_t begin, end;
@ -471,6 +475,9 @@ public:
{ copy_rest_of_path(end+1, length(), new_path); } { copy_rest_of_path(end+1, length(), new_path); }
swap(new_path); swap(new_path);
assert(length()%2==is_even); // bracket flattening is supposed to preserve length parity
return true; return true;
} }
} }
@ -495,25 +502,43 @@ public:
bool res=false; bool res=false;
std::size_t i; std::size_t i;
std::size_t lastturn=m_path.size()-(is_closed()?0:1); std::size_t lastturn=m_path.size()-(is_closed()?0:1);
Self new_path(m_map); for (i=0; !res && i<lastturn; ++i)
for (i=0; i<lastturn; )
{ {
if (m_path[i]==m_map.template beta<2>(m_path[next_index(i)])) if (m_path[i]==m_map.template beta<2>(m_path[next_index(i)]))
{ { res=true; }
i+=2; }
res=true;
} if (!res)
else { return false; }
{
new_path.push_back(m_path[i]); // We copy this dart #ifndef NDEBUG
++i; bool is_even=length()%2;
} #endif // NDEBUG
--i; // Because we did a ++ before to leave the loop
// Here there is a spur at position i in the path
Self new_path(m_map);
// Special case, the spur is between last dart of the path and the first dart
if (is_closed() && i==m_path.size()-1)
{
copy_rest_of_path(1, m_path.size()-1, new_path); // copy path between 1 and m_path.size()-2
}
else
{ // Otherwise copy darts before the spur
if (i>0)
{ copy_rest_of_path(0, i, new_path); } // copy path between 0 and i-1
// and the darts after
if (i+2<m_path.size())
{ copy_rest_of_path(i+2, m_path.size(), new_path); } // copy path between 0 and m_path.size()-1
} }
if (i==m_path.size()-1)
{ new_path.push_back(m_path[m_path.size()-1]); } // we copy the last dart
swap(new_path); swap(new_path);
return res;
assert(length()%2==is_even); // spur rremoval is supposed to preserve length parity
return true;
} }
// Simplify the path by removing all spurs // Simplify the path by removing all spurs
@ -615,6 +640,7 @@ public:
/* else /* else
{ assert(false); } // We think (?) that this case is not possible */ { assert(false); } // We think (?) that this case is not possible */
} }
} }
void push_l_shape_cycle_2() void push_l_shape_cycle_2()
@ -651,6 +677,10 @@ public:
if (length()==2) if (length()==2)
{ return push_l_shape_2darts(); } { return push_l_shape_2darts(); }
#ifndef NDEBUG
bool is_even=length()%2;
#endif // NDEBUG
std::size_t begin, middle, end; std::size_t begin, middle, end;
std::size_t lastturn=m_path.size()-(is_closed()?0:1); std::size_t lastturn=m_path.size()-(is_closed()?0:1);
std::size_t next_turn; std::size_t next_turn;
@ -728,6 +758,9 @@ public:
{ copy_rest_of_path(end+1, length(), new_path); } { copy_rest_of_path(end+1, length(), new_path); }
swap(new_path); swap(new_path);
assert(length()%2==is_even); // push lshape is supposed to preserve length parity (maybe preserve length ?? TODO check)
return true; return true;
} }
@ -743,7 +776,7 @@ public:
while(right_push_one_step()) while(right_push_one_step())
{ res=true; { res=true;
std::cout<<"RP "; display(); display_pos_and_neg_turns(); std::cout<<"PUSH "; display(); display_pos_and_neg_turns();
std::cout<<std::endl; std::cout<<std::endl;
} }
return res; return res;

View File

@ -18,7 +18,7 @@ typedef CGAL::Linear_cell_complex_for_combinatorial_map<2,3> LCC_3_cmap;
typedef CGAL::Linear_cell_complex_for_generalized_map<2,3> LCC_3_gmap; typedef CGAL::Linear_cell_complex_for_generalized_map<2,3> LCC_3_gmap;
#define NB_TESTS 25 // 0 ... 24 #define NB_TESTS 25 // 0 ... 24
int nbtests=0; static int nbtests=0;
enum Transformation // enum for the type of transformations enum Transformation // enum for the type of transformations
{ {
@ -27,7 +27,7 @@ enum Transformation // enum for the type of transformations
FULL_SIMPLIFICATION FULL_SIMPLIFICATION
}; };
unsigned int starting_seed; static unsigned int starting_seed;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void transform_path(CGAL::Path_on_surface<LCC_3_cmap>& path, Transformation t, void transform_path(CGAL::Path_on_surface<LCC_3_cmap>& path, Transformation t,
@ -164,7 +164,7 @@ bool unit_test_canonize(std::vector<CGAL::Path_on_surface<LCC_3_cmap> >& paths,
std::cout<<"."<<std::flush; std::cout<<"."<<std::flush;
#endif #endif
for (int i=0; i<paths.size(); ++i) for (unsigned int i=0; i<paths.size(); ++i)
{ {
if (draw) if (draw)
{ {
@ -524,7 +524,7 @@ bool test_double_torus_quad(bool draw, int testtorun)
std::vector<CGAL::Path_on_surface<LCC_3_cmap> > transformed_paths; std::vector<CGAL::Path_on_surface<LCC_3_cmap> > transformed_paths;
// Test 23 (3 g1 cycles) // Test 23 (3 g1 cycles)
for (int i=0; i<3; ++i) for (unsigned int i=0; i<3; ++i)
{ {
paths.push_back(CGAL::Path_on_surface<LCC_3_cmap>(lcc)); paths.push_back(CGAL::Path_on_surface<LCC_3_cmap>(lcc));
CGAL::generate_g1_double_torus(paths[i], i); CGAL::generate_g1_double_torus(paths[i], i);
@ -559,11 +559,11 @@ bool test_double_torus_quad(bool draw, int testtorun)
generate_random_closed_path(p, random.get_int(5, 20), random); // random path, length between 30 and 500 generate_random_closed_path(p, random.get_int(5, 20), random); // random path, length between 30 and 500
// p.close(); // p.close();
paths.push_back(p); paths.push_back(p);
/* update_path_randomly(p, random);
paths.push_back(p);
update_path_randomly(p, random); update_path_randomly(p, random);
paths.push_back(p);
/* update_path_randomly(p, random);
paths.push_back(p); */ paths.push_back(p); */
for (int i=0; i<paths.size(); ++i) for (unsigned int i=0; i<paths.size(); ++i)
{ {
transformed_paths.push_back transformed_paths.push_back
(cmt2.transform_original_path_into_quad_surface(paths[i])); (cmt2.transform_original_path_into_quad_surface(paths[i]));
@ -672,7 +672,7 @@ int main(int argc, char** argv)
CGAL::Random r; // Used when user do not provide its own seed. CGAL::Random r; // Used when user do not provide its own seed.
starting_seed=r.get_int(0,INT_MAX); starting_seed=r.get_int(0,INT_MAX);
for (int i=1; i<argc; ++i) for (unsigned int i=1; i<(unsigned int)argc; ++i)
{ {
arg=argv[i]; arg=argv[i];
if (arg=="-draw") if (arg=="-draw")