Update isotopy test; seems to work now; need more tests.

This commit is contained in:
Guillaume Damiand 2018-07-04 17:00:28 +02:00
parent 5a5f754b5a
commit 53ed894ec7
4 changed files with 168 additions and 17 deletions

View File

@ -26,6 +26,7 @@
#include <boost/unordered_map.hpp>
#include <CGAL/Random.h>
#include <CGAL/Path_on_surface.h>
#include <CGAL/Combinatorial_map_basic_operations.h>
namespace CGAL {
@ -129,6 +130,27 @@ namespace CGAL {
std::cout<<"Paths are all valid ? "<<(are_paths_valid()?"YES":"NO")
<<std::endl;
auto marktemp=m_map.get_new_mark();
Dart_handle dh2=NULL;
for (auto it=m_map.darts().begin(); it!=m_map.darts().end(); ++it)
{
if (!m_map.is_marked(it, marktemp))
{
std::cout<<"Degree="<<CGAL::template degree<Map, 0>(m_map, it)<<std::endl;
std::cout<<"Co-degree="<<CGAL::template codegree<Map, 2>(m_map, it)<<std::endl;
dh2=it;
do
{
m_map.mark(dh2, marktemp);
std::cout<<m_map.darts().index(dh2)<<" "
<<m_map.darts().index(m_map.template beta<0>(dh2))<<std::endl;
dh2=m_map.template beta<0,2>(dh2);
}
while(dh2!=it);
}
}
m_map.free_mark(marktemp);
m_map.display_darts(std::cout);
#endif
}

View File

@ -348,6 +348,53 @@ void generate_g2_torus(Path& p, std::size_t i)
}
}
template<typename Path>
void generate_g1_v0_double_torus(Path& p)
{ // 1st generator
p.clear();
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[16]));
extend_straight_negative(p, 2);
}
template<typename Path>
void generate_g1_v1_double_torus(Path& p)
{ // 1st generator
p.clear();
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[4]));
extend_straight_negative(p, 2);
}
template<typename Path>
void generate_g1_v2_double_torus(Path& p)
{ // 1st generator
p.clear();
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[2]));
extend_straight_negative(p, 2);
p.reverse();
}
template<typename Path>
void generate_g2_v1_double_torus(Path& p)
{ // 2nd generator
p.clear();
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[10]));
extend_straight_negative(p, 2);
extend_uturn_negative(p, 1);
}
template<typename Path>
void generate_g1_double_torus(Path& p, std::size_t i)
{
assert(i<3);
switch(i)
{
case 0: generate_g1_v0_double_torus(p); break;
case 1: generate_g1_v1_double_torus(p); break;
case 2: generate_g1_v2_double_torus(p); break;
default: assert(false);
}
}
} // namespace CGAL
#endif // CGAL_CREATION_OF_TEST_CASES_FOR_PATHS_H //

View File

