diff options
author | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-12 05:43:06 +0000 |
---|---|---|
committer | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-12 05:43:06 +0000 |
commit | ad6a64ad5a4f4121410250021eda0904eb9c718c (patch) | |
tree | fdad2e783a79b388cde1826e3b344d8977d1183a /src/common/include/gudhi_patches/CGAL/internal | |
parent | f9a32a464156dd61b444f0e70c8342642363e8ea (diff) | |
parent | f0e5330a88f9e89a887769ab79f6db6dd4e1c35a (diff) |
Merge from trunk.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/qt5@1848 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: c8e1376894207c8c08896f750f71c115e07f6d95
Diffstat (limited to 'src/common/include/gudhi_patches/CGAL/internal')
5 files changed, 621 insertions, 0 deletions
diff --git a/src/common/include/gudhi_patches/CGAL/internal/Combination_enumerator.h b/src/common/include/gudhi_patches/CGAL/internal/Combination_enumerator.h new file mode 100644 index 00000000..f411e827 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Combination_enumerator.h @@ -0,0 +1,148 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (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 +// 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) : Samuel Hornus + +#ifndef CGAL_INTERNAL_COMBINATION_ENUMERATOR_H +#define CGAL_INTERNAL_COMBINATION_ENUMERATOR_H + +#include <CGAL/basic.h> +#include <vector> + +namespace CGAL { + +namespace internal { + +class Combination_enumerator +{ + // types and member data + typedef std::vector<int> Combination; + Combination combi_; + const int k_; + const int min_; + const int max_; + const int max_at_pos_0_; + +public: + + // For generating all the combinations of |k| distinct elements in the + // interval [min, max] (both included) + Combination_enumerator(const int k, const int min, const int max) + : combi_(k), k_(k), min_(min), max_(max), max_at_pos_0_(max + 1 - k) + { + CGAL_assertion_msg( min <= max, "min is larger than max"); + CGAL_assertion_msg( 1 <= k && k <= ( max - min + 1 ), "wrong value of k"); + init(); + } + + Combination_enumerator(const Combination_enumerator & c) + : combi_(c.combi_), k_(c.k_), min_(c.min_), max_(c.max_), max_at_pos_0_(c.max_at_pos_0_) + {} + + int number_of_elements() + { + return k_; + } + + void init() + { + combi_.resize(k_); + for( int i = 0; i < k_; ++i ) + element(i) = min_ + i; + } + + bool end() const + { + return ( element(0) > max_at_pos_0_ ); + } + + int element(const int i) const + { + CGAL_assertion( 0 <= i && i < k_ ); + return combi_[i]; + } + + int & element(const int i) + { + CGAL_assertion( 0 <= i && i < k_ ); + return combi_[i]; + } + + int operator[](const int i) const + { + return element(i); + } + + int & operator[](const int i) + { + return element(i); + } + + void operator++() + { + int i = k_ - 1; + int max_at_pos_i(max_); + while( ( i >= 0 ) && ( element(i) >= max_at_pos_i ) ) + { + --i; + --max_at_pos_i; + } + if( -1 == i ) + { + if( element(0) == max_at_pos_0_ ) + ++element(0); // mark then end of the enumeration with an impossible value + // Note than when we have arrived at the end of the enumeration, applying + // operator++() again does not change anything, so it is safe to + // apply it too many times. + } + else + { + ++element(i); + for( int j = i + 1; j < k_; ++j ) + element(j) = element(i) + j - i; + } + } + + Combination_enumerator operator++(int) + { + Combination_enumerator tmp(*this); + ++(*this); + return tmp; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - TESTING +#if 0 + void test() + { + std::cerr << '\n'; + while( ! end() ) + { + std::cerr << '\n'; + for( int i = 0; i < k_; ++i ) + std::cerr << element(i) << ' '; + ++(*this); + } + init(); + } +#endif +}; + +} // end of namespace internal + +} // end of namespace CGAL + +#endif // CGAL_INTERNAL_COMBINATION_ENUMERATOR_H diff --git a/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h b/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h new file mode 100644 index 00000000..ee6195d9 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h @@ -0,0 +1,116 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (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 +// 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) : Samuel Hornus + +#ifndef CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H +#define CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H + +#include <CGAL/Compact_container.h> +#include <CGAL/Dimension.h> +#include <CGAL/array.h> +#include <vector> + +namespace CGAL { + +namespace internal { + +// Utility for adding one to an Dimension_tag: + +template<typename D> +struct Dimen_plus_one; + +template<> +struct Dimen_plus_one<Dynamic_dimension_tag> +{ + typedef Dynamic_dimension_tag type; +}; + +template<int D> +struct Dimen_plus_one<Dimension_tag<D> > +{ + typedef Dimension_tag<D+1> type; +}; + +// A SMALL CONTAINER UTILITY FOR DYNAMIC/STATIC MEMORY MANAGEMENT + +// stores an array of static or dynamic size, depending on template parameter <B>. + +template< typename Containee, typename D, bool WithCompactContainerHelper = false> + struct S_or_D_array; // S = static, D = dynamic + +// The case of static size: +template< typename Containee, int D, bool WithCompactContainerHelper > +struct S_or_D_array< Containee, Dimension_tag< D >, WithCompactContainerHelper > +: public array<Containee, D> +{ + typedef array<Containee, D> Base; + S_or_D_array(const int) + : Base() + {} + S_or_D_array(const int, const Containee & c) + : Base() + { + assign(c); + } + void* for_compact_container() const + { + return (*this)[0].for_compact_container(); + } + void* & for_compact_container() + { + return (*this)[0].for_compact_container(); + } +}; + +// The case of dynamic size +template< typename Containee > +struct S_or_D_array< Containee, Dynamic_dimension_tag, false > +: public std::vector<Containee> +{ + typedef std::vector<Containee> Base; + // TODO: maybe we should use some "small-vector-optimized" class. + S_or_D_array(const int d) + : Base(d) + {} + S_or_D_array(const int d, const Containee & c) + : Base(d, c) + {} +}; + +// The case of dynamic size with for_compact_container +template< typename Containee > +struct S_or_D_array< Containee, Dynamic_dimension_tag, true > +: public std::vector<Containee> +{ + typedef std::vector<Containee> Base; + S_or_D_array(const int d) + : Base(d), fcc_(NULL) + {} + S_or_D_array(const int d, const Containee & c) + : Base(d, c), fcc_(NULL) + {} + void* fcc_; + void* for_compact_container() const { return fcc_; } + void* & for_compact_container() { return fcc_; } +}; + +} // end of namespace internal + +} // end of namespace CGAL + +#endif // CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H diff --git a/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Dummy_TDS.h b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Dummy_TDS.h new file mode 100644 index 00000000..b3a0ec98 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Dummy_TDS.h @@ -0,0 +1,49 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (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 +// 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) : Samuel Hornus + +#ifndef CGAL_INTERNAL_TRIANGULATION_DUMMY_TDS_H +#define CGAL_INTERNAL_TRIANGULATION_DUMMY_TDS_H + +namespace CGAL { + +namespace internal { +namespace Triangulation { + +struct Dummy_TDS +{ + struct Vertex {}; + struct Vertex_handle {}; + struct Vertex_iterator {}; + struct Vertex_const_handle {}; + struct Vertex_const_iterator {}; + struct Full_cell {}; + struct Full_cell_handle {}; + struct Full_cell_iterator {}; + struct Full_cell_const_handle {}; + struct Full_cell_const_iterator {}; + struct Vertex_handle_const_iterator {}; + struct Full_cell_data {}; +}; + +} // namespace Triangulation +} // namespace internal + +} //namespace CGAL + +#endif // CGAL_INTERNAL_TRIANGULATION_DUMMY_TDS_H diff --git a/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Triangulation_ds_iterators.h b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Triangulation_ds_iterators.h new file mode 100644 index 00000000..7e360026 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/Triangulation_ds_iterators.h @@ -0,0 +1,154 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (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 +// 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) : Samuel Hornus (Well... `copy, paste and hack' of Monique Teillaud's work) + +#ifndef CGAL_INTERNAL_TRIANGULATION_TRIANGULATION_DS_ITERATORS_H +#define CGAL_INTERNAL_TRIANGULATION_TRIANGULATION_DS_ITERATORS_H + +namespace CGAL { + +namespace internal { +namespace Triangulation { + +template< typename TDS > +class Triangulation_ds_facet_iterator +{ + typedef typename TDS::Full_cell_handle Full_cell_handle; + typedef typename TDS::Facet Facet; + + typedef Facet value_type; + typedef const Facet * pointer; + typedef const Facet & reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + + typedef Triangulation_ds_facet_iterator<TDS> Facet_iterator; + + TDS & tds_; + Facet ft_; + const int cur_dim_; + +public: + Triangulation_ds_facet_iterator(TDS & tds) + : tds_(tds), ft_(tds.full_cells_begin(), 0), cur_dim_(tds.current_dimension()) + { + CGAL_assertion( cur_dim_ > 0 ); + while( ! canonical() ) + raw_increment(); + } + + Triangulation_ds_facet_iterator(TDS & tds, int) + : tds_(tds), ft_(tds.full_cells_end(), 0), cur_dim_(tds.current_dimension()) + { + CGAL_assertion( cur_dim_ > 0 ); + CGAL_assertion( canonical() ); + } + + Facet_iterator & operator++() + { + increment(); + return (*this); + } + + Facet_iterator operator++(int) + { + Facet_iterator tmp(*this); + increment(); + return tmp; + } + + Facet_iterator & operator--() + { + decrement(); + return (*this); + } + + Facet_iterator operator--(int) + { + Facet_iterator tmp(*this); + decrement(); + return tmp; + } + + bool operator==(const Facet_iterator & fi) const + { + return (&tds_ == &fi.tds_) && + (tds_.index_of_covertex(ft_) == fi.tds_.index_of_covertex(fi.ft_)) && + (tds_.full_cell(ft_) == fi.tds_.full_cell(fi.ft_)); + } + + bool operator!=(const Facet_iterator & fi) const + { + return !(*this == fi); + } + + reference operator*() const + { + return ft_; + } + + pointer operator->() const + { + return &ft_; + } + +private: + bool canonical() + { + if( tds_.full_cells_end() == tds_.full_cell(ft_) ) + return ( 0 == tds_.index_of_covertex(ft_) ); + return ( tds_.full_cell(ft_) < + tds_.full_cell(ft_)->neighbor(tds_.index_of_covertex(ft_)) ); + } + + void raw_decrement() + { + int i = tds_.index_of_covertex(ft_); + if( i == 0 ) + ft_ = Facet(--tds_.full_cell(ft_), cur_dim_); + else + ft_ = Facet(tds_.full_cell(ft_), i - 1); + } + + void raw_increment() + { + int i = tds_.index_of_covertex(ft_); + if( i == cur_dim_ ) + ft_ = Facet(++tds_.full_cell(ft_), 0); + else + ft_ = Facet(tds_.full_cell(ft_), i + 1); + } + + void decrement() + { + do { raw_decrement(); } while( ! canonical() ); + } + + void increment() + { + do { raw_increment(); } while( ! canonical() ); + } +}; + +} // namespace Triangulation +} // namespace internal + +} //namespace CGAL + +#endif // CGAL_INTERNAL_TRIANGULATION_TRIANGULATION_DS_ITERATORS_H diff --git a/src/common/include/gudhi_patches/CGAL/internal/Triangulation/utilities.h b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/utilities.h new file mode 100644 index 00000000..a1ffc775 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Triangulation/utilities.h @@ -0,0 +1,154 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (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 +// 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) : Samuel Hornus + +#ifndef CGAL_INTERNAL_TRIANGULATION_UTILITIES_H +#define CGAL_INTERNAL_TRIANGULATION_UTILITIES_H + +#include <CGAL/basic.h> + +namespace CGAL { + +namespace internal { +namespace Triangulation { + +template< class TDS > +struct Dark_full_cell_data +{ + typedef typename TDS::Full_cell_handle Full_cell_handle; + Full_cell_handle light_copy_; + int count_; + Dark_full_cell_data() : light_copy_(), count_(0) {} +}; + +template< class TDS > +struct Compare_faces_with_common_first_vertex +{ + typedef typename TDS::Face Face; + + const int d_; + +public: + + Compare_faces_with_common_first_vertex(const int d) + : d_(d) + { + CGAL_assertion( 0 < d ); + } + + explicit Compare_faces_with_common_first_vertex(); + + bool operator()(const Face & left, const Face & right) const + { + CGAL_assertion( d_ == left.face_dimension() ); + CGAL_assertion( d_ == right.face_dimension() ); + for( int i = 1; i <= d_; ++i ) + { + if( left.vertex(i) < right.vertex(i) ) + return true; + if( right.vertex(i) < left.vertex(i) ) + return false; + } + return false; + } +}; + +template< class T > +struct Compare_vertices_for_upper_face +{ + typedef typename T::Vertex_const_handle VCH; + + const T & t_; + +public: + + Compare_vertices_for_upper_face(const T & t) + : t_(t) + {} + + explicit Compare_vertices_for_upper_face(); + + bool operator()(const VCH & left, const VCH & right) const + { + if( left == right ) + return false; + if( t_.is_infinite(left) ) + return true; + if( t_.is_infinite(right) ) + return false; + return left < right; + } +}; + +template< class T > +struct Compare_points_for_perturbation +{ + typedef typename T::Geom_traits::Point_d Point; + + const T & t_; + +public: + + Compare_points_for_perturbation(const T & t) + : t_(t) + {} + + explicit Compare_points_for_perturbation(); + + bool operator()(const Point * left, const Point * right) const + { + return (SMALLER == t_.geom_traits().compare_lexicographically_d_object()(*left, *right)); + } +}; + +template< class T > +struct Point_from_pointer +{ + typedef const typename T::Geom_traits::Point_d * argument_type; + typedef const typename T::Geom_traits::Point_d result_type; + result_type & operator()(argument_type & x) const + { + return (*x); + } + const result_type & operator()(const argument_type & x) const + { + return (*x); + } +}; + +template< typename Vertex_handle, typename Point > +struct Point_from_vertex_handle +{ + typedef Vertex_handle argument_type; + typedef Point result_type; + result_type & operator()(argument_type & x) const + { + return x->point(); + } + const result_type & operator()(const argument_type & x) const + { + return x->point(); + } +}; + +} // namespace Triangulation +} // namespace internal + +} //namespace CGAL + +#endif // CGAL_INTERNAL_TRIANGULATION_UTILITIES_H |