Revert of linear_cell_complex_3 example to use foreach which is now ok. Copyright. Add tests.

This commit is contained in:
Guillaume Damiand 2011-11-21 13:11:43 +00:00
parent c19dae7287
commit cb3c66dd90
13 changed files with 135 additions and 59 deletions

View File

@ -34,8 +34,9 @@ model of \ccc{CellAttributeWithPoint}.
There are four default template arguments:
\ccc{d2} is equal to \ccc{d},
\ccc{Traits_} is equal to \ccc{CGAL::Linear_cell_complex_traits<d2,CGAL::Exact_predicates_inexact_constructions_kernel>} if
\ccc{d2} is 2 or 3, and is \ccc{CGAL::Linear_cell_complex_traits<d2,CGAL::Cartesian_d<double>>} otherwise,
\ccc{Traits_} is equal to \ccc{CGAL::Linear_cell_complex_traits<d2>},
%\ccc{Traits_} is equal to \ccc{CGAL::Linear_cell_complex_traits<d2,CGAL::Exact_predicates_inexact_constructions_kernel>} if
%\ccc{d2} is 2 or 3, and is \ccc{CGAL::Linear_cell_complex_traits<d2,CGAL::Cartesian_d<double>>} otherwise,
\ccc{Items_} is equal to \ccc{CGAL::Linear_cell_complex_min_items<d>} and
\ccc{Alloc_} is \ccc{CGAL_ALLOCATOR(int)}.
@ -46,9 +47,9 @@ There are four default template arguments:
to inherit from any model of the \ccc{CombinatorialMap} concept.
\end{ccAdvanced}
Note that the default argument used for \ccc{Traits_} when
\emph{d2}\mygt{}3 does not use exact predicates because operations that
use predicates are only defined in 2D and 3D.
% Note that the default argument used for \ccc{Traits_} when
% \emph{d2}\mygt{}3 does not use exact predicates because operations that
% use predicates are only defined in 2D and 3D.
% +-----------------------------------+
\ccCreation

View File

@ -30,6 +30,15 @@ types and functors corresponding to the given dimension.
\ccc{K} a model of the concept \ccc{Kernel} if \ccc{d==2} or
\ccc{d==3}; a model of the concept \ccc{Kernel_d} otherwise.
There is a default template arguments for \ccc{K} which is
\ccc{CGAL::Exact_predicates_inexact_constructions_kernel}
if \ccc{d} is 2 or 3, and is \ccc{CGAL::Cartesian_d<double>}
otherwise.
Note that the default argument used for \ccc{K} when
\emph{d}\mygt{}3 does not use exact predicates because operations that
use predicates are only defined in 2D and 3D.
\ccConstants
\ccVariable{static unsigned int ambient_dimension = d;}{}

View File

@ -8,21 +8,33 @@ typedef LCC_3::Dart_handle Dart_handle;
typedef LCC_3::Point Point;
typedef LCC_3::FT FT;
// Function used to display all the vertices of a given volume
// Functor used to display all the vertices of a given volume.
template<class LCC>
void display_vol_vertices(const LCC& alcc, typename LCC::Dart_handle d)
struct Display_vol_vertices : public std::unary_function<LCC, void>
{
for (typename LCC::template One_dart_per_incident_cell_range<0,3>::
const_iterator it=alcc.template one_dart_per_incident_cell<0,3>
(d).begin(),
itend=alcc.template one_dart_per_incident_cell<0,3>
(d).end();
it!=itend; ++it)
{
std::cout << LCC_3::point(it) << "; ";
Display_vol_vertices(const LCC& alcc) :
lcc(alcc),
nb_volume(0)
{}
void operator() (typename LCC::Dart& d)
{
std::cout<<"Volume "<<++nb_volume<<" : ";
for (typename LCC::template One_dart_per_incident_cell_range<0,3>::
const_iterator it=lcc.template one_dart_per_incident_cell<0,3>
(lcc.dart_handle(d)).begin(),
itend=lcc.template one_dart_per_incident_cell<0,3>
(lcc.dart_handle(d)).end();
it!=itend; ++it)
{
std::cout << LCC_3::point(it) << "; ";
}
std::cout<<std::endl;
}
std::cout<<std::endl;
}
private:
const LCC& lcc;
unsigned int nb_volume;
};
int main()
{
@ -48,29 +60,17 @@ int main()
std::cout<<std::endl;
// Display the vertices of each volume by iterating on darts.
unsigned int nb_volume=0;
for( LCC_3::One_dart_per_cell_range<3>::iterator
it=lcc.one_dart_per_cell<3>().begin(),
itend=lcc.one_dart_per_cell<3>().end();
it!=itend; ++it )
{
std::cout<<"Volume "<<++nb_volume<<" : ";
display_vol_vertices(lcc, it);
}
std::for_each(lcc.one_dart_per_cell<3>().begin(),
lcc.one_dart_per_cell<3>().end(),
Display_vol_vertices<LCC_3>(lcc));
// 3-Sew the 2 tetrahedra along one facet
lcc.sew<3>(d1, d2);
// Display the vertices of each volume by iterating on darts.
nb_volume=0;
for( LCC_3::One_dart_per_cell_range<3>::iterator
it=lcc.one_dart_per_cell<3>().begin(),
itend=lcc.one_dart_per_cell<3>().end();
it!=itend; ++it )
{
std::cout<<"Volume "<<++nb_volume<<" : ";
display_vol_vertices(lcc, it);
}
std::for_each(lcc.one_dart_per_cell<3>().begin(),
lcc.one_dart_per_cell<3>().end(),
Display_vol_vertices<LCC_3>(lcc));
// Translate the second tetrahedra by a given vector
LCC_3::Vector v(3,1,1);
@ -84,15 +84,9 @@ int main()
}
// Display the vertices of each volume by iterating on darts.
nb_volume=0;
for( LCC_3::One_dart_per_cell_range<3>::iterator
it=lcc.one_dart_per_cell<3>().begin(),
itend=lcc.one_dart_per_cell<3>().end();
it!=itend; ++it )
{
std::cout<<"Volume "<<++nb_volume<<" : ";
display_vol_vertices(lcc, it);
}
std::for_each(lcc.one_dart_per_cell<3>().begin(),
lcc.one_dart_per_cell<3>().end(),
Display_vol_vertices<LCC_3>(lcc));
// We display the lcc characteristics.
std::cout<<"LCC characteristics: ";

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -3,8 +3,8 @@
//
// 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.
// 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.

View File

@ -1,3 +1,25 @@
// 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_LCC_2_TEST_H
#define CGAL_LCC_2_TEST_H
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Combinatorial_map_operations.h>
#include <CGAL/Linear_cell_complex_constructors.h>
@ -168,3 +190,5 @@ bool test_LCC_2()
return true;
}
#endif // CGAL_LCC_2_TEST_H

View File

@ -1,3 +1,25 @@
// 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_LCC_3_TEST_H
#define CGAL_LCC_3_TEST_H
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Combinatorial_map_operations.h>
#include <CGAL/Linear_cell_complex_constructors.h>
@ -232,3 +254,5 @@ bool test_LCC_3()
return true;
}
#endif // CGAL_LCC_3_TEST_H

View File

@ -1,3 +1,25 @@
// 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_LCC_4_TEST_H
#define CGAL_LCC_4_TEST_H
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Combinatorial_map_operations.h>
@ -247,3 +269,5 @@ bool test_LCC_4()
return true;
}
#endif // CGAL_LCC_4_TEST_H