@ -571,6 +571,14 @@ public:
else
{ CGAL::extend_straight_positive(new_path, 1); }
}
if (begin==middle && next_index(middle)==end)
{ // TODO: check if we need to do also something for !case_seven ?
// if (case_seven)
{ CGAL::extend_uturn_positive(new_path, 1); }
/* else
{ assert(false); } // We think (?) that this case is not possible */
}
}
void push_l_shape_cycle_2()
@ -583,10 +591,30 @@ public:
CGAL::extend_straight_positive_until(*this, d1);
}
bool push_l_shape_2darts()
{
Dart_const_handle d1=NULL;
if (next_negative_turn(0)==1)
d1=m_map.template beta<2,1>(get_ith_dart(0));
else if (next_negative_turn(1)==1)
d1=m_map.template beta<2,1>(get_ith_dart(1));
else return false;
clear();
push_back(d1);
CGAL::extend_uturn_positive(*this, 1);
//push_back(m_map.template beta<1>(d1));
return true;
}
bool right_push_one_step()
{
if (is_empty()) { return false; }
if (length()==2)
{ return push_l_shape_2darts(); }
std::size_t begin, middle, end;
std::size_t lastturn=m_path.size()-(is_closed()?0:1);
std::size_t next_turn;
@ -626,7 +654,8 @@ public:
else
{
if (next_turn==1)
{ // Here middle is a real middle; we already know begin (or we know
{
// Here middle is a real middle; we already know begin (or we know
// that there is no -2 before if !prev2), we only need to compute
// end.
if (!prev2) { begin=middle; } // There is no -2 before this -1
@ -676,7 +705,11 @@ public:
{
bool res=false;
while(right_push_one_step())
{ res=true; }
{ res=true;
std::cout<<"RP "; display(); display_pos_and_neg_turns();
std::cout<<std::endl;
}
return res;
}
@ -686,18 +719,32 @@ public:
if (!is_closed())
{ return; }
std::cout<<"##########################################"<<std::endl;
std::cout<<"Init "; display();
std::cout<<std::endl;
display_pos_and_neg_turns();
bool modified=false;
std::cout<<"RS "; remove_spurs_one_step();
display();
std::cout<<std::endl;
do
{
modified=bracket_flattening_one_step();
if (!modified)
{
modified=remove_spurs_one_step();
if (!modified)
{ modified=right_push_one_step(); }
}
std::cout<<"BF "; display();
std::cout<<std::endl;
modified=modified || remove_spurs_one_step();
std::cout<<"RS "; display();
std::cout<<std::endl;
}
while(modified);
right_push();
}
std::vector<std::size_t> compute_positive_turns() const
@ -824,8 +871,8 @@ public:
std::cout<<m_map.darts().index(get_ith_dart(i));
if (i<length()-1) { std::cout<<" "; }
}
if (is_closed())
{ std::cout<<" "<<m_map.darts().index(get_ith_dart(0)); }
if (is_closed())
{ std::cout<<" c "; } //<<m_map.darts().index(get_ith_dart(0)); }
}
protected:

View File

@ -17,7 +17,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;
#define NB_TESTS 23 // 0 ... 22
#define NB_TESTS 24 // 0 ... 23
int nbtests=0;
enum Transformation // enum for the type of transformations
@ -402,8 +402,8 @@ bool test_some_random_paths_on_cube(bool draw, int testtorun)
{ res=false; }
generate_random_bracket(path, 5, 12, 8, random); // Test 20
if (!unit_test(path, FULL_SIMPLIFICATION, 0, "(2^4 1 2^12 1 2^8 ...)",
"2", draw, testtorun))
if (!unit_test(path, PUSH, 0, "(2^4 1 2^12 1 2^8 ...)",
"2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 2 2 2 2 0 2 2 2 2 1 2 1", draw, testtorun))
{ res=false; }
return true;
@ -455,7 +455,7 @@ bool test_torus_quad(bool draw, int testtorun)
{ res=false; }
// Test 23 (3 g2 cycles) TODO BUG IN TEST 23 !!!
/* paths.clear(); transformed_paths.clear();
paths.clear(); transformed_paths.clear();
for (int i=0; i<3; ++i)
{
paths.push_back(CGAL::Path_on_surface<LCC_3_cmap>(lcc));
@ -468,11 +468,40 @@ bool test_torus_quad(bool draw, int testtorun)
"canonize paths on torus gen2",
draw, testtorun))
{ res=false; }
*/
return res;
}
///////////////////////////////////////////////////////////////////////////////
bool test_double_torus_quad(bool draw, int testtorun)
{
bool res=true;
LCC_3_cmap lcc;
if (!CGAL::load_off(lcc, "./data/double-torus.off"))
{
std::cout<<"PROBLEM reading file ./data/double-torus.off"<<std::endl;
exit(EXIT_FAILURE);
}
CGAL::Combinatorial_map_tools<LCC_3_cmap> cmt(lcc);
std::vector<CGAL::Path_on_surface<LCC_3_cmap> > paths;
std::vector<CGAL::Path_on_surface<LCC_3_cmap> > transformed_paths;
// Test 21 (3 g1 cycles)
for (int i=0; i<3; ++i)
{
paths.push_back(CGAL::Path_on_surface<LCC_3_cmap>(lcc));
CGAL::generate_g1_double_torus(paths[i], i);
transformed_paths.push_back
(cmt.transform_original_path_into_quad_surface(paths[i]));
}
if (!unit_test_canonize(paths, transformed_paths,
"canonize paths on double torus gen1",
draw, testtorun))
{ res=false; }
}
///////////////////////////////////////////////////////////////////////////////
bool test_elephant(bool draw, int testtorun) // TODO LATER
{
@ -600,11 +629,17 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
if (!test_torus_quad(draw, testN))
if (!test_double_torus_quad(draw, testN))
{
std::cout<<"TEST DOUBLE TORUS FAILED."<<std::endl;
return EXIT_FAILURE;
}
/* if (!test_torus_quad(draw, testN))
{
std::cout<<"TEST TORUS FAILED."<<std::endl;
return EXIT_FAILURE;
}
} */
/* TODO LATER if (!test_file(draw, testN))
{