mirror of https://github.com/CGAL/cgal
Reintroduce package Generalized map
This commit is contained in:
parent
9bd6d59454
commit
16f490251a
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Created by the script cgal_create_cmake_script
|
||||||
|
# This is the CMake script for compiling a CGAL application.
|
||||||
|
|
||||||
|
# cmake ../ -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
# ou
|
||||||
|
# cmake ../ -DCMAKE_BUILD_TYPE=Release
|
||||||
|
|
||||||
|
project( GMap_examples )
|
||||||
|
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
|
||||||
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w -pedantic -Wextra -Wall")
|
||||||
|
|
||||||
|
if ( COMMAND cmake_policy )
|
||||||
|
cmake_policy( SET CMP0003 NEW )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Pour le problème de valgrind avec CGAL
|
||||||
|
# add_definition(-DCGAL_DISABLE_ROUNDING_MATH_CHECK)
|
||||||
|
|
||||||
|
find_package(CGAL QUIET COMPONENTS Core )
|
||||||
|
|
||||||
|
if ( CGAL_FOUND )
|
||||||
|
|
||||||
|
include( ${CGAL_USE_FILE} )
|
||||||
|
|
||||||
|
include( CGAL_CreateSingleSourceCGALProgram )
|
||||||
|
include_directories(BEFORE ../../include)
|
||||||
|
|
||||||
|
create_single_source_cgal_program( "gmap_3_simple_example.cpp" )
|
||||||
|
create_single_source_cgal_program( "gmap_4_simple_example.cpp" )
|
||||||
|
create_single_source_cgal_program( "gmap_3_with_colored_facets.cpp" )
|
||||||
|
create_single_source_cgal_program( "gmap_3_operations.cpp" )
|
||||||
|
create_single_source_cgal_program( "gmap_3_marks.cpp" )
|
||||||
|
else()
|
||||||
|
|
||||||
|
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright (c) 2010 CNRS, LIRIS, http://liris.cnrs.fr/, All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; version 2.1 of the License.
|
||||||
|
// See the file LICENSE.LGPL distributed with CGAL.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
typedef CGAL::Generalized_map<3> CMap_3;
|
||||||
|
typedef CMap_3::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CMap_3 cm;
|
||||||
|
|
||||||
|
// Reserve a mark
|
||||||
|
int mark = cm.get_new_mark();
|
||||||
|
if ( mark==-1 )
|
||||||
|
{
|
||||||
|
std::cerr<<"No more free mark, exit."<<std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create two tetrahedra.
|
||||||
|
Dart_handle dh1 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
Dart_handle dh2 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
CGAL_assertion( CGAL::is_volume_combinatorial_tetrahedron(cm, dh1) );
|
||||||
|
CGAL_assertion( CGAL::is_volume_combinatorial_tetrahedron(cm, dh2) );
|
||||||
|
|
||||||
|
// 3-sew them.
|
||||||
|
cm.sew<3>(dh1, dh2);
|
||||||
|
|
||||||
|
// Mark the darts belonging to the first tetrahedron.
|
||||||
|
for (CMap_3::Dart_of_cell_range<3>::iterator
|
||||||
|
it(cm.darts_of_cell<3>(dh1).begin()),
|
||||||
|
itend(cm.darts_of_cell<3>(dh1).end()); it!=itend; ++it)
|
||||||
|
cm.mark(it, mark);
|
||||||
|
|
||||||
|
// Remove the common 2-cell between the two cubes:
|
||||||
|
// the two tetrahedra are merged.
|
||||||
|
// cm.remove_cell<2>(dh1);
|
||||||
|
|
||||||
|
// Thanks to the mark, we know which darts come from the first tetrahedron.
|
||||||
|
unsigned int res=0;
|
||||||
|
for (CMap_3::Dart_range::iterator it(cm.darts().begin()),
|
||||||
|
itend(cm.darts().end()); it!=itend; ++it)
|
||||||
|
{
|
||||||
|
if ( cm.is_marked(it, mark) )
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<"Number of darts from the first tetrahedron: "<<res<<std::endl;
|
||||||
|
cm.free_mark(mark);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright (c) 2010 CNRS, LIRIS, http://liris.cnrs.fr/, All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; version 2.1 of the License.
|
||||||
|
// See the file LICENSE.LGPL distributed with CGAL.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
typedef CGAL::Generalized_map<3> CMap_3;
|
||||||
|
typedef CMap_3::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CMap_3 cm;
|
||||||
|
|
||||||
|
// Create one hexahedron.
|
||||||
|
Dart_handle d1 = CGAL::make_combinatorial_hexahedron(cm);
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
CGAL_assertion( CGAL::is_volume_combinatorial_hexahedron(cm, d1) );
|
||||||
|
|
||||||
|
// Add two edges along two opposite facets.
|
||||||
|
// CGAL::insert_cell_1_in_cell_2(cm,d1->alpha(1),d1->alpha(0));
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
Dart_handle d2=d1->alpha(2)->alpha(1)->alpha(1)->alpha(2);
|
||||||
|
// CGAL::insert_cell_1_in_cell_2(cm,d2,d2->alpha(1)->alpha(1));
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
// Insert a facet along these two new edges plus two initial edges of the cube.
|
||||||
|
std::vector<Dart_handle> path;
|
||||||
|
path.push_back(d1->alpha(1));
|
||||||
|
path.push_back(d1->alpha(0)->alpha(2)->alpha(1));
|
||||||
|
path.push_back(d2->alpha(0));
|
||||||
|
path.push_back(d2->alpha(2)->alpha(1));
|
||||||
|
|
||||||
|
//Dart_handle d3=CGAL::insert_cell_2_in_cell_3(cm,path.begin(),path.end());
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
// Display the m characteristics.
|
||||||
|
cm.display_characteristics(std::cout) << ", valid=" <<
|
||||||
|
cm.is_valid() << std::endl;
|
||||||
|
|
||||||
|
// We use the removal operations to get back to the initial cube.
|
||||||
|
// cm.remove_cell<2>(d3);
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
// cm.remove_cell<1>(d1->alpha(1));
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
// cm.remove_cell<1>(d2->alpha(0));
|
||||||
|
CGAL_assertion( cm.is_valid() );
|
||||||
|
|
||||||
|
// Display the m characteristics.
|
||||||
|
cm.display_characteristics(std::cout) << ", valid="
|
||||||
|
<< cm.is_valid() << std::endl;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
typedef CGAL::Generalized_map<3> CMap_3;
|
||||||
|
typedef CMap_3::Dart_handle Dart_const_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CMap_3 cm;
|
||||||
|
|
||||||
|
// Create two tetrahedra.
|
||||||
|
Dart_const_handle d1 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
Dart_const_handle d2 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
|
||||||
|
// Display the map characteristics.
|
||||||
|
cm.display_characteristics(std::cout);
|
||||||
|
std::cout<<", valid="<<cm.is_valid()<<std::endl;
|
||||||
|
|
||||||
|
unsigned int res = 0;
|
||||||
|
// Iterate through all the darts of the first tetrahedron.
|
||||||
|
// Note that CMap_3::Dart_of_orbit_range<1,2> is in 3D equivalent to
|
||||||
|
// CMap_3::Dart_of_cell_range<3>.
|
||||||
|
for (CMap_3::Dart_of_orbit_range<0,1,2>::const_iterator
|
||||||
|
it(cm.darts_of_orbit<0,1,2>(d1).begin()),
|
||||||
|
itend(cm.darts_of_orbit<0,1,2>(d1).end());
|
||||||
|
it!=itend; ++it)
|
||||||
|
++res;
|
||||||
|
|
||||||
|
std::cout<<"Number of darts of the first tetrahedron: "<<res<<std::endl;
|
||||||
|
|
||||||
|
res = 0;
|
||||||
|
// Iterate through all the darts of the face incident to d1.
|
||||||
|
for (CMap_3::Dart_of_orbit_range<0,1>::const_iterator
|
||||||
|
it(cm.darts_of_orbit<0,1>(d1).begin()),
|
||||||
|
itend(cm.darts_of_orbit<0,1>(d1).end());
|
||||||
|
it!=itend; ++it)
|
||||||
|
++res;
|
||||||
|
|
||||||
|
std::cout<<"Number of darts of the face incident to d1: "<<res<<std::endl;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
// Copyright (c) 2010 CNRS, LIRIS, http://liris.cnrs.fr/, All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; version 2.1 of the License.
|
||||||
|
// See the file LICENSE.LGPL distributed with CGAL.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <CGAL/Cell_attribute.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
struct Sum_functor
|
||||||
|
{
|
||||||
|
template<class Cell_attribute>
|
||||||
|
void operator()(Cell_attribute& ca1,Cell_attribute& ca2)
|
||||||
|
{ ca1.info()=ca1.info()+ca2.info(); }
|
||||||
|
};
|
||||||
|
struct Divide_by_two_functor
|
||||||
|
{
|
||||||
|
template<class Cell_attribute>
|
||||||
|
void operator()(Cell_attribute& ca1,Cell_attribute& ca2)
|
||||||
|
{
|
||||||
|
ca1.info()=(ca1.info()/2);
|
||||||
|
ca2.info()=(ca1.info());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitem
|
||||||
|
{
|
||||||
|
template<class CMap>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<3, CMap> Dart;
|
||||||
|
typedef CGAL::Cell_attribute<CMap, int, CGAL::Tag_true,
|
||||||
|
Sum_functor, Divide_by_two_functor>
|
||||||
|
Facet_attribute;
|
||||||
|
typedef CGAL::cpp0x::tuple<void,void,Facet_attribute> Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CGAL::Generalized_map<3,Myitem> CMap_3;
|
||||||
|
typedef CMap_3::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CMap_3 cm;
|
||||||
|
|
||||||
|
// Create 2 cubes.
|
||||||
|
Dart_handle dh1 = CGAL::make_combinatorial_hexahedron(cm);
|
||||||
|
Dart_handle dh2 = CGAL::make_combinatorial_hexahedron(cm);
|
||||||
|
|
||||||
|
// 1) Create all 2-attributes and associated them to darts.
|
||||||
|
for (CMap_3::Dart_range::iterator
|
||||||
|
it=cm.darts().begin(), itend=cm.darts().end();
|
||||||
|
it!=itend; ++it)
|
||||||
|
{
|
||||||
|
if ( it->attribute<2>()==NULL )
|
||||||
|
cm.set_attribute<2>(it, cm.create_attribute<2>());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) Set the color of all facets of the first cube to 1
|
||||||
|
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator
|
||||||
|
it=cm.one_dart_per_incident_cell<2,3>(dh1).begin(),
|
||||||
|
itend=cm.one_dart_per_incident_cell<2,3>(dh1).end(); it!=itend; ++it)
|
||||||
|
{ it->attribute<2>()->info()=7; }
|
||||||
|
|
||||||
|
// 3) Set the color of all facets of the second cube to 19
|
||||||
|
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator it=
|
||||||
|
cm.one_dart_per_incident_cell<2,3>(dh2).begin(),
|
||||||
|
itend=cm.one_dart_per_incident_cell<2,3>(dh2).end(); it!=itend; ++it)
|
||||||
|
{ it->attribute<2>()->info()=13; }
|
||||||
|
|
||||||
|
// 4) 3-Sew the two cubes along one facet
|
||||||
|
cm.sew<3>(dh1, dh2);
|
||||||
|
|
||||||
|
// 5) Display all the values of 2-attributes
|
||||||
|
for (CMap_3::Attribute_range<2>::type::iterator
|
||||||
|
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
||||||
|
it!=itend; ++it)
|
||||||
|
{
|
||||||
|
std::cout<<it->info()<<"; ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl;
|
||||||
|
|
||||||
|
// 6) Barycentric triangulation of one facet of the first cube.
|
||||||
|
//CGAL::insert_cell_0_in_cell_2(cm, dh2);
|
||||||
|
|
||||||
|
// 7) Display all the values of 2-attributes
|
||||||
|
for (CMap_3::Attribute_range<2>::type::iterator
|
||||||
|
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
||||||
|
it!=itend; ++it)
|
||||||
|
{
|
||||||
|
std::cout<<it->info()<<"; ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl;
|
||||||
|
cm.display_characteristics(std::cout);
|
||||||
|
std::cout<<", valid="<<cm.is_valid()<<std::endl;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright (c) 2010 CNRS, LIRIS, http://liris.cnrs.fr/, All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; version 2.1 of the License.
|
||||||
|
// See the file LICENSE.LGPL distributed with CGAL.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include<CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
typedef CGAL::Generalized_map<4> CMap_4;
|
||||||
|
typedef CMap_4::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CMap_4 cm;
|
||||||
|
Dart_handle d1 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
Dart_handle d2 = CGAL::make_combinatorial_tetrahedron(cm);
|
||||||
|
|
||||||
|
CGAL_assertion(cm.is_valid());
|
||||||
|
|
||||||
|
cm.sew<4>(d1,d2);
|
||||||
|
|
||||||
|
cm.display_characteristics(std::cout);
|
||||||
|
std::cout<<", valid="<<cm.is_valid()<<std::endl;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_CELL_CONST_ITERATORS_H
|
||||||
|
#define CGAL_GMAP_CELL_CONST_ITERATORS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/GMap_cell_iterators.h>
|
||||||
|
|
||||||
|
// TODO do all the orbit iterator of any orbit ?
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file GMap_cell_const_iterators.h
|
||||||
|
* The cell const iterators. There are 3 classes:
|
||||||
|
* - GMap_cell_const_iterator<Map,i,dim>
|
||||||
|
* - GMap_one_dart_per_incident_cell_const_iterator<Map,Ite,i,dim>
|
||||||
|
* - GMap_one_dart_per_cell_const_iterator<Map,Ite,i,dim>
|
||||||
|
*/
|
||||||
|
|
||||||
|
//****************************************************************************
|
||||||
|
template <typename Map_,unsigned int i,unsigned int dim=Map_::dimension>
|
||||||
|
class GMap_cell_const_iterator: public GMap_cell_iterator<Map_,i,dim,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_cell_iterator<Map_,i,dim,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_cell_const_iterator(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_cell_const_iterator
|
||||||
|
(const GMap_cell_iterator<Map_,i,dim,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template <typename Map_,unsigned int i,unsigned int j,
|
||||||
|
unsigned int dim=Map_::dimension>
|
||||||
|
class GMap_one_dart_per_incident_cell_const_iterator:
|
||||||
|
public GMap_one_dart_per_incident_cell_iterator<Map_,i,j,dim,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_one_dart_per_incident_cell_iterator<Map_,i,j,dim,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_one_dart_per_incident_cell_const_iterator(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap, adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_one_dart_per_incident_cell_const_iterator
|
||||||
|
(const GMap_one_dart_per_incident_cell_iterator<Map_,i,j,dim,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template <typename Map_,unsigned int i,unsigned int dim=Map_::dimension>
|
||||||
|
class GMap_one_dart_per_cell_const_iterator:
|
||||||
|
public GMap_one_dart_per_cell_iterator<Map_,i,dim,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_one_dart_per_cell_iterator<Map_,i,dim,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_one_dart_per_cell_const_iterator(const Map_& amap): Base(amap)
|
||||||
|
{}
|
||||||
|
/// Constructor with a dart in parameter (for end iterator).
|
||||||
|
GMap_one_dart_per_cell_const_iterator(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap)
|
||||||
|
{ this->set_current_dart(adart); }
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_one_dart_per_cell_const_iterator
|
||||||
|
(const GMap_one_dart_per_cell_iterator<Map_,i,dim,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()))
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
//****************************************************************************
|
||||||
|
} // namespace CGAL
|
||||||
|
//******************************************************************************
|
||||||
|
#endif // CGAL_GMAP_CELL_CONST_ITERATORS_H
|
||||||
|
//******************************************************************************
|
||||||
|
|
@ -0,0 +1,202 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_CELL_ITERATORS_H
|
||||||
|
#define CGAL_GMAP_CELL_ITERATORS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Cell_iterators.h>
|
||||||
|
|
||||||
|
// TODO do all the orbit iterator of any orbit ?
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file Cell_iterators.h
|
||||||
|
* Cell iterators. There are 3 classes:
|
||||||
|
* * - GMap_cell_iterator<Map,i,dim>: one dart per each i-cell
|
||||||
|
* * - GMap_one_dart_per_incident_cell_iterator<Map,Ite,i,dim>
|
||||||
|
* * - GMap_one_dart_per_cell_iterator<Map,Ite,i,dim>
|
||||||
|
*/
|
||||||
|
|
||||||
|
//****************************************************************************
|
||||||
|
/* Class GMap_cell_iterator<Map,i,dim,Tag_false>: to iterate onto
|
||||||
|
* all the cells of the gmap.
|
||||||
|
*/
|
||||||
|
template <typename Map_,unsigned int i,unsigned int dim,bool Const>
|
||||||
|
class GMap_cell_iterator: public GMap_dart_iterator_basic_of_all<Map_,Const>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_basic_of_all<Map_,Const> Base;
|
||||||
|
typedef GMap_cell_iterator<Map_,i,dim,Const> Self;
|
||||||
|
|
||||||
|
typedef typename Base::Dart_handle Dart_handle;
|
||||||
|
typedef typename Base::Map Map;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Unmark all the marked darts during the iterator.
|
||||||
|
void unmark_treated_darts()
|
||||||
|
{
|
||||||
|
if (this->mmap->is_whole_map_unmarked(mmark_number)) return;
|
||||||
|
|
||||||
|
this->mmap->negate_mark(mmark_number);
|
||||||
|
|
||||||
|
if (this->mmap->is_whole_map_unmarked(mmark_number)) return;
|
||||||
|
|
||||||
|
Base::rewind();
|
||||||
|
mark_cell<Map,i,dim>(*this->mmap, (*this),
|
||||||
|
mmark_number);
|
||||||
|
while (this->mmap->number_of_unmarked_darts(mmark_number) > 0)
|
||||||
|
this->operator++();
|
||||||
|
this->mmap->negate_mark(mmark_number);
|
||||||
|
CGAL_assertion(this->mmap->is_whole_map_unmarked(mmark_number));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_cell_iterator(Map& amap):
|
||||||
|
Base(amap),
|
||||||
|
mmark_number(amap.get_new_mark())
|
||||||
|
{
|
||||||
|
CGAL_static_assertion( (boost::is_same<typename Base::Basic_iterator,
|
||||||
|
Tag_true>::value) );
|
||||||
|
CGAL_assertion(amap.is_whole_map_unmarked(mmark_number));
|
||||||
|
mark_cell<Map,i,dim>(amap, (*this), mmark_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructor.
|
||||||
|
~GMap_cell_iterator()
|
||||||
|
{
|
||||||
|
if (this->mmap->get_number_of_times_mark_reserved(mmark_number)==1)
|
||||||
|
unmark_treated_darts();
|
||||||
|
this->mmap->free_mark(mmark_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copy constructor.
|
||||||
|
GMap_cell_iterator(const Self& aiterator):
|
||||||
|
Base(aiterator),
|
||||||
|
mmark_number(aiterator.mmark_number)
|
||||||
|
{ this->mmap->share_a_mark(mmark_number); }
|
||||||
|
|
||||||
|
/// Assignment operator.
|
||||||
|
Self& operator=(Self& aiterator)
|
||||||
|
{
|
||||||
|
if (this != &aiterator)
|
||||||
|
{
|
||||||
|
Base::operator=(aiterator);
|
||||||
|
mmark_number = aiterator.mmark_number;
|
||||||
|
this->mmap->share_a_mark(mmark_number);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rewind of the iterator to its beginning.
|
||||||
|
void rewind()
|
||||||
|
{
|
||||||
|
unmark_treated_darts();
|
||||||
|
Base::rewind();
|
||||||
|
mark_cell<Map,i,dim>(*this->mmap, (*this), mmark_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Postfix ++ operator.
|
||||||
|
Self operator++(int)
|
||||||
|
{ Self res=*this; operator ++(); return res; }
|
||||||
|
|
||||||
|
/// Prefix ++ operator.
|
||||||
|
Self& operator++()
|
||||||
|
{
|
||||||
|
CGAL_assertion(this->cont());
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Base::operator++();
|
||||||
|
}
|
||||||
|
while (this->cont() &&
|
||||||
|
this->mmap->is_marked((*this), mmark_number));
|
||||||
|
|
||||||
|
if (this->cont())
|
||||||
|
mark_cell<Map,i,dim>(*this->mmap, (*this), mmark_number);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// A mark used to mark treated cells.
|
||||||
|
int mmark_number;
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
/* Class GMap_one_dart_per_incident_cell_iterator<Map,i,j,dim>: to iterate
|
||||||
|
* onto one dart per i-cell incident to the given j-cell.
|
||||||
|
*/
|
||||||
|
template <typename Map_,unsigned int i,unsigned int j,
|
||||||
|
unsigned int dim=Map_::dimension,bool Const=false>
|
||||||
|
class GMap_one_dart_per_incident_cell_iterator:
|
||||||
|
public CMap_cell_iterator<Map_,
|
||||||
|
GMap_dart_iterator_basic_of_cell
|
||||||
|
<Map_,j,dim,Const>, i,dim,Const>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_one_dart_per_incident_cell_iterator<Map_,i,j,dim,Const> Self;
|
||||||
|
typedef CMap_cell_iterator<Map_,
|
||||||
|
GMap_dart_iterator_basic_of_cell<Map_,j,
|
||||||
|
dim,Const>,
|
||||||
|
i,dim,Const> Base;
|
||||||
|
|
||||||
|
typedef typename Base::Dart_handle Dart_handle;
|
||||||
|
typedef typename Base::Map Map;
|
||||||
|
|
||||||
|
typedef Tag_false Use_mark;
|
||||||
|
typedef Tag_false Basic_iterator;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_one_dart_per_incident_cell_iterator(Map& amap, Dart_handle adart):
|
||||||
|
Base(amap, adart)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
/* Class GMap_one_dart_per_cell_iterator<Map,i,dim>: to iterate onto the
|
||||||
|
* i-cells incident of the map (one dart by each i-cell).
|
||||||
|
*/
|
||||||
|
template <typename Map_,unsigned int i,unsigned int dim=Map_::dimension,
|
||||||
|
bool Const=false>
|
||||||
|
class GMap_one_dart_per_cell_iterator:
|
||||||
|
public CMap_cell_iterator<Map_,GMap_dart_iterator_basic_of_all<Map_,Const>,
|
||||||
|
i,dim,Const>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_one_dart_per_cell_iterator<Map_,i,dim,Const> Self;
|
||||||
|
typedef CMap_cell_iterator<Map_,
|
||||||
|
GMap_dart_iterator_basic_of_all<Map_,Const>,
|
||||||
|
i,dim,Const> Base;
|
||||||
|
|
||||||
|
typedef typename Base::Dart_handle Dart_handle;
|
||||||
|
typedef typename Base::Map Map;
|
||||||
|
|
||||||
|
typedef Tag_false Use_mark;
|
||||||
|
typedef Tag_false Basic_iterator;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_one_dart_per_cell_iterator(Map& amap): Base(amap)
|
||||||
|
{}
|
||||||
|
/// Constructor with a dart in parameter (for end iterator).
|
||||||
|
GMap_one_dart_per_cell_iterator(Map& amap, Dart_handle adart): Base(amap)
|
||||||
|
{ this->set_current_dart(adart); }
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
//****************************************************************************
|
||||||
|
} // namespace CGAL
|
||||||
|
//******************************************************************************
|
||||||
|
#endif // CGAL_GMAP_CELL_ITERATORS_H
|
||||||
|
//******************************************************************************
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_DART_H
|
||||||
|
#define CGAL_GMAP_DART_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Compact_container.h>
|
||||||
|
#include <CGAL/assertions.h>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file GMap_dart.h
|
||||||
|
* Definition of nD dart for generalized maps.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
template <typename Map,unsigned int i>
|
||||||
|
struct basic_link_alpha_functor;
|
||||||
|
|
||||||
|
template <typename CMap,unsigned int i>
|
||||||
|
struct link_alpha_functor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Definition of nD dart.
|
||||||
|
* The GMap_dart class describes an nD dart (basic element of a
|
||||||
|
* generalized map). A dart is composed with handle towards its neighbors,
|
||||||
|
* a bitset containing Boolean marks, and handle towards enabled attributes.
|
||||||
|
* n is the dimension of the space (2 for 2D, 3 for 3D...)
|
||||||
|
* Refs the ref class
|
||||||
|
*/
|
||||||
|
template <int d, typename Refs>
|
||||||
|
struct GMap_dart
|
||||||
|
{
|
||||||
|
template < unsigned int, class, class, class, class >
|
||||||
|
friend class Generalized_map_base;
|
||||||
|
|
||||||
|
template < unsigned int, class, class >
|
||||||
|
friend class Generalized_map_storage_1;
|
||||||
|
|
||||||
|
template < unsigned int, class, class >
|
||||||
|
friend class Generalized_map_storage_2;
|
||||||
|
|
||||||
|
template <class, class, class>
|
||||||
|
friend class Compact_container;
|
||||||
|
|
||||||
|
template<class, unsigned int, unsigned int>
|
||||||
|
friend struct Remove_cell_functor;
|
||||||
|
|
||||||
|
template<class, unsigned int>
|
||||||
|
friend struct Contract_cell_functor;
|
||||||
|
|
||||||
|
template <typename, unsigned int>
|
||||||
|
friend struct internal::link_alpha_functor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef GMap_dart<d,Refs> Self;
|
||||||
|
typedef typename Refs::Dart_handle Dart_handle;
|
||||||
|
typedef typename Refs::size_type size_type;
|
||||||
|
typedef typename Refs::Dart_const_handle Dart_const_handle;
|
||||||
|
typedef typename Refs::Helper Helper;
|
||||||
|
/// Typedef for attributes
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_handle: public Refs::template Attribute_handle<i>
|
||||||
|
{};
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_const_handle: public Refs::template Attribute_const_handle<i>
|
||||||
|
{};
|
||||||
|
|
||||||
|
/// The number of used marks.
|
||||||
|
static const size_type NB_MARKS = Refs::NB_MARKS;
|
||||||
|
|
||||||
|
/// The dimension of the generalized map.
|
||||||
|
static const unsigned int dimension = d;
|
||||||
|
|
||||||
|
/** Return the alpha of this dart for a given dimension.
|
||||||
|
* @return alpha(\em i).
|
||||||
|
*/
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_handle alpha()
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return malpha[i];
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_const_handle alpha() const
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return malpha[i];
|
||||||
|
}
|
||||||
|
Dart_handle alpha(unsigned int i)
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return malpha[i];
|
||||||
|
}
|
||||||
|
Dart_const_handle alpha(unsigned int i) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return malpha[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @return a handle on the i-attribute
|
||||||
|
template<int i>
|
||||||
|
typename Attribute_handle<i>::type attribute()
|
||||||
|
{
|
||||||
|
CGAL_static_assertion_msg( Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"attribute<i> but i-attributes are disabled.");
|
||||||
|
return CGAL::cpp0x::get<Helper::template Dimension_index<i>::value>
|
||||||
|
(mattribute_handles);
|
||||||
|
}
|
||||||
|
template<int i>
|
||||||
|
typename Attribute_const_handle<i>::type attribute() const
|
||||||
|
{
|
||||||
|
CGAL_static_assertion_msg( Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"attribute<i> but i-attributes are disabled.");
|
||||||
|
return CGAL::cpp0x::get<Helper::template Dimension_index<i>::value>
|
||||||
|
(mattribute_handles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the mark value of a given mark number.
|
||||||
|
* @param amark the mark number.
|
||||||
|
* @return the value for this number.
|
||||||
|
*/
|
||||||
|
bool get_mark(int amark) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
|
||||||
|
return mmarks[(size_type)amark];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the mark of a given mark number to a given value.
|
||||||
|
* @param amark the mark number.
|
||||||
|
* @param AValue the value.
|
||||||
|
*/
|
||||||
|
void set_mark(int amark, bool avalue) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
|
||||||
|
mmarks.set((size_type)amark, avalue);
|
||||||
|
}
|
||||||
|
/** Flip the mark of a given mark number.
|
||||||
|
* @param amark the mark number.
|
||||||
|
*/
|
||||||
|
void flip_mark(int amark) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
|
||||||
|
mmarks.flip((size_type)amark);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return all the marks of this dart.
|
||||||
|
* @return the marks.
|
||||||
|
*/
|
||||||
|
std::bitset<NB_MARKS> get_marks() const
|
||||||
|
{ return mmarks; }
|
||||||
|
|
||||||
|
/** Set simultaneously all the marks of this dart to a given value.
|
||||||
|
* @param amarks the value of the marks.
|
||||||
|
*/
|
||||||
|
void set_marks(const std::bitset<NB_MARKS>& amarks) const
|
||||||
|
{ mmarks = amarks; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Default constructor: no real initialisation,
|
||||||
|
* because this is done in the generalized map class.
|
||||||
|
*/
|
||||||
|
GMap_dart()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/** Copy constructor:
|
||||||
|
* @param adart a dart.
|
||||||
|
*/
|
||||||
|
GMap_dart(const GMap_dart& adart) :
|
||||||
|
mmarks(adart.mmarks),
|
||||||
|
mattribute_handles(adart.mattribute_handles)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i <= dimension; ++i)
|
||||||
|
malpha[i] = adart.malpha[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void * for_compact_container() const
|
||||||
|
{ return malpha[0].for_compact_container(); }
|
||||||
|
void * & for_compact_container()
|
||||||
|
{ return malpha[0].for_compact_container(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Alpha for each dimension +1 (from 0 to dimension).
|
||||||
|
Dart_handle malpha[dimension+1];
|
||||||
|
|
||||||
|
/// Values of Boolean marks.
|
||||||
|
mutable std::bitset<NB_MARKS> mmarks;
|
||||||
|
|
||||||
|
/// Attributes enabled
|
||||||
|
typename Helper::Attribute_handles mattribute_handles;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GMAP_DART_H //
|
||||||
|
// EOF //
|
||||||
|
|
@ -0,0 +1,282 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_DART_CONST_ITERATORS_HH
|
||||||
|
#define CGAL_GMAP_DART_CONST_ITERATORS_HH 1
|
||||||
|
|
||||||
|
#include <CGAL/GMap_dart_iterators.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file GMap_dart_const_iterators.h
|
||||||
|
* Definition of gmap dart const iterators.
|
||||||
|
* There are 7 iterators:
|
||||||
|
* - GMap_dart_const_iterator_basic_of_orbit<Map,Alpha...>
|
||||||
|
* - GMap_dart_const_iterator_basic_of_cell<Map,i,d>
|
||||||
|
* - GMap_dart_const_iterator_basic_of_involution<Map,i,d>
|
||||||
|
* - GMap_dart_const_iterator_basic_of_all<Map>
|
||||||
|
* - GMap_dart_const_iterator_of_orbit<Map,Alpha...>
|
||||||
|
* - GMap_dart_const_iterator_of_cell<Map,i,d>
|
||||||
|
* - GMap_dart_const_iterator_of_involution<Map,i,d>
|
||||||
|
*/
|
||||||
|
//****************************************************************************
|
||||||
|
#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
|
||||||
|
template<typename Map_,unsigned int...Alpha>
|
||||||
|
class GMap_dart_const_iterator_basic_of_orbit:
|
||||||
|
public GMap_dart_iterator_basic_of_orbit_generic<Map_,true,Alpha...>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_const_iterator_basic_of_orbit<Map_,Alpha...> Self;
|
||||||
|
typedef GMap_dart_iterator_basic_of_orbit_generic<Map_,true,Alpha...> Base;
|
||||||
|
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart,
|
||||||
|
int amark):
|
||||||
|
Base(amap,adart,amark)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit
|
||||||
|
(const GMap_dart_const_iterator_basic_of_orbit<Map_,Alpha...>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart(),
|
||||||
|
it.mmark_number)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,unsigned int...Alpha>
|
||||||
|
class GMap_dart_const_iterator_of_orbit:
|
||||||
|
public GMap_dart_iterator_of_orbit_generic<Map_,true,Alpha...>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_const_iterator_of_orbit<Map_,Alpha...> Self;
|
||||||
|
typedef GMap_dart_iterator_of_orbit_generic<Map_,true,Alpha...> Base;
|
||||||
|
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_of_orbit
|
||||||
|
(const GMap_dart_iterator_of_orbit<Map_,Alpha...>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,int B1=-1,int B2=-1,int B3=-1,int B4=-1,int B5=-1,
|
||||||
|
int B6=-1,int B7=-1,int B8=-1,int B9=-1>
|
||||||
|
class GMap_dart_const_iterator_basic_of_orbit:
|
||||||
|
public GMap_dart_iterator_basic_of_orbit_generic<Map_,true,B1,B2,B3,B4,
|
||||||
|
B5,B6,B7,B8,B9>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_const_iterator_basic_of_orbit<Map_,B1,B2,B3,B4,B5,B6,
|
||||||
|
B7,B8,B9> Self;
|
||||||
|
typedef GMap_dart_iterator_basic_of_orbit_generic<Map_,true,B1,B2,B3,B4,
|
||||||
|
B5,B6,B7,B8,B9> Base;
|
||||||
|
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart,
|
||||||
|
int amark):
|
||||||
|
Base(amap,adart,amark)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_basic_of_orbit
|
||||||
|
(const GMap_dart_const_iterator_basic_of_orbit<Map_,B1,B2,B3,B4,B5,B6,
|
||||||
|
B7,B8,B9>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart(),
|
||||||
|
it.mmark_number)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,int B1=-1,int B2=-1,int B3=-1,int B4=-1,int B5=-1,
|
||||||
|
int B6=-1,int B7=-1,int B8=-1,int B9=-1>
|
||||||
|
class GMap_dart_const_iterator_of_orbit:
|
||||||
|
public GMap_dart_iterator_of_orbit_generic<Map_,true,B1,B2,B3,B4,
|
||||||
|
B5,B6,B7,B8,B9>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_const_iterator_of_orbit<Map_,B1,B2,B3,B4,B5,B6,
|
||||||
|
B7,B8,B9> Self;
|
||||||
|
typedef GMap_dart_iterator_of_orbit_generic<Map_,true,B1,B2,B3,B4,
|
||||||
|
B5,B6,B7,B8,B9> Base;
|
||||||
|
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_dart_const_iterator_of_orbit(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_of_orbit
|
||||||
|
(const GMap_dart_iterator_of_orbit<Map_,B1,B2,B3,B4,B5,B6,B7,B8,B9>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
#endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_>
|
||||||
|
class GMap_dart_const_iterator_basic_of_all:
|
||||||
|
public GMap_dart_iterator_basic_of_all<Map_,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_basic_of_all<Map_,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_all(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_all(const Map_& amap,
|
||||||
|
Dart_const_handle adart,
|
||||||
|
int /*amark*/):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_basic_of_all
|
||||||
|
(const GMap_dart_iterator_basic_of_all<Map_,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,int i,int d=Map_::dimension>
|
||||||
|
class GMap_dart_const_iterator_basic_of_cell:
|
||||||
|
public GMap_dart_iterator_basic_of_cell<Map_,i,d,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_basic_of_cell<Map_,i,d,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_cell(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_cell(const Map_& amap,
|
||||||
|
Dart_const_handle adart, int amark):
|
||||||
|
Base(amap,adart,amark)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_basic_of_cell
|
||||||
|
(const GMap_dart_iterator_basic_of_cell<Map_,i,d,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_, int i, int d=Map_::dimension>
|
||||||
|
class GMap_dart_const_iterator_of_cell:
|
||||||
|
public GMap_dart_iterator_of_cell<Map_,i,d,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_of_cell<Map_,i,d,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_of_cell(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_of_cell
|
||||||
|
(const GMap_dart_iterator_of_cell<Map_,i,d,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,int i,int d=Map_::dimension>
|
||||||
|
class GMap_dart_const_iterator_basic_of_involution:
|
||||||
|
public GMap_dart_iterator_basic_of_involution<Map_,i,d,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_basic_of_involution<Map_,i,d,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_involution(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_basic_of_involution(const Map_& amap,
|
||||||
|
Dart_const_handle adart,
|
||||||
|
int amark):
|
||||||
|
Base(amap,adart,amark)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_basic_of_involution
|
||||||
|
(const GMap_dart_iterator_basic_of_involution<Map_,i,d,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart(), it.mmark_number)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
template<typename Map_,int i,int d=Map_::dimension>
|
||||||
|
class GMap_dart_const_iterator_of_involution:
|
||||||
|
public GMap_dart_iterator_of_involution<Map_,i,d,true>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_dart_iterator_of_involution<Map_,i,d,true> Base;
|
||||||
|
typedef typename Map_::Dart_const_handle Dart_const_handle;
|
||||||
|
|
||||||
|
/* Main constructor. */
|
||||||
|
GMap_dart_const_iterator_of_involution(const Map_& amap,
|
||||||
|
Dart_const_handle adart):
|
||||||
|
Base(amap,adart)
|
||||||
|
{}
|
||||||
|
/// Constructor from non const version.
|
||||||
|
GMap_dart_const_iterator_of_involution
|
||||||
|
(const GMap_dart_iterator_of_involution<Map_,i,d,false>& it):
|
||||||
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
} // namespace CGAL
|
||||||
|
//******************************************************************************
|
||||||
|
#endif // CGAL_GMAP_DART_CONST_ITERATORS_HH
|
||||||
|
//******************************************************************************
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,291 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_CONSTRUCTORS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_CONSTRUCTORS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Combinatorial_map_basic_operations.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file Generalized_map_constructors.h
|
||||||
|
* Basic creation operations for a generalized map.
|
||||||
|
* Create edge, triangle, quadrilateral, tetrahedron, hexahedron.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Create an edge.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @return a dart of the new edge.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle make_edge(Map& amap)
|
||||||
|
{
|
||||||
|
typename Map::Dart_handle d1 = amap.create_dart();
|
||||||
|
typename Map::Dart_handle d2 = amap.create_dart();
|
||||||
|
amap.basic_link_alpha(d1, d2, 0);
|
||||||
|
return d1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a combinatorial polygon of length alg
|
||||||
|
* (a cycle of alg edges alpha1 links together).
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @return a new dart.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle make_combinatorial_polygon(Map& amap,
|
||||||
|
unsigned int alg)
|
||||||
|
{
|
||||||
|
CGAL_assertion(alg>0);
|
||||||
|
|
||||||
|
typename Map::Dart_handle start = make_edge(amap);
|
||||||
|
typename Map::Dart_handle prev = amap.template alpha<0>(start);
|
||||||
|
for ( unsigned int nb=1; nb<alg; ++nb )
|
||||||
|
{
|
||||||
|
typename Map::Dart_handle cur = make_edge(amap);
|
||||||
|
amap.template basic_link_alpha<1>(prev, cur);
|
||||||
|
prev=amap.template alpha<0>(cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
amap.template basic_link_alpha<1>(prev, start);
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if a face is a combinatorial polygon of length alg
|
||||||
|
* (a cycle of alg darts beta1 links together).
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart an intial dart
|
||||||
|
* @return true iff the face containing adart is a polygon of length alg.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
bool is_face_combinatorial_polygon(const Map& amap,
|
||||||
|
typename Map::Dart_const_handle adart,
|
||||||
|
unsigned int alg)
|
||||||
|
{
|
||||||
|
CGAL_assertion(alg>0);
|
||||||
|
|
||||||
|
unsigned int nb = 0;
|
||||||
|
typename Map::Dart_const_handle cur = adart;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
++nb;
|
||||||
|
if ( amap.is_free(cur, 0) || amap.is_free(amap.alpha(cur, 0), 1) )
|
||||||
|
return false; // Open face
|
||||||
|
cur = amap.alpha(cur,0,1);
|
||||||
|
}
|
||||||
|
while( cur!=adart );
|
||||||
|
return (nb==alg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a combinatorial tetrahedron from 4 triangles.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param d1 a dart onto a first triangle.
|
||||||
|
* @param d2 a dart onto a second triangle.
|
||||||
|
* @param d3 a dart onto a third triangle.
|
||||||
|
* @param d4 a dart onto a fourth triangle.
|
||||||
|
* @return a new dart.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle
|
||||||
|
make_combinatorial_tetrahedron(Map& amap,
|
||||||
|
typename Map::Dart_handle d1,
|
||||||
|
typename Map::Dart_handle d2,
|
||||||
|
typename Map::Dart_handle d3,
|
||||||
|
typename Map::Dart_handle d4)
|
||||||
|
{
|
||||||
|
amap.template topo_sew<2>(d1, d2);
|
||||||
|
amap.template topo_sew<2>(d3, amap.alpha(d2, 1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d1, 1), amap.alpha(d3, 1));
|
||||||
|
amap.template topo_sew<2>(d4, amap.alpha(d2, 0, 1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d4, 0, 1), amap.alpha(d3, 0, 1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d4, 1), amap.alpha(d1, 0, 1));
|
||||||
|
|
||||||
|
return d1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if a volume is a combinatorial tetrahedron.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart an intial dart
|
||||||
|
* @return true iff the volume containing adart is a combinatorial tetrahedron.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
bool is_volume_combinatorial_tetrahedron(const Map& amap,
|
||||||
|
typename Map::Dart_const_handle d1)
|
||||||
|
{
|
||||||
|
typename Map::Dart_const_handle d2 = amap.alpha(d1, 2);
|
||||||
|
typename Map::Dart_const_handle d3 = amap.alpha(d2, 1, 2);
|
||||||
|
typename Map::Dart_const_handle d4 = amap.alpha(d2, 0, 1, 2);
|
||||||
|
|
||||||
|
if ( !is_face_combinatorial_polygon(amap, d1, 3) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d2, 3) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d3, 3) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d4, 3) ) return false;
|
||||||
|
|
||||||
|
// TODO do better with marks (?).
|
||||||
|
if ( belong_to_same_cell<Map,2,1>(amap, d1, d2) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d3) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d4) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d3) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d4) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d3, d4) ) return false;
|
||||||
|
|
||||||
|
if ( amap.alpha(d1,1,2)!=amap.alpha(d3,1) ||
|
||||||
|
amap.alpha(d4,0,1,2)!=amap.alpha(d3,0,1) ||
|
||||||
|
amap.alpha(d4,1,2)!=amap.alpha(d1,0,1) ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Create a new combinatorial tetrahedron.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @return a new dart.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle make_combinatorial_tetrahedron(Map& amap)
|
||||||
|
{
|
||||||
|
typename Map::Dart_handle d1 = make_combinatorial_polygon(amap,3);
|
||||||
|
typename Map::Dart_handle d2 = make_combinatorial_polygon(amap,3);
|
||||||
|
typename Map::Dart_handle d3 = make_combinatorial_polygon(amap,3);
|
||||||
|
typename Map::Dart_handle d4 = make_combinatorial_polygon(amap,3);
|
||||||
|
|
||||||
|
return make_combinatorial_tetrahedron(amap, d1, d2, d3, d4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a combinatorial hexahedron from 6 quadrilaterals.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param d1 a dart onto a first quadrilateral.
|
||||||
|
* @param d2 a dart onto a second quadrilateral.
|
||||||
|
* @param d3 a dart onto a third quadrilateral.
|
||||||
|
* @param d4 a dart onto a fourth quadrilateral.
|
||||||
|
* @param d5 a dart onto a fifth quadrilateral.
|
||||||
|
* @param d6 a dart onto a sixth quadrilateral.
|
||||||
|
* @return a dart of the new cuboidal_cell.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle
|
||||||
|
make_combinatorial_hexahedron(Map& amap,
|
||||||
|
typename Map::Dart_handle d1,
|
||||||
|
typename Map::Dart_handle d2,
|
||||||
|
typename Map::Dart_handle d3,
|
||||||
|
typename Map::Dart_handle d4,
|
||||||
|
typename Map::Dart_handle d5,
|
||||||
|
typename Map::Dart_handle d6)
|
||||||
|
{
|
||||||
|
amap.template topo_sew<2>(d1,
|
||||||
|
amap.alpha(d4,1,0,1,0));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d1,0,1),
|
||||||
|
amap.alpha(d6,1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d1,1,0,1),
|
||||||
|
d2);
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d1,1),
|
||||||
|
d5);
|
||||||
|
|
||||||
|
amap.template topo_sew<2>(d3,
|
||||||
|
amap.alpha(d2,1,0,1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d3,0,1,0),
|
||||||
|
amap.alpha(d6,0,1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d3,1,0,1,0),
|
||||||
|
d4);
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d3,1),
|
||||||
|
amap.alpha(d5,0,1,0,1));
|
||||||
|
|
||||||
|
amap.template topo_sew<2>(d6,
|
||||||
|
amap.alpha(d4,1,0));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d6,1,0,1),
|
||||||
|
amap.alpha(d2,0,1));
|
||||||
|
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d5,1,0),
|
||||||
|
amap.alpha(d4,0,1));
|
||||||
|
amap.template topo_sew<2>(amap.alpha(d5,0,1),
|
||||||
|
amap.alpha(d2,1));
|
||||||
|
return d1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if a volume is a combinatorial hexahedron.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart an intial dart
|
||||||
|
* @return true iff the volume containing adart is a combinatorial hexahedron.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
bool is_volume_combinatorial_hexahedron(const Map& amap,
|
||||||
|
typename Map::Dart_const_handle d1)
|
||||||
|
{
|
||||||
|
typename Map::Dart_const_handle d2 = amap.alpha(d1,1,0,1,2);
|
||||||
|
typename Map::Dart_const_handle d3 = amap.alpha(d2,1,0,1,2);
|
||||||
|
typename Map::Dart_const_handle d4 = amap.alpha(d3,1,0,1,0,2);
|
||||||
|
typename Map::Dart_const_handle d5 = amap.alpha(d1,1,2);
|
||||||
|
typename Map::Dart_const_handle d6 = amap.alpha(d4,1,0,2);
|
||||||
|
|
||||||
|
if (!is_face_combinatorial_polygon(amap, d1, 4) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d2, 4) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d3, 4) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d4, 4) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d5, 4) ||
|
||||||
|
!is_face_combinatorial_polygon(amap, d6, 4) ) return false;
|
||||||
|
|
||||||
|
// TODO do better with marks.
|
||||||
|
if ( belong_to_same_cell<Map,2,1>(amap, d1, d2) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d3) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d4) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d5) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d1, d6) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d3) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d4) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d5) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d2, d6) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d3, d4) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d3, d5) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d3, d6) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d4, d5) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d4, d6) ||
|
||||||
|
belong_to_same_cell<Map,2,1>(amap, d5, d6) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( amap.alpha(d1,2) !=amap.alpha(d4,0,1,0,1) ||
|
||||||
|
amap.alpha(d1,0,1,2) !=amap.alpha(d6,1) ||
|
||||||
|
amap.alpha(d3,0,1,2) !=amap.alpha(d6,0,1,0) ||
|
||||||
|
amap.alpha(d3,1,2) !=amap.alpha(d5,0,1,0,1) ||
|
||||||
|
amap.alpha(d6,1,0,1,2)!=amap.alpha(d2,0,1) ||
|
||||||
|
amap.alpha(d5,1,2) !=amap.alpha(d4,0,1,0) ||
|
||||||
|
amap.alpha(d5,0,1,2) !=amap.alpha(d2,1) ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a new combinatorial hexahedron.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @return a new dart.
|
||||||
|
*/
|
||||||
|
template < class Map >
|
||||||
|
typename Map::Dart_handle make_combinatorial_hexahedron(Map& amap)
|
||||||
|
{
|
||||||
|
typename Map::Dart_handle d1 = make_combinatorial_polygon(amap,4);
|
||||||
|
typename Map::Dart_handle d2 = make_combinatorial_polygon(amap,4);
|
||||||
|
typename Map::Dart_handle d3 = make_combinatorial_polygon(amap,4);
|
||||||
|
typename Map::Dart_handle d4 = make_combinatorial_polygon(amap,4);
|
||||||
|
typename Map::Dart_handle d5 = make_combinatorial_polygon(amap,4);
|
||||||
|
typename Map::Dart_handle d6 = make_combinatorial_polygon(amap,4);
|
||||||
|
|
||||||
|
return make_combinatorial_hexahedron(amap, d1, d2, d3, d4, d5, d6);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_CONSTRUCTORS_H //
|
||||||
|
// EOF //
|
||||||
|
|
@ -0,0 +1,545 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_INSERTIONS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_INSERTIONS_H
|
||||||
|
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
/** @file Generalized_map_insertions.h
|
||||||
|
* Insertion operations on generalized map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Insert a vertex in a given edge.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the edge (!=NULL).
|
||||||
|
* @return a dart of the new vertex.
|
||||||
|
*/
|
||||||
|
template<class CMap>
|
||||||
|
typename CMap::Dart_handle
|
||||||
|
insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
|
||||||
|
typename CMap::template
|
||||||
|
Attribute_handle<0>::type ah=CMap::null_handle )
|
||||||
|
{
|
||||||
|
typename CMap::Dart_handle d1, d2;
|
||||||
|
int mark=amap.get_new_mark();
|
||||||
|
|
||||||
|
// 1) We store all the darts of the edge.
|
||||||
|
std::deque<typename CMap::Dart_handle> vect;
|
||||||
|
int m=amap.get_new_mark();
|
||||||
|
{
|
||||||
|
for ( typename CMap::template Dart_of_cell_basic_range<1>::iterator
|
||||||
|
it=amap.template darts_of_cell_basic<1>(adart, m).begin();
|
||||||
|
it != amap.template darts_of_cell_basic<1>(adart, m).end(); ++it )
|
||||||
|
vect.push_back(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) For each dart of the cell, we modify link of neighbors.
|
||||||
|
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
|
||||||
|
for (; it != vect.end(); ++it)
|
||||||
|
{
|
||||||
|
d1 = amap.create_dart();
|
||||||
|
|
||||||
|
if (!amap.template is_free<0>(*it) &&
|
||||||
|
amap.is_marked(amap.template alpha<0>(*it), mark))
|
||||||
|
amap.template basic_link_alpha<1>(d1, amap.template alpha<0,0>(*it));
|
||||||
|
|
||||||
|
amap.template basic_link_alpha<0>(*it, d1);
|
||||||
|
amap.mark(*it, mark);
|
||||||
|
|
||||||
|
for ( unsigned int dim=2; dim<=CMap::dimension; ++dim )
|
||||||
|
{
|
||||||
|
if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), mark))
|
||||||
|
{
|
||||||
|
amap.basic_link_alpha(amap.beta(*it, dim, 0), d1, dim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We copy all the attributes except for dim=0
|
||||||
|
CMap::Helper::template Foreach_enabled_attributes_except
|
||||||
|
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>::
|
||||||
|
run(&amap,*it,d1);
|
||||||
|
// We initialise the 0-atttrib to ah
|
||||||
|
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
|
||||||
|
run(&amap, d1, ah);
|
||||||
|
amap.mark(*it, mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (it = vect.begin(); it != vect.end(); ++it)
|
||||||
|
{
|
||||||
|
amap.unmark(*it, m);
|
||||||
|
amap.unmark(*it, mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion(amap.is_whole_map_unmarked(m));
|
||||||
|
CGAL_assertion(amap.is_whole_map_unmarked(mark));
|
||||||
|
|
||||||
|
amap.free_mark(m);
|
||||||
|
amap.free_mark(mark);
|
||||||
|
|
||||||
|
if ( !amap.template is_free<1>(amap.template alpha<0>(adart)) )
|
||||||
|
{
|
||||||
|
CGAL::internal::Degroup_attribute_functor_run<CMap, 1>::
|
||||||
|
run(&amap, adart, amap.template alpha<0,1>(adart));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return amap.template alpha<0>(adart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Insert a vertex in the given 2-cell which is splitted in triangles,
|
||||||
|
* once for each inital edge of the facet.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the facet to triangulate.
|
||||||
|
* @return A dart incident to the new vertex.
|
||||||
|
*/
|
||||||
|
template < class CMap >
|
||||||
|
typename CMap::Dart_handle
|
||||||
|
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
|
||||||
|
typename CMap::template
|
||||||
|
Attribute_handle<0>::type ah=CMap::null_handle )
|
||||||
|
{
|
||||||
|
CGAL_assertion(adart!=amap.null_handle);
|
||||||
|
|
||||||
|
typename CMap::Dart_handle d1=amap.null_handle, d2=amap.null_handle;
|
||||||
|
|
||||||
|
// Mark used to mark darts already treated.
|
||||||
|
int treated = amap.get_new_mark();
|
||||||
|
int m = amap.get_new_mark();
|
||||||
|
|
||||||
|
// Stack of darts of the face
|
||||||
|
std::deque<typename CMap::Dart_handle> vect;
|
||||||
|
{
|
||||||
|
for ( typename CMap::template Dart_of_cell_basic_range<2>::iterator
|
||||||
|
it=amap.template darts_of_cell_basic<2>(adart,m).begin();
|
||||||
|
it != amap.template darts_of_cell_basic<2>(adart,m).end(); ++it )
|
||||||
|
vect.push_back(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stack of darts to degroup (one dart per edge of the face)
|
||||||
|
std::deque<typename CMap::Dart_handle> todegroup;
|
||||||
|
{
|
||||||
|
for ( typename CMap::template Dart_of_cell_basic_range<2,2>::iterator
|
||||||
|
it=amap.template darts_of_cell_basic<2,2>(adart).begin();
|
||||||
|
it != amap.template darts_of_cell_basic<2,2>(adart).end(); ++it )
|
||||||
|
if ( it!=adart && it!=amap.template alpha<0>(adart) )
|
||||||
|
todegroup.push_back(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) For each dart of the cell, we modify link of neighbors.
|
||||||
|
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
|
||||||
|
for (; it != vect.end(); ++it)
|
||||||
|
{
|
||||||
|
d1 = amap.create_dart();
|
||||||
|
d2 = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(d1, d2);
|
||||||
|
amap.mark(*it, treated);
|
||||||
|
|
||||||
|
amap.template basic_link_alpha<1>(*it, d1);
|
||||||
|
|
||||||
|
if (!amap.template is_free<0>(*it) &&
|
||||||
|
amap.is_marked(amap.template alpha<0>(*it), treated))
|
||||||
|
amap.template basic_link_alpha<1>(d2, amap.template alpha<0,1,0>(*it));
|
||||||
|
|
||||||
|
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim )
|
||||||
|
{
|
||||||
|
if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), treated))
|
||||||
|
{
|
||||||
|
amap.basic_link_alpha(amap.beta(*it, dim, 1), d1, dim);
|
||||||
|
amap.basic_link_alpha(amap.beta(*it, dim, 1, 0), d2, dim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We copy all the attributes except for dim=1
|
||||||
|
CMap::Helper::template Foreach_enabled_attributes_except
|
||||||
|
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 1>::
|
||||||
|
run(&amap,*it,d1);
|
||||||
|
// We initialise the 0-atttrib to ah
|
||||||
|
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
|
||||||
|
run(&amap, d2, ah);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (it = vect.begin(); it != vect.end(); ++it)
|
||||||
|
{
|
||||||
|
amap.unmark(*it, m);
|
||||||
|
amap.unmark(*it, treated);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion(amap.is_whole_map_unmarked(m));
|
||||||
|
CGAL_assertion(amap.is_whole_map_unmarked(treated));
|
||||||
|
amap.free_mark(m);
|
||||||
|
amap.free_mark(treated);
|
||||||
|
|
||||||
|
for (it = todegroup.begin(); it != todegroup.end(); ++it)
|
||||||
|
{
|
||||||
|
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
|
||||||
|
run(&amap, adart, *it);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return amap.template alpha<1,0>(adart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if an edge can be inserted onto a 2-cell between two given darts.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart1 a first dart.
|
||||||
|
* @param adart2 a second dart.
|
||||||
|
* @return true iff an edge can be inserted between adart1 and adart2.
|
||||||
|
*/
|
||||||
|
template < class CMap >
|
||||||
|
bool is_insertable_cell_1_in_cell_2(const CMap& amap,
|
||||||
|
typename CMap::Dart_const_handle adart1,
|
||||||
|
typename CMap::Dart_const_handle adart2)
|
||||||
|
{
|
||||||
|
if ( adart1==adart2 || adart1==amap.template alpha<0>(adart2) ) return false;
|
||||||
|
for ( CGAL::CMap_dart_const_iterator_of_orbit<CMap,0,1> it(amap,adart1);
|
||||||
|
it.cont(); ++it )
|
||||||
|
{
|
||||||
|
if ( it==adart2 ) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Insert an edge in a 2-cell between two given darts.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||||
|
* @param adart2 a second dart of the facet. If NULL insert a dangling edge.
|
||||||
|
* @return a dart of the new edge, and not incident to the
|
||||||
|
* same vertex than adart1.
|
||||||
|
*/
|
||||||
|
template<class CMap>
|
||||||
|
typename CMap::Dart_handle
|
||||||
|
insert_cell_1_in_cell_2(CMap& amap,
|
||||||
|
typename CMap::Dart_handle adart1,
|
||||||
|
typename CMap::Dart_handle adart2)
|
||||||
|
{
|
||||||
|
if ( adart2!=amap.null_handle)
|
||||||
|
{
|
||||||
|
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
|
||||||
|
}
|
||||||
|
|
||||||
|
int m1=amap.get_new_mark();
|
||||||
|
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it1(amap, adart1, m1);
|
||||||
|
|
||||||
|
int m2=amap.get_new_mark();
|
||||||
|
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it2(amap, adart2, m2);
|
||||||
|
|
||||||
|
typename CMap::Dart_handle d1=amap.null_handle;
|
||||||
|
typename CMap::Dart_handle d2=amap.null_handle;
|
||||||
|
|
||||||
|
int treated=amap.get_new_mark();
|
||||||
|
|
||||||
|
for ( ; it1.cont(); ++it1)
|
||||||
|
{
|
||||||
|
CGAL_assertion (it2.cont() );
|
||||||
|
d1 = amap.create_dart();
|
||||||
|
d2 = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(d1, d2);
|
||||||
|
amap.mark(it1,treated);
|
||||||
|
|
||||||
|
if ( !amap.template is_free<1>(it1) &&
|
||||||
|
amap.is_marked(amap.template alpha<1>(it1), treated) )
|
||||||
|
{
|
||||||
|
amap.template basic_link_alpha<2>(amap.template alpha<1,1>(it1), d1);
|
||||||
|
amap.template basic_link_alpha<2>(amap.template alpha<2,0>(d1), d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||||
|
{
|
||||||
|
if ( !amap.is_free(it1, dim) &&
|
||||||
|
amap.is_marked(amap.alpha(it1, dim), treated) )
|
||||||
|
{
|
||||||
|
amap.basic_link_alpha(amap.alpha(it1, dim, 1), d1, dim);
|
||||||
|
amap.basic_link_alpha(amap.alpha(d1, dim, 0), d2, dim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
amap.template link_alpha<1>(it1, d1);
|
||||||
|
if ( adart2!=amap.null_handle )
|
||||||
|
{
|
||||||
|
amap.template link_alpha<1>(it2, d2);
|
||||||
|
++it2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !amap.template is_free<2>(d1) && d2!=amap.null_handle )
|
||||||
|
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
|
||||||
|
run(&amap, d1, amap.template alpha<2>(d1));
|
||||||
|
|
||||||
|
amap.negate_mark(m1);
|
||||||
|
it1.rewind();
|
||||||
|
|
||||||
|
if ( adart2!=amap.null_handle )
|
||||||
|
{ it2.rewind(); amap.negate_mark(m2); }
|
||||||
|
|
||||||
|
for ( ; it1.cont(); ++it1, ++it2)
|
||||||
|
{
|
||||||
|
amap.mark(it1,m1);
|
||||||
|
amap.unmark(it1,treated);
|
||||||
|
if ( adart2!=amap.null_handle ) amap.mark(it2,m2);
|
||||||
|
}
|
||||||
|
amap.negate_mark(m1);
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||||
|
amap.free_mark(m1);
|
||||||
|
amap.free_mark(treated);
|
||||||
|
|
||||||
|
if ( adart2!=amap.null_handle )
|
||||||
|
{
|
||||||
|
amap.negate_mark(m2);
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(m2) );
|
||||||
|
}
|
||||||
|
amap.free_mark(m2);
|
||||||
|
|
||||||
|
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return amap.template alpha<1>(adart1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if a 2-cell can be inserted onto a given 3-cell along
|
||||||
|
* a path of edges.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param afirst iterator on the begining of the path.
|
||||||
|
* @param alast iterator on the end of the path.
|
||||||
|
* @return true iff a 2-cell can be inserted along the path.
|
||||||
|
* the path is a sequence of dartd, one per edge
|
||||||
|
* where the face will be inserted.
|
||||||
|
*/
|
||||||
|
template <class CMap, class InputIterator>
|
||||||
|
bool is_insertable_cell_2_in_cell_3(const CMap& amap,
|
||||||
|
InputIterator afirst,
|
||||||
|
InputIterator alast)
|
||||||
|
{
|
||||||
|
CGAL_assertion( CMap::dimension>= 3 );
|
||||||
|
|
||||||
|
// The path must have at least one dart.
|
||||||
|
if (afirst==alast) return false;
|
||||||
|
typename CMap::Dart_const_handle prec = amap.null_handle;
|
||||||
|
typename CMap::Dart_const_handle od = amap.null_handle;
|
||||||
|
|
||||||
|
for (InputIterator it(afirst); it!=alast; ++it)
|
||||||
|
{
|
||||||
|
// The path must contain only non empty darts.
|
||||||
|
if (*it == amap.null_handle) return false;
|
||||||
|
|
||||||
|
// Two consecutive darts of the path must belong to two edges
|
||||||
|
// incident to the same vertex of the same volume.
|
||||||
|
if (prec != amap.null_handle)
|
||||||
|
{
|
||||||
|
if ( amap.template is_free<0>(prec) ) return false;
|
||||||
|
|
||||||
|
// alpha0(prec) and *it must belong to the same vertex of the same volume
|
||||||
|
if ( !CGAL::belong_to_same_cell<CMap, 0, 2>
|
||||||
|
(amap, amap.template alpha<0>(prec), *it) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
prec = *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The path must be closed.
|
||||||
|
if ( amap.template is_free<0>(prec) ) return false;
|
||||||
|
if (!CGAL::belong_to_same_cell<CMap, 0, 2>
|
||||||
|
(amap, amap.template alpha<0>(prec), *afirst))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Insert a 2-cell in a given 3-cell along a path of darts.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param afirst iterator on the begining of the path.
|
||||||
|
* @param alast iterator on the end of the path.
|
||||||
|
* the path is a sequence of dartd, one per edge
|
||||||
|
* where the face will be inserted.
|
||||||
|
* @return a dart of the new 2-cell.
|
||||||
|
*/
|
||||||
|
template<class CMap, class InputIterator>
|
||||||
|
typename CMap::Dart_handle
|
||||||
|
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
|
||||||
|
{
|
||||||
|
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
|
||||||
|
|
||||||
|
typename CMap::Dart_handle prec = amap.null_handle, d = amap.null_handle,
|
||||||
|
dd = amap.null_handle, first = amap.null_handle;
|
||||||
|
bool withAlpha3 = false;
|
||||||
|
|
||||||
|
int treated = amap.get_new_mark();
|
||||||
|
|
||||||
|
{
|
||||||
|
for (InputIterator it(afirst); !withAlpha3 && it!=alast; ++it)
|
||||||
|
{
|
||||||
|
if (!amap.template is_free<2>(*it)) withAlpha3 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
for (InputIterator it(afirst); it!=alast; ++it)
|
||||||
|
{
|
||||||
|
d = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(d, amap.create_dart());
|
||||||
|
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
dd = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(dd, amap.create_dart());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( prec!=amap.null_handle )
|
||||||
|
{
|
||||||
|
amap.template basic_link_alpha<1>(prec, d);
|
||||||
|
if (withAlpha3)
|
||||||
|
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec), dd);
|
||||||
|
}
|
||||||
|
else first = amap.template alpha<0>(d);
|
||||||
|
|
||||||
|
if ( !amap.template is_free<2>(*it) )
|
||||||
|
{
|
||||||
|
amap.template link_alpha<2>(amap.template alpha<2>(*it), dd);
|
||||||
|
}
|
||||||
|
|
||||||
|
amap.template link_alpha<2>(*it, d);
|
||||||
|
if (withAlpha3) amap.template basic_link_alpha<3>(d, dd);
|
||||||
|
|
||||||
|
prec = amap.template alpha<0>(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
amap.template basic_link_alpha<1>(prec, first);
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec),
|
||||||
|
amap.template alpha<3>(first));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make copies of the new facet for dimension >=4
|
||||||
|
/* for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
|
||||||
|
{
|
||||||
|
if ( !amap.is_free(*it, dim) )
|
||||||
|
{
|
||||||
|
ddd = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(ddd, amap.create_dart());
|
||||||
|
amap.basic_link_alpha(d, ddd, dim);
|
||||||
|
amap.basic_link_alpha(amap.template alpha<0>(d),
|
||||||
|
amap.template alpha<0>(ddd), dim);
|
||||||
|
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
dddd = amap.create_dart();
|
||||||
|
amap.template basic_link_alpha<0>(dddd, amap.create_dart());
|
||||||
|
|
||||||
|
amap.basic_link_alpha(dd, dddd, dim);
|
||||||
|
amap.basic_link_alpha(amap.template alpha<0>(dd),
|
||||||
|
amap.template alpha<0>(dddd), dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Make copies of the new facet for dimension >=4
|
||||||
|
for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
|
||||||
|
{
|
||||||
|
if ( !amap.is_free(first, dim) )
|
||||||
|
{
|
||||||
|
typename CMap::Dart_handle first2 = amap.null_handle;
|
||||||
|
prec = amap.null_handle;
|
||||||
|
for ( CMap_dart_iterator_basic_of_orbit<CMap,0,1> it(amap, first);
|
||||||
|
it.cont(); ++it )
|
||||||
|
{
|
||||||
|
d = amap.create_dart();
|
||||||
|
amap.basic_link_alpha(amap.template alpha<2>(it), d, dim);
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
dd = amap.create_dart();
|
||||||
|
amap.basic_link_alpha_for_involution
|
||||||
|
(amap.template alpha<2,3>(it), dd, dim);
|
||||||
|
amap.template basic_link_alpha_for_involution<3>(d, dd);
|
||||||
|
}
|
||||||
|
if ( prec!=amap.null_handle )
|
||||||
|
{
|
||||||
|
amap.link_alpha_0(prec, d);
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
amap.basic_link_alpha_1(amap.template alpha<3>(prec), dd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else first2 = prec;
|
||||||
|
|
||||||
|
// We consider dim2=2 out of the loop to use link_alpha instead of
|
||||||
|
// basic _link_alpha (to modify non void attributes only once).
|
||||||
|
if ( !amap.template is_free<2>(it) &&
|
||||||
|
amap.is_free(amap.template alpha<2>(it), dim) )
|
||||||
|
amap.template link_alpha_for_involution<2>
|
||||||
|
(amap.alpha(it,2,dim), d);
|
||||||
|
if ( withAlpha3 &&
|
||||||
|
!amap.template is_free<2>(amap.template alpha<3>(it)) &&
|
||||||
|
amap.is_free(amap.template alpha<3,2>(it), dim) )
|
||||||
|
amap.template link_alpha_for_involution<2>(amap.alpha(it,3,2,dim), dd);
|
||||||
|
|
||||||
|
for ( unsigned int dim2=3; dim2<=CMap::dimension; ++dim2 )
|
||||||
|
{
|
||||||
|
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
|
||||||
|
{
|
||||||
|
if ( !amap.is_free(it, dim2) && amap.is_free(amap.alpha(it, dim2), dim) )
|
||||||
|
amap.basic_link_alpha_for_involution(amap.alpha(it, dim2, dim),
|
||||||
|
d, dim2);
|
||||||
|
if ( withAlpha3 && !amap.is_free(amap.template alpha<3>(it), dim2) &&
|
||||||
|
amap.is_free(amap.alpha(it, 3, dim2), dim) )
|
||||||
|
amap.basic_link_alpha_for_involution
|
||||||
|
(amap.alpha(it, 3, dim2, dim), dd, dim2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prec = d;
|
||||||
|
}
|
||||||
|
amap.basic_link_alpha_0( prec, first2 );
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{
|
||||||
|
amap.basic_link_alpha_1( amap.template alpha<3>(prec),
|
||||||
|
amap.template alpha<3>(first2) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Degroup the attributes
|
||||||
|
if ( withAlpha3 )
|
||||||
|
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not
|
||||||
|
// have their 3-attribute
|
||||||
|
CGAL::internal::Degroup_attribute_functor_run<CMap, 3>::
|
||||||
|
run(&amap, first, amap.template alpha<3>(first));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_INSERTIONS_H
|
||||||
|
|
@ -0,0 +1,237 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_ITERATORS_BASE_HH
|
||||||
|
#define CGAL_GENERALIZED_MAP_ITERATORS_BASE_HH 1
|
||||||
|
|
||||||
|
// to get OperationState type, some OP, and CMap_dart_iterator
|
||||||
|
#include <CGAL/Combinatorial_map_iterators_base.h>
|
||||||
|
|
||||||
|
// Other includes
|
||||||
|
#include <CGAL/Compact_container.h>
|
||||||
|
#include <queue>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file generalized_map_iterators_base.h
|
||||||
|
* Basic classes that serve as tools for definition of iterators.
|
||||||
|
* There is 1 class:
|
||||||
|
* - GMap_extend_iterator<GMap,Ite,Ai> to extend the given iterator by
|
||||||
|
* adding the involution Ai.
|
||||||
|
*/
|
||||||
|
//****************************************************************************
|
||||||
|
/// Enum of all the possible operations used by the ++ operator.
|
||||||
|
/// Extension of the enum for generalized maps.
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
OP_ALPHAI=OP_END+1, ///< Previous op was the first alpha.
|
||||||
|
OP_ALPHAJ, ///< Previous op was the second alpha.
|
||||||
|
OP_ALPHAK, ///< Previous op was the third alpha.
|
||||||
|
OP_ALPHAIJ, ///< Previous op was the composition of two alpha.
|
||||||
|
OP_ALPHAJI, ///< Previous op was the composition of two alpha.
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
/* Class GMap_extend_iterator<Map,Ite,Ai> which extend a given iterator by
|
||||||
|
* adding Ai and by using a stack and a mark.
|
||||||
|
* General case when Ite does not have already a stack.
|
||||||
|
*/
|
||||||
|
template <typename Map_,typename Ite,int Ai,
|
||||||
|
typename Ite_has_stack=typename Ite::Use_mark>
|
||||||
|
class GMap_extend_iterator: public Ite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_extend_iterator<Map_,Ite,Ai, Ite_has_stack> Self;
|
||||||
|
typedef Ite Base;
|
||||||
|
|
||||||
|
typedef typename Base::Dart_handle Dart_handle;
|
||||||
|
typedef typename Base::Map Map;
|
||||||
|
|
||||||
|
typedef Tag_true Use_mark;
|
||||||
|
|
||||||
|
CGAL_static_assertion( (Ai<=Map::dimension &&
|
||||||
|
boost::is_same<Ite_has_stack,Tag_false>::value) );
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_extend_iterator(Map& amap, Dart_handle adart, int amark):
|
||||||
|
Base(amap, adart),
|
||||||
|
mmark_number(amark),
|
||||||
|
minitial_dart(adart)
|
||||||
|
{
|
||||||
|
if ( adart!=amap.null_handle )
|
||||||
|
{
|
||||||
|
this->mmap->mark(adart, mmark_number);
|
||||||
|
if (!this->mmap->template is_free<Ai>(adart))
|
||||||
|
{
|
||||||
|
mto_treat.push(this->mmap->template alpha<Ai>(adart));
|
||||||
|
this->mmap->mark(this->mmap->template alpha<Ai>(adart),
|
||||||
|
mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rewind of the iterator to its beginning.
|
||||||
|
void rewind()
|
||||||
|
{
|
||||||
|
CGAL_assertion(mmark_number != -1);
|
||||||
|
Base::operator= ( Base(*this->mmap,minitial_dart) );
|
||||||
|
mto_treat = std::queue<Dart_handle>();
|
||||||
|
this->mmap->mark(minitial_dart, mmark_number);
|
||||||
|
if (!this->mmap->template is_free<Ai>(minitial_dart))
|
||||||
|
{
|
||||||
|
mto_treat.push(this->mmap->template alpha<Ai>(minitial_dart));
|
||||||
|
this->mmap->mark(this->mmap->template alpha<Ai>(minitial_dart),
|
||||||
|
mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prefix ++ operator.
|
||||||
|
Self& operator++()
|
||||||
|
{
|
||||||
|
CGAL_assertion(mmark_number != -1);
|
||||||
|
CGAL_assertion(this->cont());
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Base::operator++();
|
||||||
|
}
|
||||||
|
while ( this->cont() &&
|
||||||
|
this->mmap->is_marked(*this, mmark_number) );
|
||||||
|
|
||||||
|
if ( !this->cont() )
|
||||||
|
{
|
||||||
|
if ( !mto_treat.empty() )
|
||||||
|
{
|
||||||
|
Base::operator= ( Base(*this->mmap,mto_treat.front()) );
|
||||||
|
mto_treat.pop();
|
||||||
|
this->mprev_op = OP_POP;
|
||||||
|
CGAL_assertion( this->mmap->is_marked((*this), mmark_number) );
|
||||||
|
|
||||||
|
if (!this->mmap->is_free(*this, Ai) &&
|
||||||
|
!this->mmap->is_marked(this->mmap->alpha(*this, Ai), mmark_number) )
|
||||||
|
{
|
||||||
|
mto_treat.push(this->mmap->alpha(*this, Ai));
|
||||||
|
this->mmap->mark(this->mmap->alpha(*this, Ai), mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->mmap->mark((*this), mmark_number);
|
||||||
|
if (!this->mmap->is_free(*this, Ai) &&
|
||||||
|
!this->mmap->is_marked(this->mmap->alpha(*this, Ai), mmark_number) )
|
||||||
|
{
|
||||||
|
mto_treat.push(this->mmap->alpha(*this, Ai));
|
||||||
|
this->mmap->mark(this->mmap->alpha(*this, Ai), mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Postfix ++ operator.
|
||||||
|
Self operator++(int)
|
||||||
|
{ Self res=*this; operator ++(); return res; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Queue of darts to process.
|
||||||
|
std::queue<Dart_handle> mto_treat;
|
||||||
|
|
||||||
|
/// Index of the used mark.
|
||||||
|
int mmark_number;
|
||||||
|
|
||||||
|
/// Initial dart
|
||||||
|
Dart_handle minitial_dart;
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
/* Class GMap_extend_iterator<Map,Ite,Ai> which extend a given iterator by
|
||||||
|
* adding Ai and by using a stack and a mark.
|
||||||
|
* Specialization when Ite has already a stack.
|
||||||
|
*/
|
||||||
|
template <typename Map_,typename Ite,int Ai>
|
||||||
|
class GMap_extend_iterator<Map_,Ite,Ai,Tag_true>: public Ite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef GMap_extend_iterator<Map_,Ite,Ai,Tag_true> Self;
|
||||||
|
typedef Ite Base;
|
||||||
|
|
||||||
|
typedef typename Base::Dart_handle Dart_handle;
|
||||||
|
typedef typename Base::Map Map;
|
||||||
|
|
||||||
|
typedef Tag_true Use_mark;
|
||||||
|
|
||||||
|
/// Main constructor.
|
||||||
|
GMap_extend_iterator(Map& amap, Dart_handle adart, int amark):
|
||||||
|
Base(amap, adart, amark)
|
||||||
|
{
|
||||||
|
if (adart!=amap.null_handle)
|
||||||
|
{
|
||||||
|
if (!this->mmap->is_free(adart, Ai) &&
|
||||||
|
!this->mmap->is_marked(this->mmap->alpha(amap, Ai), this->mmark_number))
|
||||||
|
{
|
||||||
|
this->mto_treat.push(adart->alpha(Ai));
|
||||||
|
this->mmap->mark(this->mmap->alpha(this->minitial_dart, Ai), this->mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rewind of the iterator to its beginning.
|
||||||
|
void rewind()
|
||||||
|
{
|
||||||
|
CGAL_assertion(this->mmark_number != -1);
|
||||||
|
Base::rewind();
|
||||||
|
if ( !this->mmap->is_free(this->minitial_dart, Ai) )
|
||||||
|
{
|
||||||
|
this->mto_treat.push(this->mmap->alpha(this->minitial_dart, Ai));
|
||||||
|
this->mmap->mark(this->mmap->alpha(this->minitial_dart, Ai), this->mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prefix ++ operator.
|
||||||
|
Self& operator++()
|
||||||
|
{
|
||||||
|
Base::operator++();
|
||||||
|
|
||||||
|
if ( this->cont() )
|
||||||
|
{
|
||||||
|
CGAL_assertion( this->mmap->is_marked(*this, this->mmark_number) );
|
||||||
|
|
||||||
|
if (!this->mmap->is_free(*this, Ai) &&
|
||||||
|
!this->mmap->is_marked(this->mmap->alpha(*this, Ai),
|
||||||
|
this->mmark_number))
|
||||||
|
{
|
||||||
|
this->mto_treat.push(this->mmap->alpha(*this, Ai));
|
||||||
|
this->mmap->mark(this->mmap->alpha(*this, Ai), this->mmark_number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Postfix ++ operator.
|
||||||
|
Self operator++(int)
|
||||||
|
{ Self res=*this; operator ++(); return res; }
|
||||||
|
};
|
||||||
|
//****************************************************************************
|
||||||
|
//****************************************************************************
|
||||||
|
} // namespace CGAL
|
||||||
|
//******************************************************************************
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_ITERATORS_BASE_HH
|
||||||
|
//******************************************************************************
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_MIN_ITEMS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_MIN_ITEMS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/GMap_dart.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file Generalized_map_min_items.h
|
||||||
|
* Definition of min item class for dD generalized map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Minimal items for dD generalized map.
|
||||||
|
* Generalized_map_min_items defines what is the minimal item
|
||||||
|
* class for a d-gmap It provides definitions for darts without attribute.
|
||||||
|
*/
|
||||||
|
template <unsigned int d>
|
||||||
|
struct Generalized_map_min_items
|
||||||
|
{
|
||||||
|
/// Dart_wrapper defines the type of darts used, and enabled attributes.
|
||||||
|
template < class Refs >
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart< d, Refs > Dart;
|
||||||
|
typedef CGAL::cpp11::tuple<> Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_MIN_ITEMS_H //
|
||||||
|
// EOF //
|
||||||
|
|
@ -0,0 +1,422 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_OPERATIONS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_OPERATIONS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Generalized_map_insertions.h>
|
||||||
|
#include <deque>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
/** @file Generalized_map_operations.h
|
||||||
|
* Some operations to modify a generalized map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Test if an i-cell can be removed.
|
||||||
|
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
||||||
|
* or if there are at most two (i+1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be removed.
|
||||||
|
*/
|
||||||
|
template <class CMap, unsigned int i, unsigned int nmi=CMap::dimension-i>
|
||||||
|
struct Is_removable_functor
|
||||||
|
{
|
||||||
|
static bool run(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
|
{
|
||||||
|
// TODO? Optimisation for dim-2, and to not test all the darts of the cell?
|
||||||
|
bool res = true;
|
||||||
|
for ( CGAL::GMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart);
|
||||||
|
res && it.cont(); ++it )
|
||||||
|
{
|
||||||
|
if (amap.template alpha<i+2,i+1>(it)!=amap.template alpha<i+1,i+2>(it))
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for i=CMap::dimension
|
||||||
|
template <class CMap, unsigned int i>
|
||||||
|
struct Is_removable_functor<CMap, i, 0>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
|
// Specialization for i=CMap::dimension-1
|
||||||
|
template <class CMap, unsigned int i>
|
||||||
|
struct Is_removable_functor<CMap, i, 1>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
|
/** Test if an i-cell can be removed.
|
||||||
|
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
||||||
|
* or if there are at most two (i+1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be removed.
|
||||||
|
*/
|
||||||
|
template < class CMap, unsigned int i >
|
||||||
|
bool is_removable(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
|
{ return CGAL::Is_removable_functor<CMap, i>::run(amap,adart); }
|
||||||
|
|
||||||
|
/** Remove an i-cell, 0<=i<dimension, and merge eventually both incident
|
||||||
|
* (i+1)-cells.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the i-cell to remove.
|
||||||
|
* @return the number of deleted darts.
|
||||||
|
*/
|
||||||
|
template<class CMap, unsigned int i, unsigned int nmi>
|
||||||
|
struct Remove_cell_functor
|
||||||
|
{
|
||||||
|
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion ( i<CMap::dimension );
|
||||||
|
CGAL_assertion( (is_removable<CMap,i>(amap, adart)) );
|
||||||
|
|
||||||
|
size_t res = 0;
|
||||||
|
|
||||||
|
typename CMap::Dart_handle d1, d2;
|
||||||
|
typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle;
|
||||||
|
|
||||||
|
int mark = amap.get_new_mark();
|
||||||
|
int mark_modified_darts = amap.get_new_mark();
|
||||||
|
|
||||||
|
std::deque<typename CMap::Dart_handle> to_erase;
|
||||||
|
|
||||||
|
// First we store and mark all the darts of the i-cell to remove.
|
||||||
|
for ( CGAL::GMap_dart_iterator_basic_of_cell<CMap,i> it(amap,adart,mark);
|
||||||
|
it.cont(); ++it )
|
||||||
|
{
|
||||||
|
to_erase.push_back(it);
|
||||||
|
if ( !amap.template is_free<i+1>(it) && dg1==amap.null_handle )
|
||||||
|
{ dg1=it; dg2=amap.template alpha<i+1>(it); }
|
||||||
|
amap.mark(it, mark);
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We group the two (i+1)-cells incident if they exist.
|
||||||
|
if ( dg1!=amap.null_handle )
|
||||||
|
CGAL::internal::Group_attribute_functor_run<CMap, i+1>::
|
||||||
|
run(&amap, dg1, dg2);
|
||||||
|
|
||||||
|
// During the operation, we store in modified_darts the darts modified
|
||||||
|
// to test after the loop the non void attributes that are split.
|
||||||
|
std::deque<typename CMap::Dart_handle> modified_darts;
|
||||||
|
|
||||||
|
// For each dart of the i-cell, we modify i-links of neighbors.
|
||||||
|
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||||
|
to_erase.begin();
|
||||||
|
for ( ; it!=to_erase.end(); ++it )
|
||||||
|
{
|
||||||
|
d1=amap.template alpha<i>(*it);
|
||||||
|
|
||||||
|
if ( !amap.is_marked(d1, mark) )
|
||||||
|
{
|
||||||
|
d2=amap.template alpha<i+1,i>(*it);
|
||||||
|
while ( amap.is_marked(d2, mark) )
|
||||||
|
{
|
||||||
|
d2=amap.template alpha<i+1,i>(d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !amap.is_marked(d1, mark_modified_darts) )
|
||||||
|
{
|
||||||
|
CGAL_assertion( !amap.is_marked(d2, mark_modified_darts) );
|
||||||
|
amap.template basic_link_alpha<i>(d1, d2);
|
||||||
|
amap.mark(d1, mark_modified_darts);
|
||||||
|
modified_darts.push_back(d1);
|
||||||
|
// TODO push only one out of two dart ?
|
||||||
|
if ( d2!=d1 )
|
||||||
|
{
|
||||||
|
modified_darts.push_back(d2);
|
||||||
|
amap.mark(d2, mark_modified_darts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We test the split of all the incident cells for all the non
|
||||||
|
// void attributes.
|
||||||
|
CMap::Helper::template Foreach_enabled_attributes_except
|
||||||
|
<CGAL::internal::Test_split_attribute_functor<CMap,i>, i>::
|
||||||
|
run(&amap, modified_darts, mark_modified_darts);
|
||||||
|
|
||||||
|
// We remove all the darts of the i-cell.
|
||||||
|
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
|
||||||
|
{ amap.erase_dart(*it); }
|
||||||
|
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||||
|
amap.free_mark(mark);
|
||||||
|
|
||||||
|
// If no attribute is enabled (or if only i-attributes are enabled),
|
||||||
|
// the darts are not unmark by Foreach_enabled_attributes_except.
|
||||||
|
// Thus we unmark them now.
|
||||||
|
if ( !amap.is_whole_map_unmarked(mark_modified_darts) )
|
||||||
|
{
|
||||||
|
for ( it=modified_darts.begin();
|
||||||
|
it!=modified_darts.end(); ++it )
|
||||||
|
amap.unmark(*it, mark_modified_darts);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion ( amap.is_whole_map_unmarked(mark_modified_darts) );
|
||||||
|
amap.free_mark(mark_modified_darts);
|
||||||
|
|
||||||
|
#ifdef CGAL_GMAP_TEST_VALID_REMOVALS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Remove a d-cell, in a d-map (special case).
|
||||||
|
* @param amap the used combinatorial map.
|
||||||
|
* @param adart a dart of the volume to remove.
|
||||||
|
* @return the number of deleted darts.
|
||||||
|
*/
|
||||||
|
template<class Gmap,unsigned int i>
|
||||||
|
struct Remove_cell_functor<Gmap,i,0>
|
||||||
|
{
|
||||||
|
static size_t run(Gmap& amap, typename Gmap::Dart_handle adart)
|
||||||
|
{
|
||||||
|
int mark = amap.get_new_mark();
|
||||||
|
std::deque<typename Gmap::Dart_handle> to_erase;
|
||||||
|
size_t res = 0;
|
||||||
|
|
||||||
|
std::deque<typename Gmap::Dart_handle> modified_darts;
|
||||||
|
|
||||||
|
// We mark all the darts of the d-cell.
|
||||||
|
for ( CGAL::GMap_dart_iterator_basic_of_cell<Gmap,Gmap::dimension>
|
||||||
|
it(amap,adart,mark); it.cont(); ++it )
|
||||||
|
{
|
||||||
|
to_erase.push_back(it);
|
||||||
|
amap.mark(it,mark);
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We unlink all the darts of the volume for alpha-d.
|
||||||
|
typename std::deque<typename Gmap::Dart_handle>::iterator
|
||||||
|
it = to_erase.begin();
|
||||||
|
for ( it = to_erase.begin(); it != to_erase.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( !amap.template is_free<Gmap::dimension>(*it) &&
|
||||||
|
!amap.is_marked(amap.template alpha<Gmap::dimension>(*it), mark) )
|
||||||
|
{
|
||||||
|
modified_darts.push_back(amap.template alpha<Gmap::dimension>(*it));
|
||||||
|
amap.template unlink_alpha<Gmap::dimension>(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We test the split of all the incident cells for all the non
|
||||||
|
// void attributes.
|
||||||
|
Gmap::Helper::template Foreach_enabled_attributes_except
|
||||||
|
<CGAL::internal::Test_split_attribute_functor<Gmap,i>,
|
||||||
|
Gmap::dimension>::run(&amap, modified_darts);
|
||||||
|
|
||||||
|
// We remove all the darts of the d-cell.
|
||||||
|
for ( it = to_erase.begin(); it != to_erase.end(); ++it )
|
||||||
|
{ amap.erase_dart(*it); }
|
||||||
|
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||||
|
amap.free_mark(mark);
|
||||||
|
|
||||||
|
#ifdef CGAL_GMAP_TEST_VALID_REMOVALS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Remove an i-cell, 0<=i<=dimension.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the i-cell to remove.
|
||||||
|
* @return the number of deleted darts.
|
||||||
|
*/
|
||||||
|
template< class Gmap, unsigned int i >
|
||||||
|
size_t remove_cell(Gmap& amap, typename Gmap::Dart_handle adart)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
CGAL::Remove_cell_functor<Gmap,i,Gmap::dimension-i>::run(amap,adart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if an i-cell can be contracted.
|
||||||
|
* An i-cell can be contracted if i==1
|
||||||
|
* or if there are at most two (i-1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be contracted.
|
||||||
|
*/
|
||||||
|
template <class Gmap, unsigned int i>
|
||||||
|
struct Is_contractible_functor
|
||||||
|
{
|
||||||
|
static bool run(const Gmap& amap, typename Gmap::Dart_const_handle adart)
|
||||||
|
{
|
||||||
|
// TODO ? Optimisation possible to not test all the darts of the cell ?
|
||||||
|
bool res = true;
|
||||||
|
for ( CGAL::GMap_dart_const_iterator_of_cell<Gmap,i> it(amap, adart);
|
||||||
|
res && it.cont(); ++it )
|
||||||
|
{
|
||||||
|
if (amap.template alpha<i-2,i-1>(it)!=amap.template alpha<i-1,i-2>(it))
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for i=0
|
||||||
|
template <class Gmap>
|
||||||
|
struct Is_contractible_functor<Gmap, 0>
|
||||||
|
{
|
||||||
|
static bool run(const Gmap&, typename Gmap::Dart_const_handle)
|
||||||
|
{ return false; }
|
||||||
|
};
|
||||||
|
// Specialization for i=1
|
||||||
|
template <class Gmap>
|
||||||
|
struct Is_contractible_functor<Gmap, 1>
|
||||||
|
{
|
||||||
|
static bool run(const Gmap&, typename Gmap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
|
/** Test if an i-cell can be contracted.
|
||||||
|
* An i-cell can be contracted if i==1
|
||||||
|
* or if there are at most two (i-1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be contracted.
|
||||||
|
*/
|
||||||
|
template < class Gmap, unsigned int i >
|
||||||
|
bool is_contractible(const Gmap& amap, typename Gmap::Dart_const_handle adart)
|
||||||
|
{ return CGAL::Is_contractible_functor<Gmap, i>::run(amap,adart); }
|
||||||
|
|
||||||
|
/** Contract an i-cell, 1<=i<=dimension, and merge eventually both incident
|
||||||
|
* (i-1)-cells.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the i-cell to contract.
|
||||||
|
* @return the number of deleted darts.
|
||||||
|
*/
|
||||||
|
template<class Gmap, unsigned int i>
|
||||||
|
struct Contract_cell_functor
|
||||||
|
{
|
||||||
|
static size_t run(Gmap& amap, typename Gmap::Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion ( 1<=i && i<=Gmap::dimension );
|
||||||
|
CGAL_assertion( (is_contractible<Gmap,i>(amap, adart)) );
|
||||||
|
|
||||||
|
size_t res = 0;
|
||||||
|
|
||||||
|
typename Gmap::Dart_handle d1, d2;
|
||||||
|
typename Gmap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle;
|
||||||
|
|
||||||
|
int mark = amap.get_new_mark();
|
||||||
|
int mark_modified_darts = amap.get_new_mark();
|
||||||
|
|
||||||
|
// First we store and mark all the darts of the i-cell to contract.
|
||||||
|
std::deque<typename Gmap::Dart_handle> to_erase;
|
||||||
|
for ( CGAL::GMap_dart_iterator_basic_of_cell<Gmap,i> it(amap,adart,mark);
|
||||||
|
it.cont(); ++it )
|
||||||
|
{
|
||||||
|
to_erase.push_back(it);
|
||||||
|
if ( !amap.template is_free<i-1>(it) && dg1==amap.null_handle )
|
||||||
|
{ dg1=it; dg2=amap.template alpha<i-1>(it); }
|
||||||
|
amap.mark(it, mark);
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We group the two (i-1)-cells incident if they exist.
|
||||||
|
if ( dg1!=amap.null_handle )
|
||||||
|
CGAL::internal::Group_attribute_functor_run<Gmap,i-1>::
|
||||||
|
run(&amap, dg1, dg2);
|
||||||
|
|
||||||
|
// During the operation, we store in modified_darts the darts modified
|
||||||
|
// to test after the loop the non void attributes that are split.
|
||||||
|
std::deque<typename Gmap::Dart_handle> modified_darts;
|
||||||
|
|
||||||
|
// For each dart of the i-cell, we modify i-links of neighbors.
|
||||||
|
typename std::deque<typename Gmap::Dart_handle>::iterator it =
|
||||||
|
to_erase.begin();
|
||||||
|
for ( ; it!=to_erase.end(); ++it )
|
||||||
|
{
|
||||||
|
d1 = amap.template alpha<i>(*it);
|
||||||
|
if ( !amap.is_marked(d1, mark) )
|
||||||
|
{
|
||||||
|
d2 = amap.template alpha<i-1,i>(*it);
|
||||||
|
while ( amap.is_marked(d2, mark) )
|
||||||
|
{ d2 = amap.template alpha<i-1,i>(d2); }
|
||||||
|
|
||||||
|
if ( !amap.is_marked(d1, mark_modified_darts) )
|
||||||
|
{
|
||||||
|
CGAL_assertion( !amap.is_marked(d2, mark_modified_darts) );
|
||||||
|
amap.template basic_link_alpha<i>(d1, d2);
|
||||||
|
amap.mark(d1, mark_modified_darts);
|
||||||
|
modified_darts.push_back(d1);
|
||||||
|
// TODO push only one out of two dart ?
|
||||||
|
if ( d1!=d2 )
|
||||||
|
{
|
||||||
|
amap.mark(d2, mark_modified_darts);
|
||||||
|
modified_darts.push_back(d2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We test the split of all the incident cells for all the non
|
||||||
|
// void attributes.
|
||||||
|
Gmap::Helper::template Foreach_enabled_attributes_except
|
||||||
|
<CGAL::internal::Test_split_attribute_functor<Gmap,i>, i>::
|
||||||
|
run(&amap, modified_darts, mark_modified_darts);
|
||||||
|
|
||||||
|
// We remove all the darts of the i-cell.
|
||||||
|
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
|
||||||
|
{ amap.erase_dart(*it); }
|
||||||
|
|
||||||
|
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||||
|
amap.free_mark(mark);
|
||||||
|
|
||||||
|
// If no attribute is enabled (or if only i-attributes are enabled),
|
||||||
|
// the darts are not unmark by Foreach_enabled_attributes_except.
|
||||||
|
// Thus we unmark them now.
|
||||||
|
if ( !amap.is_whole_map_unmarked(mark_modified_darts) )
|
||||||
|
{
|
||||||
|
for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it )
|
||||||
|
amap.unmark(*it, mark_modified_darts);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion ( amap.is_whole_map_unmarked(mark_modified_darts) );
|
||||||
|
amap.free_mark(mark_modified_darts);
|
||||||
|
|
||||||
|
#ifdef CGAL_GMAP_TEST_VALID_CONTRACTIONS
|
||||||
|
CGAL_assertion( amap.is_valid() );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Contract an i-cell, 1<=i<=dimension.
|
||||||
|
* @param amap the used generalized map.
|
||||||
|
* @param adart a dart of the i-cell to remove.
|
||||||
|
* @return the number of deleted darts.
|
||||||
|
*/
|
||||||
|
template < class Gmap, unsigned int i >
|
||||||
|
size_t contract_cell(Gmap& amap, typename Gmap::Dart_handle adart)
|
||||||
|
{ return CGAL::Contract_cell_functor<Gmap,i>::run(amap,adart); }
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_OPERATIONS_H //
|
||||||
|
// EOF //
|
||||||
|
|
@ -0,0 +1,359 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_STORAGES_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_STORAGES_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Combinatorial_map_storages.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/** @file Generalized_map_storages.h
|
||||||
|
* Definition of storages for dD Generalized map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Storage of darts with compact container, alpha with handles
|
||||||
|
template<unsigned int d_, class Items_, class Alloc_ >
|
||||||
|
class Generalized_map_storage_1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Generalized_map_storage_1<d_, Items_, Alloc_> Self;
|
||||||
|
typedef CGAL::Tag_false Use_index;
|
||||||
|
|
||||||
|
typedef internal::Combinatorial_map_helper<Self> Helper;
|
||||||
|
|
||||||
|
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
|
||||||
|
typedef typename Dart_wrapper::Dart Dart;
|
||||||
|
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
|
||||||
|
|
||||||
|
typedef Compact_container<Dart,Dart_allocator> Dart_container;
|
||||||
|
|
||||||
|
typedef typename Dart_container::iterator Dart_handle;
|
||||||
|
typedef typename Dart_container::const_iterator Dart_const_handle;
|
||||||
|
typedef typename Dart_container::size_type size_type;
|
||||||
|
|
||||||
|
typedef CGAL::Void* Null_handle_type;
|
||||||
|
static Null_handle_type null_handle;
|
||||||
|
|
||||||
|
typedef Items_ Items;
|
||||||
|
typedef Alloc_ Alloc;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Container_for_attributes :
|
||||||
|
public Compact_container<T, typename Alloc_::template rebind<T>::other>
|
||||||
|
{};
|
||||||
|
|
||||||
|
/// Typedef for attributes
|
||||||
|
typedef typename Dart_wrapper::Attributes Attributes;
|
||||||
|
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_type: public Helper::template Attribute_type<i>
|
||||||
|
{};
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_handle: public Helper::template Attribute_handle<i>
|
||||||
|
{};
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_const_handle:
|
||||||
|
public Helper::template Attribute_const_handle<i>
|
||||||
|
{};
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_range: public Helper::template Attribute_range<i>
|
||||||
|
{};
|
||||||
|
template<int i>
|
||||||
|
struct Attribute_const_range:
|
||||||
|
public Helper::template Attribute_const_range<i>
|
||||||
|
{};
|
||||||
|
|
||||||
|
/// Number of marks
|
||||||
|
static const size_type NB_MARKS = 32;
|
||||||
|
|
||||||
|
/// The dimension of the generalized map.
|
||||||
|
static const unsigned int dimension = d_;
|
||||||
|
|
||||||
|
typedef Handle_hash_function Hash_function;
|
||||||
|
|
||||||
|
// Init
|
||||||
|
void init_storage()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/** Return if this dart is free for adimension.
|
||||||
|
* @param dh a dart handle
|
||||||
|
* @param i the dimension.
|
||||||
|
* @return true iff dh is linked with NULL for \em adimension.
|
||||||
|
*/
|
||||||
|
template<unsigned int i>
|
||||||
|
bool is_free(Dart_const_handle dh) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( dh!=NULL );
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return dh->malpha[i]==dh;
|
||||||
|
}
|
||||||
|
bool is_free(Dart_const_handle dh, unsigned int i) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( dh!=NULL );
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
return dh->malpha[i]==dh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set simultaneously all the marks of this dart to a given value.
|
||||||
|
void set_dart_marks(Dart_const_handle ADart,
|
||||||
|
const std::bitset<NB_MARKS>& amarks) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ADart!=NULL );
|
||||||
|
ADart->set_marks(amarks);
|
||||||
|
}
|
||||||
|
/// Return all the marks of a dart.
|
||||||
|
std::bitset<NB_MARKS> get_dart_marks(Dart_const_handle ADart) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ADart!=NULL );
|
||||||
|
return ADart->get_marks();
|
||||||
|
}
|
||||||
|
/// Return the mark value of dart a given mark number.
|
||||||
|
bool get_dart_mark(Dart_const_handle ADart, int amark) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ADart!=NULL );
|
||||||
|
return ADart->get_mark(amark);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the mark of a given mark number to a given value.
|
||||||
|
void set_dart_mark(Dart_const_handle ADart, int amark, bool avalue) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ADart!=NULL );
|
||||||
|
ADart->set_mark(amark, avalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Flip the mark of a given mark number to a given value.
|
||||||
|
void flip_dart_mark(Dart_const_handle ADart, int amark) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ADart!=NULL );
|
||||||
|
ADart->flip_mark(amark);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Access to alpha maps
|
||||||
|
Dart_handle get_alpha(Dart_handle ADart, int B1)
|
||||||
|
{
|
||||||
|
CGAL_assertion(ADart!=NULL && B1>=0 && B1<=(int)dimension);
|
||||||
|
return ADart->malpha[B1];
|
||||||
|
}
|
||||||
|
Dart_const_handle get_alpha(Dart_const_handle ADart, int B1) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(ADart!=NULL && B1>=0 && B1<=(int)dimension);
|
||||||
|
return ADart->malpha[B1];
|
||||||
|
}
|
||||||
|
template<int B1>
|
||||||
|
Dart_handle get_alpha(Dart_handle ADart)
|
||||||
|
{
|
||||||
|
CGAL_assertion(ADart!=NULL && B1>=0 && B1<=(int)dimension);
|
||||||
|
return ADart->malpha[B1];
|
||||||
|
}
|
||||||
|
template<int B1>
|
||||||
|
Dart_const_handle get_alpha(Dart_const_handle ADart) const
|
||||||
|
{
|
||||||
|
CGAL_assertion(ADart!=NULL && B1>=0 && B1<=(int)dimension);
|
||||||
|
return ADart->malpha[B1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a handle on the i-attribute
|
||||||
|
template<unsigned int i>
|
||||||
|
typename Attribute_handle<i>::type attribute(Dart_handle ADart)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"attribute<i> called but i-attributes are disabled.");
|
||||||
|
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
|
||||||
|
(ADart->mattribute_handles);
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
typename Attribute_const_handle<i>::type
|
||||||
|
attribute(Dart_const_handle ADart) const
|
||||||
|
{
|
||||||
|
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"attribute<i> called but i-attributes are disabled.");
|
||||||
|
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
|
||||||
|
(ADart->mattribute_handles);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the attribute given its handle
|
||||||
|
template<unsigned int i>
|
||||||
|
typename Attribute_type<i>::type&
|
||||||
|
get_attribute(typename Attribute_handle<i>::type ah)
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return *ah;
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
const typename Attribute_type<i>::type&
|
||||||
|
get_attribute(typename Attribute_const_handle<i>::type ah) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return *ah;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dart & get_dart(Dart_handle ah)
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return *ah;
|
||||||
|
}
|
||||||
|
const Dart & get_dart(Dart_const_handle ah) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return *ah;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the dart of the given attribute
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_handle dart_of_attribute(typename Attribute_handle<i>::type ah)
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return ah->dart();
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_const_handle
|
||||||
|
dart_of_attribute(typename Attribute_const_handle<i>::type ah) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return ah->dart();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the dart of the given attribute
|
||||||
|
template<unsigned int i>
|
||||||
|
void set_dart_of_attribute(typename Attribute_handle<i>::type ah,
|
||||||
|
Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
ah->set_dart(adart);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the info of the given attribute
|
||||||
|
template<unsigned int i>
|
||||||
|
typename Attribute_type<i>::type::Info &
|
||||||
|
info_of_attribute(typename Attribute_handle<i>::type ah)
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return ah->info();
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
const typename Attribute_type<i>::type::Info &
|
||||||
|
info_of_attribute(typename Attribute_const_handle<i>::type ah) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( ah!=NULL );
|
||||||
|
return ah->info();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the info of the i-cell attribute associated with the given dart
|
||||||
|
template<unsigned int i>
|
||||||
|
typename Attribute_type<i>::type::Info & info(Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_assertion( adart!=NULL );
|
||||||
|
CGAL_assertion( attribute<i>(adart)!=NULL );
|
||||||
|
return info_of_attribute<i>(attribute<i>(adart));
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
const typename Attribute_type<i>::type::Info &
|
||||||
|
info(Dart_const_handle adart) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( adart!=NULL );
|
||||||
|
CGAL_assertion( attribute<i>(adart)!=NULL );
|
||||||
|
return info_of_attribute<i>(attribute<i>(adart));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the dart of the i-cell attribute associated with the given dart
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_handle & dart(Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_assertion( adart!=NULL );
|
||||||
|
CGAL_assertion( attribute<i>(adart)!=NULL );
|
||||||
|
return dart_of_attribute<i>(attribute<i>(adart));
|
||||||
|
}
|
||||||
|
template<unsigned int i>
|
||||||
|
Dart_const_handle dart(Dart_const_handle adart) const
|
||||||
|
{
|
||||||
|
CGAL_assertion( adart!=NULL );
|
||||||
|
CGAL_assertion( attribute<i>(adart)!=NULL );
|
||||||
|
return dart_of_attribute<i>(attribute<i>(adart));
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_dart(Dart_const_handle ADart) const
|
||||||
|
{ std::cout<<&*ADart; }
|
||||||
|
|
||||||
|
template<unsigned int i>
|
||||||
|
void display_attribute(typename Attribute_const_handle<i>::type ah) const
|
||||||
|
{ std::cout<<&*ah; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Set the handle on the i th attribute
|
||||||
|
template<unsigned int i>
|
||||||
|
void basic_set_dart_attribute(Dart_handle dh,
|
||||||
|
typename Attribute_handle<i>::type ah)
|
||||||
|
{
|
||||||
|
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
|
||||||
|
(dh->mattribute_handles) = ah;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Link a dart with a given dart for a given dimension.
|
||||||
|
* @param adart the dart to link.
|
||||||
|
* @param adart2 the dart to link with.
|
||||||
|
* @param i the dimension.
|
||||||
|
*/
|
||||||
|
template<unsigned int i>
|
||||||
|
void dart_link_alpha(Dart_handle adart, Dart_handle adart2)
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
CGAL_assertion(adart!=NULL && adart2!=NULL);
|
||||||
|
adart->malpha[i] = adart2;
|
||||||
|
}
|
||||||
|
void dart_link_alpha(Dart_handle adart, Dart_handle adart2, unsigned int i)
|
||||||
|
{
|
||||||
|
CGAL_assertion(i <= dimension);
|
||||||
|
CGAL_assertion(adart!=NULL && adart2!=NULL);
|
||||||
|
adart->malpha[i] = adart2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unlink a dart for a given dimension.
|
||||||
|
* @param adart a dart.
|
||||||
|
* @param i the dimension.
|
||||||
|
*/
|
||||||
|
template<unsigned int i>
|
||||||
|
void dart_unlink_alpha(Dart_handle adart)
|
||||||
|
{
|
||||||
|
CGAL_assertion(adart!=NULL && i <= dimension);
|
||||||
|
adart->malpha[i] = adart;
|
||||||
|
}
|
||||||
|
void dart_unlink_alpha(Dart_handle adart, unsigned int i)
|
||||||
|
{
|
||||||
|
CGAL_assertion(adart!=NULL && i <= dimension);
|
||||||
|
adart->malpha[i] = adart;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Dart container.
|
||||||
|
Dart_container mdarts;
|
||||||
|
|
||||||
|
/// Tuple of attributes containers
|
||||||
|
typename Helper::Attribute_containers mattribute_containers;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// null_handle
|
||||||
|
template < unsigned int d_, class Items_, class Alloc_ >
|
||||||
|
typename Generalized_map_storage_1<d_, Items_, Alloc_>::Null_handle_type
|
||||||
|
Generalized_map_storage_1<d_, Items_, Alloc_>::null_handle = NULL;
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_STORAGES_H //
|
||||||
|
// EOF //
|
||||||
|
|
@ -0,0 +1,426 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_GROUP_FUNCTORS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_GROUP_FUNCTORS_H 1
|
||||||
|
|
||||||
|
#include <CGAL/Unique_hash_map.h>
|
||||||
|
#include <CGAL/internal/Generalized_map_internal_functors.h>
|
||||||
|
#include <CGAL/GMap_dart_iterators.h>
|
||||||
|
#include <CGAL/Combinatorial_map_functors.h>
|
||||||
|
|
||||||
|
/* Definition of functors used to group/ungroup attributes (we need functors
|
||||||
|
* as attributes are stored in tuple, thus all the access must be done at
|
||||||
|
* compiling time). Some of these functors are used with
|
||||||
|
* Foreach_enabled_attributes to iterate through all the non void attribs.
|
||||||
|
* These functors used other functors defined in Combinatorial_map_functors.h
|
||||||
|
*
|
||||||
|
* Group_attribute_functor_of_dart<CMap> to group the <i>-attributes of two
|
||||||
|
* given darts (except for j-dim). Only the attributes of the two given
|
||||||
|
* darts are possibly modified.
|
||||||
|
*
|
||||||
|
* Group_attribute_functor_of_dart_run<CMap,i> same than
|
||||||
|
* Group_attribute_functor_of_dart<CMap>::run<i>, with i template argument
|
||||||
|
* given in the struct to enable specialization.
|
||||||
|
*
|
||||||
|
* Group_attribute_functor<CMap> to group the <i>-attributes of two
|
||||||
|
* given i-cells (except for j-adim). If one i-attribute is NULL, we set the
|
||||||
|
* darts of its i-cell to the second attribute. If both i-attributes are
|
||||||
|
* non NULL, we overide all the i-attribute of the second i-cell to the
|
||||||
|
* first i-attribute.
|
||||||
|
*
|
||||||
|
* Degroup_attribute_functor_run<CMap> to degroup one i-attributes in two
|
||||||
|
* (except for j-adim).
|
||||||
|
*
|
||||||
|
* Test_split_attribute_functor<CMap,i> to test if there is some i-attributes
|
||||||
|
* that are split after an operation. Modified darts are given in a
|
||||||
|
* std::deque.
|
||||||
|
*/
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
// ************************************************************************
|
||||||
|
/// Functor used for link_beta to update the i-attributes of
|
||||||
|
/// dh2 on the attributes of dh1 dart, except if i=j.
|
||||||
|
/// (j is the dimension of the beta modified between dh1 and dh2,
|
||||||
|
/// so that after the modification we will have beta_j(dh1)==dh2)
|
||||||
|
/// Only attributes of dh1 or dh2 can be modified. If one dart as its
|
||||||
|
/// attribute equal to null, it takes the attributes of the second dart.
|
||||||
|
/// If both attributes are non null, dh2 takes the attribute of dh1.
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j=CMap::dimension+1,
|
||||||
|
typename T=typename CMap::template Attribute_type<i>::type>
|
||||||
|
struct Group_attribute_functor_of_dart_run
|
||||||
|
{
|
||||||
|
/// Group the i-attribute of dh1 and dh2.
|
||||||
|
static void run(CMap* amap,
|
||||||
|
typename CMap::Dart_handle dh1,
|
||||||
|
typename CMap::Dart_handle dh2)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion( i<=CMap::dimension );
|
||||||
|
CGAL_static_assertion( i!=j );
|
||||||
|
CGAL_static_assertion_msg(CMap::Helper::template
|
||||||
|
Dimension_index<i>::value>=0,
|
||||||
|
"Group_attribute_functor_of_dart_run<i> but "
|
||||||
|
"i-attributes are disabled");
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a1=amap->template attribute<i>(dh1);
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a2=amap->template attribute<i>(dh2);
|
||||||
|
|
||||||
|
// If the two attributes are equal, nothing to do.
|
||||||
|
if ( a1==a2 ) return;
|
||||||
|
|
||||||
|
if ( a1==CMap::null_handle ) amap->template set_dart_attribute<i>(dh1, a2);
|
||||||
|
else amap->template set_dart_attribute<i>(dh2, a1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for i=j. Do nothing as j is the dimension to not consider.
|
||||||
|
template<typename CMap, unsigned int i, typename T>
|
||||||
|
struct Group_attribute_functor_of_dart_run<CMap,i,i,T>
|
||||||
|
{
|
||||||
|
static void run(CMap*,
|
||||||
|
typename CMap::Dart_handle,
|
||||||
|
typename CMap::Dart_handle)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
/// Functor used for link_beta to update the attributes of
|
||||||
|
/// adart2 on the attributes of this dart, except for j-attributes.
|
||||||
|
/// (j is the dimension of the beta modified between adart1 and adart2,
|
||||||
|
/// so that after the modification we will have beta_j(adart1)==adart2)
|
||||||
|
/// We define run<i> to allows to use this functor with
|
||||||
|
/// Foreach_enabled_attributes.
|
||||||
|
/// If you know i at compiling time, use directly
|
||||||
|
/// Group_attribute_functor_of_dart_run.
|
||||||
|
template<typename CMap, unsigned int j=CMap::dimension+1>
|
||||||
|
struct Group_attribute_functor_of_dart
|
||||||
|
{
|
||||||
|
template <unsigned int i>
|
||||||
|
static void run(CMap* amap,
|
||||||
|
typename CMap::Dart_handle adart1,
|
||||||
|
typename CMap::Dart_handle adart2)
|
||||||
|
{
|
||||||
|
CGAL::internal::Group_attribute_functor_of_dart_run<CMap,i,j>::
|
||||||
|
run(amap,adart1,adart2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
// Functor used to group the two i-attributes of the two i-cells, except
|
||||||
|
// the attribute of j
|
||||||
|
// (j is the dimension of the beta modified between adart1 and adart2).
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j=CMap::dimension+1,
|
||||||
|
typename T=typename CMap::template Attribute_type<i>::type>
|
||||||
|
struct Group_attribute_functor_run
|
||||||
|
{
|
||||||
|
static void run(CMap* amap,
|
||||||
|
typename CMap::Dart_handle adart1,
|
||||||
|
typename CMap::Dart_handle adart2)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion( i<=CMap::dimension );
|
||||||
|
CGAL_static_assertion( i!=j );
|
||||||
|
CGAL_static_assertion_msg
|
||||||
|
( CMap::Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"Group_attribute_functor_run<i> but i-attributes are disabled" );
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a1=amap->template attribute<i>(adart1);
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a2=amap->template attribute<i>(adart2);
|
||||||
|
|
||||||
|
// If the two attributes are equal, nothing to do.
|
||||||
|
if ( a1 == a2 ) return;
|
||||||
|
|
||||||
|
typename CMap::Dart_handle toSet = amap->null_handle;
|
||||||
|
|
||||||
|
// If the attribute associated to adart1 is NULL, set it with
|
||||||
|
// the attribute associated to adart2 (necessarily != NULL)
|
||||||
|
if (a1 == CMap::null_handle)
|
||||||
|
{ toSet = adart1; a1 = a2; }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toSet = adart2;
|
||||||
|
if (a2 != CMap::null_handle)
|
||||||
|
{
|
||||||
|
CGAL::internal::Call_merge_functor<CMap, i>::run(amap, a1, a2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
amap->template set_attribute<i>(toSet, a1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for void attributes.
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j>
|
||||||
|
struct Group_attribute_functor_run<CMap, i, j, CGAL::Void>
|
||||||
|
{
|
||||||
|
static void run( CMap*,
|
||||||
|
typename CMap::Dart_handle,
|
||||||
|
typename CMap::Dart_handle )
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// Specialization for i=j. Do nothing as j is the dimension to not consider.
|
||||||
|
template<typename CMap, unsigned int i, typename T>
|
||||||
|
struct Group_attribute_functor_run<CMap,i,i,T>
|
||||||
|
{
|
||||||
|
static void run(CMap*,
|
||||||
|
typename CMap::Dart_handle,
|
||||||
|
typename CMap::Dart_handle)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
/// Functor used for sew to update the attributes of
|
||||||
|
/// adart2 on the attributes of this dart, except for j-attributes.
|
||||||
|
/// (j is the dimension of the beta modified between adart1 and adart2,
|
||||||
|
/// so that after the modification we will have beta_j(adart1)==adart2)
|
||||||
|
/// We define run<i> to allows to use this functor with
|
||||||
|
/// Foreach_enabled_attributes.
|
||||||
|
/// If you know i at compiling time, use directly
|
||||||
|
/// Group_attribute_functor_run.
|
||||||
|
template<typename CMap, unsigned int j=CMap::dimension+1>
|
||||||
|
struct Group_attribute_functor
|
||||||
|
{
|
||||||
|
template <unsigned int i>
|
||||||
|
static void run(CMap* amap,
|
||||||
|
typename CMap::Dart_handle adart1,
|
||||||
|
typename CMap::Dart_handle adart2)
|
||||||
|
{ CGAL::internal::Group_attribute_functor_run<CMap,i,j>::
|
||||||
|
run(amap,adart1,adart2); }
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
// Functor used to degroup one i-attribute of one i-cell in two, except the
|
||||||
|
// attribute of j.
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j=CMap::dimension+1,
|
||||||
|
typename T=typename CMap::template Attribute_type<i>::type>
|
||||||
|
struct Degroup_attribute_functor_run
|
||||||
|
{
|
||||||
|
static void run(CMap* amap,
|
||||||
|
typename CMap::Dart_handle adart1,
|
||||||
|
typename CMap::Dart_handle adart2)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion( i<=CMap::dimension );
|
||||||
|
CGAL_static_assertion( i!=j );
|
||||||
|
CGAL_static_assertion_msg
|
||||||
|
( CMap::Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"Degroup_attribute_functor_run<i> but i-attributes are disabled" );
|
||||||
|
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a1=amap->template attribute<i>(adart1);
|
||||||
|
|
||||||
|
// If there is no first attribute, nothing to degroup.
|
||||||
|
if ( a1==CMap::null_handle ) return;
|
||||||
|
|
||||||
|
// If the second attribute is non null and already different from a1,
|
||||||
|
// nothing to do.
|
||||||
|
if ( a1!=amap->template attribute<i>(adart2) &&
|
||||||
|
amap->template attribute<i>(adart2)!=CMap::null_handle ) return;
|
||||||
|
|
||||||
|
CGAL_assertion( (!CGAL::belong_to_same_cell<CMap,i>
|
||||||
|
(*amap, adart1, adart2)) );
|
||||||
|
|
||||||
|
// As we split, we set the dart of the first attribute to adart1 for which
|
||||||
|
// we are sure it belongs to the first i-cell.
|
||||||
|
amap->template get_attribute<i>(a1).set_dart(adart1);
|
||||||
|
|
||||||
|
typename CMap::template Attribute_handle<i>::type
|
||||||
|
a2 = amap->template
|
||||||
|
create_attribute<i>(amap->template get_attribute<i>(a1));
|
||||||
|
|
||||||
|
amap->template set_attribute<i>(adart2, a2);
|
||||||
|
CGAL::internal::Call_split_functor<CMap, i>::run(amap, a1, a2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for void attributes.
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j>
|
||||||
|
struct Degroup_attribute_functor_run<CMap, i, j, CGAL::Void>
|
||||||
|
{
|
||||||
|
static void run(CMap*,
|
||||||
|
typename CMap::Dart_handle,
|
||||||
|
typename CMap::Dart_handle)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// Specialization for i==j.
|
||||||
|
template<typename CMap, unsigned int i, typename T>
|
||||||
|
struct Degroup_attribute_functor_run<CMap, i, i, T>
|
||||||
|
{
|
||||||
|
static void run(CMap*,
|
||||||
|
typename CMap::Dart_handle,
|
||||||
|
typename CMap::Dart_handle)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
// Function used by Test_split_attribute_functor_run to process one dart.
|
||||||
|
// Test the split of the i-cell containing the given dart adart.
|
||||||
|
// When we process a dart, we search in the Unique_hash_map if its
|
||||||
|
// i-attribute was already found. If yes, it means that we already
|
||||||
|
// found an i-cell with this attribute, thus this attribute is split.
|
||||||
|
// We mark (with mark) all the darts of the i-cell containing adart to
|
||||||
|
// process them exactly once.
|
||||||
|
template<typename CMap, unsigned int i>
|
||||||
|
void test_split_attribute_functor_one_dart
|
||||||
|
( CMap* amap, typename CMap::Dart_handle adart,
|
||||||
|
CGAL::Unique_hash_map<typename CMap::template Attribute_handle<i>::type,
|
||||||
|
unsigned int, typename CMap::Hash_function> &
|
||||||
|
found_attributes, int mark )
|
||||||
|
{
|
||||||
|
CGAL_assertion( amap!=NULL );
|
||||||
|
CGAL_static_assertion_msg(CMap::Helper::template
|
||||||
|
Dimension_index<i>::value>=0,
|
||||||
|
"Test_split_attribute_functor_one_dart<i> but "
|
||||||
|
"i-attributes are disabled");
|
||||||
|
|
||||||
|
typedef typename CMap::template Attribute_handle<i>::type
|
||||||
|
Attribute_handle_i;
|
||||||
|
|
||||||
|
// If the current dart has no attribute, or if it is aldready marked,
|
||||||
|
// nothing to do.
|
||||||
|
if ( amap->template attribute<i>(adart)==CMap::null_handle ||
|
||||||
|
amap->is_marked(adart, mark) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Attribute_handle_i a1 = amap->template attribute<i>(adart);
|
||||||
|
if ( found_attributes.is_defined(a1) )
|
||||||
|
{ // Here the attribute was already present in the hash_map
|
||||||
|
Attribute_handle_i a2 = amap->template
|
||||||
|
create_attribute<i>(amap->template get_attribute<i>(a1));
|
||||||
|
|
||||||
|
for ( CGAL::GMap_dart_iterator_basic_of_cell<CMap, i>
|
||||||
|
itj(*amap, adart, mark); itj.cont(); ++itj )
|
||||||
|
{
|
||||||
|
amap->template set_dart_attribute<i>(itj, a2);
|
||||||
|
amap->mark(itj, mark);
|
||||||
|
}
|
||||||
|
CGAL::internal::Call_split_functor<CMap, i>::run(amap, a1, a2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Here the attribute was not in the hash_map.
|
||||||
|
found_attributes[a1]=1;
|
||||||
|
amap->template set_dart_of_attribute<i>(a1, adart);
|
||||||
|
|
||||||
|
for ( CGAL::GMap_dart_iterator_basic_of_cell<CMap, i>
|
||||||
|
itj(*amap, adart, mark); itj.cont(); ++itj )
|
||||||
|
{
|
||||||
|
CGAL_assertion( amap->template attribute<i>(itj)==a1 );
|
||||||
|
amap->mark(itj, mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ************************************************************************
|
||||||
|
/// Functor used for unsew to test if i-attributes are split after an
|
||||||
|
/// operation, except for j-attributes.
|
||||||
|
/// (j is the dimension of the beta modified for darts in modified_darts,
|
||||||
|
/// if j==0 modified_darts2 are the darts modified for beta_1).
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j=CMap::dimension+1,
|
||||||
|
typename T=typename CMap::template Attribute_type<i>::type>
|
||||||
|
struct Test_split_attribute_functor_run
|
||||||
|
{
|
||||||
|
// modified_darts is the set of modified darts for beta_j
|
||||||
|
static void run( CMap* amap,
|
||||||
|
const std::deque<typename CMap::Dart_handle>
|
||||||
|
&modified_darts,
|
||||||
|
int mark_modified_darts=-1)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion( i<=CMap::dimension );
|
||||||
|
CGAL_assertion( i!=j );
|
||||||
|
CGAL_assertion( amap!=NULL );
|
||||||
|
CGAL_static_assertion_msg(CMap::Helper::template
|
||||||
|
Dimension_index<i>::value>=0,
|
||||||
|
"Test_split_attribute_functor_run<i> but "
|
||||||
|
"i-attributes are disabled");
|
||||||
|
|
||||||
|
typedef typename CMap::template Attribute_handle<i>::type
|
||||||
|
Attribute_handle_i;
|
||||||
|
|
||||||
|
CGAL::Unique_hash_map<Attribute_handle_i, unsigned int,
|
||||||
|
typename CMap::Hash_function> found_attributes;
|
||||||
|
|
||||||
|
int mark = amap->get_new_mark(); // to mark incident cells.
|
||||||
|
typename std::deque<typename CMap::Dart_handle>::const_iterator
|
||||||
|
it=modified_darts.begin();
|
||||||
|
for ( ; it!=modified_darts.end(); ++it )
|
||||||
|
{
|
||||||
|
CGAL::internal::test_split_attribute_functor_one_dart<CMap,i>
|
||||||
|
(amap, *it, found_attributes, mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we unmark all the marked darts.
|
||||||
|
amap->negate_mark(mark);
|
||||||
|
for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( mark_modified_darts!=-1 )
|
||||||
|
amap->unmark(*it, mark_modified_darts);
|
||||||
|
|
||||||
|
if ( !amap->is_marked(*it, mark) )
|
||||||
|
CGAL::mark_cell<CMap, i>(*amap, *it, mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion( amap->is_whole_map_marked(mark) );
|
||||||
|
amap->free_mark(mark);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for void attributes.
|
||||||
|
template<typename CMap, unsigned int i, unsigned int j>
|
||||||
|
struct Test_split_attribute_functor_run<CMap, i, j, CGAL::Void>
|
||||||
|
{
|
||||||
|
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
|
||||||
|
int=-1)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// Specialization for i=j.
|
||||||
|
template<typename CMap, unsigned int i, typename T>
|
||||||
|
struct Test_split_attribute_functor_run<CMap, i, i, T>
|
||||||
|
{
|
||||||
|
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
|
||||||
|
int=-1)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// Specialization for i=1 and j=0 (edge attributes are not modified
|
||||||
|
// when we modify beta_0).
|
||||||
|
template<typename CMap, typename T>
|
||||||
|
struct Test_split_attribute_functor_run<CMap, 1, 0, T>
|
||||||
|
{
|
||||||
|
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
|
||||||
|
int=-1)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
/// Functor used for unsew to test if i-attributes are split after an
|
||||||
|
/// operation, except for j-attributes.
|
||||||
|
/// We define run<i> to allows to use this functor with
|
||||||
|
/// Foreach_enabled_attributes.
|
||||||
|
template<typename CMap, unsigned int j=CMap::dimension+1>
|
||||||
|
struct Test_split_attribute_functor
|
||||||
|
{
|
||||||
|
// Test the split of i-attributes, for all modified darts given in
|
||||||
|
// modified_darts, and marked with mark_modified_darts.
|
||||||
|
// For each split attribute, create a new i-attribute, associate
|
||||||
|
// it with the new i-cell and call onsplit functors.
|
||||||
|
template <unsigned int i>
|
||||||
|
static void run( CMap* amap,
|
||||||
|
const std::deque<typename CMap::Dart_handle>
|
||||||
|
&modified_darts,
|
||||||
|
int mark_modified_darts=-1)
|
||||||
|
{
|
||||||
|
CGAL::internal::Test_split_attribute_functor_run<CMap, i, j>::
|
||||||
|
run(amap, modified_darts, mark_modified_darts);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// ************************************************************************
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_GROUP_FUNCTORS_H
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_INTERNAL_FUNCTORS_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_INTERNAL_FUNCTORS_H
|
||||||
|
|
||||||
|
/* Definition of functors used internally for generalized maps.
|
||||||
|
*
|
||||||
|
* internal::Alpha_functor<Dart, i...> to call several beta on the given dart.
|
||||||
|
* Indices are given as parameter of the run function.
|
||||||
|
*
|
||||||
|
* internal::Alpha_functor_static<Dart, i...> to call several beta on the given
|
||||||
|
* dart. Indices are given as template arguments.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <CGAL/internal/Combinatorial_map_internal_functors.h>
|
||||||
|
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
// ****************************************************************************
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
// ****************************************************************************
|
||||||
|
// Alpha functor, used to combine several alpha.
|
||||||
|
#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
|
||||||
|
template<typename CMap, typename Dart_handle, typename ... Alphas>
|
||||||
|
struct Alpha_functor;
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle>
|
||||||
|
struct Alpha_functor<CMap, Dart_handle, int>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart, int B)
|
||||||
|
{ return AMap->get_alpha(ADart, B); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle>
|
||||||
|
struct Alpha_functor<CMap, Dart_handle, unsigned int>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart, unsigned int B)
|
||||||
|
{ return AMap->get_alpha(ADart, B); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle, typename ... Alphas>
|
||||||
|
struct Alpha_functor<CMap, Dart_handle, int, Alphas...>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart, int B, Alphas... alphas)
|
||||||
|
{ return Alpha_functor<CMap, Dart_handle, Alphas...>::
|
||||||
|
run(AMap, AMap->get_alpha(ADart, B), alphas...); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle, typename ... Alphas>
|
||||||
|
struct Alpha_functor<CMap, Dart_handle, unsigned int, Alphas...>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart, unsigned int B,
|
||||||
|
Alphas... alphas)
|
||||||
|
{ return Alpha_functor<CMap, Dart_handle, Alphas...>::
|
||||||
|
run(AMap, AMap->get_alpha(ADart, B), alphas...); }
|
||||||
|
};
|
||||||
|
// ****************************************************************************
|
||||||
|
template<typename CMap, typename Dart_handle, int ... Alphas>
|
||||||
|
struct Alpha_functor_static;
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle, int B>
|
||||||
|
struct Alpha_functor_static<CMap, Dart_handle, B>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart)
|
||||||
|
{ return AMap->template get_alpha<B>(ADart); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename CMap, typename Dart_handle, int B, int ... Alphas>
|
||||||
|
struct Alpha_functor_static<CMap, Dart_handle, B, Alphas...>
|
||||||
|
{
|
||||||
|
static Dart_handle run(CMap* AMap, Dart_handle ADart)
|
||||||
|
{ return Alpha_functor_static<CMap, Dart_handle, Alphas...>::
|
||||||
|
run(AMap, AMap->template get_alpha<B>(ADart)); }
|
||||||
|
};
|
||||||
|
#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
|
||||||
|
// ****************************************************************************
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_INTERNAL_FUNCTORS_H
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_SEWABLE_H
|
||||||
|
#define CGAL_GENERALIZED_MAP_SEWABLE_H
|
||||||
|
|
||||||
|
#include <CGAL/GMap_dart_const_iterators.h>
|
||||||
|
#include <CGAL/Unique_hash_map.h>
|
||||||
|
|
||||||
|
/* Definition of functor used to test if two darts are i-sewable
|
||||||
|
* (we use functors as there are different specializations).
|
||||||
|
* @todo Specializations ?
|
||||||
|
*/
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
// Generic case (and for the moment the only one).
|
||||||
|
template<typename CMap, unsigned int i, unsigned int dim=CMap::dimension>
|
||||||
|
struct GMap_is_sewable_functor
|
||||||
|
{
|
||||||
|
static bool run( const CMap* amap,
|
||||||
|
typename CMap::Dart_const_handle adart1,
|
||||||
|
typename CMap::Dart_const_handle adart2 )
|
||||||
|
{
|
||||||
|
CGAL_assertion( i<=CMap::dimension );
|
||||||
|
if ( !amap->template is_free<i>(adart1) ||
|
||||||
|
!amap->template is_free<i>(adart2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( adart1==adart2 )
|
||||||
|
{
|
||||||
|
if ( i==1 ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hash map to build the isomorphism between the two i-cells.
|
||||||
|
CGAL::Unique_hash_map<typename CMap::Dart_const_handle,
|
||||||
|
typename CMap::Dart_const_handle,
|
||||||
|
typename CMap::Hash_function> bijection;
|
||||||
|
|
||||||
|
int m1 = amap->get_new_mark();
|
||||||
|
int m2 = amap->get_new_mark();
|
||||||
|
CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i>
|
||||||
|
I1(*amap, adart1, m1);
|
||||||
|
CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i>
|
||||||
|
I2(*amap, adart2, m2);
|
||||||
|
bool res = true;
|
||||||
|
int mbijection = amap->get_new_mark();
|
||||||
|
|
||||||
|
while ( res && I1.cont() && I2.cont() )
|
||||||
|
{
|
||||||
|
amap->mark(I1, mbijection);
|
||||||
|
bijection[I1]=I2;
|
||||||
|
|
||||||
|
CGAL_assertion( amap->template is_free<i>(I1) );
|
||||||
|
CGAL_assertion( amap->template is_free<i>(I2) );
|
||||||
|
|
||||||
|
// We can remove this constraint which is not required for
|
||||||
|
// combinatorial map definition, but which is quite "normal"
|
||||||
|
// Indeed in this case we try to i-sew an i-cell with itself (case
|
||||||
|
// of folded cells).
|
||||||
|
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||||
|
|
||||||
|
for ( unsigned int j=0; res && j<=CMap::dimension; ++j )
|
||||||
|
{
|
||||||
|
if ( j+1!=i && j!=i && j!=i+1 )
|
||||||
|
{
|
||||||
|
if ( amap->is_free(I1,j) )
|
||||||
|
{
|
||||||
|
if ( !amap->is_free(I2,j) ) res=false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( amap->is_free(I2,j) ) res=false;
|
||||||
|
else if ( amap->is_marked(amap->alpha(I1,j), mbijection) )
|
||||||
|
{
|
||||||
|
if ( bijection[amap->alpha(I1,j)]!=amap->alpha(I2,j) ) res=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++I1; ++I2;
|
||||||
|
}
|
||||||
|
if ( I1.cont()!=I2.cont() )
|
||||||
|
res = false;
|
||||||
|
|
||||||
|
amap->negate_mark(m1);
|
||||||
|
amap->negate_mark(m2);
|
||||||
|
I1.rewind(); I2.rewind();
|
||||||
|
while ( amap->number_of_marked_darts(mbijection)>0 )
|
||||||
|
{
|
||||||
|
amap->unmark(I1, mbijection);
|
||||||
|
++I1; ++I2;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_assertion( amap->is_whole_map_marked(m1) );
|
||||||
|
CGAL_assertion( amap->is_whole_map_marked(m2) );
|
||||||
|
CGAL_assertion( amap->is_whole_map_unmarked(mbijection) );
|
||||||
|
amap->free_mark(m1);
|
||||||
|
amap->free_mark(m2);
|
||||||
|
amap->free_mark(mbijection);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace internal
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_COMBINATORIAL_MAP_SEWABLE_H
|
||||||
|
//******************************************************************************
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Generalized map in d-dimension
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
Implementation of generalized maps.
|
||||||
|
|
||||||
|
A generalized map is a mathematical model allowing to represent an
|
||||||
|
object in any dimension by describing the subdivision of the object in
|
||||||
|
vertices, edges, faces, volumes, ... and the incidence relationships
|
||||||
|
on them. Generalized maps allow to describe non orientable object,
|
||||||
|
contrary to combinatorial maps. However, their main interest is their
|
||||||
|
homogeneity in any dimension which simplify the algorithms.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Guillaume Damiand
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
# cd debug; cmake .. -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
# cd release; cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||||
|
|
||||||
|
project( Generalized_map_test )
|
||||||
|
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
|
||||||
|
if ( COMMAND cmake_policy )
|
||||||
|
cmake_policy( SET CMP0003 NEW )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
####################################################################################
|
||||||
|
OPTION(BUILD_TESTS "Build tests." ON)
|
||||||
|
|
||||||
|
if (BUILD_TESTS)
|
||||||
|
ENABLE_TESTING()
|
||||||
|
INCLUDE(CTest)
|
||||||
|
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage -frounding-math")
|
||||||
|
endif (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage -frounding-math")
|
||||||
|
endif (CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
endif (BUILD_TESTS)
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
find_package(CGAL QUIET COMPONENTS Core )
|
||||||
|
|
||||||
|
if ( NOT CGAL_FOUND )
|
||||||
|
message(FATAL_ERROR "This program requires the CGAL library, and will not be compiled.")
|
||||||
|
endif ( NOT CGAL_FOUND )
|
||||||
|
|
||||||
|
include( ${CGAL_USE_FILE} )
|
||||||
|
|
||||||
|
# Try to use gcov but does not work... TODO
|
||||||
|
#set(CMAKE_CXX_FLAGS "-g -frounding-math")
|
||||||
|
#set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS})
|
||||||
|
#add_definitions(-fprofile-arcs -ftest-coverage)
|
||||||
|
|
||||||
|
#include( CGAL_CreateSingleSourceCGALProgram )
|
||||||
|
include_directories(BEFORE ../../include)
|
||||||
|
add_executable(Generalized_map_test 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} )
|
||||||
|
|
||||||
|
if (BUILD_TESTS)
|
||||||
|
ADD_TEST(Generalized_map_test "./Generalized_map_test")
|
||||||
|
endif (BUILD_TESTS)
|
||||||
|
|
@ -0,0 +1,187 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GENERALIZED_MAP_2_TEST
|
||||||
|
#define CGAL_GENERALIZED_MAP_2_TEST 1
|
||||||
|
|
||||||
|
#include <CGAL/Generalized_map_constructors.h>
|
||||||
|
#include <CGAL/Generalized_map_operations.h>
|
||||||
|
|
||||||
|
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// #define GMAP_TRACE_TEST_BEGIN 1
|
||||||
|
|
||||||
|
void trace_test_begin()
|
||||||
|
{
|
||||||
|
#ifdef GMAP_TRACE_TEST_BEGIN
|
||||||
|
static unsigned int nbtest = 0;
|
||||||
|
|
||||||
|
std::cout<<"Test "<<nbtest++<<" ..."<<std::flush;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void trace_test_end()
|
||||||
|
{
|
||||||
|
#ifdef GMAP_TRACE_TEST_BEGIN
|
||||||
|
std::cout<<"Ok."<<std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void trace_display_msg(const char*
|
||||||
|
#ifdef GMAP_TRACE_TEST_BEGIN
|
||||||
|
msg
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef GMAP_TRACE_TEST_BEGIN
|
||||||
|
std::cout<<"***************** "<<msg<<"***************** "<<std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename GMAP>
|
||||||
|
bool check_number_of_cells_2(GMAP& gmap, unsigned int nbv, unsigned int nbe,
|
||||||
|
unsigned int nbf, unsigned int nbcc)
|
||||||
|
{
|
||||||
|
if ( !gmap.is_valid() )
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the gmap is not valid."<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned int> nbc;
|
||||||
|
nbc=gmap.count_all_cells();
|
||||||
|
|
||||||
|
if (nbv!=nbc[0] || nbe!=nbc[1] || nbf!=nbc[2] || nbcc!=nbc[3])
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the number of cells is not correct. We must have "
|
||||||
|
<<" ("<<nbv<<", "<<nbe<<", "<<nbf<<", "<<nbcc<<") and we have"
|
||||||
|
<<" ("<<nbc[0]<<", "<<nbc[1]<<", "<<nbc[2]<<", "<<nbc[3]<<")."
|
||||||
|
<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Gmap>
|
||||||
|
bool test_GMAP_2()
|
||||||
|
{
|
||||||
|
Gmap gmap;
|
||||||
|
|
||||||
|
typedef typename Gmap::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
// Construction operations
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh1=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh2=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh3=CGAL::make_edge(gmap);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 6, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<1>(dh1,dh2);
|
||||||
|
gmap.template sew<1>(gmap.alpha(dh2, 0),dh3);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 4, 3, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh5=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
Dart_handle dh6=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 10, 9, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<2>(dh5,dh6);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 8, 8, 3, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
dh5=gmap.template alpha<1>(dh5);
|
||||||
|
dh6=gmap.template alpha<1>(dh6);
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, gmap.template alpha<1>(dh5));
|
||||||
|
if ( !check_number_of_cells_2(gmap, 8, 7, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 2>(gmap, dh6);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 6, 5, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, gmap.template alpha<1>(dh5));
|
||||||
|
if ( !check_number_of_cells_2(gmap, 5, 4, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, dh5);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 4, 3, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, dh2);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 3, 2, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, dh1);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 2, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::contract_cell<Gmap, 1>(gmap, dh3);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 0, 0, 0, 0) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh7=CGAL::make_combinatorial_hexahedron(gmap); // f1
|
||||||
|
Dart_handle dh8=gmap.template alpha<2,1,0,1,2>(dh7); // f2 opposite to f1
|
||||||
|
Dart_handle dh9=gmap.template alpha<2>(dh7); // face incident to f1 and d2
|
||||||
|
|
||||||
|
CGAL::remove_cell<Gmap,2>(gmap, dh7);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 8, 12, 5, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<Gmap,2>(gmap, dh8);
|
||||||
|
if ( !check_number_of_cells_2(gmap, 8, 12, 4, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<2>();
|
||||||
|
if ( !check_number_of_cells_2(gmap, 8, 12, 6, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !CGAL::is_volume_combinatorial_hexahedron(gmap, dh9) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: the closed volume is not a combinatorial hexahedron.\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CGAL_GENERALIZED_MAP_2_TEST
|
||||||
|
|
@ -0,0 +1,165 @@
|
||||||
|
// Copyright (c) 2011 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_3_TEST_H
|
||||||
|
#define CGAL_GMAP_3_TEST_H
|
||||||
|
|
||||||
|
#include "Generalized_map_2_test.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if ( !gmap.is_valid() )
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the gmap is not valid."<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned int> nbc;
|
||||||
|
nbc=gmap.count_all_cells();
|
||||||
|
|
||||||
|
if (nbv!=nbc[0] || nbe!=nbc[1] || nbf!=nbc[2] || nbvol!=nbc[3] ||
|
||||||
|
nbcc!=nbc[4])
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the number of cells is not correct. We must have "
|
||||||
|
<<" ("<<nbv<<", "<<nbe<<", "<<nbf<<", "<<nbvol<<", "<<nbcc
|
||||||
|
<<") and we have"<<" ("<<nbc[0]<<", "<<nbc[1]<<", "<<nbc[2]<<", "
|
||||||
|
<<nbc[3]<<", "<<nbc[4]<<")."
|
||||||
|
<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename GMAP>
|
||||||
|
bool test_GMAP_3()
|
||||||
|
{
|
||||||
|
GMAP gmap;
|
||||||
|
|
||||||
|
typedef typename GMAP::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
// Construction operations
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh1=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh2=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh3=CGAL::make_edge(gmap);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 6, 3, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<1>(dh1,dh2);
|
||||||
|
gmap.template sew<1>(gmap.alpha(dh2,0),dh3);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 4, 3, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh5=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
Dart_handle dh6=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 10, 9, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<2>(dh5,dh6);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 8, 8, 3, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.clear();
|
||||||
|
Dart_handle dh7=CGAL::make_combinatorial_hexahedron(gmap); // f1
|
||||||
|
Dart_handle dh8=gmap.template alpha<2,1,0,1,2>(dh7); // f2 opposite to f1
|
||||||
|
Dart_handle dh9=gmap.template alpha<2>(dh7); // face incident to f1 and d2
|
||||||
|
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh7);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 8, 12, 5, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh8);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 8, 12, 4, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh10=CGAL::make_combinatorial_hexahedron(gmap);
|
||||||
|
gmap.template sew<3>(dh9,dh10);
|
||||||
|
if ( !check_number_of_cells_3(gmap, 12, 20, 9, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
GMAP gmap2(gmap);
|
||||||
|
if ( !check_number_of_cells_3(gmap2, 12, 20, 9, 2, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !gmap.is_isomorphic_to(gmap2) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: gmap and gmap2 are not isomorphic (after copy).\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<2>();
|
||||||
|
if ( !check_number_of_cells_3(gmap, 12, 20, 11, 2, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !CGAL::is_volume_combinatorial_hexahedron(gmap, dh9) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: the closed volume is not a combinatorial hexahedron.\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<3>();
|
||||||
|
if ( !check_number_of_cells_3(gmap, 12, 20, 11, 3, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,3>(gmap, gmap.alpha(dh9, 2, 3));
|
||||||
|
if ( !check_number_of_cells_3(gmap, 12, 20, 11, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, gmap.alpha(dh9, 2));
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, gmap.alpha(dh9, 1, 0, 1, 2));
|
||||||
|
if ( !check_number_of_cells_3(gmap, 12, 20, 9, 2, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !gmap.is_isomorphic_to(gmap2) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: gmap and gmap2 are not isomorphic (after close and removals).\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CGAL_GMAP_3_TEST_H
|
||||||
|
|
@ -0,0 +1,450 @@
|
||||||
|
// Copyright (c) 2014 CNRS and LIRIS' Establishments (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 3 of the License,
|
||||||
|
// or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||||
|
//
|
||||||
|
#ifndef CGAL_GMAP_4_TEST_H
|
||||||
|
#define CGAL_GMAP_4_TEST_H
|
||||||
|
|
||||||
|
#include <CGAL/Generalized_map_operations.h>
|
||||||
|
#include "Generalized_map_2_test.h"
|
||||||
|
|
||||||
|
template<typename GMAP>
|
||||||
|
bool check_number_of_cells_4(GMAP& gmap, unsigned int nbv, unsigned int nbe,
|
||||||
|
unsigned int nbf, unsigned int nbvol,
|
||||||
|
unsigned int nbhvol, unsigned int nbcc)
|
||||||
|
{
|
||||||
|
if ( !gmap.is_valid() )
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the gmap is not valid."<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned int> nbc;
|
||||||
|
nbc=gmap.count_all_cells();
|
||||||
|
|
||||||
|
if (nbv!=nbc[0] || nbe!=nbc[1] || nbf!=nbc[2] || nbvol!=nbc[3] ||
|
||||||
|
nbhvol!=nbc[4] || nbcc!=nbc[5])
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the number of cells is not correct. We must have "
|
||||||
|
<<" ("<<nbv<<", "<<nbe<<", "<<nbf<<", "<<nbvol<<", "<<nbhvol
|
||||||
|
<<", "<<nbcc<<") and we have"<<" ("<<nbc[0]<<", "<<nbc[1]<<", "
|
||||||
|
<<nbc[2]<<", "<<nbc[3]<<", "<<nbc[4]<<", "<<nbc[5]<<")."
|
||||||
|
<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename GMAP>
|
||||||
|
bool test_GMAP_4()
|
||||||
|
{
|
||||||
|
GMAP gmap;
|
||||||
|
|
||||||
|
typedef typename GMAP::Dart_handle Dart_handle;
|
||||||
|
|
||||||
|
// Construction operations
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh1=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh2=CGAL::make_edge(gmap);
|
||||||
|
Dart_handle dh3=CGAL::make_edge(gmap);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 6, 3, 3, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<1>(dh1,dh2);
|
||||||
|
gmap.template sew<1>(gmap.alpha(dh2,0),dh3);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 4, 3, 1, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh5=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
Dart_handle dh6=CGAL::make_combinatorial_polygon(gmap, 3);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 10, 9, 3, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<2>(dh5,dh6);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 8, 8, 3, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.clear();
|
||||||
|
Dart_handle dh7=CGAL::make_combinatorial_hexahedron(gmap); // f1
|
||||||
|
Dart_handle dh8=gmap.template alpha<2,1,0,1,2>(dh7); // f2 opposite to f1
|
||||||
|
Dart_handle dh9=gmap.template alpha<2>(dh7); // face incident to f1 and d2
|
||||||
|
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh7);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 8, 12, 5, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh8);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 8, 12, 4, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh10=CGAL::make_combinatorial_hexahedron(gmap);
|
||||||
|
gmap.template sew<3>(dh9,dh10);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 9, 2, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh11=CGAL::make_combinatorial_hexahedron(gmap);
|
||||||
|
gmap.template sew<4>(dh10,dh11);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 9, 2, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
GMAP gmap2(gmap);
|
||||||
|
if ( !check_number_of_cells_4(gmap2, 12, 20, 9, 2, 2, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !gmap.is_isomorphic_to(gmap2) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: gmap and gmap2 are not isomorphic (after copy).\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<2>();
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 11, 2, 2, 1) )
|
||||||
|
return false;
|
||||||
|
if ( !CGAL::is_volume_combinatorial_hexahedron(gmap, dh9) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: the closed volume is not a combinatorial hexahedron.\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<3>();
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 11, 4, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template close<4>();
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 11, 4, 3, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,4>(gmap, gmap.alpha(dh9, 2, 3, 4));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 11, 4, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,3>(gmap, gmap.alpha(dh9, 2, 3));
|
||||||
|
CGAL::remove_cell<GMAP,3>(gmap, gmap.alpha(dh10, 2, 4, 3));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 11, 2, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, gmap.alpha(dh9, 2));
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, gmap.alpha(dh9, 1, 0, 1, 2));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 20, 9, 2, 2, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !gmap.is_isomorphic_to(gmap2) )
|
||||||
|
{
|
||||||
|
std::cout<<"Error: gmap and gmap2 are not isomorphic (after close and removals).\n";
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* trace_test_begin();
|
||||||
|
Dart_handle dh7=gmap.template insert_barycenter_in_cell<1>(dh1);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 9, 9, 6, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh8=gmap.template insert_barycenter_in_cell<2>(dh5);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 10, 12, 8, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh9=gmap.template insert_point_in_cell<1>(dh2,apoint<GMAP>(1,0,3,0));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 11, 13, 8, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh10=gmap.template insert_point_in_cell<2>(dh6,apoint<GMAP>(6,5,3,0));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 16, 10, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh11=gmap.insert_dangling_cell_1_in_cell_2(dh8,apoint<GMAP>(6,5.2,3,0));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 13, 17, 10, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh12 = gmap.make_tetrahedron(apoint<GMAP>(-1, 0, 0,0),apoint<GMAP>(0, 2, 0,0),
|
||||||
|
apoint<GMAP>(1, 0, 0,0),apoint<GMAP>(1, 1, 2,0));
|
||||||
|
Dart_handle dh13 = gmap.make_tetrahedron(apoint<GMAP>(0, 2, -1,0),apoint<GMAP>(-1, 0, -1,0),
|
||||||
|
apoint<GMAP>(1, 0, -1,0),apoint<GMAP>(1, 1, -3,0));
|
||||||
|
if ( !check_number_of_cells_4(gmap, 21, 29, 18, 4, 4, 4) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<3>(dh12, dh13);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 18, 26, 17, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh14=gmap.template insert_barycenter_in_cell<2>(dh12);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 19, 29, 19, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh15=gmap.template insert_barycenter_in_cell<1>(dh14);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 20, 30, 19, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template sew<4>(dh12, dh13);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 19, 27, 16, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh16=gmap.template insert_barycenter_in_cell<1>(dh15);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 20, 28, 16, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
Dart_handle dh17=gmap.template insert_barycenter_in_cell<2>(dh16);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 21, 33, 20, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Removal operations
|
||||||
|
trace_test_begin();
|
||||||
|
std::stack<Dart_handle> toremove;
|
||||||
|
for ( typename GMAP::template Dart_of_cell_range<0,2>::iterator
|
||||||
|
it=gmap.template darts_of_cell<0,2>(dh17).begin(),
|
||||||
|
itend=gmap.template darts_of_cell<0,2>(dh17).end();
|
||||||
|
it!=itend; ++it )
|
||||||
|
toremove.push( it );
|
||||||
|
while ( !toremove.empty() )
|
||||||
|
{
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, toremove.top());
|
||||||
|
toremove.pop();
|
||||||
|
}
|
||||||
|
if ( !check_number_of_cells_4(gmap, 20, 28, 16, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,0>(gmap, dh16);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 19, 27, 16, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template unsew<4>(dh12);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 20, 30, 19, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,0>(gmap, dh15);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 19, 29, 19, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, gmap.beta(dh14,2,1));
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, gmap.beta(dh14,0));
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, dh14);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 18, 26, 17, 4, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template unsew<3>(dh12);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 21, 29, 18, 4, 4, 4) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,3>(gmap, dh13);
|
||||||
|
CGAL::remove_cell<GMAP,3>(gmap, dh12);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 13, 17, 10, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, dh11);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 12, 16, 10, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
for ( typename GMAP::template Dart_of_cell_range<0,2>::iterator
|
||||||
|
it=gmap.template darts_of_cell<0,2>(dh10).begin(),
|
||||||
|
itend=gmap.template darts_of_cell<0,2>(dh10).end();
|
||||||
|
it!=itend; ++it )
|
||||||
|
toremove.push( it );
|
||||||
|
while ( !toremove.empty() )
|
||||||
|
{
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, toremove.top());
|
||||||
|
toremove.pop();
|
||||||
|
}
|
||||||
|
if ( !check_number_of_cells_4(gmap, 11, 13, 8, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,0>(gmap, dh9);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 10, 12, 8, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
for ( typename GMAP::template Dart_of_cell_range<0,2>::iterator
|
||||||
|
it=gmap.template darts_of_cell<0,2>(dh8).begin(),
|
||||||
|
itend=gmap.template darts_of_cell<0,2>(dh8).end();
|
||||||
|
it!=itend; ++it )
|
||||||
|
toremove.push( it );
|
||||||
|
while ( !toremove.empty() )
|
||||||
|
{
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, toremove.top());
|
||||||
|
toremove.pop();
|
||||||
|
}
|
||||||
|
if ( !check_number_of_cells_4(gmap, 9, 9, 6, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,0>(gmap, dh7);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 8, 8, 6, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template unsew<2>(dh5);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 10, 9, 6, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh6);
|
||||||
|
CGAL::remove_cell<GMAP,2>(gmap, dh5);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 4, 3, 4, 1, 1, 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template unsew<1>(dh2);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 5, 3, 5, 2, 2, 2) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.template unsew<0>(dh2);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 6, 3, 6, 3, 3, 3) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, dh1);
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, dh2);
|
||||||
|
CGAL::remove_cell<GMAP,1>(gmap, dh3);
|
||||||
|
if ( !check_number_of_cells_4(gmap, 0, 0, 0, 0, 0, 0) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
dh1 = gmap.make_tetrahedron(apoint<GMAP>(-1, 0, 0,0),apoint<GMAP>(0, 2, 0,0),
|
||||||
|
apoint<GMAP>(1, 0, 0,0),apoint<GMAP>(1, 1, 2,0));
|
||||||
|
dh2 = gmap.make_tetrahedron(apoint<GMAP>(0, 2, -1,0),apoint<GMAP>(-1, 0, -1,0),
|
||||||
|
apoint<GMAP>(1, 0, -1,0),apoint<GMAP>(1, 1, -3,0));
|
||||||
|
|
||||||
|
if ( !gmap.template is_sewable<4>(dh1, dh2) )
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the two 3-cells are not sewable."<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
dh3 = gmap.beta(dh1,2);
|
||||||
|
dh5 = gmap.template beta<1, 2>(dh1);
|
||||||
|
|
||||||
|
gmap.template unsew<2>(dh3);
|
||||||
|
gmap.template unsew<2>(dh5);
|
||||||
|
gmap.template sew<2>(dh1, dh5);
|
||||||
|
gmap.template sew<2>(gmap.beta(dh1,1), dh3);
|
||||||
|
|
||||||
|
if ( gmap.template is_sewable<4>(dh1, dh2) )
|
||||||
|
{
|
||||||
|
std::cout<<"ERROR: the two 3-cells are sewable."<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.clear();
|
||||||
|
dh1 = gmap.make_tetrahedron(apoint<GMAP>(-1, 0, 0,0),apoint<GMAP>(0, 2, 0,0),
|
||||||
|
apoint<GMAP>(1, 0, 0,0),apoint<GMAP>(1, 1, 2,0));
|
||||||
|
dh2 = gmap.make_tetrahedron(apoint<GMAP>(0, 2, -1,0),apoint<GMAP>(-1, 0, -1,0),
|
||||||
|
apoint<GMAP>(1, 0, -1,0),apoint<GMAP>(1, 1, -3,0));
|
||||||
|
dh3 = gmap.make_tetrahedron(apoint<GMAP>(0, 2, -4,0),apoint<GMAP>(-1, 0, -4,0),
|
||||||
|
apoint<GMAP>(1, 0, -4,0),apoint<GMAP>(1, 1, -5,0));
|
||||||
|
gmap.template sew<3>(dh1, dh2);
|
||||||
|
gmap.template sew<4>(dh1, dh3);
|
||||||
|
|
||||||
|
GMAP gmap2(gmap);
|
||||||
|
if ( !gmap.is_valid() ) { assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.reverse_orientation();
|
||||||
|
if ( !gmap.is_valid() ) { assert(false); return false; }
|
||||||
|
if ( gmap2.is_isomorphic_to(gmap) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap, false) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.reverse_orientation();
|
||||||
|
if ( !gmap.is_valid() ) { assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap, false) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.reverse_orientation_connected_component(dh1);
|
||||||
|
if ( !gmap.is_valid() ) { assert(false); return false; }
|
||||||
|
if ( gmap2.is_isomorphic_to(gmap) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap, false) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
trace_test_begin();
|
||||||
|
gmap.reverse_orientation_connected_component(dh1);
|
||||||
|
if ( !gmap.is_valid() ) { assert(false); return false; }
|
||||||
|
if ( !gmap2.is_isomorphic_to(gmap) )
|
||||||
|
{ assert(false); return false; }
|
||||||
|
trace_test_end();
|
||||||
|
|
||||||
|
// import_from_polyhedron<GMAP>(gmap,ap);
|
||||||
|
|
||||||
|
gmap.clear();
|
||||||
|
|
||||||
|
// import_from_plane_graph<GMAP>(gmap,ais);
|
||||||
|
*/
|
||||||
|
gmap.clear();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CGAL_GMAP_4_TEST_H
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
#include <CGAL/Generalized_map.h>
|
||||||
|
#include <CGAL/Cell_attribute.h>
|
||||||
|
|
||||||
|
#include "Generalized_map_2_test.h"
|
||||||
|
#include "Generalized_map_3_test.h"
|
||||||
|
#include "Generalized_map_4_test.h"
|
||||||
|
|
||||||
|
struct Sum_functor
|
||||||
|
{
|
||||||
|
template<class Cell_attribute>
|
||||||
|
void operator()(Cell_attribute& ca1,Cell_attribute& ca2)
|
||||||
|
{ ca1.info()=ca1.info()+ca2.info(); }
|
||||||
|
};
|
||||||
|
struct Divide_by_two_functor
|
||||||
|
{
|
||||||
|
template<class Cell_attribute>
|
||||||
|
void operator()(Cell_attribute& ca1,Cell_attribute& ca2)
|
||||||
|
{
|
||||||
|
ca1.info()=(ca1.info()/2);
|
||||||
|
ca2.info()=(ca1.info());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitems_2
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<2, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_true,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitems_2c
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<2, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_false,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
struct Myitems_3
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<3, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_true,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitems_3c
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<3, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_false,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitems_4
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<4, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_true,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib,myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Myitems_4c
|
||||||
|
{
|
||||||
|
template <class GMAP>
|
||||||
|
struct Dart_wrapper
|
||||||
|
{
|
||||||
|
typedef CGAL::GMap_dart<4, GMAP> Dart;
|
||||||
|
|
||||||
|
typedef CGAL::Cell_attribute<GMAP,int,CGAL::Tag_false,Sum_functor,
|
||||||
|
Divide_by_two_functor> myattrib;
|
||||||
|
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib,myattrib>
|
||||||
|
Attributes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout<<"Generalized_map start test (v1)."<<std::flush;
|
||||||
|
|
||||||
|
trace_display_msg("\ntest_GMAP_2<GMAP2>");
|
||||||
|
typedef CGAL::Generalized_map<2> GMAP2;
|
||||||
|
if ( !test_GMAP_2<GMAP2>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_2<GMAP2>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_3<GMAP3>");
|
||||||
|
typedef CGAL::Generalized_map<3> GMAP3;
|
||||||
|
if ( !test_GMAP_3<GMAP3>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_3<GMAP3>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_4<GMAP4>");
|
||||||
|
typedef CGAL::Generalized_map<4> GMAP4;
|
||||||
|
if ( !test_GMAP_4<GMAP4>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_4<GMAP4>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_2<GMAP2b>");
|
||||||
|
typedef CGAL::Generalized_map<2,Myitems_2> GMAP2b;
|
||||||
|
if ( !test_GMAP_2<GMAP2b>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_2<GMAP2b>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_2<GMAP2c>");
|
||||||
|
typedef CGAL::Generalized_map<2,Myitems_2c> GMAP2c;
|
||||||
|
if ( !test_GMAP_2<GMAP2c>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_2<GMAP2c>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_3<GMAP3b>");
|
||||||
|
typedef CGAL::Generalized_map<3,Myitems_3> GMAP3b;
|
||||||
|
if ( !test_GMAP_3<GMAP3b>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_3<GMAP3b>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_3<GMAP3c>");
|
||||||
|
typedef CGAL::Generalized_map<3,Myitems_3c> GMAP3c;
|
||||||
|
if ( !test_GMAP_3<GMAP3c>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_3<GMAP3c>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_4<GMAP4b>");
|
||||||
|
typedef CGAL::Generalized_map<4,Myitems_4> GMAP4b;
|
||||||
|
if ( !test_GMAP_4<GMAP4b>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_4<GMAP4b>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_display_msg("test_GMAP_4<GMAP4c>");
|
||||||
|
typedef CGAL::Generalized_map<4,Myitems_4c> GMAP4c;
|
||||||
|
if ( !test_GMAP_4<GMAP4c>() )
|
||||||
|
{
|
||||||
|
std::cout<<" Error during Test_GMAP_4<GMAP4c>."<<std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<" Success."<<std::endl;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,317 @@
|
||||||
|
OFF
|
||||||
|
154 161 313
|
||||||
|
-0.000357203 -0.235365 -0.160125
|
||||||
|
-0.000357203 -0.201317 -0.488359
|
||||||
|
-0.000357203 -0.292821 0.0217439
|
||||||
|
0.190729 -0.13758 0.378379
|
||||||
|
0.13019 -0.267236 0.298845
|
||||||
|
0.190729 0.0100846 0.378379
|
||||||
|
0.0215368 0.217461 -0.51172
|
||||||
|
0.0299628 0.207248 -0.0999594
|
||||||
|
0.0292682 0.222545 -0.275104
|
||||||
|
0.0768803 0.121009 -0.13791
|
||||||
|
0.0359848 0.17055 -0.040928
|
||||||
|
0.0299468 -0.152925 -0.34216
|
||||||
|
0.025316 0.0079986 -0.671613
|
||||||
|
0.112137 0.0486489 -0.334468
|
||||||
|
0.17708 0.0141305 -0.001149
|
||||||
|
0.11094 0.149864 0.298845
|
||||||
|
0.0221919 -0.110187 -0.590456
|
||||||
|
0.0936803 -0.22453 0.026899
|
||||||
|
0.113404 -0.0498528 -0.316654
|
||||||
|
0.0652844 0.112329 -0.345801
|
||||||
|
0.17708 -0.120885 0.017739
|
||||||
|
0.0936803 0.144433 -0.0331753
|
||||||
|
-0.000357203 -0.335018 0.298845
|
||||||
|
-0.000357203 0.158995 -0.742002
|
||||||
|
-0.000357203 0.00799863 -0.742002
|
||||||
|
-0.000357203 0.231668 -0.508839
|
||||||
|
-0.000357203 -0.150077 -0.732558
|
||||||
|
-0.000357203 0.183546 0.298845
|
||||||
|
-0.000357203 0.232012 -0.275104
|
||||||
|
0.190729 0.0489168 0.495135
|
||||||
|
0.11094 0.149864 0.495135
|
||||||
|
0.13019 -0.267236 0.495135
|
||||||
|
0.190729 -0.0987481 0.495135
|
||||||
|
0.165251 0.0336246 0.567519
|
||||||
|
0.0961008 0.121112 0.567519
|
||||||
|
-0.000357203 0.150303 0.567519
|
||||||
|
-0.000357203 -0.299119 0.567519
|
||||||
|
0.112784 -0.240374 0.567519
|
||||||
|
0.165251 -0.0943517 0.567519
|
||||||
|
0.158169 0.0203713 0.567519
|
||||||
|
0.0832397 0.0961934 0.567519
|
||||||
|
-0.000357203 0.121493 0.567519
|
||||||
|
-0.000357203 -0.268007 0.567519
|
||||||
|
0.0976983 -0.217095 0.567519
|
||||||
|
0.158169 -0.0905415 0.567519
|
||||||
|
0.158169 0.0203713 0.484629
|
||||||
|
0.0832397 0.0961934 0.484629
|
||||||
|
-0.000357203 0.121493 0.484629
|
||||||
|
0.0976983 -0.217095 0.484629
|
||||||
|
0.158169 -0.0905415 0.484629
|
||||||
|
0.232021 -0.0969884 0.147736
|
||||||
|
0.222564 -0.0120031 0.135774
|
||||||
|
0.241484 -0.0124758 0.32577
|
||||||
|
0.251828 -0.105423 0.32577
|
||||||
|
0.221675 -0.0537317 -0.14475
|
||||||
|
0.547234 0.011391 0.135774
|
||||||
|
0.566079 0.0115894 0.32577
|
||||||
|
0.573698 -0.0568671 0.32577
|
||||||
|
0.545139 -0.0195028 -0.0723815
|
||||||
|
0.5542 -0.0512014 0.147736
|
||||||
|
0.873235 0.0322361 0.18891
|
||||||
|
0.883911 0.0323485 0.29654
|
||||||
|
0.888226 -0.00643099 0.29654
|
||||||
|
0.872049 0.0147353 0.0957062
|
||||||
|
0.877181 -0.00322145 0.195687
|
||||||
|
0.956323 0.0235341 0.192298
|
||||||
|
0.963222 0.0286616 0.264585
|
||||||
|
0.143323 0.0162689 -0.433251
|
||||||
|
0.0684487 0.00718598 -0.642478
|
||||||
|
0.142247 0.0417387 -0.448393
|
||||||
|
0.379652 0.0694599 -0.566806
|
||||||
|
0.37455 0.0944136 -0.566806
|
||||||
|
0.405166 0.0746761 -0.587722
|
||||||
|
0.343995 0.0918102 -0.908647
|
||||||
|
0.400064 0.0996298 -0.587722
|
||||||
|
0.420699 -0.131311 -0.566806
|
||||||
|
0.39516 -0.100331 -0.908647
|
||||||
|
0.446883 -0.129375 -0.587722
|
||||||
|
0.3308 0.214471 -0.908647
|
||||||
|
0.344344 0.242162 -0.566806
|
||||||
|
0.369364 0.249793 -0.587722
|
||||||
|
0.349639 0.09078 -0.834104
|
||||||
|
-0.0943947 0.144433 -0.0331752
|
||||||
|
-0.177794 0.0141305 -0.001149
|
||||||
|
-0.112851 0.0486489 -0.334468
|
||||||
|
-0.0659988 0.112329 -0.345801
|
||||||
|
-0.0775947 0.121009 -0.13791
|
||||||
|
-0.0260305 0.0079986 -0.671613
|
||||||
|
-0.0222512 0.217461 -0.51172
|
||||||
|
-0.0943947 -0.22453 0.026899
|
||||||
|
-0.130905 -0.267236 0.298845
|
||||||
|
-0.000357203 0.173965 -0.0160962
|
||||||
|
-0.111655 0.149864 0.298845
|
||||||
|
-0.0366992 0.17055 -0.040928
|
||||||
|
-0.0306611 -0.152925 -0.34216
|
||||||
|
-0.114118 -0.0498528 -0.316654
|
||||||
|
-0.177794 -0.120885 0.0177391
|
||||||
|
-0.0299827 0.222544 -0.275104
|
||||||
|
-0.0229063 -0.110187 -0.590456
|
||||||
|
-0.0306772 0.207248 -0.0999594
|
||||||
|
-0.000357203 0.216146 -0.0919062
|
||||||
|
-0.191443 0.0100846 0.378379
|
||||||
|
-0.191443 -0.13758 0.378379
|
||||||
|
-0.87395 0.0322361 0.18891
|
||||||
|
-0.957037 0.0235341 0.192298
|
||||||
|
-0.884625 0.0323485 0.29654
|
||||||
|
-0.963936 0.0286615 0.264585
|
||||||
|
-0.346372 0.0918103 -0.905359
|
||||||
|
-0.40588 0.0746761 -0.587722
|
||||||
|
-0.400779 0.0996299 -0.602235
|
||||||
|
-0.222389 -0.0537316 -0.14475
|
||||||
|
-0.111655 0.149864 0.495135
|
||||||
|
-0.191443 0.0489168 0.495135
|
||||||
|
-0.000357203 0.183546 0.495135
|
||||||
|
-0.130905 -0.267236 0.495135
|
||||||
|
-0.000357203 -0.335018 0.495135
|
||||||
|
-0.191443 -0.0987481 0.495135
|
||||||
|
-0.0968152 0.121112 0.567519
|
||||||
|
-0.165965 0.0336246 0.567519
|
||||||
|
-0.113498 -0.240374 0.567519
|
||||||
|
-0.165965 -0.0943517 0.567519
|
||||||
|
-0.0839541 0.0961934 0.567519
|
||||||
|
-0.143884 0.0203713 0.567519
|
||||||
|
-0.0984127 -0.217095 0.567519
|
||||||
|
-0.143884 -0.0905415 0.567519
|
||||||
|
-0.0839541 0.0961934 0.484629
|
||||||
|
-0.143884 0.0203713 0.484629
|
||||||
|
-0.0984127 -0.217095 0.484629
|
||||||
|
-0.000357203 -0.268007 0.484629
|
||||||
|
-0.143884 -0.0905415 0.484629
|
||||||
|
-0.223278 -0.0120031 0.135774
|
||||||
|
-0.242198 -0.0124758 0.32577
|
||||||
|
-0.252542 -0.105423 0.32577
|
||||||
|
-0.232736 -0.0969883 0.147736
|
||||||
|
-0.872763 0.0147353 0.0957062
|
||||||
|
-0.566794 0.0115894 0.32577
|
||||||
|
-0.547948 0.011391 0.135774
|
||||||
|
-0.574412 -0.0568671 0.32577
|
||||||
|
-0.554914 -0.0512014 0.147736
|
||||||
|
-0.545854 -0.0195028 -0.0723815
|
||||||
|
-0.888941 -0.00643099 0.29654
|
||||||
|
-0.877895 -0.00322148 0.195687
|
||||||
|
-0.069163 0.00718598 -0.642478
|
||||||
|
-0.144038 0.0162689 -0.433251
|
||||||
|
-0.142961 0.0417387 -0.448393
|
||||||
|
-0.375265 0.0944137 -0.58132
|
||||||
|
-0.350353 0.0907801 -0.834105
|
||||||
|
-0.380366 0.0694599 -0.566806
|
||||||
|
-0.421413 -0.131311 -0.658428
|
||||||
|
-0.397537 -0.100331 -0.882239
|
||||||
|
-0.447598 -0.129375 -0.691307
|
||||||
|
-0.333177 0.214471 -0.877766
|
||||||
|
-0.345058 0.242162 -0.663246
|
||||||
|
-0.370078 0.249793 -0.695961
|
||||||
|
5 14 13 19 9 21
|
||||||
|
3 24 6 19
|
||||||
|
4 2 17 4 22
|
||||||
|
5 27 15 21 10 91
|
||||||
|
4 18 20 17 11
|
||||||
|
4 18 11 24 12
|
||||||
|
3 6 24 23
|
||||||
|
4 28 8 6 25
|
||||||
|
3 25 6 23
|
||||||
|
3 16 1 26
|
||||||
|
4 17 2 0 11
|
||||||
|
4 11 0 1 16
|
||||||
|
3 10 21 9
|
||||||
|
3 8 19 6
|
||||||
|
4 7 100 91 10
|
||||||
|
3 7 10 9
|
||||||
|
4 21 15 5 14
|
||||||
|
4 20 3 4 17
|
||||||
|
4 60 61 66 65
|
||||||
|
3 73 74 72
|
||||||
|
5 14 54 20 18 13
|
||||||
|
4 15 30 29 5
|
||||||
|
4 27 113 30 15
|
||||||
|
4 4 31 115 22
|
||||||
|
4 3 32 31 4
|
||||||
|
4 5 29 32 3
|
||||||
|
4 30 34 33 29
|
||||||
|
4 113 35 34 30
|
||||||
|
4 31 37 36 115
|
||||||
|
4 32 38 37 31
|
||||||
|
4 29 33 38 32
|
||||||
|
4 34 40 39 33
|
||||||
|
4 35 41 40 34
|
||||||
|
4 37 43 42 36
|
||||||
|
4 38 44 43 37
|
||||||
|
4 33 39 44 38
|
||||||
|
4 40 46 45 39
|
||||||
|
4 41 47 46 40
|
||||||
|
4 43 48 128 42
|
||||||
|
4 44 49 48 43
|
||||||
|
4 39 45 49 44
|
||||||
|
4 7 8 28 100
|
||||||
|
4 7 9 19 8
|
||||||
|
3 14 51 54
|
||||||
|
4 5 52 51 14
|
||||||
|
4 3 53 52 5
|
||||||
|
4 20 50 53 3
|
||||||
|
3 50 20 54
|
||||||
|
3 60 65 63
|
||||||
|
4 52 56 55 51
|
||||||
|
4 53 57 56 52
|
||||||
|
4 50 59 57 53
|
||||||
|
4 51 55 58 54
|
||||||
|
4 54 58 59 50
|
||||||
|
4 56 61 60 55
|
||||||
|
4 57 62 61 56
|
||||||
|
4 59 64 62 57
|
||||||
|
4 55 60 63 58
|
||||||
|
4 58 63 64 59
|
||||||
|
4 66 62 64 65
|
||||||
|
3 65 64 63
|
||||||
|
3 66 61 62
|
||||||
|
4 12 68 67 18
|
||||||
|
4 13 69 68 12
|
||||||
|
4 18 67 69 13
|
||||||
|
4 69 71 81 68
|
||||||
|
4 67 70 71 69
|
||||||
|
3 76 77 75
|
||||||
|
3 79 80 78
|
||||||
|
4 70 72 74 71
|
||||||
|
5 73 76 75 70 81
|
||||||
|
4 72 77 76 73
|
||||||
|
4 70 75 77 72
|
||||||
|
5 71 79 78 73 81
|
||||||
|
4 74 80 79 71
|
||||||
|
4 73 78 80 74
|
||||||
|
4 81 70 67 68
|
||||||
|
5 86 85 84 83 82
|
||||||
|
4 24 87 84 85
|
||||||
|
4 90 89 2 22
|
||||||
|
5 93 82 92 27 91
|
||||||
|
4 89 96 95 94
|
||||||
|
3 94 95 87
|
||||||
|
4 88 97 28 25
|
||||||
|
3 88 25 23
|
||||||
|
3 1 98 26
|
||||||
|
4 0 2 89 94
|
||||||
|
4 1 0 94 98
|
||||||
|
4 24 98 94 87
|
||||||
|
3 82 93 86
|
||||||
|
3 85 97 88
|
||||||
|
4 91 100 99 93
|
||||||
|
3 93 99 86
|
||||||
|
4 101 92 82 83
|
||||||
|
4 90 102 96 89
|
||||||
|
4 106 105 103 104
|
||||||
|
3 26 98 24
|
||||||
|
3 109 107 108
|
||||||
|
5 95 96 110 83 84
|
||||||
|
4 112 111 92 101
|
||||||
|
4 111 113 27 92
|
||||||
|
4 115 114 90 22
|
||||||
|
4 114 116 102 90
|
||||||
|
4 116 112 101 102
|
||||||
|
4 118 117 111 112
|
||||||
|
4 117 35 113 111
|
||||||
|
4 36 119 114 115
|
||||||
|
4 119 120 116 114
|
||||||
|
4 120 118 112 116
|
||||||
|
4 122 121 117 118
|
||||||
|
4 121 41 35 117
|
||||||
|
4 42 123 119 36
|
||||||
|
4 123 124 120 119
|
||||||
|
4 124 122 118 120
|
||||||
|
4 126 125 121 122
|
||||||
|
4 125 47 41 121
|
||||||
|
4 128 127 123 42
|
||||||
|
4 127 129 124 123
|
||||||
|
4 129 126 122 124
|
||||||
|
4 28 97 99 100
|
||||||
|
4 85 86 99 97
|
||||||
|
3 130 83 110
|
||||||
|
4 130 131 101 83
|
||||||
|
4 131 132 102 101
|
||||||
|
4 132 133 96 102
|
||||||
|
3 96 133 110
|
||||||
|
3 104 103 134
|
||||||
|
4 136 135 131 130
|
||||||
|
4 135 137 132 131
|
||||||
|
4 137 138 133 132
|
||||||
|
4 139 136 130 110
|
||||||
|
4 138 139 110 133
|
||||||
|
4 103 105 135 136
|
||||||
|
4 105 140 137 135
|
||||||
|
4 140 141 138 137
|
||||||
|
4 134 103 136 139
|
||||||
|
4 141 134 139 138
|
||||||
|
4 141 140 106 104
|
||||||
|
3 141 104 134
|
||||||
|
3 105 106 140
|
||||||
|
4 143 142 87 95
|
||||||
|
4 142 144 84 87
|
||||||
|
4 144 143 95 84
|
||||||
|
4 146 145 144 142
|
||||||
|
4 145 147 143 144
|
||||||
|
3 150 149 148
|
||||||
|
3 153 152 151
|
||||||
|
4 109 108 147 145
|
||||||
|
5 147 148 149 107 146
|
||||||
|
4 149 150 108 107
|
||||||
|
4 150 148 147 108
|
||||||
|
5 107 151 152 145 146
|
||||||
|
4 152 153 109 145
|
||||||
|
4 153 151 107 109
|
||||||
|
4 143 147 146 142
|
||||||
|
10 128 48 49 45 46 47 125 126 129 127
|
||||||
|
3 88 23 24
|
||||||
|
4 19 13 12 24
|
||||||
|
3 16 26 24
|
||||||
|
3 11 16 24
|
||||||
|
3 85 88 24
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,6 @@
|
||||||
|
0 0 0
|
||||||
|
1 0 0
|
||||||
|
0 1 0
|
||||||
|
0 0 1
|
||||||
|
2 2 2
|
||||||
|
-1 0 1
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
0 0 0
|
||||||
|
1 0 0
|
||||||
|
0 1 0
|
||||||
|
0 0 1
|
||||||
|
2 2 2
|
||||||
Loading…
Reference in New Issue