From cb3c66dd90080068aed267e10b18fedb9cd285d7 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Mon, 21 Nov 2011 13:11:43 +0000 Subject: [PATCH] Revert of linear_cell_complex_3 example to use foreach which is now ok. Copyright. Add tests. --- .../Linear_cell_complex.tex | 11 +-- .../Linear_cell_complex_traits.tex | 9 +++ .../linear_cell_complex_3.cpp | 74 +++++++++---------- .../include/CGAL/Cell_attribute_with_point.h | 4 +- .../include/CGAL/Linear_cell_complex.h | 4 +- .../CGAL/Linear_cell_complex_constructors.h | 4 +- .../Linear_cell_complex_incremental_builder.h | 4 +- .../CGAL/Linear_cell_complex_min_items.h | 4 +- .../CGAL/Linear_cell_complex_operations.h | 4 +- .../include/CGAL/Linear_cell_complex_traits.h | 4 +- .../Linear_cell_complex_2_test.h | 24 ++++++ .../Linear_cell_complex_3_test.h | 24 ++++++ .../Linear_cell_complex_4_test.h | 24 ++++++ 13 files changed, 135 insertions(+), 59 deletions(-) diff --git a/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex.tex b/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex.tex index 6fe619827aa..45b97c19538 100644 --- a/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex.tex +++ b/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex.tex @@ -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} if -\ccc{d2} is 2 or 3, and is \ccc{CGAL::Linear_cell_complex_traits>} otherwise, +\ccc{Traits_} is equal to \ccc{CGAL::Linear_cell_complex_traits}, +%\ccc{Traits_} is equal to \ccc{CGAL::Linear_cell_complex_traits} if +%\ccc{d2} is 2 or 3, and is \ccc{CGAL::Linear_cell_complex_traits>} otherwise, \ccc{Items_} is equal to \ccc{CGAL::Linear_cell_complex_min_items} 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 diff --git a/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex_traits.tex b/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex_traits.tex index df224017560..a3efc4a590a 100644 --- a/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex_traits.tex +++ b/Linear_cell_complex/doc_tex/Linear_cell_complex_ref/Linear_cell_complex_traits.tex @@ -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} +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;}{} diff --git a/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_3.cpp b/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_3.cpp index 06360c8cc63..8da83fb5966 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_3.cpp +++ b/Linear_cell_complex/examples/Linear_cell_complex/linear_cell_complex_3.cpp @@ -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 -void display_vol_vertices(const LCC& alcc, typename LCC::Dart_handle d) +struct Display_vol_vertices : public std::unary_function { - 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<::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-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)); // 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)); // We display the lcc characteristics. std::cout<<"LCC characteristics: "; diff --git a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h index 7bdb093285e..abb7ca90938 100644 --- a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h +++ b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h index e4150f0262e..e2706d25ff7 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h index bf40bfbe877..ca008ec9b10 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h index 00b6662300e..758f6cd18e2 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h index b8886b8d888..eb2a6f5d16a 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_min_items.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h index 058ff72da07..574e0b0f90d 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h @@ -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. diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_traits.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_traits.h index edff0db943c..00ff177890a 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_traits.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_traits.h @@ -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. diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h index 8baa2a362df..5b426908234 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h @@ -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 +// +#ifndef CGAL_LCC_2_TEST_H +#define CGAL_LCC_2_TEST_H + #include #include #include @@ -168,3 +190,5 @@ bool test_LCC_2() return true; } + +#endif // CGAL_LCC_2_TEST_H diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h index 53467c4c9d9..10af0c4a4db 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h @@ -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 +// +#ifndef CGAL_LCC_3_TEST_H +#define CGAL_LCC_3_TEST_H + #include #include #include @@ -232,3 +254,5 @@ bool test_LCC_3() return true; } + +#endif // CGAL_LCC_3_TEST_H diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_4_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_4_test.h index 07949db7657..d7512283dde 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_4_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_4_test.h @@ -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 +// +#ifndef CGAL_LCC_4_TEST_H +#define CGAL_LCC_4_TEST_H + #include #include @@ -247,3 +269,5 @@ bool test_LCC_4() return true; } + +#endif // CGAL_LCC_4_TEST_H