Add test for cylinder and torus

This commit is contained in:
Youmu 2020-07-16 16:39:59 -04:00
parent 6078a8cdb6
commit 1f8ccad1e9
5 changed files with 213 additions and 11 deletions

View File

@ -34,9 +34,11 @@ set(SOURCE_FILES
path_tests.cpp
path_with_rle_deformation_tests.cpp
shortest_noncontractible_cycle_tests.cpp
simplicity_cylinder.cpp
simplicity_double_torus.cpp
simplicity_double_torus_with_holes.cpp
simplicity_homology_group.cpp
simplicity_torus.cpp
test_homotopy.cpp
test_homotopy_with_polygonal_schema.cpp
test_shortest_cycle_non_contractible.cpp

View File

@ -0,0 +1,114 @@
#include <CGAL/Polygonal_schema.h>
#include <CGAL/Path_on_surface.h>
#include <CGAL/Curves_on_surface_topology.h>
using namespace CGAL::Surface_mesh_topology;
typedef Polygonal_schema_with_combinatorial_map<> PS;
///////////////////////////////////////////////////////////////////////////////
void create_mesh_1(PS& ps)
{
ps.add_facet("a b c d");
ps.add_facet("-b e -d f");
ps.add_facet("-a -e");
ps.add_facet("-c -f");
ps.perforate_facet("-a");
ps.perforate_facet("-c");
}
///////////////////////////////////////////////////////////////////////////////
void create_mesh_2(PS& ps)
{
ps.add_facet("a b c d");
ps.add_facet("-b e -d f");
ps.add_facet("-a -e");
ps.add_facet("-c -f");
ps.perforate_facet("-a");
ps.perforate_facet("-c");
ps.perforate_facet("a");
}
///////////////////////////////////////////////////////////////////////////////
void create_mesh_3(PS& ps)
{
ps.add_facet("a b c d");
ps.add_facet("-b e -d f");
ps.add_facet("-a -e");
ps.add_facet("-c -f");
ps.perforate_facet("-a");
ps.perforate_facet("-c");
ps.perforate_facet("e");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_1(Path_on_surface<PS>& p)
{
p.push_back_by_label("a e");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_2(Path_on_surface<PS>& p)
{
p.push_back_by_label("a b -f d a e");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_3(Path_on_surface<PS>& p)
{
p.push_back_by_label("a b c d");
}
///////////////////////////////////////////////////////////////////////////////
int main()
{
PS ps[2];
create_mesh_1(ps[0]);
create_mesh_2(ps[1]);
std::size_t num_ps = sizeof(ps) / sizeof(PS);
bool res=true;
for(std::size_t i = 0; i < num_ps; ++i)
{
Curves_on_surface_topology<PS> cst(ps[i]);
Path_on_surface<PS> p1(ps[i]), p2(ps[i]), p3(ps[i]);
create_path_1(p1);
create_path_2(p2);
create_path_3(p3);
if(!cst.is_homotopic_to_simple_cycle(p1))
{
std::cout<<"ERROR simplicity_cylinder surface"
<< (i+1) << "/test1: "
<<"Path p1 should be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if(cst.is_homotopic_to_simple_cycle(p2))
{
std::cout<<"ERROR simplicity_cylinder surface"
<< (i+1) << "/test2: "
<<"Path p2 should not be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if(!cst.is_homotopic_to_simple_cycle(p3))
{
std::cout<<"ERROR simplicity_cylinder surface"
<< (i+1) << "/test3: "
<<"Path p3 should be homotopic to a simple cycle"
<<std::endl;
res=false;
}
}
if (res)
{
std::cout<<"SUCCESS simplicity_cylinder; all tests ok."<<std::endl;
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}

View File

@ -6,7 +6,7 @@ using namespace CGAL::Surface_mesh_topology;
typedef Polygonal_schema_with_combinatorial_map<> PS;
///////////////////////////////////////////////////////////////////////////////
void create_mesh1(PS& ps)
void create_mesh_1(PS& ps)
{
ps.add_facet("b -a g f e");
ps.add_facet("-b k i -g");
@ -22,7 +22,7 @@ void create_mesh1(PS& ps)
}
///////////////////////////////////////////////////////////////////////////////
void create_mesh2(PS& ps)
void create_mesh_2(PS& ps)
{
ps.add_facet("a b -a -b o");
ps.add_facet("-o -p");
@ -31,7 +31,7 @@ void create_mesh2(PS& ps)
}
///////////////////////////////////////////////////////////////////////////////
void create_mesh3(PS& ps)
void create_mesh_3(PS& ps)
{
ps.add_facet("a b -a -b s");
ps.add_facet("c d -c -d -s");
@ -73,9 +73,9 @@ void create_path_4(Path_on_surface<PS>& p)
int main()
{
PS ps[3];
create_mesh1(ps[0]);
create_mesh2(ps[1]);
create_mesh3(ps[2]);
create_mesh_1(ps[0]);
create_mesh_2(ps[1]);
create_mesh_3(ps[2]);
std::size_t num_ps = sizeof(ps) / sizeof(PS);
bool res=true;
@ -92,7 +92,7 @@ int main()
if(!cst.is_homotopic_to_simple_cycle(p1))
{
std::cout<<"ERROR simplicity_double_torus_with_holes surface"
<< i << "/test1: "
<< (i+1) << "/test1: "
<<"Path p1 should be homotopic to a simple cycle"
<<std::endl;
res=false;
@ -101,7 +101,7 @@ int main()
if(cst.is_homotopic_to_simple_cycle(p2))
{
std::cout<<"ERROR simplicity_double_torus_with_holes surface"
<< i << "/test2: "
<< (i+1) << "/test2: "
<<"Path p2 should not be homotopic to a simple cycle"
<<std::endl;
res=false;
@ -110,7 +110,7 @@ int main()
if(!cst.is_homotopic_to_simple_cycle(p3))
{
std::cout<<"ERROR simplicity_double_torus_with_holes surface"
<< i << "/test3: "
<< (i+1) << "/test3: "
<<"Path p3 should be homotopic to a simple cycle"
<<std::endl;
res=false;
@ -119,7 +119,7 @@ int main()
if(cst.is_homotopic_to_simple_cycle(p4))
{
std::cout<<"ERROR simplicity_double_torus_with_holes surface"
<< i << "/test4: "
<< (i+1) << "/test4: "
<<"Path p4 should not be homotopic to a simple cycle"
<<std::endl;
res=false;

View File

@ -123,7 +123,7 @@ int main()
if (res)
{
std::cout<<"SUCCESS simplicity_double_torus_with_holes; all tests ok."<<std::endl;
std::cout<<"SUCCESS simplicity_homology_group; all tests ok."<<std::endl;
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,86 @@
#include <CGAL/Polygonal_schema.h>
#include <CGAL/Path_on_surface.h>
#include <CGAL/Curves_on_surface_topology.h>
using namespace CGAL::Surface_mesh_topology;
typedef Polygonal_schema_with_combinatorial_map<> PS;
///////////////////////////////////////////////////////////////////////////////
void create_path_1(Path_on_surface<PS>& p)
{
p.push_back_by_label("a b a a b");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_2(Path_on_surface<PS>& p)
{
p.push_back_by_label("a b");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_3(Path_on_surface<PS>& p)
{
p.push_back_by_label("-a b a b b");
}
///////////////////////////////////////////////////////////////////////////////
void create_path_4(Path_on_surface<PS>& p)
{
p.push_back_by_label("-a -b a a -b -b a a -b a -b -b");
}
///////////////////////////////////////////////////////////////////////////////
int main()
{
PS ps;
ps.add_facet("a b -a -b");
Curves_on_surface_topology<PS> cst(ps);
Path_on_surface<PS> p1(ps), p2(ps), p3(ps), p4(ps);
create_path_1(p1);
create_path_2(p2);
create_path_3(p3);
create_path_4(p4);
bool res=true;
if(!cst.is_homotopic_to_simple_cycle(p1))
{
std::cout<<"ERROR simplicity_torus test1: "
<<"Path p1 should be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if(!cst.is_homotopic_to_simple_cycle(p2))
{
std::cout<<"ERROR simplicity_torus test2: "
<<"Path p2 should be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if(cst.is_homotopic_to_simple_cycle(p3))
{
std::cout<<"ERROR simplicity_torus test3: "
<<"Path p3 should not be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if(cst.is_homotopic_to_simple_cycle(p4))
{
std::cout<<"ERROR simplicity_torus test4: "
<<"Path p4 should not be homotopic to a simple cycle"
<<std::endl;
res=false;
}
if (res)
{
std::cout<<"SUCCESS simplicity_torus; all tests ok."<<std::endl;
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}