Start test suite for insertion in GMap

This commit is contained in:
Guillaume Damiand 2016-10-03 16:52:13 -04:00
parent ecb0bcc8a5
commit 7cd227fd08
6 changed files with 300 additions and 21 deletions

View File

@ -1169,7 +1169,7 @@ namespace CGAL {
Base(amap, adart),
mmark_number(amark)
{
CGAL_assertion( d>=2 && d<=Map::dimension );
CGAL_assertion( d<=Map::dimension );
CGAL_assertion( i<=Map::dimension );
if (adart!=this->mmap->null_handle)
this->mmap->mark(adart, mmark_number);

View File

@ -3260,7 +3260,7 @@ namespace CGAL {
bool update_attributes=true )
{
Dart_handle d1, d2;
size_type mark=get_new_mark();
size_type amark=get_new_mark();
// 1) We store all the darts of the edge.
std::deque<Dart_handle> vect;
@ -3278,17 +3278,18 @@ namespace CGAL {
{
d1 = create_dart();
if (!(is_free<0>(*it)) && is_marked(alpha<0>(*it), mark))
if (!(this->template is_free<0>(*it)) &&
is_marked(alpha<0>(*it), amark))
basic_link_alpha<1>(d1, alpha<0,0>(*it));
basic_link_alpha<0>(*it, d1);
mark(*it, mark);
mark(*it, amark);
for ( unsigned int dim=2; dim<=dimension; ++dim )
{
if (!is_free(*it, dim) && is_marked(alpha(*it, dim), mark))
if (!is_free(*it, dim) && is_marked(alpha(*it, dim), amark))
{
basic_link_alpha(beta(*it, dim, 0), d1, dim);
basic_link_alpha(alpha(*it, dim, 0), d1, dim);
}
}
@ -3304,30 +3305,30 @@ namespace CGAL {
// We initialise the 0-atttrib to ah
CGAL::internal::Set_i_attribute_of_dart_functor<Self, 0>::
run(this, d1, ah);
mark(*it, mark);
mark(*it, amark);
}
}
for (it = vect.begin(); it != vect.end(); ++it)
{
unmark(*it, m);
unmark(*it, mark);
unmark(*it, amark);
}
CGAL_assertion(is_whole_map_unmarked(m));
CGAL_assertion(is_whole_map_unmarked(mark));
CGAL_assertion(is_whole_map_unmarked(amark));
free_mark(m);
free_mark(mark);
free_mark(amark);
if (are_attributes_automatically_managed() && update_attributes)
{
if ( !(is_free<1>(alpha<0>(adart))) )
{
CGAL::internal::GMap_degroup_attribute_functor_run<Self, 1>::
run(this, adart, alpha<0,1>(adart));
if ( !(this->template is_free<1>(alpha<0>(adart))) )
{
CGAL::internal::GMap_degroup_attribute_functor_run<Self, 1>::
run(this, adart, alpha<0,1>(adart));
}
}
}
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( is_valid() );
@ -3490,11 +3491,15 @@ namespace CGAL {
CGAL_assertion(is_insertable_cell_1_in_cell_2(adart1, adart2));
}
/* CGAL::GMap_dart_iterator_basic_of_involution<Self,1> will contain all
* alpha_i except alpha_0, alpha_1 and alpha_2, i.e. this is
* <alpha_3,...,alpha_d>
*/
size_type m1=get_new_mark();
CGAL::GMap_dart_iterator_basic_of_involution<Self,0,1> it1(*this, adart1, m1);
CGAL::GMap_dart_iterator_basic_of_involution<Self,1> it1(*this, adart1, m1);
size_type m2=get_new_mark();
CGAL::GMap_dart_iterator_basic_of_involution<Self,0,1> it2(*this, adart2, m2);
CGAL::GMap_dart_iterator_basic_of_involution<Self,1> it2(*this, adart2, m2);
Dart_handle d1=null_handle;
Dart_handle d2=null_handle;
@ -3506,7 +3511,6 @@ namespace CGAL {
CGAL_assertion (it2.cont() );
d1 = create_dart();
d2 = create_dart();
this->template basic_link_alpha<0>(d1, d2);
mark(it1,treated);
if ( !this->template is_free<1>(it1) &&
@ -3533,6 +3537,10 @@ namespace CGAL {
++it2;
}
// We do the link_alpha<0> after the link_alpha<1> to update the
// possible attributes of d2.
this->template link_alpha<0>(d1, d2);
if (are_attributes_automatically_managed() && update_attributes && ah!=NULL)
{
internal::Set_i_attribute_of_dart_functor<Self, 0>::run(this, d1, ah);

View File

@ -43,7 +43,12 @@ include( ${CGAL_USE_FILE} )
#include( CGAL_CreateSingleSourceCGALProgram )
include_directories(BEFORE ../../include)
add_executable(Generalized_map_test Generalized_map_test.cpp)
add_executable(Generalized_map_test
GMap_test_insertions.h
Generalized_map_2_test.h
Generalized_map_3_test.h
Generalized_map_4_test.h
Generalized_map_test.cpp)
#create_single_source_cgal_program( "Generalized_map_test.cpp" )
target_link_libraries(Generalized_map_test ${CGAL_LIBRARIES}
${CGAL_3RD_PARTY_LIBRARIES} )

View File

@ -0,0 +1,260 @@
#ifndef GMAP_TEST_INSERTIONS_H
#define GMAP_TEST_INSERTIONS_H
template<typename GMAP>
bool check_number_of_cells_3(GMAP& gmap, unsigned int nbv, unsigned int nbe,
unsigned int nbf, unsigned int nbvol,
unsigned int nbcc);
template<typename GMAP>
bool test_vertex_insertion(GMAP& gmap)
{
typename GMAP::Dart_handle d1, d2, d3;
trace_test_begin();
d1 = gmap.create_dart();
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 2, 1, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.create_dart(); gmap.template sew<1>(d1, d1);
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 2, 1, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 3, 2, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
gmap.template sew<1>(d1, gmap.template alpha<0>(d1));
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
d2 = gmap.make_edge();
gmap.template sew<2>(d1, d2);
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 3, 2, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
d2 = gmap.make_edge();
gmap.template sew<2>(d1, d2);
gmap.template sew<1>(d1, gmap.template alpha<0>(d1));
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
d2 = gmap.make_edge();
gmap.template sew<2>(d1, d2);
gmap.template sew<1>(d1, gmap.template alpha<0>(d1));
gmap.template sew<1>(d2, gmap.template alpha<0>(d2));
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(3);
d2 = gmap.template alpha<0,1>(d1);
d3 = gmap.template alpha<1>(d1);
gmap.insert_cell_0_in_cell_1(d1);
gmap.insert_cell_0_in_cell_1(d2);
gmap.insert_cell_0_in_cell_1(d3);
if ( !check_number_of_cells_3(gmap, 6, 6, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(3);
d2 = gmap.make_combinatorial_polygon(3);
gmap.template sew<3>(d1, d2);
d2 = gmap.template alpha<0,1>(d1);
d3 = gmap.template alpha<1>(d1);
gmap.insert_cell_0_in_cell_1(d1);
gmap.insert_cell_0_in_cell_1(d2);
gmap.insert_cell_0_in_cell_1(d3);
if ( !check_number_of_cells_3(gmap, 6, 6, 1, 2, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(3);
d2 = gmap.make_combinatorial_polygon(3);
gmap.template sew<2>(d1, d2);
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 5, 6, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(3);
d2 = gmap.make_combinatorial_polygon(3);
gmap.template sew<2>(d1, d2);
gmap.insert_cell_0_in_cell_1(gmap.template alpha<0,1>(d1));
gmap.insert_cell_0_in_cell_1(gmap.template alpha<1>(d1));
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 7, 8, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_hexahedron();
d2 = gmap.make_combinatorial_hexahedron();
gmap.template sew<3>(d1, d2);
gmap.insert_cell_0_in_cell_1(gmap.template alpha<0,1,0,1>(d1));
gmap.insert_cell_0_in_cell_1(gmap.template alpha<0,1>(d1));
gmap.insert_cell_0_in_cell_1(gmap.template alpha<1>(d1));
gmap.insert_cell_0_in_cell_1(d1);
if ( !check_number_of_cells_3(gmap, 16, 24, 11, 2, 1) )
return false;
gmap.clear();
return true;
}
template<typename GMAP>
bool test_edge_insertion(GMAP& gmap)
{
typename GMAP::Dart_handle d1, d2, d3;
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
gmap.insert_cell_1_in_cell_2(d1, gmap.alpha(d1,0,1,0));
if ( !check_number_of_cells_3(gmap, 4, 5, 2, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
d2 = gmap.make_combinatorial_polygon(4);
gmap.template sew<3>(d1, d2);
gmap.insert_cell_1_in_cell_2(d1, gmap.alpha(d1,0,1,0));
if ( !check_number_of_cells_3(gmap, 4, 5, 2, 2, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
d2 = gmap.make_combinatorial_polygon(4);
gmap.template sew<2>(d1, d2);
gmap.insert_cell_1_in_cell_2(d1, gmap.alpha(d1,0,1,0));
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.create_dart();
gmap.insert_dangling_cell_1_in_cell_2(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
gmap.template sew<1>(d1, gmap.alpha(d1, 0));
gmap.insert_dangling_cell_1_in_cell_2(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 1, 1, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_edge();
d2 = gmap.make_edge();
gmap.template sew<3>(d1, d2);
gmap.template sew<1>(d1, gmap.alpha(d1, 0));
gmap.insert_dangling_cell_1_in_cell_2(d1);
if ( !check_number_of_cells_3(gmap, 2, 2, 2, 2, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
gmap.insert_dangling_cell_1_in_cell_2(d1);
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
d2 = gmap.make_combinatorial_polygon(4);
gmap.template sew<3>(d1, d2);
gmap.insert_dangling_cell_1_in_cell_2(d1);
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear();
return true;
}
template<typename GMAP>
bool test_face_insertion(GMAP& gmap)
{
typename GMAP::Dart_handle d1, d2, d3;
std::vector<typename GMAP::Dart_handle> v;
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(4);
v.push_back(d1); v.push_back(gmap.beta(v[0],1));
v.push_back(gmap.beta(v[1],1)); v.push_back(gmap.beta(v[2],1));
gmap.insert_cell_2_in_cell_3(v.begin(),v.end());
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear(); v.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_polygon(3);
d2 = gmap.make_combinatorial_polygon(3);
gmap.template sew<2>(d1, d2);
v.push_back(d1); v.push_back(gmap.beta(v[0],1));
v.push_back(gmap.beta(v[1],1));
gmap.insert_cell_2_in_cell_3(v.begin(),v.end());
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear(); v.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_hexahedron();
d2 = gmap.beta(d1,2);
v.push_back(d2); v.push_back(gmap.beta(v[0],1,2,1));
v.push_back(gmap.beta(v[1],1,2,1)); v.push_back(gmap.beta(v[2],1,2,1));
gmap.insert_cell_2_in_cell_3(v.begin(),v.end());
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear(); v.clear();
trace_test_begin();
d1 = gmap.make_combinatorial_hexahedron();
d2 = gmap.make_combinatorial_hexahedron();
gmap.template sew<3>(d1,d2);
// d3 = gmap.beta(d1, 2);
// d4 = gmap.beta(d1, 1,3,1,2);
// assert(d4==gmap.beta(d1,1,3,1,2));
gmap.template remove_cell<2>(d1);
// v.push_back(d3); v.push_back(gmap.beta(v[0],1,2,1));
// v.push_back(gmap.beta(v[1],1,2,1)); v.push_back(gmap.beta(v[2],1,2,1));
gmap.insert_cell_2_in_cell_3(v.begin(),v.end());
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 1) )
return false;
gmap.clear(); v.clear();
return true;
}
#endif // GMAP_TEST_INSERTIONS_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
// Copyright (c) 2016 CNRS and LIRIS' Establishments (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or

View File

@ -1,4 +1,4 @@
// Copyright (c) 2011 CNRS and LIRIS' Establishments (France).
// Copyright (c) 2016 CNRS and LIRIS' Establishments (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
@ -21,6 +21,7 @@
#define CGAL_GMAP_3_TEST_H
#include "Generalized_map_2_test.h"
#include "GMap_test_insertions.h"
#include <iostream>
#include <fstream>
@ -155,8 +156,13 @@ bool test_GMAP_3()
assert(false);
return false;
}
gmap.clear();
if (!test_vertex_insertion(gmap))
return false;
if (!test_edge_insertion(gmap))
return false;
return true;
}