From e82ea5de96bc1beb186449cff4998ebe7cfa5b2b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 29 Jan 2020 17:13:11 +0100 Subject: [PATCH 01/24] Add move-semantic to Compact_container That required a refactoring the timestamper feature. And the explanation why is quite long... Let's do it. The CGAL triangulations use the `Rebind_TDS` feature. During the instanciation of `Compact_container` it is important that `T` is allowed to be incomplete, otherwise the circular dependencies between TDS and Vertex/Cell cannot be resolved by the compiler. In previous implementation of the timestamper, to allow `T` to be an incomplete type, the compact container only carried a *point* to the time stamper, allocated on the heap. A moved-from compact container would only be valid if one recreated a time stamper for it on the head in the move-constructor. As I want move operations to be `noexcept`, I needed to change that implementation. Now the triangulation always carries a time stamp counter (`std::size`), independently of the type `T`, and the time stamper is an empty class, with static methods. That allows `T` to be incomplete during the declaration of `Compact_container`. --- .../include/CGAL/Compact_container.h | 148 +++++++++++------- .../CGAL/Concurrent_compact_container.h | 59 ++++--- STL_Extension/include/CGAL/Time_stamper.h | 33 +--- .../STL_Extension/test_Compact_container.cpp | 14 +- .../test_Concurrent_compact_container.cpp | 4 + 5 files changed, 147 insertions(+), 111 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index ee83c6c4d0b..86dd6e45fe5 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -223,7 +224,8 @@ class Compact_container public: typedef typename Default::Get< TimeStamper_, CGAL::Time_stamper_impl >::type - Time_stamper_impl; + Time_stamper; + typedef Time_stamper Time_stamper_impl; // backward-compatibility typedef T value_type; typedef Allocator allocator_type; @@ -250,16 +252,14 @@ public: explicit Compact_container(const Allocator &a = Allocator()) : alloc(a) - , time_stamper(new Time_stamper_impl()) { - init (); + init(); } template < class InputIterator > Compact_container(InputIterator first, InputIterator last, const Allocator & a = Allocator()) : alloc(a) - , time_stamper(new Time_stamper_impl()) { init(); std::copy(first, last, CGAL::inserter(*this)); @@ -268,14 +268,19 @@ public: // The copy constructor and assignment operator preserve the iterator order Compact_container(const Compact_container &c) : alloc(c.get_allocator()) - , time_stamper(new Time_stamper_impl()) { init(); block_size = c.block_size; - *time_stamper = *c.time_stamper; + time_stamp = c.time_stamp.load(); std::copy(c.begin(), c.end(), CGAL::inserter(*this)); } + Compact_container(Compact_container&& c) noexcept + : alloc(c.get_allocator()) + { + c.swap(*this); + } + Compact_container & operator=(const Compact_container &c) { if (&c != this) { @@ -285,10 +290,16 @@ public: return *this; } + Compact_container & operator=(Compact_container&& c) noexcept + { + Self tmp(std::move(c)); + tmp.swap(*this); + return *this; + } + ~Compact_container() { clear(); - delete time_stamper; } bool is_used(const_iterator ptr) const @@ -328,17 +339,8 @@ public: return all_items[block_number].first[index_in_block]; } - void swap(Self &c) - { - std::swap(alloc, c.alloc); - std::swap(capacity_, c.capacity_); - std::swap(size_, c.size_); - std::swap(block_size, c.block_size); - std::swap(first_item, c.first_item); - std::swap(last_item, c.last_item); - std::swap(free_list, c.free_list); - all_items.swap(c.all_items); - std::swap(time_stamper, c.time_stamper); + friend void swap(Compact_container& a, Compact_container b) { + a.swap(b); } iterator begin() { return iterator(first_item, 0, 0); } @@ -383,7 +385,7 @@ public: new (ret) value_type(args...); CGAL_assertion(type(ret) == USED); ++size_; - time_stamper->set_time_stamp(ret); + Time_stamper::set_time_stamp(ret, time_stamp); return iterator(ret, 0); } @@ -397,7 +399,7 @@ public: std::allocator_traits::construct(alloc, ret, t); CGAL_assertion(type(ret) == USED); ++size_; - time_stamper->set_time_stamp(ret); + Time_stamper::set_time_stamp(ret, time_stamp); return iterator(ret, 0); } @@ -652,7 +654,21 @@ public: static bool is_begin_or_end(const_pointer ptr) { return type(ptr)==START_END; } + void swap(Self &c) + { + std::swap(alloc, c.alloc); + std::swap(capacity_, c.capacity_); + std::swap(size_, c.size_); + std::swap(block_size, c.block_size); + std::swap(first_item, c.first_item); + std::swap(last_item, c.last_item); + std::swap(free_list, c.free_list); + all_items.swap(c.all_items); + // non-atomic swap of time_stamp: + c.time_stamp = time_stamp.exchange(c.time_stamp.load()); + } +private: // We store a vector of pointers to all allocated blocks and their sizes. // Knowing all pointers, we don't have to walk to the end of a block to reach // the pointer to the next block. @@ -660,7 +676,9 @@ public: // by walking through the block till its end. // This opens up the possibility for the compiler to optimize the clear() // function considerably when has_trivial_destructor. - typedef std::vector > All_items; + using All_items = std::vector >; + + using time_stamp_t = std::atomic; void init() { @@ -671,21 +689,18 @@ public: first_item = nullptr; last_item = nullptr; all_items = All_items(); - time_stamper->reset(); + time_stamp = 0; } allocator_type alloc; - size_type capacity_; - size_type size_; - size_type block_size; - pointer free_list; - pointer first_item; - pointer last_item; - All_items all_items; - - // This is a pointer, so that the definition of Compact_container does - // not require a complete type `T`. - Time_stamper_impl* time_stamper; + size_type capacity_ = 0; + size_type size_ = 0; + size_type block_size = Increment_policy::first_block_size; + pointer free_list = nullptr; + pointer first_item = nullptr; + pointer last_item = nullptr; + All_items all_items = {}; + time_stamp_t time_stamp = {}; }; template < class T, class Allocator, class Increment_policy, class TimeStamper > @@ -759,7 +774,7 @@ void Compact_container::allocate_ne for (size_type i = block_size; i >= 1; --i) { EraseCounterStrategy::set_erase_counter(*(new_block + i), 0); - time_stamper->initialize_time_stamp(new_block + i); + Time_stamper::initialize_time_stamp(new_block + i); put_on_free_list(new_block + i); } // We insert this new block at the end. @@ -839,7 +854,6 @@ namespace internal { template < class DSC, bool Const > class CC_iterator { - typedef typename DSC::iterator iterator; typedef CC_iterator Self; public: typedef DSC CC; @@ -861,26 +875,52 @@ namespace internal { m_ptr.p = nullptr; } - // Either a harmless copy-ctor, - // or a conversion from iterator to const_iterator. - CC_iterator (const iterator &it) + CC_iterator (const CC_iterator &it) #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - : ts(Time_stamper_impl::time_stamp(it.operator->())) + : ts(Time_stamper::time_stamp(it.operator->())) #endif { m_ptr.p = it.operator->(); } - // Same for assignment operator (otherwise MipsPro warns) - CC_iterator & operator= (const iterator &it) - { - m_ptr.p = it.operator->(); + // Converting constructor from mutable to constant iterator + template + CC_iterator(const CC_iterator< + typename std::enable_if<(Const && !OtherConst), DSC>::type, + OtherConst> &const_it) #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - ts = Time_stamper_impl::time_stamp(it.operator->()); + : ts(Time_stamper::time_stamp(const_it.operator->())) +#endif + { + m_ptr.p = const_it.operator->(); + } + + // Assignment operator from mutable to constant iterator + template + CC_iterator & operator= (const CC_iterator< + typename std::enable_if<(Const && !OtherConst), DSC>::type, + OtherConst> &const_it) + { + m_ptr.p = const_it.operator->(); +#ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP + ts = Time_stamper::time_stamp(const_it.operator->()); #endif return *this; } + CC_iterator(CC_iterator&& it) noexcept +#ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP + : ts(Time_stamper::time_stamp(it.operator->())) +#endif + { + m_ptr.p = it.operator->(); + it.m_ptr.p = nullptr; + } + + ~CC_iterator() = default; + CC_iterator& operator=(const CC_iterator&) = default; + CC_iterator& operator=(CC_iterator&&) = default; + // Construction from nullptr CC_iterator (std::nullptr_t CGAL_assertion_code(n)) #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP @@ -893,7 +933,7 @@ namespace internal { private: - typedef typename DSC::Time_stamper_impl Time_stamper_impl; + typedef typename DSC::Time_stamper Time_stamper; #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP std::size_t ts; #endif @@ -925,7 +965,7 @@ namespace internal { increment(); #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP else - ts = Time_stamper_impl::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr.p); #endif // CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP } @@ -938,7 +978,7 @@ namespace internal { m_ptr.p = ptr; #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP if(ptr != nullptr){ - ts = Time_stamper_impl::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr.p); } #endif // end CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP } @@ -959,7 +999,7 @@ namespace internal { DSC::type(m_ptr.p) == DSC::START_END) { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - ts = Time_stamper_impl::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr.p); #endif return; } @@ -983,7 +1023,7 @@ namespace internal { DSC::type(m_ptr.p) == DSC::START_END) { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - ts = Time_stamper_impl::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr.p); #endif return; } @@ -1022,7 +1062,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP bool is_time_stamp_valid() const { - return (ts == 0) || (ts == Time_stamper_impl::time_stamp(m_ptr.p)); + return (ts == 0) || (ts == Time_stamper::time_stamp(m_ptr.p)); } #endif // CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP @@ -1036,7 +1076,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper_impl::less(m_ptr.p, other.m_ptr.p); + return Time_stamper::less(m_ptr.p, other.m_ptr.p); } bool operator>(const CC_iterator& other) const @@ -1044,7 +1084,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper_impl::less(other.m_ptr.p, m_ptr.p); + return Time_stamper::less(other.m_ptr.p, m_ptr.p); } bool operator<=(const CC_iterator& other) const @@ -1052,7 +1092,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper_impl::less(m_ptr.p, other.m_ptr.p) + return Time_stamper::less(m_ptr.p, other.m_ptr.p) || (*this == other); } @@ -1061,7 +1101,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper_impl::less(other.m_ptr.p, m_ptr.p) + return Time_stamper::less(other.m_ptr.p, m_ptr.p) || (*this == other); } diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 5fad68c1719..c9ee56954b7 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -210,7 +210,8 @@ class Concurrent_compact_container typedef Concurrent_compact_container_traits Traits; public: - typedef CGAL::Time_stamper_impl Time_stamper_impl; + typedef CGAL::Time_stamper_impl Time_stamper; + typedef Time_stamper Time_stamper_impl; // backward compatibility typedef T value_type; typedef Allocator allocator_type; @@ -241,7 +242,6 @@ public: explicit Concurrent_compact_container(const Allocator &a = Allocator()) : m_alloc(a) - , m_time_stamper(new Time_stamper_impl()) { init (); } @@ -250,7 +250,6 @@ public: Concurrent_compact_container(InputIterator first, InputIterator last, const Allocator & a = Allocator()) : m_alloc(a) - , m_time_stamper(new Time_stamper_impl()) { init(); std::copy(first, last, CGAL::inserter(*this)); @@ -259,13 +258,18 @@ public: // The copy constructor and assignment operator preserve the iterator order Concurrent_compact_container(const Concurrent_compact_container &c) : m_alloc(c.get_allocator()) - , m_time_stamper(new Time_stamper_impl()) { init(); m_block_size = c.m_block_size; std::copy(c.begin(), c.end(), CGAL::inserter(*this)); } + Concurrent_compact_container(Concurrent_compact_container&& c) noexcept + : m_alloc(c.get_allocator()) + { + c.swap(*this); + } + Concurrent_compact_container & operator=(const Concurrent_compact_container &c) { if (&c != this) { @@ -275,10 +279,16 @@ public: return *this; } + Concurrent_compact_container & operator=(Concurrent_compact_container&& c) noexcept + { + Self tmp(std::move(c)); + tmp.swap(*this); + return *this; + } + ~Concurrent_compact_container() { clear(); - delete m_time_stamper; } bool is_used(const_iterator ptr) const @@ -290,11 +300,8 @@ public: { std::swap(m_alloc, c.m_alloc); #if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE - { // non-atomic swap - size_type other_capacity = c.m_capacity; - c.m_capacity = size_type(m_capacity); - m_capacity = other_capacity; - } + // non-atomic swap of m_capacity + c.m_capacity = m_capacity.exchange(c.m_capacity.load()); #else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE std::swap(m_capacity, c.m_capacity); #endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE @@ -304,7 +311,12 @@ public: std::swap(m_last_item, c.m_last_item); std::swap(m_free_lists, c.m_free_lists); m_all_items.swap(c.m_all_items); - std::swap(m_time_stamper, c.m_time_stamper); + // non-atomic swap of m_time_stamp + c.m_time_stamp = m_time_stamp.exchange(c.m_time_stamp.load()); + } + + friend void swap(Concurrent_compact_container& a, Concurrent_compact_container& b) { + a.swap(b); } iterator begin() { return iterator(m_first_item, 0, 0); } @@ -544,7 +556,7 @@ private: { CGAL_assertion(type(ret) == USED); fl->dec_size(); - m_time_stamper->set_time_stamp(ret); + Time_stamper::set_time_stamp(ret, m_time_stamp); return iterator(ret, 0); } @@ -619,8 +631,9 @@ private: // by walking through the block till its end. // This opens up the possibility for the compiler to optimize the clear() // function considerably when has_trivial_destructor. - typedef std::vector > All_items; + using All_items = std::vector >; + using time_stamp_t = std::atomic; void init() { @@ -636,25 +649,23 @@ private: m_first_item = nullptr; m_last_item = nullptr; m_all_items = All_items(); - m_time_stamper->reset(); + m_time_stamp = 0; } allocator_type m_alloc; #if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE - std::atomic m_capacity; + std::atomic m_capacity = {}; #else // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE - size_type m_capacity; + size_type m_capacity = {}; #endif // not CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE - size_type m_block_size; + size_type m_block_size = CGAL_INIT_CONCURRENT_COMPACT_CONTAINER_BLOCK_SIZE; Free_lists m_free_lists; - pointer m_first_item; - pointer m_last_item; - All_items m_all_items; + pointer m_first_item = nullptr; + pointer m_last_item = nullptr; + All_items m_all_items = {}; mutable Mutex m_mutex; + time_stamp_t m_time_stamp = {}; - // This is a pointer, so that the definition of Compact_container does - // not require a complete type `T`. - Time_stamper_impl* m_time_stamper; }; template < class T, class Allocator > @@ -770,7 +781,7 @@ void Concurrent_compact_container:: for (size_type i = old_block_size; i >= 1; --i) { EraseCounterStrategy::set_erase_counter(*(new_block + i), 0); - m_time_stamper->initialize_time_stamp(new_block + i); + Time_stamper::initialize_time_stamp(new_block + i); put_on_free_list(new_block + i, fl); } } diff --git a/STL_Extension/include/CGAL/Time_stamper.h b/STL_Extension/include/CGAL/Time_stamper.h index 6d65ec3cfb1..f0cfe44a574 100644 --- a/STL_Extension/include/CGAL/Time_stamper.h +++ b/STL_Extension/include/CGAL/Time_stamper.h @@ -28,26 +28,12 @@ constexpr size_t rounded_down_log2(size_t n) template struct Time_stamper { - Time_stamper() - : time_stamp_() {} - - Time_stamper(const Time_stamper& ts) - : time_stamp_() - { - time_stamp_ = std::size_t(ts.time_stamp_); - } - - Time_stamper& operator=(const Time_stamper& ts) - { - time_stamp_ = std::size_t(ts.time_stamp_); - return *this; - } - static void initialize_time_stamp(T* pt) { pt->set_time_stamp(std::size_t(-1)); } - void set_time_stamp(T* pt) { + template + static void set_time_stamp(T* pt, time_stamp_t& time_stamp_) { if(pt->time_stamp() == std::size_t(-1)) { const std::size_t new_ts = time_stamp_++; pt->set_time_stamp(new_ts); @@ -96,23 +82,14 @@ struct Time_stamper return time_stamp(p_t1) < time_stamp(p_t2); } } - - void reset() { - time_stamp_ = 0; - } -private: -#ifdef CGAL_NO_ATOMIC - std::size_t time_stamp_; -#else - CGAL::cpp11::atomic time_stamp_; -#endif }; // end class template Time_stamper template struct No_time_stamp { public: - void set_time_stamp(T*) {} + template + static void set_time_stamp(T*, time_stamp_t&) {} static bool less(const T* p_t1,const T* p_t2) { return p_t1 < p_t2; } @@ -130,8 +107,6 @@ public: constexpr std::size_t shift = internal::rounded_down_log2(sizeof(T)); return reinterpret_cast(p) >> shift; } - - void reset() {} }; // end class template No_time_stamp // That class template is an auxiliary class. It has a diff --git a/STL_Extension/test/STL_Extension/test_Compact_container.cpp b/STL_Extension/test/STL_Extension/test_Compact_container.cpp index 117b5d1ec44..3d370105a6a 100644 --- a/STL_Extension/test/STL_Extension/test_Compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Compact_container.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,11 @@ inline bool check_empty(const Cont &c) template < class Cont > void test(const Cont &) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + // Testing if all types are provided. typename Cont::value_type t0; @@ -319,22 +325,22 @@ int main() // Check the time stamper policies if(! boost::is_base_of, - C1::Time_stamper_impl>::value) + C1::Time_stamper>::value) { std::cerr << "Error timestamper of C1\n"; return 1; } if(! boost::is_base_of, - C2::Time_stamper_impl>::value) + C2::Time_stamper>::value) { std::cerr << "Error timestamper of C2\n"; return 1; } if(! boost::is_base_of, - C3::Time_stamper_impl>::value) + C3::Time_stamper>::value) { std::cerr << "Error timestamper of C3\n"; return 1; } if(! boost::is_base_of, - C4::Time_stamper_impl>::value) + C4::Time_stamper>::value) { std::cerr << "Error timestamper of C4\n"; return 1; } diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index afe1de689da..8db20f3b173 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -183,6 +183,10 @@ private: template < class Cont > void test(const Cont &) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); // Testing if all types are provided. typename Cont::value_type t0; From 3b564a20f81d1da1e4b11fe1402f7aa5b246b59d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 11:11:19 +0100 Subject: [PATCH 02/24] Add move-semantic to TDS_3 --- .../CGAL/Triangulation_data_structure_3.h | 19 +++++++++++ .../test/TDS_3/include/CGAL/_test_cls_tds_3.h | 33 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index e971ee6a7db..f7b145f014d 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -230,6 +230,15 @@ public: copy_tds(tds); } + Triangulation_data_structure_3(Tds && tds) + noexcept(noexcept(Cell_range(std::move(tds._cells))) && + noexcept(Vertex_range(std::move(tds._vertices)))) + : _dimension(std::exchange(tds._dimension, -2)) + , _cells(std::move(tds._cells)) + , _vertices(std::move(tds._vertices)) + { + } + Tds & operator= (const Tds & tds) { if (&tds != this) { @@ -239,6 +248,16 @@ public: return *this; } + Tds & operator= (Tds && tds) + noexcept(noexcept(Tds(std::move(tds)))) + { + Tds tmp(std::move(tds)); + swap(tmp); + return *this; + } + + ~Triangulation_data_structure_3() = default; // for the rule-of-five + size_type number_of_vertices() const { return vertices().size(); } int dimension() const {return _dimension;} diff --git a/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h b/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h index a8b8fe41dbe..bdf03c645d8 100644 --- a/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h +++ b/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h @@ -26,6 +26,11 @@ template void _test_cls_tds_3( const Tds &) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + typedef typename Tds::Vertex_range Vertex_range; typedef typename Tds::Cell_range Cell_range; @@ -115,6 +120,34 @@ _test_cls_tds_3( const Tds &) std::cout << "ok" << std::endl; assert(tds6.is_valid()); + // Test move-constructors and move-assignments + { + Tds tds7 = tds5; + Tds tds8{std::move(tds7)}; + Tds tds9 = tds5; + Tds tds10; + tds10 = std::move(tds9); + Tds tds11 = Tds(tds5); // construct from a temporary + Tds tds12 = std::move(tds11); + + assert(tds7.is_valid()); + assert(tds8.is_valid()); + assert(tds9.is_valid()); + assert(tds10.is_valid()); + assert(tds11.is_valid()); + assert(tds12.is_valid()); + assert(tds7.dimension()==-2); + assert(tds8.dimension()==2); + assert(tds9.dimension()==-2); + assert(tds10.dimension()==2); + assert(tds11.dimension()==-2); + assert(tds12.dimension()==2); + tds11.~Tds(); + // check tds12 is still valid after the destruction of tds11 + assert(tds12.is_valid()); + assert(tds12.dimension()==2); + } + std::cout << " Insert are tested in test_triangulation_3 " << std::endl; std::cout << " Iterator and circulator are tested in test_triangulation_3 " << std::endl; From b56cdcb743465a3c9f4fdff83ca6230b76a1763f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 11:23:37 +0100 Subject: [PATCH 03/24] Add move-semantic to CGAL (non-periodic) 3D triangulations - For `Triangulation_3`, the rule-of-zero cannot be used, because of the infinite vertex. A special copy-constructor and copy-assignment operators are required. But one can `= default the move-constructor and move-assignment operator, as well as the destructor. - For `Delaunay_triangulation_3`, the rule-of-zero is sufficient. Nothing to do. - For `Regular_triangulation_3`, the `hidden_point_visitor` data member is a function that is constructed with the `this` pointer, so the rule-of-zero cannot be used. Probably the move-constructor and move-assignment operator could be explicitly defaulted. --- ...angulation_cell_base_with_circumcenter_3.h | 15 +++++++++++ .../include/CGAL/Regular_triangulation_3.h | 27 ++++++++++++++++--- .../include/CGAL/Triangulation_3.h | 21 ++++++++------- .../include/CGAL/_test_cls_delaunay_3.h | 6 +++++ .../include/CGAL/_test_cls_regular_3.h | 7 +++++ .../include/CGAL/_test_cls_triangulation_3.h | 6 +++++ 6 files changed, 70 insertions(+), 12 deletions(-) diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 6c9c6a6e4ea..44610ed6de8 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -63,6 +63,13 @@ public: : Cb(c), circumcenter_(c.circumcenter_ != nullptr ? new Point(*(c.circumcenter_)) : nullptr) {} + Delaunay_triangulation_cell_base_with_circumcenter_3 + (Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) + : Cb(std::move(c)), circumcenter_(nullptr) + { + std::swap(circumcenter_, c.circumcenter_); + } + Delaunay_triangulation_cell_base_with_circumcenter_3& operator=(const Delaunay_triangulation_cell_base_with_circumcenter_3 &c) { @@ -71,6 +78,14 @@ public: return *this; } + Delaunay_triangulation_cell_base_with_circumcenter_3& + operator=(Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) + { + Delaunay_triangulation_cell_base_with_circumcenter_3 tmp=std::move(c); + std::swap(tmp, *this); + return *this; + } + Delaunay_triangulation_cell_base_with_circumcenter_3( Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 17cabad626a..3d56833e370 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -193,21 +193,42 @@ public: CGAL_triangulation_postcondition(is_valid()); } + Regular_triangulation_3(Regular_triangulation_3&& rt) + noexcept(noexcept(Tr_Base(std::move(rt)))) + : Tr_Base(std::move(rt)), hidden_point_visitor(this) + { + CGAL_triangulation_postcondition(is_valid()); + } + + ~Regular_triangulation_3() = default; + void swap(Regular_triangulation_3& tr) + noexcept(noexcept(this->Tr_Base::swap(tr))) { // The 'vertices' and 'hidden_points' members of 'hidden_point_visitor' should be empty // as they are only filled (and cleared) during the insertion of a point. // Hidden points are not stored there, but rather in cells. Thus, the only thing that must be set // is the triangulation pointer. Hidden_point_visitor new_hpv(this); - std::swap(hidden_point_visitor, new_hpv); + using std::swap; + swap(hidden_point_visitor, new_hpv); Tr_Base::swap(tr); } - Regular_triangulation_3& operator=(Regular_triangulation_3 tr) + Regular_triangulation_3& operator=(const Regular_triangulation_3& tr) { - swap(tr); + Regular_triangulation_3 copy(tr); + copy.swap(*this); + return *this; + } + + Regular_triangulation_3& operator=(Regular_triangulation_3&& tr) + noexcept(noexcept(Regular_triangulation_3(std::move(tr))) && + noexcept(std::declval().swap(*this))) + { + Regular_triangulation_3 copy(std::move(tr)); + copy.swap(*this); return *this; } diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 6941c6c8acf..07cc5761a31 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -728,6 +728,9 @@ public: CGAL_triangulation_expensive_postcondition(*this == tr); } + Triangulation_3(Triangulation_3&& tr) = default; + ~Triangulation_3() = default; + template < typename InputIterator > Triangulation_3(InputIterator first, InputIterator last, const GT& gt = GT(), Lock_data_structure *lock_ds = nullptr) @@ -754,21 +757,21 @@ public: init_tds(); } - Triangulation_3& operator=(Triangulation_3 tr) + Triangulation_3& operator=(const Triangulation_3& tr) { - // Because the parameter tr is passed by value, the triangulation passed - // as argument has been copied. - // The following 'swap' consumes the *copy* and the original triangulation - // is left untouched. - swap(tr); + Triangulation_3 copy(tr); + swap(copy); return *this; } + Triangulation_3& operator=(Triangulation_3&& tr) = default; + // HELPING FUNCTIONS - void swap(Triangulation_3& tr) + void swap(Triangulation_3& tr) noexcept { - std::swap(tr._gt, _gt); - std::swap(tr.infinite, infinite); + using std::swap; + swap(tr._gt, _gt); + swap(tr.infinite, infinite); _tds.swap(tr._tds); Base::swap(tr); } diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h index e2c9029eb10..a6b5ded18a7 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -170,6 +171,11 @@ _test_cls_delaunay_3(const Triangulation &) { typedef Triangulation Cls; + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + typedef typename Test_location_policy::Location_policy Location_policy; // We assume the traits class has been tested already diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h index 3c646b27be4..6c5793d0de2 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h @@ -15,12 +15,19 @@ #include #include #include +#include #include template void _test_cls_regular_3(const Triangulation &) { typedef Triangulation Cls; + + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + typedef typename Triangulation::Geom_traits Gt; CGAL_USE_TYPE(Gt); diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index 3d647fcad94..b73de19db78 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "_test_cls_iterator.h" #include "_test_cls_circulator.h" @@ -79,6 +80,11 @@ _test_cls_triangulation_3(const Triangulation &) { typedef Triangulation Cls; + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + // We assume the traits class has been tested already // actually, any traits is good if it has been tested From db55548830a3feec3b34749d0dce6f6a2b13d8af Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 11:08:58 +0100 Subject: [PATCH 04/24] Fix a conversion warning --- .../test/STL_Extension/test_Concurrent_compact_container.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 8db20f3b173..37003ba37a5 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -161,7 +161,7 @@ public: { m_iterators[i] = m_cont.insert(m_values[i]); // Random-pick an element to erase - int index_to_erase = rand() % m_values.size(); + auto index_to_erase = rand() % m_values.size(); // If it exists bool comparand = false; if (m_free_elements[index_to_erase].compare_exchange_weak(comparand, true) ) From 2717864bd7906e476b8a59fc08388a546a314797 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 11:11:39 +0100 Subject: [PATCH 05/24] Fix warnings cppcoreguidelines-special-member-functions (clang-tidy) - Remove trivial copy-constructors that prevents the compiler to generate the other special member functions. --- .../include/CGAL/Concurrent_compact_container.h | 9 ++------- .../test_Concurrent_compact_container.cpp | 17 ----------------- .../CGAL/Triangulation_data_structure_3.h | 15 +++++++++------ .../include/CGAL/Delaunay_triangulation_3.h | 17 ----------------- .../include/CGAL/Regular_triangulation_3.h | 17 ----------------- 5 files changed, 11 insertions(+), 64 deletions(-) diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index c9ee56954b7..e968312c453 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -114,6 +114,8 @@ namespace CCC_internal { // Free list (head and size) template< typename pointer, typename size_type, typename CCC > class Free_list { + // Not that the implicitly-defined member functions copy the + // pointer, and not the pointed data. public: Free_list() : m_head(nullptr), m_size(0) { #if CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE @@ -150,13 +152,6 @@ public: #endif // CGAL_CONCURRENT_COMPACT_CONTAINER_APPROXIMATE_SIZE } bool empty() { return size() == 0; } - // Warning: copy the pointer, not the data! - Free_list& operator= (const Free_list& other) - { - m_head = other.m_head; - m_size = other.m_size; - return *this; - } void merge(Free_list &other) { diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 37003ba37a5..0795806ac2b 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -33,7 +33,6 @@ struct Node_1 : public CGAL::Compact_container_base { Node_1() {} - Node_1(const Node_1& o) : time_stamp_(o.time_stamp_) {} bool operator==(const Node_1 &) const { return true; } bool operator!=(const Node_1 &) const { return false; } bool operator< (const Node_1 &) const { return false; } @@ -89,11 +88,6 @@ public: : m_values(values), m_cont(cont), m_iterators(iterators) {} - Insert_in_CCC_functor(const Insert_in_CCC_functor &other) - : m_values(other.m_values), m_cont(other.m_cont), - m_iterators(other.m_iterators) - {} - void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) @@ -118,11 +112,6 @@ public: : m_cont(cont), m_iterators(iterators) {} - Erase_in_CCC_functor(const Erase_in_CCC_functor &other) - : m_cont(other.m_cont), - m_iterators(other.m_iterators) - {} - void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) @@ -149,12 +138,6 @@ public: m_free_elements(free_elements), m_num_erasures(num_erasures) {} - Insert_and_erase_in_CCC_functor(const Insert_and_erase_in_CCC_functor &other) - : m_values(other.m_values), m_cont(other.m_cont), - m_iterators(other.m_iterators), m_free_elements(other.m_free_elements), - m_num_erasures(other.m_num_erasures) - {} - void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index f7b145f014d..f0c35a7a1e3 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -935,12 +935,6 @@ public: *output++ = e; return *this; } - Facet_it& operator=(const Facet_it& f) { - output = f.output; - filter = f.filter; - return *this; - } - Facet_it(const Facet_it&)=default; }; Facet_it facet_it() { return Facet_it(output, filter); @@ -1065,6 +1059,15 @@ public: } } + // Implement the rule-of-five, to please the diagnostic + // `cppcoreguidelines-special-member-functions` of clang-tidy. + // Instead of defaulting those special member functions, let's + // delete them, to prevent any misuse. + Vertex_extractor(const Vertex_extractor&) = delete; + Vertex_extractor(Vertex_extractor&&) = delete; + Vertex_extractor& operator=(const Vertex_extractor&) = delete; + Vertex_extractor& operator=(Vertex_extractor&&) = delete; + ~Vertex_extractor() { for(std::size_t i=0; i < tmp_vertices.size(); ++i){ diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index 70764f7bfa0..4f1de418ff2 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -887,11 +887,6 @@ protected: : m_dt(dt), m_points(points), m_tls_hint(tls_hint) {} - // Constructor - Insert_point(const Insert_point& ip) - : m_dt(ip.m_dt), m_points(ip.m_points), m_tls_hint(ip.m_tls_hint) - {} - // operator() void operator()(const tbb::blocked_range& r) const { @@ -967,12 +962,6 @@ protected: m_tls_hint(tls_hint) {} - // Constructor - Insert_point_with_info(const Insert_point_with_info& ip) - : m_dt(ip.m_dt), m_points(ip.m_points), m_infos(ip.m_infos), - m_indices(ip.m_indices), m_tls_hint(ip.m_tls_hint) - {} - // operator() void operator()(const tbb::blocked_range& r) const { @@ -1046,12 +1035,6 @@ protected: m_vertices_to_remove_sequentially(vertices_to_remove_sequentially) {} - // Constructor - Remove_point(const Remove_point& rp) - : m_dt(rp.m_dt), m_vertices(rp.m_vertices), - m_vertices_to_remove_sequentially(rp.m_vertices_to_remove_sequentially) - {} - // operator() void operator()(const tbb::blocked_range& r) const { diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 3d56833e370..22122a53e41 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -1408,11 +1408,6 @@ protected: : m_rt(rt), m_points(points), m_tls_hint(tls_hint) {} - // Constructor - Insert_point(const Insert_point& ip) - : m_rt(ip.m_rt), m_points(ip.m_points), m_tls_hint(ip.m_tls_hint) - {} - // operator() void operator()(const tbb::blocked_range& r) const { @@ -1519,12 +1514,6 @@ protected: m_tls_hint(tls_hint) {} - // Constructor - Insert_point_with_info(const Insert_point_with_info &ip) - : m_rt(ip.m_rt), m_points(ip.m_points), m_infos(ip.m_infos), - m_indices(ip.m_indices), m_tls_hint(ip.m_tls_hint) - {} - // operator() void operator()(const tbb::blocked_range& r) const { @@ -1636,12 +1625,6 @@ protected: m_vertices_to_remove_sequentially(vertices_to_remove_sequentially) {} - // Constructor - Remove_point(const Remove_point& rp) - : m_rt(rp.m_rt), m_vertices(rp.m_vertices), - m_vertices_to_remove_sequentially(rp.m_vertices_to_remove_sequentially) - {} - // operator() void operator()(const tbb::blocked_range& r) const { From b311ab59edf7b77849b11266404020cc90693c63 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 11:13:57 +0100 Subject: [PATCH 06/24] [modernize-use-nullptr] (clang-tidy) --- .../STL_Extension/test_Concurrent_compact_container.cpp | 2 +- Triangulation_3/include/CGAL/Triangulation_3.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 0795806ac2b..84a65304eb1 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -60,7 +60,7 @@ public: int rnd; Node_2() - : p(NULL), rnd(CGAL::get_default_random().get_int(0, 100)) {} + : p(nullptr), rnd(CGAL::get_default_random().get_int(0, 100)) {} bool operator==(const Node_2 &n) const { return rnd == n.rnd; } bool operator!=(const Node_2 &n) const { return rnd != n.rnd; } diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 07cc5761a31..9f6b7301666 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -179,7 +179,7 @@ public: void *get_lock_data_structure() const { - return 0; + return nullptr; } void set_lock_data_structure(void *) const {} @@ -245,7 +245,7 @@ protected: public: bool is_parallel() const { - return m_lock_ds != 0; + return m_lock_ds != nullptr; } // LOCKS @@ -1139,7 +1139,7 @@ public: typename std::iterator_traits::value_type, Point > - >::type* = NULL) + >::type* = nullptr) #else template < class InputIterator > std::ptrdiff_t insert(InputIterator first, InputIterator last) From 290c3a2011c08a7a9b8f18a0880b1828fdb8001e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 13:19:06 +0100 Subject: [PATCH 07/24] I forgot Triangulation_hierarchy_3 (Fast_location)! Note that a move-from object of class `Triangulation_hierarchy_3` is not really valid. I have just verified that it can be destroyed. Even a call to `clear()` on a moved-from hierarchy will segfault! To be fixed later... --- .../include/CGAL/Triangulation_hierarchy_3.h | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index 5e554cd14c5..f936cacdda8 100644 --- a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -51,6 +51,8 @@ #include #include +#include + #endif //CGAL_TRIANGULATION_3_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO namespace CGAL { @@ -92,7 +94,7 @@ public: private: // here is the stack of triangulations which form the hierarchy - Tr_Base* hierarchy[maxlevel]; + std::array hierarchy; boost::rand48 random; void set_up_down(Vertex_handle up, Vertex_handle down) @@ -107,6 +109,18 @@ public: Triangulation_hierarchy_3(const Triangulation_hierarchy_3& tr); + Triangulation_hierarchy_3(Triangulation_hierarchy_3&& other) + noexcept( noexcept(Tr_Base(std::move(other))) ) + : Tr_Base(std::move(other)) + , random(std::move(other.random)) + { + hierarchy[0] = this; + for(int i=1; i Triangulation_hierarchy_3(InputIterator first, InputIterator last, const Geom_traits& traits = Geom_traits()) @@ -125,9 +139,30 @@ public: return *this; } - ~Triangulation_hierarchy_3(); + Triangulation_hierarchy_3 & operator=(Triangulation_hierarchy_3&& tr) + noexcept( noexcept(Triangulation_hierarchy_3(std::move(tr))) && + noexcept(this->swap(std::declval())) ) + { + Triangulation_hierarchy_3 tmp(std::move(tr)); + swap(tmp); + return *this; + } - void swap(Triangulation_hierarchy_3 &tr); + ~Triangulation_hierarchy_3() + { + clear(); + for(int i=1; iTr_Base::swap(tr))) + { + Tr_Base::swap(tr); + for(int i=1; i &tr) } } -template -void -Triangulation_hierarchy_3:: -swap(Triangulation_hierarchy_3 &tr) -{ - Tr_Base::swap(tr); - for(int i=1; i -Triangulation_hierarchy_3:: -~Triangulation_hierarchy_3() -{ - clear(); - for(int i=1; i void Triangulation_hierarchy_3:: From f7218dadd692e9f20af27aef063f32cd50d1e578 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 14:19:49 +0100 Subject: [PATCH 08/24] Do not use swap for the move-assignment of TDS_3 We can write the operator easily without swap. --- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index f0c35a7a1e3..82744371605 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -251,8 +251,9 @@ public: Tds & operator= (Tds && tds) noexcept(noexcept(Tds(std::move(tds)))) { - Tds tmp(std::move(tds)); - swap(tmp); + _cells = std::move(tds._cells); + _vertices = std::move(tds._vertices); + _dimension = std::exchange(tds._dimension, -2); return *this; } From aed73efb46f6fb21e46bfd789d1432133a4d87aa Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 14:20:39 +0100 Subject: [PATCH 09/24] Move-semantic for TDS_2 --- .../CGAL/Triangulation_data_structure_2.h | 35 +++++++++++++++---- .../test/TDS_2/include/CGAL/_test_cls_tds_2.h | 33 +++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index 303115158b2..9eb67f85818 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -105,8 +105,13 @@ protected: public: Triangulation_data_structure_2(); Triangulation_data_structure_2(const Tds &tds); + Triangulation_data_structure_2(Triangulation_data_structure_2&& tds) + noexcept(noexcept(Face_range(std::move(tds._faces))) && + noexcept(Vertex_range(std::move(tds._vertices)))); + ~Triangulation_data_structure_2(); Tds& operator= (const Tds &tds); + Tds& operator= (Tds&& tds) noexcept(noexcept(Tds(std::move(tds)))); void swap(Tds &tds); //ACCESS FUNCTIONS @@ -642,9 +647,6 @@ public: Triangulation_default_data_structure_2(const Geom_traits& = Geom_traits()) : Tds() {} - - Triangulation_default_data_structure_2(const Tdds &tdds) - : Tds(tdds) {} }; //for backward compatibility @@ -657,8 +659,6 @@ public: typedef Triangulation_data_structure_using_list_2 Tdsul; Triangulation_data_structure_using_list_2(): Tds() {} - Triangulation_data_structure_using_list_2(const Tdsul &tdsul) - : Tds(tdsul) {} }; @@ -675,6 +675,17 @@ Triangulation_data_structure_2(const Tds &tds) copy_tds(tds); } +template < class Vb, class Fb> +Triangulation_data_structure_2 :: +Triangulation_data_structure_2(Tds &&tds) + noexcept(noexcept(Face_range(std::move(tds._faces))) && + noexcept(Vertex_range(std::move(tds._vertices)))) + : _dimension(std::exchange(tds._dimension, -2)) + , _faces(std::move(tds._faces)) + , _vertices(std::move(tds._vertices)) +{ +} + template < class Vb, class Fb> Triangulation_data_structure_2 :: ~Triangulation_data_structure_2() @@ -682,7 +693,7 @@ Triangulation_data_structure_2 :: clear(); } -//assignement +//copy-assignment template < class Vb, class Fb> Triangulation_data_structure_2& Triangulation_data_structure_2 :: @@ -692,6 +703,18 @@ operator= (const Tds &tds) return *this; } +//move-assignment +template < class Vb, class Fb> +Triangulation_data_structure_2& +Triangulation_data_structure_2 :: +operator= (Tds &&tds) noexcept(noexcept(Tds(std::move(tds)))) +{ + _faces = std::move(tds._faces); + _vertices = std::move(tds._vertices); + _dimension = std::exchange(tds._dimension, -2); + return *this; +} + template < class Vb, class Fb> void Triangulation_data_structure_2:: diff --git a/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h b/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h index 78bce69ebf8..44d04c40a9c 100644 --- a/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h +++ b/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h @@ -44,6 +44,11 @@ template void _test_cls_tds_2( const Tds &) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + typedef typename Tds::Vertex_range Vertex_range; typedef typename Tds::Face_range Face_range; @@ -128,6 +133,34 @@ _test_cls_tds_2( const Tds &) assert(tds3.dimension()== 1); assert(tds3.number_of_vertices() == 4); assert(tds3.is_valid() ); + + // Test move-constructors and move-assignments + { + Tds tds7 = tds3; + Tds tds8{std::move(tds7)}; + Tds tds9 = tds3; + Tds tds10; + tds10 = std::move(tds9); + Tds tds11 = Tds(tds3); // construct from a temporary + Tds tds12 = std::move(tds11); + + assert(tds7.is_valid()); + assert(tds8.is_valid()); + assert(tds9.is_valid()); + assert(tds10.is_valid()); + assert(tds11.is_valid()); + assert(tds12.is_valid()); + assert(tds7.dimension()==-2); + assert(tds8.dimension()==1); + assert(tds9.dimension()==-2); + assert(tds10.dimension()==1); + assert(tds11.dimension()==-2); + assert(tds12.dimension()==1); + tds11.~Tds(); + // check tds12 is still valid after the destruction of tds11 + assert(tds12.is_valid()); + assert(tds12.dimension()==1); + } Vertex_handle w4 = tds4.insert_first(); Vertex_handle v4_1 = tds4.insert_second(); From 14b8930f791318365a55ac48d3ff226d8554ea7a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 14:49:31 +0100 Subject: [PATCH 10/24] Fix a clang-tidy warning by using nullptr instead of 0 --- Spatial_sorting/include/CGAL/spatial_sort.h | 3 ++- TDS_2/include/CGAL/Triangulation_data_structure_2.h | 2 +- .../include/CGAL/Constrained_triangulation_2.h | 10 +++++----- Triangulation_2/include/CGAL/Triangulation_2.h | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Spatial_sorting/include/CGAL/spatial_sort.h b/Spatial_sorting/include/CGAL/spatial_sort.h index 8aa44ff6af7..891889e4b50 100644 --- a/Spatial_sorting/include/CGAL/spatial_sort.h +++ b/Spatial_sorting/include/CGAL/spatial_sort.h @@ -118,7 +118,8 @@ void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end, typedef std::iterator_traits ITraits; typedef typename ITraits::value_type value_type; - internal::spatial_sort(begin, end, k, policy, static_cast (0), + internal::spatial_sort(begin, end, k, policy, + static_cast (nullptr), threshold_hilbert,threshold_multiscale,ratio); } diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index 9eb67f85818..680ab3579e9 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -822,7 +822,7 @@ is_edge(Vertex_handle va, Vertex_handle vb, { Face_handle fc = va->face(); Face_handle start = fc; - if (fc == 0) return false; + if (fc == nullptr) return false; int inda, indb; do { inda=fc->index(va); diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index 4805a68e33e..9fe6473e79a 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -556,7 +556,7 @@ public: { Edge_circulator ec=incident_edges(v), done(ec); bool are_there = false; - if (ec == 0) return are_there; + if (ec == nullptr) return are_there; do { if(is_constrained(*ec)) { *out++ = *ec; @@ -572,7 +572,7 @@ public: OutputItEdges incident_constraints(Vertex_handle v, OutputItEdges out) const { Edge_circulator ec=incident_edges(v), done(ec); - if (ec == 0) return out; + if (ec == nullptr) return out; do { if(is_constrained(*ec)) *out++ = *ec; ec++; @@ -1064,7 +1064,7 @@ update_constraints_incident(Vertex_handle va, //dimension() ==2 int cwi, ccwi, indf; Face_circulator fc=incident_faces(va), done(fc); - CGAL_triangulation_assertion(fc != 0); + CGAL_triangulation_assertion(fc != nullptr); do { indf = fc->index(va); cwi=cw(indf); @@ -1091,7 +1091,7 @@ clear_constraints_incident(Vertex_handle va) Edge_circulator ec=incident_edges(va), done(ec); Face_handle f; int indf; - if ( ec != 0){ + if ( ec != nullptr){ do { f = (*ec).first ; indf = (*ec).second; @@ -1278,7 +1278,7 @@ Constrained_triangulation_2:: remove_incident_constraints(Vertex_handle v) { Edge_circulator ec=incident_edges(v), done(ec); - if (ec == 0) return; + if (ec == nullptr) return; do { if(is_constrained(*ec)) { remove_constrained_edge((*ec).first, (*ec).second);} diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index de91b826848..62c1d72902d 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -625,7 +625,7 @@ std::ptrdiff_t insert(InputIterator first, InputIterator last, typename std::iterator_traits::value_type, Point > - >::type* = NULL) + >::type* = nullptr) #else template < class InputIterator > std::ptrdiff_t @@ -1013,7 +1013,7 @@ includes_edge(Vertex_handle va, Vertex_handle vb, Orientation orient; int indv; Edge_circulator ec = incident_edges(va), done(ec); - if (ec != 0) { + if (ec != nullptr) { do { //find the index of the other vertex of *ec indv = 3 - ((*ec).first)->index(va) - (*ec).second ; @@ -2602,7 +2602,7 @@ march_locate_2D_LFC(Face_handle start, }else { lfc = Line_face_circulator(start->vertex(0), this, t); } - if(lfc==0 || lfc.collinear_outside()){ + if(lfc==nullptr || lfc.collinear_outside()){ // point t lies outside or on the convex hull // we walk on the convex hull to find it out Face_circulator fc = incident_faces(infinite_vertex()); From 75ec5c0da7cca2a393040025a3d85d2f9ac45f6d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 15:37:57 +0100 Subject: [PATCH 11/24] Add move-semantic to T_2, CT_2, Dt_2, and CDT_2 Still todo: `Constrained_triangulation_plus_2`, and `Triangulation_hierarchy_2`. --- .../CGAL/Constrained_Delaunay_triangulation_2.h | 13 +++++++++++++ .../include/CGAL/Constrained_triangulation_2.h | 11 +++++++++++ .../include/CGAL/Delaunay_triangulation_2.h | 5 +++++ Triangulation_2/include/CGAL/Triangulation_2.h | 5 +++++ .../CGAL/_test_cls_const_Del_triangulation_2.h | 5 +++++ .../CGAL/_test_cls_constrained_triangulation_2.h | 5 +++++ .../CGAL/_test_cls_delaunay_triangulation_2.h | 5 +++++ .../include/CGAL/_test_cls_triangulation_2.h | 4 ++++ .../Triangulation_2/include/CGAL/_test_traits.h | 7 ------- 9 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index a3d3af22911..5749e72c58e 100644 --- a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -141,6 +141,19 @@ public: virtual ~Constrained_Delaunay_triangulation_2() {} + // Ensure rule-of-five: define the copy- and move- constructors + // as well as the copy- and move- assignment operators. + Constrained_Delaunay_triangulation_2( + const Constrained_Delaunay_triangulation_2 &) = default; + Constrained_Delaunay_triangulation_2( + Constrained_Delaunay_triangulation_2 &&) = default; + + Constrained_Delaunay_triangulation_2 & + operator=(const Constrained_Delaunay_triangulation_2 &) = default; + + Constrained_Delaunay_triangulation_2 & + operator=(Constrained_Delaunay_triangulation_2 &&) = default; + // FLIPS bool is_flipable(Face_handle f, int i, bool perturb = true) const; void flip(Face_handle& f, int i); diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index 9fe6473e79a..4198a2dff18 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -201,6 +201,17 @@ public: //TODO Is that destructor correct ? virtual ~Constrained_triangulation_2() {} + // Ensure rule-of-five: define the copy- and move- constructors + // as well as the copy- and move- assignment operators. + Constrained_triangulation_2(const Constrained_triangulation_2 &) = default; + Constrained_triangulation_2(Constrained_triangulation_2 &&) = default; + + Constrained_triangulation_2 & + operator=(const Constrained_triangulation_2 &) = default; + + Constrained_triangulation_2 & + operator=(Constrained_triangulation_2 &&) = default; + Constrained_edges_iterator constrained_edges_begin() const { diff --git a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h index b570e082a0c..dd85df9acb0 100644 --- a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h @@ -90,6 +90,11 @@ public: : Triangulation_2(tr) { CGAL_triangulation_postcondition(is_valid()); } + Delaunay_triangulation_2(Delaunay_triangulation_2&&) = default; + Delaunay_triangulation_2& operator=(const Delaunay_triangulation_2&) = default; + Delaunay_triangulation_2& operator=(Delaunay_triangulation_2&&) = default; + ~Delaunay_triangulation_2() = default; + template Delaunay_triangulation_2(InputIterator first, InputIterator last, const Gt& gt = Gt()) diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 62c1d72902d..fa892beffc0 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -241,6 +241,7 @@ public: // CONSTRUCTORS Triangulation_2(const Geom_traits& geom_traits=Geom_traits()); Triangulation_2(const Triangulation_2 &tr); + Triangulation_2(Triangulation_2&&) = default; template Triangulation_2(InputIterator first, InputIterator last, @@ -253,6 +254,10 @@ public: //Assignement Triangulation_2 &operator=(const Triangulation_2 &tr); + Triangulation_2 &operator=(Triangulation_2 &&) = default; + + // Destructor + ~Triangulation_2() = default; //Helping void copy_triangulation(const Triangulation_2 &tr); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h index bdd49c1c738..6581267f164 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h @@ -30,6 +30,11 @@ template void _test_cls_const_Del_triangulation(const Triangul&) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + //typedef Triangulation Cls; typedef typename Triangul::Geom_traits Gt; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index eaa9e936e1c..1fe1183d3db 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -92,6 +92,11 @@ template void _test_cls_constrained_triangulation(const Triang &) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + // typedef Triangulation Cls; typedef typename Triang::Geom_traits Gt; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h index 2204331cfe8..f9cc6fcb2aa 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h @@ -39,6 +39,11 @@ template void _test_cls_delaunay_triangulation_2( const Del & ) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); + //typedef Del Delaunay; typedef typename Del::Point Point; typedef typename Del::Locate_type Locate_type; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h index ce242c40be3..498ff9139be 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h @@ -39,6 +39,10 @@ template void _test_cls_triangulation_2( const Triangul & ) { + static_assert(std::is_nothrow_move_constructible::value, + "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, + "move assignment is missing"); //typedef Triangulation Cls; // We assume the traits class has been tested already diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h index 10e712567e9..4eaf0541a29 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h @@ -36,7 +36,6 @@ protected: double _x, _y; public: Triangulation_test_point() {} - Triangulation_test_point(const Point &p) : _x(p.test_x()), _y(p.test_y()) {} Triangulation_test_point(double x, double y) : _x(x), _y(y) {} Triangulation_test_point(double hx, double hy, double hw) : _x(hx/hw), _y(hy/hw) @@ -47,7 +46,6 @@ public: bool compare(const Point &p) const { return test_x()==p.test_x() && test_y()==p.test_y(); } bool uncompare(const Point &p) const { return !compare(p); } - Point &operator=(const Point &p) { _x=p.test_x(); _y=p.test_y(); return *this; } void test_set(TESTFT x, TESTFT y) { _x=x; _y=y; } bool operator==(const Point &p) const {return this->compare(p);} }; @@ -436,11 +434,6 @@ public: typedef Triangulation_test_Construct_ray_2 Construct_ray_2; - _Triangulation_test_traits() {} - _Triangulation_test_traits(const _Triangulation_test_traits &) {} - _Triangulation_test_traits &operator= - (const _Triangulation_test_traits &) { return *this; } - Less_x_2 less_x_2_object() const { return Less_x_2();} From 94be80c2ebfbbf1becd6fcde854868e3195823d6 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 16:27:41 +0100 Subject: [PATCH 12/24] fix clang-tidy warnings --- .../include/CGAL/Constrained_triangulation_plus_2.h | 4 ++-- .../internal/Polyline_constraint_hierarchy_2.h | 8 ++------ .../include/CGAL/Triangulation_hierarchy_2.h | 2 +- .../CGAL/Triangulation_hierarchy_vertex_base_2.h | 10 +++++----- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index dad024bd902..79e3553a324 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -398,7 +398,7 @@ public: ++beg; Face_container fc(*this); - Constraint_id head = 0, tail = 0; + Constraint_id head = nullptr, tail = nullptr; if(pos != beg){ // split off head --pos; @@ -479,7 +479,7 @@ public: return pos; } - Constraint_id head = 0, tail = 0; + Constraint_id head = nullptr, tail = nullptr; Vertices_in_constraint_iterator bit = vertices_in_constraint_begin(cid); Vertices_in_constraint_iterator pred = pos; --pred; diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index 91d58c4b9dc..e7eb16a5372 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -154,10 +154,6 @@ public: public: Context() : enclosing(nullptr) {} - Context(const Context& hc) - : enclosing(hc.enclosing), pos(hc.pos) - {} - Vertex_it vertices_begin()const { return enclosing->skip_begin();} Vertex_it current()const {return pos;} Vertex_it vertices_end()const {return enclosing->skip_end();} @@ -499,7 +495,7 @@ swap(Constraint_id first, Constraint_id second){ // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->enclosing = 0; + ctit->enclosing = nullptr; break; } } @@ -530,7 +526,7 @@ swap(Constraint_id first, Constraint_id second){ // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { - if(ctit->enclosing == 0){ + if(ctit->enclosing == nullptr){ ctit->enclosing = second.vl_ptr(); break; } diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 30fa8deac9b..a8262f522e2 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -724,7 +724,7 @@ locate_in_all(const Point& p, level--; } - for (int i=level+1; i 0) { pos[level]=position=hierarchy[level]->locate(p, position); // locate at that level from "position" diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h index e70c3851c51..65f15868cbf 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h @@ -41,13 +41,13 @@ public: }; Triangulation_hierarchy_vertex_base_2() - : Base(), _up(0), _down(0) + : Base() {} Triangulation_hierarchy_vertex_base_2(const Point & p, Face_handle f) - : Base(p,f), _up(0), _down(0) + : Base(p,f) {} Triangulation_hierarchy_vertex_base_2(const Point & p) - : Base(p), _up(0), _down(0) + : Base(p) {} Vertex_handle up() {return _up;} @@ -57,8 +57,8 @@ public: private: - Vertex_handle _up; // same vertex one level above - Vertex_handle _down; // same vertex one level below + Vertex_handle _up = nullptr; // same vertex one level above + Vertex_handle _down = nullptr; // same vertex one level below }; } //namespace CGAL From 20bb2c8428821cd80dd0d00103b2113f75634612 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 31 Jan 2020 16:28:07 +0100 Subject: [PATCH 13/24] Add move-semantic to CT_plus_2 and Tr_hierarchy_2 --- .../CGAL/Constrained_triangulation_plus_2.h | 4 +++ .../Polyline_constraint_hierarchy_2.h | 4 ++- .../include/CGAL/Triangulation_hierarchy_2.h | 32 +++++++++++++++++-- .../include/CGAL/Triangulation_hierarchy_3.h | 13 +++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 79e3553a324..00128211057 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -216,6 +216,8 @@ public: , hierarchy(Vh_less_xy(this)) { copy_triangulation(ctp);} + Constrained_triangulation_plus_2(Constrained_triangulation_plus_2&&) = default; + virtual ~Constrained_triangulation_plus_2() {} Constrained_triangulation_plus_2 & operator=(const Constrained_triangulation_plus_2& ctp) @@ -224,6 +226,8 @@ public: return *this; } + Constrained_triangulation_plus_2& operator=(Constrained_triangulation_plus_2&&) = default; + template Constrained_triangulation_plus_2(InputIterator first, InputIterator last, diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index e7eb16a5372..bf89ead3c58 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -182,10 +182,12 @@ public: : comp(comp) , sc_to_c_map(Pair_compare(comp)) { } - Polyline_constraint_hierarchy_2(const Polyline_constraint_hierarchy_2& ch); + Polyline_constraint_hierarchy_2(const Polyline_constraint_hierarchy_2& ch); + Polyline_constraint_hierarchy_2(Polyline_constraint_hierarchy_2&&) = default; ~Polyline_constraint_hierarchy_2(){ clear();} void clear(); Polyline_constraint_hierarchy_2& operator=(const Polyline_constraint_hierarchy_2& ch); + Polyline_constraint_hierarchy_2& operator=(Polyline_constraint_hierarchy_2&& ch) = default; // Query bool is_subconstrained_edge(T va, T vb) const; diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index a8262f522e2..9dfb0e4e010 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace CGAL { @@ -83,13 +84,25 @@ public: private: // here is the stack of triangulations which form the hierarchy - Tr_Base* hierarchy[Triangulation_hierarchy_2__maxlevel]; + std::array hierarchy; boost::rand48 random; public: Triangulation_hierarchy_2(const Geom_traits& traits = Geom_traits()); Triangulation_hierarchy_2(const Triangulation_hierarchy_2& tr); + Triangulation_hierarchy_2(Triangulation_hierarchy_2&& other) + noexcept( noexcept(Tr_Base(std::move(other))) ) + : Tr_Base(std::move(other)) + , random(std::move(other.random)) + { + hierarchy[0] = this; + for(int i=1; i Triangulation_hierarchy_2(InputIterator first, InputIterator beyond, const Geom_traits& traits = Geom_traits()) @@ -103,11 +116,25 @@ public: } Triangulation_hierarchy_2 &operator=(const Triangulation_hierarchy_2& tr); + + Triangulation_hierarchy_2 & operator=(Triangulation_hierarchy_2&& other) + noexcept( noexcept(Triangulation_hierarchy_2(std::move(other))) ) + { + static_cast(*this) = std::move(other); + hierarchy[0] = this; + for(int i=1; iTr_Base::swap(tr))); void clear(); // CHECKING @@ -366,6 +393,7 @@ template void Triangulation_hierarchy_2:: swap(Triangulation_hierarchy_2 &tr) + noexcept(noexcept(this->Tr_Base::swap(tr))) { Tr_Base* temp; Tr_Base::swap(tr); diff --git a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index f936cacdda8..e92fbf94e07 100644 --- a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -139,12 +139,15 @@ public: return *this; } - Triangulation_hierarchy_3 & operator=(Triangulation_hierarchy_3&& tr) - noexcept( noexcept(Triangulation_hierarchy_3(std::move(tr))) && - noexcept(this->swap(std::declval())) ) + Triangulation_hierarchy_3 & operator=(Triangulation_hierarchy_3&& other) + noexcept( noexcept(Triangulation_hierarchy_3(std::move(other))) ) { - Triangulation_hierarchy_3 tmp(std::move(tr)); - swap(tmp); + static_cast(*this) = std::move(other); + hierarchy[0] = this; + for(int i=1; i Date: Tue, 4 Feb 2020 10:12:29 +0100 Subject: [PATCH 14/24] Less use of swap --- ...angulation_cell_base_with_circumcenter_3.h | 7 +++---- .../include/CGAL/Regular_triangulation_3.h | 21 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 44610ed6de8..7c4239af9b2 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -65,9 +65,8 @@ public: Delaunay_triangulation_cell_base_with_circumcenter_3 (Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) - : Cb(std::move(c)), circumcenter_(nullptr) + : Cb(std::move(c)), circumcenter_(std::exchange(c.circumcenter_, nullptr)) { - std::swap(circumcenter_, c.circumcenter_); } Delaunay_triangulation_cell_base_with_circumcenter_3& @@ -81,8 +80,8 @@ public: Delaunay_triangulation_cell_base_with_circumcenter_3& operator=(Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) { - Delaunay_triangulation_cell_base_with_circumcenter_3 tmp=std::move(c); - std::swap(tmp, *this); + Cb::operator=(std::move(c)); + circumcenter_ = std::exchange(c.circumcenter_, nullptr); return *this; } diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 22122a53e41..8502a68264d 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -205,14 +205,13 @@ public: void swap(Regular_triangulation_3& tr) noexcept(noexcept(this->Tr_Base::swap(tr))) { - // The 'vertices' and 'hidden_points' members of 'hidden_point_visitor' should be empty - // as they are only filled (and cleared) during the insertion of a point. - // Hidden points are not stored there, but rather in cells. Thus, the only thing that must be set - // is the triangulation pointer. - Hidden_point_visitor new_hpv(this); - using std::swap; - swap(hidden_point_visitor, new_hpv); - + // The 'vertices' and 'hidden_points' members of + // 'hidden_point_visitor' should be empty as they are only filled + // (and cleared) during the insertion of a point. Hidden points + // are not stored there, but rather in cells. Thus, the only thing + // that must be set is the triangulation pointer, and it is + // already correctly set. There is nothing to do about + // 'hidden_point_visitor'. Tr_Base::swap(tr); } @@ -224,11 +223,9 @@ public: } Regular_triangulation_3& operator=(Regular_triangulation_3&& tr) - noexcept(noexcept(Regular_triangulation_3(std::move(tr))) && - noexcept(std::declval().swap(*this))) + noexcept(noexcept(Regular_triangulation_3(std::move(tr)))) { - Regular_triangulation_3 copy(std::move(tr)); - copy.swap(*this); + Tr_Base::operator=(std::move(tr)); return *this; } From 24082a71142f11c5b853d6f2b0f822bba6b85ecd Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 12 Feb 2020 16:30:26 +0100 Subject: [PATCH 15/24] Fix compilation errors, with a few compiler ``` include/CGAL/Triangulation_hierarchy_3.h:163:23: error: invalid use of 'this' at top level noexcept(noexcept(this->Tr_Base::swap(tr))) ^~~~ ``` That is actually the subject of a C++ Defect: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1207 Anyway, this was used only for the `noexcept` specification of `swap` functions, and I no longer use `swap` for the move semantic. I can remove those noexcept` specifications. --- Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h | 4 +--- Triangulation_3/include/CGAL/Regular_triangulation_3.h | 1 - Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 9dfb0e4e010..91ca9486b0a 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -133,8 +133,7 @@ public: //Helping void copy_triangulation(const Triangulation_hierarchy_2 &tr); - void swap(Triangulation_hierarchy_2 &tr) - noexcept(noexcept(this->Tr_Base::swap(tr))); + void swap(Triangulation_hierarchy_2 &tr); void clear(); // CHECKING @@ -393,7 +392,6 @@ template void Triangulation_hierarchy_2:: swap(Triangulation_hierarchy_2 &tr) - noexcept(noexcept(this->Tr_Base::swap(tr))) { Tr_Base* temp; Tr_Base::swap(tr); diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 8502a68264d..dfa28cf61e6 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -203,7 +203,6 @@ public: ~Regular_triangulation_3() = default; void swap(Regular_triangulation_3& tr) - noexcept(noexcept(this->Tr_Base::swap(tr))) { // The 'vertices' and 'hidden_points' members of // 'hidden_point_visitor' should be empty as they are only filled diff --git a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index e92fbf94e07..a395e1c13e9 100644 --- a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -160,7 +160,6 @@ public: }; void swap(Triangulation_hierarchy_3 &tr) - noexcept(noexcept(this->Tr_Base::swap(tr))) { Tr_Base::swap(tr); for(int i=1; i Date: Wed, 19 Feb 2020 16:27:10 +0100 Subject: [PATCH 16/24] "Fix" for dumb MSVC compilers https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-5.1-Ic-77/Triangulation_2/TestReport_afabri_x64_Cygwin-Windows10_MSVC2015-Debug-64bits.gz My guess is that the compiler short-circuits `Const &&` when the argument `Const` is `false`, and then the expression `Const && !OtherConst` is no-longer dependent on the argument `OtherConst`. That "fix" just turn `Const && !OtherConst` to `!OtherConst && Const`. --- STL_Extension/include/CGAL/Compact_container.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 86dd6e45fe5..6c135a9f36f 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -886,7 +886,7 @@ namespace internal { // Converting constructor from mutable to constant iterator template CC_iterator(const CC_iterator< - typename std::enable_if<(Const && !OtherConst), DSC>::type, + typename std::enable_if<(!OtherConst && Const), DSC>::type, OtherConst> &const_it) #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP : ts(Time_stamper::time_stamp(const_it.operator->())) @@ -898,7 +898,7 @@ namespace internal { // Assignment operator from mutable to constant iterator template CC_iterator & operator= (const CC_iterator< - typename std::enable_if<(Const && !OtherConst), DSC>::type, + typename std::enable_if<(!OtherConst && Const), DSC>::type, OtherConst> &const_it) { m_ptr.p = const_it.operator->(); From 20910607d50406778149b815bf98b631a229f93b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 21 Feb 2020 14:22:44 +0100 Subject: [PATCH 17/24] std::set and std::map are not nothrow-move-constructible --- .../include/CGAL/_test_cls_const_Del_triangulation_2.h | 9 +++++++-- .../include/CGAL/_test_cls_constrained_triangulation_2.h | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h index 6581267f164..25e9cac0432 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h @@ -30,8 +30,13 @@ template void _test_cls_const_Del_triangulation(const Triangul&) { - static_assert(std::is_nothrow_move_constructible::value, - "move cstr is missing"); + // The following assertion is commented, because, in CT_plus_2, + // one uses `std::set` and `std::map`, and their move-constructors + // may throw. + // + // static_assert(std::is_nothrow_move_constructible::value, + // "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, "move assignment is missing"); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index 1fe1183d3db..0d854e4188e 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -92,8 +92,13 @@ template void _test_cls_constrained_triangulation(const Triang &) { - static_assert(std::is_nothrow_move_constructible::value, - "move cstr is missing"); + // The following assertion is commented, because, in CT_plus_2, + // one uses `std::set` and `std::map`, and their move-constructors + // may throw. + // + // static_assert(std::is_nothrow_move_constructible::value, + // "move cstr is missing"); + static_assert(std::is_nothrow_move_assignable::value, "move assignment is missing"); From a060fb639644ca2742e68b832545c140d03f89e9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 21 Feb 2020 14:23:18 +0100 Subject: [PATCH 18/24] Fix segfault in the dtor of a moved-from Triangulation_hierarchy_2 --- Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 91ca9486b0a..1fbe3957270 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -417,8 +417,8 @@ void Triangulation_hierarchy_2:: clear() { - for(int i=0;iclear(); + for(int i=0;iclear(); } From e3d7f7946db42f52317b23fcc150a39dcde76e53 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 28 Feb 2020 14:01:20 +0100 Subject: [PATCH 19/24] CC_iterator(CC_iterator&&) is now `= default` That fixes a segmentation fault with Visual Studio in Skin Surface Meshing. --- STL_Extension/include/CGAL/Compact_container.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 6c135a9f36f..f6946fc2758 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -908,15 +908,7 @@ namespace internal { return *this; } - CC_iterator(CC_iterator&& it) noexcept -#ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - : ts(Time_stamper::time_stamp(it.operator->())) -#endif - { - m_ptr.p = it.operator->(); - it.m_ptr.p = nullptr; - } - + CC_iterator(CC_iterator&& it) = default; ~CC_iterator() = default; CC_iterator& operator=(const CC_iterator&) = default; CC_iterator& operator=(CC_iterator&&) = default; From 378554e5a748f326a3ca84f17ea43ad8a2becd2a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 6 Mar 2020 16:42:23 +0100 Subject: [PATCH 20/24] Change the API of `for_compact_container`/`Compact_container_traits` Now, we have a proper pair of getter/setter, and the `void` pointer is get by a `reinterpret_cast`, instead of a union. Cc: @mglisse --- .../include/CGAL/Cell_attribute.h | 8 +- Combinatorial_map/include/CGAL/Dart.h | 4 +- .../include/CGAL/Regular_complex_d.h | 4 +- .../include/CGAL/Interval_skip_list.h | 4 +- .../include/CGAL/Compact_mesh_cell_base_3.h | 2 +- .../Periodic_3_triangulation_ds_cell_base_3.h | 2 +- ...eriodic_3_triangulation_ds_vertex_base_3.h | 4 +- .../cc_benchmark.cpp | 2 +- .../STL_Extension/CGAL/Compact_container.h | 13 ++- .../CGAL/Concurrent_compact_container.h | 8 +- .../include/CGAL/Compact_container.h | 99 +++++++++---------- .../CGAL/Concurrent_compact_container.h | 6 +- .../STL_Extension/test_Compact_container.cpp | 2 +- .../test_Compact_container_is_used.cpp | 2 +- .../test_Concurrent_compact_container.cpp | 2 +- .../Concepts/TriangulationDSFaceBase_2.h | 2 +- .../Concepts/TriangulationDSVertexBase_2.h | 2 +- .../CGAL/Triangulation_ds_face_base_2.h | 2 +- .../CGAL/Triangulation_ds_vertex_base_2.h | 2 +- .../Concepts/TriangulationDSCellBase_3.h | 2 +- .../Concepts/TriangulationDSVertexBase_3.h | 2 +- .../CGAL/Triangulation_ds_cell_base_3.h | 2 +- .../CGAL/Triangulation_ds_vertex_base_3.h | 4 +- .../Concepts/TriangulationDSFullCell.h | 2 +- .../Concepts/TriangulationDSVertex.h | 2 +- .../TDS_full_cell_default_storage_policy.h | 2 +- .../include/CGAL/Triangulation_ds_full_cell.h | 2 +- .../include/CGAL/Triangulation_ds_vertex.h | 2 +- .../CGAL/internal/Static_or_dynamic_array.h | 6 +- 29 files changed, 96 insertions(+), 100 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 3b239c5f1f9..db0fe4d3917 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -197,8 +197,8 @@ namespace CGAL { void * for_compact_container() const { return vp; } - void * & for_compact_container() - { return vp; } + void for_compact_container(void *p) + { vp = p; } private: /// Reference counting: the number of darts linked to this cell. @@ -310,8 +310,8 @@ namespace CGAL { void * for_compact_container() const { return mdart.for_compact_container(); } - void * & for_compact_container() - { return mdart.for_compact_container(); } + void for_compact_container(void *p) + { mdart.for_compact_container(p); } private: /// The dart handle associated with the cell. diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 04d2044c481..2b13b9d7911 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -105,8 +105,8 @@ namespace CGAL { void * for_compact_container() const { return mf[0].for_compact_container(); } - void * & for_compact_container() - { return mf[0].for_compact_container(); } + void for_compact_container(void *p) + { mf[0].for_compact_container(p); } Dart_handle get_f(unsigned int i) const { diff --git a/Convex_hull_d/include/CGAL/Regular_complex_d.h b/Convex_hull_d/include/CGAL/Regular_complex_d.h index c0365871c2b..ee50aefc331 100644 --- a/Convex_hull_d/include/CGAL/Regular_complex_d.h +++ b/Convex_hull_d/include/CGAL/Regular_complex_d.h @@ -87,7 +87,7 @@ public: void* pp; void* for_compact_container() const { return pp; } - void* & for_compact_container() { return pp; } + void for_compact_container(void *p) { pp = p; } #ifdef CGAL_USE_LEDA LEDA_MEMORY(RC_vertex_d) @@ -153,7 +153,7 @@ public: void* pp; void* for_compact_container() const { return pp; } - void* & for_compact_container() { return pp; } + void for_compact_container(void *p) { pp = p; } #if 0 struct Point_const_iterator { diff --git a/Interval_skip_list/include/CGAL/Interval_skip_list.h b/Interval_skip_list/include/CGAL/Interval_skip_list.h index 172e48ebf3f..1c13f5d5cde 100644 --- a/Interval_skip_list/include/CGAL/Interval_skip_list.h +++ b/Interval_skip_list/include/CGAL/Interval_skip_list.h @@ -115,7 +115,7 @@ class Interval_for_container : public Interval_ {} void * for_compact_container() const { return p; } - void * & for_compact_container() { return p; } + void for_compact_container(void *ptr) { p = ptr; } }; @@ -457,7 +457,7 @@ class Interval_for_container : public Interval_ public: #ifdef CGAL_ISL_USE_CCC void * for_compact_container() const { return p; } - void * & for_compact_container() { return p; } + void for_compact_container(void *ptr) { p = ptr; } #endif bool operator==(const IntervalListElt& e) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index ae091b60be3..cea2e2405ba 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -491,7 +491,7 @@ public: // For use by Compact_container. void * for_compact_container() const { return N[0].for_compact_container(); } - void * & for_compact_container() { return N[0].for_compact_container(); } + void for_compact_container(void *p) { N[0].for_compact_container(p); } // TDS internal data access functions. TDS_data& tds_data() { return _tds_data; } diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_cell_base_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_cell_base_3.h index f8f32f0e820..e69b2fe8dba 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_cell_base_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_cell_base_3.h @@ -233,7 +233,7 @@ public: // For use by Compact_container. void * for_compact_container() const { return N[0].for_compact_container(); } - void * & for_compact_container() { return N[0].for_compact_container(); } + void for_compact_container(void *p) { N[0].for_compact_container(p); } // TDS internal data access functions. TDS_data& tds_data() { return _tds_data; } diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_vertex_base_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_vertex_base_3.h index 539c3278bf3..e264e523063 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_vertex_base_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_ds_vertex_base_3.h @@ -80,8 +80,8 @@ public: // For use by the Compact_container. void * for_compact_container() const { return _c.for_compact_container(); } - void * & for_compact_container() - { return _c.for_compact_container(); } + void for_compact_container(void *p) + { _c.for_compact_container(p); } private: Cell_handle _c; diff --git a/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp b/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp index 8daa0bcf94e..3158f09b096 100644 --- a/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp +++ b/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp @@ -26,7 +26,7 @@ struct Truc { Truc(int v = 0) : value(v), /*value2(v), */p(NULL) {} void * for_compact_container() const { return p; } - void * & for_compact_container() { return p; } + void for_compact_container(void *ptr) { p = ptr; } int value; int value2; diff --git a/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h b/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h index a4d4d902bb8..b29bdf8887c 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h +++ b/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h @@ -30,10 +30,9 @@ Returns the pointer necessary for `Compact_container_traits`. void * for_compact_container() const; /*! -Returns a reference to the pointer necessary for -`Compact_container_traits`. +Sets the pointer necessary for `Compact_container_traits` to `p`. */ -void * & for_compact_container(); +void for_compact_container(void* p); /// @} @@ -796,7 +795,7 @@ types `T` to make them usable with the default `Compact_container_traits`. `void * t.for_compact_container() const;` -`void *& t.for_compact_container();`. +`void t.for_compact_container(void *);`. */ @@ -820,11 +819,11 @@ static void * pointer(const T &t); /// \name Operations /// @{ /*! -Returns a reference to the pointer held by `t`. -The template version defines this function as: `return t.for_compact_container();` +Sets the pointer held by `t` to `p`. +The template version defines this function as: `t.for_compact_container(p);` */ -static void * & pointer(T &t); + static void set_pointer(T &t, void* p); diff --git a/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h b/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h index 74c2ce4d5d7..8f55b19bb7f 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h @@ -22,7 +22,7 @@ types `T` to make them usable with the default `Concurrent_compact_container`. `T` is any type providing the following member functions: `void * t.for_compact_container() const;` -`void *& t.for_compact_container();`. +`void t.for_compact_container(void *);`. */ template< typename T > struct Concurrent_compact_container_traits { @@ -40,11 +40,11 @@ struct Concurrent_compact_container_traits { /// \name Operations /// @{ /*! - Returns a reference to the pointer held by `t`. - The template version defines this function as: `return t.for_compact_container();` + Sets the pointer held by `t` to `p`. + The template version defines this function as: `t.for_compact_container(p);` */ - static void * & pointer(T &t); + static void set_pointer(T &t, void* p); /// @} diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index f6946fc2758..2781d5befe9 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -149,15 +149,15 @@ public: Compact_container_base() : p(nullptr) {} void * for_compact_container() const { return p; } - void * & for_compact_container() { return p; } + void for_compact_container(void* ptr) { p = ptr; } }; // The traits class describes the way to access the pointer. // It can be specialized. template < class T > struct Compact_container_traits { - static void * pointer(const T &t) { return t.for_compact_container(); } - static void * & pointer(T &t) { return t.for_compact_container(); } + static void * pointer(const T &t) { return t.for_compact_container(); } + static void set_pointer(T &t, void* p) { t.for_compact_container(p); } }; namespace internal { @@ -645,8 +645,8 @@ private: // This out of range compare is always true and causes lots of // unnecessary warnings. // CGAL_precondition(0 <= t && t < 4); - Traits::pointer(*ptr) = reinterpret_cast - (reinterpret_cast(clean_pointer((char *) p)) + (int) t); + Traits::set_pointer(*ptr, reinterpret_cast + (reinterpret_cast(clean_pointer((char *) p)) + (int) t)); } public: @@ -872,7 +872,7 @@ namespace internal { : ts(0) #endif { - m_ptr.p = nullptr; + m_ptr = nullptr; } CC_iterator (const CC_iterator &it) @@ -880,7 +880,7 @@ namespace internal { : ts(Time_stamper::time_stamp(it.operator->())) #endif { - m_ptr.p = it.operator->(); + m_ptr = it.operator->(); } // Converting constructor from mutable to constant iterator @@ -892,7 +892,7 @@ namespace internal { : ts(Time_stamper::time_stamp(const_it.operator->())) #endif { - m_ptr.p = const_it.operator->(); + m_ptr = const_it.operator->(); } // Assignment operator from mutable to constant iterator @@ -901,7 +901,7 @@ namespace internal { typename std::enable_if<(!OtherConst && Const), DSC>::type, OtherConst> &const_it) { - m_ptr.p = const_it.operator->(); + m_ptr = const_it.operator->(); #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP ts = Time_stamper::time_stamp(const_it.operator->()); #endif @@ -920,7 +920,7 @@ namespace internal { #endif { CGAL_assertion (n == nullptr); - m_ptr.p = nullptr; + m_ptr = nullptr; } private: @@ -929,10 +929,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP std::size_t ts; #endif - union { - pointer p; - void *vp; - } m_ptr; + pointer m_ptr; // Only Compact_container and Concurrent_compact_container should // access these constructors. @@ -948,16 +945,16 @@ namespace internal { : ts(0) #endif { - m_ptr.p = ptr; - if (m_ptr.p == nullptr) // empty container. + m_ptr = ptr; + if (m_ptr == nullptr) // empty container. return; - ++(m_ptr.p); // if not empty, p = start - if (DSC::type(m_ptr.p) == DSC::FREE) + ++(m_ptr); // if not empty, p = start + if (DSC::type(m_ptr) == DSC::FREE) increment(); #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP else - ts = Time_stamper::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr); #endif // CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP } @@ -967,10 +964,10 @@ namespace internal { : ts(0) #endif { - m_ptr.p = ptr; + m_ptr = ptr; #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP if(ptr != nullptr){ - ts = Time_stamper::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr); } #endif // end CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP } @@ -979,49 +976,49 @@ namespace internal { void increment() { // It's either pointing to end(), or valid. - CGAL_assertion_msg(m_ptr.p != nullptr, + CGAL_assertion_msg(m_ptr != nullptr, "Incrementing a singular iterator or an empty container iterator ?"); - CGAL_assertion_msg(DSC::type(m_ptr.p) != DSC::START_END, + CGAL_assertion_msg(DSC::type(m_ptr) != DSC::START_END, "Incrementing end() ?"); // If it's not end(), then it's valid, we can do ++. do { - ++(m_ptr.p); - if (DSC::type(m_ptr.p) == DSC::USED || - DSC::type(m_ptr.p) == DSC::START_END) + ++(m_ptr); + if (DSC::type(m_ptr) == DSC::USED || + DSC::type(m_ptr) == DSC::START_END) { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - ts = Time_stamper::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr); #endif return; } - if (DSC::type(m_ptr.p) == DSC::BLOCK_BOUNDARY) - m_ptr.p = DSC::clean_pointee(m_ptr.p); + if (DSC::type(m_ptr) == DSC::BLOCK_BOUNDARY) + m_ptr = DSC::clean_pointee(m_ptr); } while (true); } void decrement() { // It's either pointing to end(), or valid. - CGAL_assertion_msg(m_ptr.p != nullptr, + CGAL_assertion_msg(m_ptr != nullptr, "Decrementing a singular iterator or an empty container iterator ?"); - CGAL_assertion_msg(DSC::type(m_ptr.p - 1) != DSC::START_END, + CGAL_assertion_msg(DSC::type(m_ptr - 1) != DSC::START_END, "Decrementing begin() ?"); // If it's not begin(), then it's valid, we can do --. do { - --m_ptr.p; - if (DSC::type(m_ptr.p) == DSC::USED || - DSC::type(m_ptr.p) == DSC::START_END) + --m_ptr; + if (DSC::type(m_ptr) == DSC::USED || + DSC::type(m_ptr) == DSC::START_END) { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - ts = Time_stamper::time_stamp(m_ptr.p); + ts = Time_stamper::time_stamp(m_ptr); #endif return; } - if (DSC::type(m_ptr.p) == DSC::BLOCK_BOUNDARY) - m_ptr.p = DSC::clean_pointee(m_ptr.p); + if (DSC::type(m_ptr) == DSC::BLOCK_BOUNDARY) + m_ptr = DSC::clean_pointee(m_ptr); } while (true); } @@ -1029,9 +1026,9 @@ namespace internal { Self & operator++() { - CGAL_assertion_msg(m_ptr.p != nullptr, + CGAL_assertion_msg(m_ptr != nullptr, "Incrementing a singular iterator or an empty container iterator ?"); - /* CGAL_assertion_msg(DSC::type(m_ptr.p) == DSC::USED, + /* CGAL_assertion_msg(DSC::type(m_ptr) == DSC::USED, "Incrementing an invalid iterator."); */ increment(); return *this; @@ -1039,10 +1036,10 @@ namespace internal { Self & operator--() { - CGAL_assertion_msg(m_ptr.p != nullptr, + CGAL_assertion_msg(m_ptr != nullptr, "Decrementing a singular iterator or an empty container iterator ?"); - /*CGAL_assertion_msg(DSC::type(m_ptr.p) == DSC::USED - || DSC::type(m_ptr.p) == DSC::START_END, + /*CGAL_assertion_msg(DSC::type(m_ptr) == DSC::USED + || DSC::type(m_ptr) == DSC::START_END, "Decrementing an invalid iterator.");*/ decrement(); return *this; @@ -1054,13 +1051,13 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP bool is_time_stamp_valid() const { - return (ts == 0) || (ts == Time_stamper::time_stamp(m_ptr.p)); + return (ts == 0) || (ts == Time_stamper::time_stamp(m_ptr)); } #endif // CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - reference operator*() const { return *(m_ptr.p); } + reference operator*() const { return *(m_ptr); } - pointer operator->() const { return (m_ptr.p); } + pointer operator->() const { return (m_ptr); } // For std::less... bool operator<(const CC_iterator& other) const @@ -1068,7 +1065,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper::less(m_ptr.p, other.m_ptr.p); + return Time_stamper::less(m_ptr, other.m_ptr); } bool operator>(const CC_iterator& other) const @@ -1076,7 +1073,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper::less(other.m_ptr.p, m_ptr.p); + return Time_stamper::less(other.m_ptr, m_ptr); } bool operator<=(const CC_iterator& other) const @@ -1084,7 +1081,7 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper::less(m_ptr.p, other.m_ptr.p) + return Time_stamper::less(m_ptr, other.m_ptr) || (*this == other); } @@ -1093,13 +1090,13 @@ namespace internal { #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP assert( is_time_stamp_valid() ); #endif - return Time_stamper::less(other.m_ptr.p, m_ptr.p) + return Time_stamper::less(other.m_ptr, m_ptr) || (*this == other); } // Can itself be used for bit-squatting. - void * for_compact_container() const { return (m_ptr.vp); } - void * & for_compact_container() { return (m_ptr.vp); } + void * for_compact_container() const { return m_ptr; } + void for_compact_container(void* p) { m_ptr = static_cast(p); } }; template < class DSC, bool Const1, bool Const2 > diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index e968312c453..4d644e547b8 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -66,7 +66,7 @@ template class has_##X { \ template < class T > struct Concurrent_compact_container_traits { static void * pointer(const T &t) { return t.for_compact_container(); } - static void * & pointer(T &t) { return t.for_compact_container(); } + static void set_pointer(T &t, void* p) { t.for_compact_container(p); } }; namespace CCC_internal { @@ -613,8 +613,8 @@ private: // This out of range compare is always true and causes lots of // unnecessary warnings. // CGAL_precondition(0 <= t && t < 4); - Traits::pointer(*ptr) = reinterpret_cast - (reinterpret_cast(clean_pointer((char *) p)) + (int) t); + Traits::set_pointer(*ptr, reinterpret_cast + (reinterpret_cast(clean_pointer((char *) p)) + (int) t)); } typedef tbb::queuing_mutex Mutex; diff --git a/STL_Extension/test/STL_Extension/test_Compact_container.cpp b/STL_Extension/test/STL_Extension/test_Compact_container.cpp index 3d370105a6a..e84d79fecfc 100644 --- a/STL_Extension/test/STL_Extension/test_Compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Compact_container.cpp @@ -72,7 +72,7 @@ public: bool operator< (const Node_2 &n) const { return rnd < n.rnd; } void * for_compact_container() const { return p_cc; } - void * & for_compact_container() { return p_cc; } + void for_compact_container(void *p) { p_cc = p; } }; template < class Cont > diff --git a/STL_Extension/test/STL_Extension/test_Compact_container_is_used.cpp b/STL_Extension/test/STL_Extension/test_Compact_container_is_used.cpp index aac89dc61d5..2d810602cde 100644 --- a/STL_Extension/test/STL_Extension/test_Compact_container_is_used.cpp +++ b/STL_Extension/test/STL_Extension/test_Compact_container_is_used.cpp @@ -15,7 +15,7 @@ public: {} void * for_compact_container() const { return p_cc; } - void * & for_compact_container() { return p_cc; } + void for_compact_container(void *p) { p_cc = p; } }; int main() diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 84a65304eb1..95f92dba74c 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -67,7 +67,7 @@ public: bool operator< (const Node_2 &n) const { return rnd < n.rnd; } void * for_compact_container() const { return p_cc; } - void * & for_compact_container() { return p_cc; } + void for_compact_container(void *p) { p_cc = p; } }; template < class Cont > diff --git a/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h b/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h index 8ef6ea99deb..71ae4e585af 100644 --- a/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h +++ b/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h @@ -183,7 +183,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void *p); /// @} diff --git a/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h b/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h index e7915a48888..dcd30aa9f07 100644 --- a/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h +++ b/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h @@ -118,7 +118,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void* p); /// @} diff --git a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h index 8de378eec8f..8aeb12f876e 100644 --- a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h +++ b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h @@ -79,7 +79,7 @@ public: // For use by Compact_container. void * for_compact_container() const {return N[0].for_compact_container(); } - void * & for_compact_container() { return N[0].for_compact_container();} + void for_compact_container(void* p) { N[0].for_compact_container(p);} static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);} diff --git a/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h b/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h index 6b4906e6566..ceabf7c4294 100644 --- a/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h +++ b/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h @@ -49,7 +49,7 @@ public: // For use by the Compact_container. void * for_compact_container() const { return _f.for_compact_container(); } - void * & for_compact_container() { return _f.for_compact_container(); } + void for_compact_container(void* p) { _f.for_compact_container(p); } private: Face_handle _f; diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h index 2856e1d70bd..9b9bffacd71 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h @@ -136,7 +136,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void *p); /// @} diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h index e1d35cb88fc..c7b68ec9175 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h @@ -116,7 +116,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void *); /*! Inputs the non-combinatorial information given by the vertex. diff --git a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h index e6ad17ca862..f8449c7eb8c 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h @@ -180,7 +180,7 @@ public: // For use by Compact_container. void * for_compact_container() const { return N[0].for_compact_container(); } - void * & for_compact_container() { return N[0].for_compact_container(); } + void for_compact_container(void* p) { N[0].for_compact_container(p); } // TDS internal data access functions. TDS_data& tds_data() { return _tds_data; } diff --git a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h index d6c5d38a057..f338340b50a 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h @@ -59,8 +59,8 @@ public: // For use by the Compact_container. void * for_compact_container() const { return _c.for_compact_container(); } - void * & for_compact_container() - { return _c.for_compact_container(); } + void for_compact_container(void* p) + { _c.for_compact_container(p); } private: Cell_handle _c; diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h b/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h index df05688010a..b25a2a7a81c 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h @@ -107,7 +107,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void *p); /// @} diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h b/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h index 0366254ca89..903da560d1c 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h @@ -106,7 +106,7 @@ void * for_compact_container() const; /*! */ -void * & for_compact_container(); +void for_compact_container(void *p); /// @} diff --git a/Triangulation/include/CGAL/TDS_full_cell_default_storage_policy.h b/Triangulation/include/CGAL/TDS_full_cell_default_storage_policy.h index d5f0735c8e8..3b6508f6017 100644 --- a/Triangulation/include/CGAL/TDS_full_cell_default_storage_policy.h +++ b/Triangulation/include/CGAL/TDS_full_cell_default_storage_policy.h @@ -44,7 +44,7 @@ struct TFC_data< Vertex_handle, Full_cell_handle, Dimen, TDS_full_cell_default_s : vertices_(dmax+1), neighbors_(dmax+1) {} void* for_compact_container() const { return vertices_.for_compact_container(); } - void* & for_compact_container() { return vertices_.for_compact_container(); } + void for_compact_container(void *p){ vertices_.for_compact_container(p); } int dimension() const { return ( vertices_.size() - 1 ); } void set_mirror_index(const int, const int) {} #ifdef BOOST_NO_INT64_T diff --git a/Triangulation/include/CGAL/Triangulation_ds_full_cell.h b/Triangulation/include/CGAL/Triangulation_ds_full_cell.h index 125cc2e443f..83b48a441d5 100644 --- a/Triangulation/include/CGAL/Triangulation_ds_full_cell.h +++ b/Triangulation/include/CGAL/Triangulation_ds_full_cell.h @@ -204,7 +204,7 @@ public: TDS_data & tds_data() { return tds_data_; } /* Concept */ void* for_compact_container() const { return combinatorics_.for_compact_container(); } - void* & for_compact_container() { return combinatorics_.for_compact_container(); } + void for_compact_container(void* p){ combinatorics_.for_compact_container(p); } bool is_valid(bool verbose = false, int = 0) const /* Concept */ { diff --git a/Triangulation/include/CGAL/Triangulation_ds_vertex.h b/Triangulation/include/CGAL/Triangulation_ds_vertex.h index a4f47d05647..c57bfbed51a 100644 --- a/Triangulation/include/CGAL/Triangulation_ds_vertex.h +++ b/Triangulation/include/CGAL/Triangulation_ds_vertex.h @@ -102,7 +102,7 @@ public: public: // FOR MEMORY MANAGEMENT void* for_compact_container() const { return full_cell_.for_compact_container(); } - void* & for_compact_container() { return full_cell_.for_compact_container(); } + void for_compact_container(void *p){ full_cell_.for_compact_container(p); } }; // end of Triangulation_ds_vertex diff --git a/Triangulation/include/CGAL/internal/Static_or_dynamic_array.h b/Triangulation/include/CGAL/internal/Static_or_dynamic_array.h index f198464e874..54fca5abaea 100644 --- a/Triangulation/include/CGAL/internal/Static_or_dynamic_array.h +++ b/Triangulation/include/CGAL/internal/Static_or_dynamic_array.h @@ -66,9 +66,9 @@ struct S_or_D_array< Containee, Dimension_tag< D >, WithCompactContainerHelper > { return (*this)[0].for_compact_container(); } - void* & for_compact_container() + void for_compact_container(void *p) { - return (*this)[0].for_compact_container(); + (*this)[0].for_compact_container(p); } }; @@ -101,7 +101,7 @@ struct S_or_D_array< Containee, Dynamic_dimension_tag, true > {} void* fcc_; void* for_compact_container() const { return fcc_; } - void* & for_compact_container() { return fcc_; } + void for_compact_container(void* p) { fcc_ = p; } }; } // end of namespace internal From 1eba82246e824cfa10934ad750ce781d325d84e6 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 9 Mar 2020 17:35:12 +0100 Subject: [PATCH 21/24] Rule of zero for CC_iterator This commit is the one fixing the mis-compilation by MSVC 2015. --- STL_Extension/include/CGAL/Compact_container.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 2781d5befe9..1536c229ded 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -875,14 +875,6 @@ namespace internal { m_ptr = nullptr; } - CC_iterator (const CC_iterator &it) -#ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP - : ts(Time_stamper::time_stamp(it.operator->())) -#endif - { - m_ptr = it.operator->(); - } - // Converting constructor from mutable to constant iterator template CC_iterator(const CC_iterator< @@ -908,11 +900,6 @@ namespace internal { return *this; } - CC_iterator(CC_iterator&& it) = default; - ~CC_iterator() = default; - CC_iterator& operator=(const CC_iterator&) = default; - CC_iterator& operator=(CC_iterator&&) = default; - // Construction from nullptr CC_iterator (std::nullptr_t CGAL_assertion_code(n)) #ifdef CGAL_COMPACT_CONTAINER_DEBUG_TIME_STAMP From d1a323c730050c74ca0d31c303e7f06bd37a2c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 26 Mar 2020 19:24:14 +0100 Subject: [PATCH 22/24] extra run of the script to remove tabs and trailing whitespaces --- .../include/CGAL/Cell_attribute.h | 6 +- Combinatorial_map/include/CGAL/Dart.h | 2 +- .../include/CGAL/Regular_complex_d.h | 160 ++-- .../include/CGAL/Interval_skip_list.h | 640 ++++++------- .../include/CGAL/Compact_mesh_cell_base_3.h | 12 +- .../cc_benchmark.cpp | 10 +- .../STL_Extension/CGAL/Compact_container.h | 850 +++++++++--------- .../CGAL/Concurrent_compact_container.h | 348 +++---- .../CGAL/Concurrent_compact_container.h | 2 +- .../STL_Extension/test_Compact_container.cpp | 2 +- .../test_Concurrent_compact_container.cpp | 30 +- .../Concepts/TriangulationDSFaceBase_2.h | 186 ++-- .../Concepts/TriangulationDSVertexBase_2.h | 126 +-- .../CGAL/Triangulation_data_structure_2.h | 670 +++++++------- .../CGAL/Triangulation_ds_face_base_2.h | 132 +-- .../CGAL/Triangulation_ds_vertex_base_2.h | 6 +- .../test/TDS_2/include/CGAL/_test_cls_tds_2.h | 138 +-- .../Concepts/TriangulationDSCellBase_3.h | 110 +-- .../Concepts/TriangulationDSVertexBase_3.h | 94 +- .../CGAL/Triangulation_data_structure_3.h | 172 ++-- .../CGAL/Triangulation_ds_cell_base_3.h | 4 +- .../CGAL/Triangulation_ds_vertex_base_3.h | 10 +- .../test/TDS_3/include/CGAL/_test_cls_tds_3.h | 96 +- .../Concepts/TriangulationDSFullCell.h | 60 +- .../Concepts/TriangulationDSVertex.h | 62 +- .../include/CGAL/Triangulation_ds_vertex.h | 2 +- .../CGAL/Constrained_triangulation_plus_2.h | 300 +++---- .../include/CGAL/Delaunay_triangulation_2.h | 4 +- .../Polyline_constraint_hierarchy_2.h | 202 ++--- .../include/CGAL/Triangulation_hierarchy_2.h | 162 ++-- .../Triangulation_hierarchy_vertex_base_2.h | 2 +- .../_test_cls_const_Del_triangulation_2.h | 40 +- .../_test_cls_constrained_triangulation_2.h | 42 +- .../CGAL/_test_cls_delaunay_triangulation_2.h | 66 +- .../include/CGAL/_test_cls_triangulation_2.h | 190 ++-- .../include/CGAL/_test_traits.h | 88 +- .../include/CGAL/Delaunay_triangulation_3.h | 4 +- ...angulation_cell_base_with_circumcenter_3.h | 4 +- .../include/CGAL/Regular_triangulation_3.h | 4 +- .../include/CGAL/Triangulation_hierarchy_3.h | 98 +- .../include/CGAL/_test_cls_delaunay_3.h | 200 ++--- .../include/CGAL/_test_cls_regular_3.h | 98 +- .../include/CGAL/_test_cls_triangulation_3.h | 246 ++--- 43 files changed, 2840 insertions(+), 2840 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index db0fe4d3917..8fa4def7b3c 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -86,8 +86,8 @@ namespace CGAL { protected: void set_id(std::size_t id) { m_id=id; } - - protected: + + protected: /// id of the cell std::size_t m_id; }; @@ -96,7 +96,7 @@ namespace CGAL { template <> class Add_id {}; - + /// Cell_attribute_without_info template diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 2b13b9d7911..bfc21e7b25a 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -113,7 +113,7 @@ namespace CGAL { assert(i<=dimension); return mf[i]; } - + protected: /** Default constructor: no real initialisation, * because this is done in the combinatorial map class. diff --git a/Convex_hull_d/include/CGAL/Regular_complex_d.h b/Convex_hull_d/include/CGAL/Regular_complex_d.h index ee50aefc331..4a5a32b1213 100644 --- a/Convex_hull_d/include/CGAL/Regular_complex_d.h +++ b/Convex_hull_d/include/CGAL/Regular_complex_d.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Michael Seel //--------------------------------------------------------------------- @@ -49,13 +49,13 @@ template class Regular_complex_d; template class Convex_hull_d; #define forall_rc_vertices(x,RC)\ -for(x = (RC).vertices_begin(); x != (RC).vertices_end(); ++x) +for(x = (RC).vertices_begin(); x != (RC).vertices_end(); ++x) #define forall_rc_simplices(x,RC)\ -for(x = (RC).simplices_begin(); x != (RC).simplices_end(); ++x) +for(x = (RC).simplices_begin(); x != (RC).simplices_end(); ++x) template -class RC_vertex_d +class RC_vertex_d { typedef RC_vertex_d Self; typedef typename Refs::Point_d Point_d; @@ -96,7 +96,7 @@ public: template -class RC_simplex_d +class RC_simplex_d { typedef RC_simplex_d Self; typedef typename Refs::Point_d Point_d; typedef typename Refs::Vertex_handle Vertex_handle; @@ -107,7 +107,7 @@ class RC_simplex_d protected: std::vector vertices; // array of vertices std::vector neighbors; // opposite simplices - std::vector opposite_vertices; + std::vector opposite_vertices; // indices of opposite vertices //------ only for convex hulls ------------------ @@ -122,7 +122,7 @@ protected: void set_vertex(int i, Vertex_handle v) { vertices[i] = v; } void set_neighbor(int i, Simplex_handle s) { neighbors[i]=s; } - void set_opposite_vertex_index(int i, int index) + void set_opposite_vertex_index(int i, int index) { opposite_vertices[i]=index; } //------ only for convex hulls ------------------ @@ -132,23 +132,23 @@ protected: //------ only for convex hulls ------------------ public: - typedef typename std::vector::const_iterator + typedef typename std::vector::const_iterator VIV_iterator; struct Point_from_VIV_iterator { typedef Vertex_handle argument_type; typedef Point_d result_type; - result_type& operator()(argument_type& x) const + result_type& operator()(argument_type& x) const { return x->point(); } - const result_type& operator()(const argument_type& x) const + const result_type& operator()(const argument_type& x) const { return x->point(); } }; typedef CGAL::Iterator_project Point_const_iterator; - Point_const_iterator points_begin() const + Point_const_iterator points_begin() const { return Point_const_iterator(vertices.begin()); } - Point_const_iterator points_end() const + Point_const_iterator points_end() const { return Point_const_iterator(vertices.end()); } void* pp; @@ -164,12 +164,12 @@ public: typedef const Point_d* pointer; typedef const Point_d& reference; - typedef typename std::vector::const_iterator + typedef typename std::vector::const_iterator ra_vertex_iterator; Point_const_iterator() : _it() {} Point_const_iterator(ra_vertex_iterator it) : _it(it) {} - + value_type operator*() const { return (*_it)->point(); } pointer operator->() const { return &(operator*()); } @@ -180,9 +180,9 @@ public: self& operator+=(difference_type i) { _it+=i; return *this; } self& operator-=(difference_type i) { _it-=i; return *this; } - self operator+(difference_type i) const + self operator+(difference_type i) const { self tmp=*this; tmp+=i; return tmp; } - self operator-(difference_type i) const + self operator-(difference_type i) const { self tmp=*this; tmp-=i; return tmp; } difference_type operator-(self x) const { return _it-x._it; } @@ -193,28 +193,28 @@ public: bool operator<(self x) const { (x - *this) > 0; } private: - ra_vertex_iterator _it; + ra_vertex_iterator _it; }; // Point_const_iterator - Point_const_iterator points_begin() const + Point_const_iterator points_begin() const { return Point_const_iterator(vertices.begin()); } - Point_const_iterator points_end() const + Point_const_iterator points_end() const { return Point_const_iterator(vertices.end()); } #endif - + RC_simplex_d() : pp(nullptr) {} - RC_simplex_d(int dmax) : + RC_simplex_d(int dmax) : vertices(dmax+1), neighbors(dmax+1), opposite_vertices(dmax+1), pp(nullptr) - { for (int i = 0; i <= dmax; i++) { - neighbors[i] = Simplex_handle(); - vertices[i] = Vertex_handle(); + { for (int i = 0; i <= dmax; i++) { + neighbors[i] = Simplex_handle(); + vertices[i] = Vertex_handle(); opposite_vertices[i] = -1; } visited_ = false; } - ~RC_simplex_d() {} + ~RC_simplex_d() {} void print(std::ostream& O=std::cout) const { @@ -228,10 +228,10 @@ public: } #ifdef CGAL_USE_LEDA - LEDA_MEMORY(RC_simplex_d) + LEDA_MEMORY(RC_simplex_d) #endif -}; +}; template std::ostream& operator<<(std::ostream& O, const RC_simplex_d& s) @@ -239,7 +239,7 @@ std::ostream& operator<<(std::ostream& O, const RC_simplex_d& s) /*{\Manpage {Regular_complex_d}{R}{Regular Simplicial Complex}{C}}*/ -/*{\Mdefinition +/*{\Mdefinition An instance |\Mvar| of type |\Mname| is a regular abstract or concrete simplicial complex. An abstract simplicial complex is a family |\Mvar| @@ -255,7 +255,7 @@ neighbors if they share $k-1$ vertices. A complex is connected if its set of maximal simplices forms a connected set under the neighboring relation. A simplicial complex is called \emph{regular} if all maximal simplices in the complex have the same dimension and if the -complex is connected. +complex is connected. A concrete simplicial complex is an abstract simplicial complex in which a point in some ambient space is associated with each vertex. @@ -275,7 +275,7 @@ All maximal simplices in a regular simplicial complex have the same dimension, which we denote |dcur|. For each maximal simplex\cgalFootnote{we drop the adjective maximal in the sequel} in |\Mvar| there is an item of type |RC_simplex_d| and for each vertex -there is an item of type |rc_vertex|. Each maximal simplex has |1+dcur| +there is an item of type |rc_vertex|. Each maximal simplex has |1+dcur| vertices indexed from $0$ to |dcur|. For any simplex $s$ and any index $i$, |C.vertex_of(s,i)| returns the $i$-th vertex of $s$. There may or may not be a simplex $t$ opposite to (the vertex with index) @@ -286,7 +286,7 @@ set. The function |C.opposite(s,i)| returns $t$ if it exists and returns |nil| otherwise. If $t$ exists then $s$ and $t$ share |dcur| vertices, namely all but vertex $i$ of $s$ and vertex |C.opposite_vertex(s,i)| of $t$. Assume that $t = |C.opposite(s,i)|$ -exists and let |j = C.opposite_vertex(s,i)|. Then |s = C.opposite(t,j)| +exists and let |j = C.opposite_vertex(s,i)|. Then |s = C.opposite(t,j)| and |i = C.opposite_vertex(t,j)| and \begin{eqnarray*} \lefteqn{\{|C.vertex_of(s,0)|,|C.vertex_of(s,1)|,\ldots, @@ -318,7 +318,7 @@ sharing a face. template class Regular_complex_d -{ +{ typedef Regular_complex_d Self; public: /*{\Mtypes 4}*/ @@ -364,11 +364,11 @@ protected: private: - Regular_complex_d(const Regular_complex_d& ); - Regular_complex_d& operator=(const Regular_complex_d& ); + Regular_complex_d(const Regular_complex_d& ); + Regular_complex_d& operator=(const Regular_complex_d& ); void clean_dynamic_memory() - { + { vertices_.clear(); simplices_.clear(); } @@ -377,7 +377,7 @@ public: /*{\Mcreation}*/ -Regular_complex_d(int d = 2, const R& Kernel = R()) +Regular_complex_d(int d = 2, const R& Kernel = R()) /*{\Mcreate creates an instance |\Mvar| of type |\Mtype|. The dimension of the underlying space is $d$ and |\Mvar| is initialized to the empty regular complex. Thus |dcur| equals $-1$. The traits class @@ -399,7 +399,7 @@ the traits class is to be found at the end of this manual page.}*/ /* In the destructor for |Regular_complex_d|, we have to release the storage which was allocated for the simplices and the vertices. */ -/*{\Mtext The data type |\Mtype| offers neither copy constructor nor +/*{\Mtext The data type |\Mtype| offers neither copy constructor nor assignment operator.}*/ /*{\Moperations 3 3}*/ @@ -412,39 +412,39 @@ int current_dimension() const { return dcur; } /*{\Mop returns the current dimension of the simplices in the complex.}*/ -Vertex_handle vertex(Simplex_handle s, int i) const +Vertex_handle vertex(Simplex_handle s, int i) const /*{\Mop returns the $i$-th vertex of $s$.\\ \precond $0 \leq i \leq |current_dimension|$. }*/ { CGAL_assertion(0<=i&&i<=dcur); return s->vertex(i); } -Vertex_const_handle vertex(Simplex_const_handle s, int i) const +Vertex_const_handle vertex(Simplex_const_handle s, int i) const { CGAL_assertion(0<=i&&i<=dcur); return s->vertex(i); } -Point_d associated_point(Vertex_handle v) const +Point_d associated_point(Vertex_handle v) const /*{\Mop returns the point associated with vertex |v|.}*/ { return v->point(); } -Point_d associated_point(Vertex_const_handle v) const +Point_d associated_point(Vertex_const_handle v) const { return v->point(); } -int index(Vertex_handle v) const +int index(Vertex_handle v) const /*{\Mop returns the index of $v$ in |C.simplex(v)|.}*/ { return v->index(); } -int index(Vertex_const_handle v) const +int index(Vertex_const_handle v) const { return v->index(); } -Simplex_handle simplex(Vertex_handle v) const +Simplex_handle simplex(Vertex_handle v) const /*{\Mop returns a simplex of which $v$ is a vertex. Note that this simplex is not unique. }*/ -{ return v->simplex(); } +{ return v->simplex(); } -Simplex_const_handle simplex(Vertex_const_handle v) const -{ return v->simplex(); } +Simplex_const_handle simplex(Vertex_const_handle v) const +{ return v->simplex(); } Point_d associated_point(Simplex_handle s, int i) const /*{\Mop same as |C.associated_point(C.vertex(s,i))|.}*/ @@ -453,13 +453,13 @@ Point_d associated_point(Simplex_handle s, int i) const Point_d associated_point(Simplex_const_handle s, int i) const { return associated_point(vertex(s,i)); } -Simplex_handle opposite_simplex(Simplex_handle s,int i) const +Simplex_handle opposite_simplex(Simplex_handle s,int i) const /*{\Mop returns the simplex opposite to the $i$-th vertex of $s$ (|Simplex_handle()| is there is no such simplex).\\ \precond $0 \leq i \leq |dcur|$. }*/ { CGAL_assertion(0<=i&&i<=dcur); return s->neighbor(i); } -Simplex_const_handle opposite_simplex(Simplex_const_handle s,int i) const +Simplex_const_handle opposite_simplex(Simplex_const_handle s,int i) const { CGAL_assertion(0<=i&&i<=dcur); return s->neighbor(i); } @@ -484,35 +484,35 @@ to be used with care as they may invalidate the data structure.}*/ void clear(int d = 0) /*{\Mop reinitializes |\Mvar| to the empty complex in dimension |dim|.}*/ { clean_dynamic_memory(); - dmax = d; dcur = -1; + dmax = d; dcur = -1; } void set_current_dimension(int d) { dcur = d; } /*{\Mop sets |dcur| to |d|. }*/ -Simplex_handle new_simplex() +Simplex_handle new_simplex() /*{\Mop adds a new simplex to |\Mvar| and returns it. The new simplex has no vertices yet.}*/ -{ +{ Simplex s(dmax); Simplex_handle h = simplices_.insert(s); return h; } -Vertex_handle new_vertex() +Vertex_handle new_vertex() /*{\Mop adds a new vertex to |\Mvar| and returns it. The new vertex has no associated simplex nor index yet. The associated point is the point |Regular_complex_d::nil_point| which is a static member of class |Regular_complex_d.|}*/ -{ - return vertices_.emplace(nil_point); +{ + return vertices_.emplace(nil_point); } -Vertex_handle new_vertex(const Point_d& p) +Vertex_handle new_vertex(const Point_d& p) /*{\Mop adds a new vertex to |\Mvar| and returns it. The new vertex has |p| as the associated point, but is has no associated simplex nor index yet.}*/ -{ +{ return vertices_.emplace(p); } @@ -520,7 +520,7 @@ void associate_vertex_with_simplex(Simplex_handle s, int i, Vertex_handle v) /*{\Mop sets the $i$-th vertex of |s| to |v| and records this fact in $v$. The latter occurs only if $v$ is non-nil.}*/ { s -> set_vertex(i,v); - if ( v != Vertex_handle() ) { + if ( v != Vertex_handle() ) { v -> set_simplex(s); v -> set_index(i); } } @@ -563,7 +563,7 @@ Size_type number_of_vertices() const { return this->vertices_.size();} Size_type number_of_simplices() const { return this->simplices_.size();} void print_statistics(std::ostream& os = std::cout) const -{ +{ os << "Regular_complex_d - statistic" << std::endl; os << "number of vertices = " << number_of_vertices() << std::endl; os << "number of simplices = " << number_of_simplices() << std::endl; @@ -595,7 +595,7 @@ std::list all_simplices() forall_rc_simplices(it,*this) res.push_back(it); return res; } -std::list all_simplices() const +std::list all_simplices() const { std::list res; Simplex_const_iterator it; forall_rc_simplices(it,*this) res.push_back(it); return res; } @@ -606,7 +606,7 @@ std::list all_vertices() forall_rc_vertices(it,*this) res.push_back(it); return res; } -std::list all_vertices() const +std::list all_vertices() const { std::list res; Vertex_const_iterator it; forall_rc_vertices(it,*this) res.push_back(it); return res; } @@ -619,18 +619,18 @@ static const Point_d nil_point; }; // Regular_complex_d // init static member: -template +template const typename Regular_complex_d::Point_d Regular_complex_d::nil_point; template void Regular_complex_d::check_topology() const -{ - Simplex_const_handle s,t; +{ + Simplex_const_handle s,t; Vertex_const_handle v; - int i,j,k; + int i,j,k; if (dcur == -1) { - if (!vertices_.empty() || !simplices_.empty() ) + if (!vertices_.empty() || !simplices_.empty() ) CGAL_error_msg( "check_topology: dcur is -1 but there are vertices or simplices"); } @@ -643,26 +643,26 @@ void Regular_complex_d::check_topology() const for(i = 0; i <= dcur; i++) { for (j = i + 1; j <= dcur; j++) { if (vertex(s,i) == vertex(s,j)) - CGAL_error_msg( "check_topology: a simplex with two equal vertices"); + CGAL_error_msg( "check_topology: a simplex with two equal vertices"); } } } forall_rc_simplices(s,*this) { for(i = 0; i <= dcur; i++) { - if ((t = opposite_simplex(s,i)) != Simplex_const_handle()) { - int l = index_of_opposite_vertex(s,i); - if (s != opposite_simplex(t,l) || + if ((t = opposite_simplex(s,i)) != Simplex_const_handle()) { + int l = index_of_opposite_vertex(s,i); + if (s != opposite_simplex(t,l) || i != index_of_opposite_vertex(t,l)) - CGAL_error_msg( "check_topology: neighbor relation is not symmetric"); + CGAL_error_msg( "check_topology: neighbor relation is not symmetric"); for (j = 0; j <= dcur; j++) { if (j != i) { // j must also occur as a vertex of t - for (k = 0; k <= dcur && + for (k = 0; k <= dcur && ( vertex(s,j) != vertex(t,k) || k == l); k++) {} - if (k > dcur) - CGAL_error_msg( "check_topology: too few shared vertices."); + if (k > dcur) + CGAL_error_msg( "check_topology: too few shared vertices."); } } } @@ -672,11 +672,11 @@ void Regular_complex_d::check_topology() const template void Regular_complex_d::check_topology_and_geometry() const -{ +{ check_topology(); Vertex_const_handle v; forall_rc_vertices(v,*this) { - if ( v == Vertex_const_handle() || + if ( v == Vertex_const_handle() || associated_point(v).identical(Regular_complex_d::nil_point) ) CGAL_error_msg("check_topology_and_geometry: \ vertex with nil_point or no associated point."); @@ -687,7 +687,7 @@ void Regular_complex_d::check_topology_and_geometry() const Simplex_const_handle s; forall_rc_simplices(s,*this) { std::vector A(dcur + 1); - for (int i = 0; i <= dcur; i++) + for (int i = 0; i <= dcur; i++) A[i] = associated_point(s,i); if ( !affinely_independent(A.begin(),A.end()) ) CGAL_error_msg("check_topology_and_geometry: \ @@ -696,13 +696,13 @@ void Regular_complex_d::check_topology_and_geometry() const } -/*{\Mtext +/*{\Mtext \headerline{Iteration Statements} -{\bf forall\_rc\_simplices}($s,C$) +{\bf forall\_rc\_simplices}($s,C$) $\{$ ``the simplices of $C$ are successively assigned to $s$'' $\}$ -{\bf forall\_rc\_vertices}($v,C$) +{\bf forall\_rc\_vertices}($v,C$) $\{$ ``the vertices of $C$ are successively assigned to $v$'' $\}$ }*/ diff --git a/Interval_skip_list/include/CGAL/Interval_skip_list.h b/Interval_skip_list/include/CGAL/Interval_skip_list.h index 1c13f5d5cde..a445981a3f2 100644 --- a/Interval_skip_list/include/CGAL/Interval_skip_list.h +++ b/Interval_skip_list/include/CGAL/Interval_skip_list.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Andreas Fabri @@ -48,7 +48,7 @@ namespace CGAL { template class IntervalSLnode; - const int MAX_FORWARD = 48; // Maximum number of forward pointers + const int MAX_FORWARD = 48; // Maximum number of forward pointers @@ -62,7 +62,7 @@ namespace CGAL { Value key; IntervalSLnode** forward; // array of forward pointers - IntervalList** markers; // array of interval markers, + IntervalList** markers; // array of interval markers, // one for each pointer IntervalList* eqMarkers; // markers for node itself int ownerCount; // number of interval end points with value equal to key @@ -79,19 +79,19 @@ namespace CGAL { void print(std::ostream& os) const; - const Value& + const Value& getValue() { return key; } - + // number of levels of this node - int - level() const + int + level() const { return(topLevel+1); } - + bool isHeader() const { @@ -99,7 +99,7 @@ namespace CGAL { } void deleteMarks(IntervalList* l); - + ~IntervalSLnode(); // destructor }; @@ -111,9 +111,9 @@ class Interval_for_container : public Interval_ void * p; public: Interval_for_container(const Interval_& i) - : Interval_(i), p(nullptr) + : Interval_(i), p(nullptr) {} - + void * for_compact_container() const { return p; } void for_compact_container(void *ptr) { p = ptr; } }; @@ -133,7 +133,7 @@ class Interval_for_container : public Interval_ typedef typename std::list::iterator Interval_handle; #else Compact_container > container; - typedef typename Compact_container >::iterator + typedef typename Compact_container >::iterator Interval_handle; #endif @@ -151,139 +151,139 @@ class Interval_for_container : public Interval_ // place markers for Interval I. I must have been inserted in the list. // left is the left endpoint of I and right is the right endpoint if I. // *** needs to be fixed: - void placeMarkers(IntervalSLnode* left, - IntervalSLnode* right, - const Interval_handle& I); + void placeMarkers(IntervalSLnode* left, + IntervalSLnode* right, + const Interval_handle& I); // remove markers for Interval I - void removeMarkers(const Interval_handle& I); + void removeMarkers(const Interval_handle& I); // adjust markers after insertion of x with update vector "update" - void adjustMarkersOnInsert(IntervalSLnode* x, - IntervalSLnode** update); + void adjustMarkersOnInsert(IntervalSLnode* x, + IntervalSLnode** update); // adjust markers to prepare for deletion of x, which has update vector // "update" - void adjustMarkersOnDelete(IntervalSLnode* x, - IntervalSLnode** update); + void adjustMarkersOnDelete(IntervalSLnode* x, + IntervalSLnode** update); // remove node x, which has updated vector update. - void remove(IntervalSLnode* x, - IntervalSLnode** update); + void remove(IntervalSLnode* x, + IntervalSLnode** update); // remove markers for Interval I starting at left, the left endpoint // of I, and and stopping at the right endpoint of I. - Interval_handle removeMarkers(IntervalSLnode* left, - const Interval& I); + Interval_handle removeMarkers(IntervalSLnode* left, + const Interval& I); // Remove markers for interval m from the edges and nodes on the // level i path from l to r. void removeMarkFromLevel(const Interval& m, int i, - IntervalSLnode *l, - IntervalSLnode* r); + IntervalSLnode *l, + IntervalSLnode* r); - // Search for search key, and return a pointer to the - // intervalSLnode x found, as well as setting the update vector - // showing pointers into x. - IntervalSLnode* search(const Value& searchKey, - IntervalSLnode** update); + // Search for search key, and return a pointer to the + // intervalSLnode x found, as well as setting the update vector + // showing pointers into x. + IntervalSLnode* search(const Value& searchKey, + IntervalSLnode** update); - - // insert a new single value - // into list, returning a pointer to its location. + + // insert a new single value + // into list, returning a pointer to its location. IntervalSLnode* insert(const Value& searchKey); - // insert an interval into list + // insert an interval into list void insert(const Interval_handle& I); public: friend class IntervalSLnode; - Interval_skip_list(); - + Interval_skip_list(); + template Interval_skip_list(InputIterator b, InputIterator e) { maxLevel = 0; header = new IntervalSLnode(MAX_FORWARD); for (int i = 0; i< MAX_FORWARD; i++) { - header->forward[i] = 0; + header->forward[i] = 0; } for(; b!= e; ++b){ - insert(*b); + insert(*b); } } - ~Interval_skip_list(); + ~Interval_skip_list(); void clear(); - int size() const + int size() const { return container.size(); } - + // return node containing // Value if found, otherwise null - IntervalSLnode* search(const Value& searchKey); + IntervalSLnode* search(const Value& searchKey); template - OutputIterator + OutputIterator find_intervals(const Value& searchKey, OutputIterator out ) { IntervalSLnode* x = header; - for(int i=maxLevel; - i >= 0 && (x->isHeader() || (x->key != searchKey)); i--) { - while (x->forward[i] != 0 && (searchKey >= x->forward[i]->key)) { - x = x->forward[i]; - } - // Pick up markers on edge as you drop down a level, unless you are at - // the searchKey node already, in which case you pick up the - // eqMarkers just prior to exiting loop. - if(!x->isHeader() && (x->key != searchKey)) { - out = x->markers[i]->copy(out); - } else if (!x->isHeader()) { // we're at searchKey - out = x->eqMarkers->copy(out); - } + for(int i=maxLevel; + i >= 0 && (x->isHeader() || (x->key != searchKey)); i--) { + while (x->forward[i] != 0 && (searchKey >= x->forward[i]->key)) { + x = x->forward[i]; + } + // Pick up markers on edge as you drop down a level, unless you are at + // the searchKey node already, in which case you pick up the + // eqMarkers just prior to exiting loop. + if(!x->isHeader() && (x->key != searchKey)) { + out = x->markers[i]->copy(out); + } else if (!x->isHeader()) { // we're at searchKey + out = x->eqMarkers->copy(out); + } } return out; } - + bool is_contained(const Value& searchKey) const { IntervalSLnode* x = header; - for(int i=maxLevel; - i >= 0 && (x->isHeader() || (x->key != searchKey)); i--) { - while (x->forward[i] != 0 && (searchKey >= x->forward[i]->key)) { - x = x->forward[i]; - } - // Pick up markers on edge as you drop down a level, unless you are at - // the searchKey node already, in which case you pick up the - // eqMarkers just prior to exiting loop. - if(!x->isHeader() && (x->key != searchKey)) { - return true; - } else if (!x->isHeader()) { // we're at searchKey - return true; - } + for(int i=maxLevel; + i >= 0 && (x->isHeader() || (x->key != searchKey)); i--) { + while (x->forward[i] != 0 && (searchKey >= x->forward[i]->key)) { + x = x->forward[i]; + } + // Pick up markers on edge as you drop down a level, unless you are at + // the searchKey node already, in which case you pick up the + // eqMarkers just prior to exiting loop. + if(!x->isHeader() && (x->key != searchKey)) { + return true; + } else if (!x->isHeader()) { // we're at searchKey + return true; + } } return false; } - + void insert(const Interval& I); @@ -292,8 +292,8 @@ class Interval_for_container : public Interval_ { int i = 0; for(; b!= e; ++b){ - insert(*b); - ++i; + insert(*b); + ++i; } return i; } @@ -306,7 +306,7 @@ class Interval_for_container : public Interval_ #ifdef CGAL_ISL_USE_LIST typedef typename std::list::const_iterator const_iterator; #else - typedef typename + typedef typename Compact_container >::const_iterator const_iterator; #endif @@ -318,7 +318,7 @@ class Interval_for_container : public Interval_ { return container.end(); } - + }; @@ -333,7 +333,7 @@ class Interval_for_container : public Interval_ typedef typename std::list::iterator Interval_handle; #else - typedef typename Compact_container >::iterator + typedef typename Compact_container >::iterator Interval_handle; #endif @@ -382,7 +382,7 @@ class Interval_for_container : public Interval_ } void erase_list_element(ILE_handle I) - { + { #ifdef CGAL_ISL_USE_CCC compact_container.erase(I); #else @@ -398,21 +398,21 @@ class Interval_for_container : public Interval_ ILE_handle get_next(ILE_handle element); void copy(IntervalList* from); // add contents of "from" to self - - + + template OutputIterator copy(OutputIterator out) const { ILE_handle e = header; - while(e!= nullptr) { - out = *(e->I); - ++out; - e = e->next; + while(e!= nullptr) { + out = *(e->I); + ++out; + e = e->next; } return out; } - + bool contains(const Interval_handle& I) const; void clear(); // delete elements of self to make self an empty list. @@ -424,10 +424,10 @@ class Interval_for_container : public Interval_ #ifdef CGAL_ISL_USE_CCC template - Compact_container > + Compact_container > IntervalList::compact_container; #endif - + @@ -439,7 +439,7 @@ class Interval_for_container : public Interval_ typedef typename std::list::iterator Interval_handle; #else - typedef typename Compact_container >::iterator + typedef typename Compact_container >::iterator Interval_handle; #endif @@ -464,7 +464,7 @@ class Interval_for_container : public Interval_ { return ( ((*I) == (*(e.I))) && (next == e.next)); } - + friend class IntervalList; @@ -474,7 +474,7 @@ class Interval_for_container : public Interval_ ~IntervalListElt(); - void + void set_next(ILE_handle nextElt) { next = nextElt; @@ -508,7 +508,7 @@ class Interval_for_container : public Interval_ for(int i=0; i<=levels; i++) { forward[i] = 0; // initialize an empty interval list - markers[i] = new IntervalList(); + markers[i] = new IntervalList(); } } @@ -526,7 +526,7 @@ class Interval_for_container : public Interval_ for(int i=0; i<=levels; i++) { forward[i] = 0; // initialize an empty interval list - markers[i] = new IntervalList(); + markers[i] = new IntervalList(); } } @@ -586,8 +586,8 @@ class Interval_for_container : public Interval_ } template - std::ostream& operator<<(std::ostream& os, - const Interval_skip_list& isl) + std::ostream& operator<<(std::ostream& os, + const Interval_skip_list& isl) { isl.print(os); return os; @@ -610,7 +610,7 @@ template void IntervalList::copy(IntervalList* from) { ILE_handle e = from->header; - while(e!=nullptr) { + while(e!=nullptr) { insert(e->I); e = e->next; } @@ -621,7 +621,7 @@ template void IntervalList::clear() { ILE_handle x = header; - ILE_handle y; + ILE_handle y; while(x!= nullptr) { // was 0 y = x; x = x->next; @@ -631,11 +631,11 @@ template } template - IntervalSLnode* + IntervalSLnode* Interval_skip_list::insert(const Value& searchKey) { - // array for maintaining update pointers - IntervalSLnode* update[MAX_FORWARD]; + // array for maintaining update pointers + IntervalSLnode* update[MAX_FORWARD]; IntervalSLnode* x; int i; @@ -646,18 +646,18 @@ template // put a new node in the list for this searchKey int newLevel = randomLevel(); if (newLevel > maxLevel){ - for(i=maxLevel+1; i<=newLevel; i++){ - update[i] = header; - header->markers[i]->clear(); - } - maxLevel = newLevel; + for(i=maxLevel+1; i<=newLevel; i++){ + update[i] = header; + header->markers[i]->clear(); + } + maxLevel = newLevel; } x = new IntervalSLnode(searchKey, newLevel); // add x to the list for(i=0; i<=newLevel; i++) { - x->forward[i] = update[i]->forward[i]; - update[i]->forward[i] = x; + x->forward[i] = update[i]->forward[i]; + update[i]->forward[i] = x; } // adjust markers to maintain marker invariant @@ -673,10 +673,10 @@ template // node x has just been inserted, with update vector `update.' template - void + void Interval_skip_list::adjustMarkersOnInsert (IntervalSLnode* x, - IntervalSLnode** update) + IntervalSLnode** update) { // Phase 1: place markers on edges leading out of x as needed. @@ -684,14 +684,14 @@ template // If a marker has to be promoted from level i to i+1 of higher, place it // in the promoted set at each step. - IntervalList promoted; + IntervalList promoted; // list of intervals that identify markers being // promoted, initially empty. - IntervalList newPromoted; + IntervalList newPromoted; // temporary set to hold newly promoted markers. - - IntervalList removePromoted; + + IntervalList removePromoted; // holding place for elements to be removed from promoted list. IntervalList tempMarkList; // temporary mark list @@ -701,41 +701,41 @@ template for(i=0; (i<= x->level() - 2) && x->forward[i+1]!=0; i++) { IntervalList* markList = update[i]->markers[i]; for(m = markList->get_first(); m != nullptr ; m = markList->get_next(m)) { - if(m->getInterval()->contains_interval(x->key,x->forward[i+1]->key)) { - // promote m - - // remove m from level i path from x->forward[i] to x->forward[i+1] - removeMarkFromLevel(*m->getInterval(), - i, - x->forward[i], - x->forward[i+1]); - // add m to newPromoted - newPromoted.insert(m->getInterval()); - } else { - // place m on the level i edge out of x - x->markers[i]->insert(m->getInterval()); - // do *not* place m on x->forward[i]; it must already be there. - } + if(m->getInterval()->contains_interval(x->key,x->forward[i+1]->key)) { + // promote m + + // remove m from level i path from x->forward[i] to x->forward[i+1] + removeMarkFromLevel(*m->getInterval(), + i, + x->forward[i], + x->forward[i+1]); + // add m to newPromoted + newPromoted.insert(m->getInterval()); + } else { + // place m on the level i edge out of x + x->markers[i]->insert(m->getInterval()); + // do *not* place m on x->forward[i]; it must already be there. + } } - + for(m = promoted.get_first(); m != nullptr; m = promoted.get_next(m)) { - if(!m->getInterval()->contains_interval(x->key, x->forward[i+1]->key)){ - // Then m does not need to be promoted higher. - // Place m on the level i edge out of x and remove m from promoted. - x->markers[i]->insert(m->getInterval()); - // mark x->forward[i] if needed - if(m->getInterval()->contains(x->forward[i]->key)) - x->forward[i]->eqMarkers->insert(m->getInterval()); - removePromoted.insert(m->getInterval()); - } else { - // continue to promote m - // Remove m from the level i path from x->forward[i] - // to x->forward[i+1]. - removeMarkFromLevel(*(m->getInterval()), - i, - x->forward[i], - x->forward[i+1]); - } + if(!m->getInterval()->contains_interval(x->key, x->forward[i+1]->key)){ + // Then m does not need to be promoted higher. + // Place m on the level i edge out of x and remove m from promoted. + x->markers[i]->insert(m->getInterval()); + // mark x->forward[i] if needed + if(m->getInterval()->contains(x->forward[i]->key)) + x->forward[i]->eqMarkers->insert(m->getInterval()); + removePromoted.insert(m->getInterval()); + } else { + // continue to promote m + // Remove m from the level i path from x->forward[i] + // to x->forward[i+1]. + removeMarkFromLevel(*(m->getInterval()), + i, + x->forward[i], + x->forward[i+1]); + } } promoted.removeAll(&removePromoted); removePromoted.clear(); @@ -744,68 +744,68 @@ template } // Combine the promoted set and updated[i]->markers[i] // and install them as the set of markers on the top edge out of x - // that is non-null. - + // that is non-null. + x->markers[i]->copy(&promoted); x->markers[i]->copy(update[i]->markers[i]); for(m=promoted.get_first(); m!=nullptr; m=promoted.get_next(m)) if(m->getInterval()->contains(x->forward[i]->key)) x->forward[i]->eqMarkers->insert(m->getInterval()); - + // Phase 2: place markers on edges leading into x as needed. - + // Markers on edges leading into x may need to be promoted as high as // the top edge coming into x, but never higher. - + promoted.clear(); - + for (i=0; (i <= x->level() - 2) && !update[i+1]->isHeader(); i++) { tempMarkList.copy(update[i]->markers[i]); - for(m = tempMarkList.get_first(); - m != nullptr; - m = tempMarkList.get_next(m)){ - if(m->getInterval()->contains_interval(update[i+1]->key,x->key)) { - // m needs to be promoted - // add m to newPromoted - newPromoted.insert(m->getInterval()); - - // Remove m from the path of level i edges between updated[i+1] - // and x (it will be on all those edges or else the invariant - // would have previously been violated. - removeMarkFromLevel(*(m->getInterval()),i,update[i+1],x); - } + for(m = tempMarkList.get_first(); + m != nullptr; + m = tempMarkList.get_next(m)){ + if(m->getInterval()->contains_interval(update[i+1]->key,x->key)) { + // m needs to be promoted + // add m to newPromoted + newPromoted.insert(m->getInterval()); + + // Remove m from the path of level i edges between updated[i+1] + // and x (it will be on all those edges or else the invariant + // would have previously been violated. + removeMarkFromLevel(*(m->getInterval()),i,update[i+1],x); + } } tempMarkList.clear(); // reclaim storage - + for(m = promoted.get_first(); m != nullptr; m = promoted.get_next(m)) { - if (!update[i]->isHeader() && - m->getInterval()->contains_interval(update[i]->key,x->key) && - !update[i+1]->isHeader() && - ! m->getInterval()->contains_interval(update[i+1]->key,x->key) ) { - // Place m on the level i edge between update[i] and x, and - // remove m from promoted. - update[i]->markers[i]->insert(m->getInterval()); - // mark update[i] if needed - if(m->getInterval()->contains(update[i]->key)) - update[i]->eqMarkers->insert(m->getInterval()); - removePromoted.insert(m->getInterval()); - } else { - // Strip m from the level i path from update[i+1] to x. - removeMarkFromLevel(*(m->getInterval()),i,update[i+1],x); - } - + if (!update[i]->isHeader() && + m->getInterval()->contains_interval(update[i]->key,x->key) && + !update[i+1]->isHeader() && + ! m->getInterval()->contains_interval(update[i+1]->key,x->key) ) { + // Place m on the level i edge between update[i] and x, and + // remove m from promoted. + update[i]->markers[i]->insert(m->getInterval()); + // mark update[i] if needed + if(m->getInterval()->contains(update[i]->key)) + update[i]->eqMarkers->insert(m->getInterval()); + removePromoted.insert(m->getInterval()); + } else { + // Strip m from the level i path from update[i+1] to x. + removeMarkFromLevel(*(m->getInterval()),i,update[i+1],x); + } + } // remove non-promoted marks from promoted promoted.removeAll(&removePromoted); removePromoted.clear(); // reclaim storage - + // add newPromoted to promoted and make newPromoted empty promoted.copy(&newPromoted); - newPromoted.clear(); + newPromoted.clear(); } - + /* Assertion: i=x->level()-1 OR update[i+1] is the header. - + If i=x->level()-1 then either x has only one level, or the top-level pointer into x must not be from the header, since otherwise we would have stopped on the previous iteration. If x has 1 level, then @@ -822,22 +822,22 @@ template update[i]->markers[i]->copy(&promoted); for(m=promoted.get_first(); m!=nullptr; m=promoted.get_next(m)) if(m->getInterval()->contains(update[i]->key)) - update[i]->eqMarkers->insert(m->getInterval()); + update[i]->eqMarkers->insert(m->getInterval()); // Place markers on x for all intervals the cross x. // (Since x is a new node, every marker coming into x must also leave x). for(i=0; ilevel(); i++) x->eqMarkers->copy(x->markers[i]); - + promoted.clear(); // reclaim storage - + } // end adjustMarkersOnInsert template void Interval_skip_list::adjustMarkersOnDelete (IntervalSLnode* x, - IntervalSLnode** update) + IntervalSLnode** update) { // x is node being deleted. It is still in the list. // update is the update vector for x. @@ -852,13 +852,13 @@ template for(i=x->level()-1; i>=0; i--){ // find marks on edge into x at level i to be demoted - for(m=update[i]->markers[i]->get_first(); m!=nullptr; - m=update[i]->markers[i]->get_next(m)){ - if(x->forward[i]==0 || - ! m->getInterval()->contains_interval(update[i]->key, - x->forward[i]->key)){ - newDemoted.insert(m->getInterval()); - } + for(m=update[i]->markers[i]->get_first(); m!=nullptr; + m=update[i]->markers[i]->get_next(m)){ + if(x->forward[i]==0 || + ! m->getInterval()->contains_interval(update[i]->key, + x->forward[i]->key)){ + newDemoted.insert(m->getInterval()); + } } // Remove newly demoted marks from edge. update[i]->markers[i]->removeAll(&newDemoted); @@ -867,26 +867,26 @@ template // Place previously demoted marks on this level as needed. for(m=demoted.get_first(); m!=nullptr; m=demoted.get_next(m)){ - // Place mark on level i from update[i+1] to update[i], not including - // update[i+1] itself, since it already has a mark if it needs one. - for(y=update[i+1]; y!=0 && y!=update[i]; y=y->forward[i]) { - if (y!=update[i+1] && m->getInterval()->contains(y->key)) - y->eqMarkers->insert(m->getInterval()); - y->markers[i]->insert(m->getInterval()); - } - if(y!=0 && y!=update[i+1] && m->getInterval()->contains(y->key)) - y->eqMarkers->insert(m->getInterval()); + // Place mark on level i from update[i+1] to update[i], not including + // update[i+1] itself, since it already has a mark if it needs one. + for(y=update[i+1]; y!=0 && y!=update[i]; y=y->forward[i]) { + if (y!=update[i+1] && m->getInterval()->contains(y->key)) + y->eqMarkers->insert(m->getInterval()); + y->markers[i]->insert(m->getInterval()); + } + if(y!=0 && y!=update[i+1] && m->getInterval()->contains(y->key)) + y->eqMarkers->insert(m->getInterval()); - // if this is the lowest level m needs to be placed on, - // then place m on the level i edge out of update[i] - // and remove m from the demoted set. - if(x->forward[i]!=0 && - m->getInterval()->contains_interval(update[i]->key, - x->forward[i]->key)) - { - update[i]->markers[i]->insert(m->getInterval()); - tempRemoved.insert(m->getInterval()); - } + // if this is the lowest level m needs to be placed on, + // then place m on the level i edge out of update[i] + // and remove m from the demoted set. + if(x->forward[i]!=0 && + m->getInterval()->contains_interval(update[i]->key, + x->forward[i]->key)) + { + update[i]->markers[i]->insert(m->getInterval()); + tempRemoved.insert(m->getInterval()); + } } demoted.removeAll(&tempRemoved); tempRemoved.clear(); @@ -895,36 +895,36 @@ template } // Phase 2: lower markers on edges to the right of D as needed - + demoted.clear(); // newDemoted is already empty for(i=x->level()-1; i>=0; i--){ for(m=x->markers[i]->get_first(); m!=nullptr ; m=x->markers[i]->get_next(m)){ - if(x->forward[i]!=0 && - (update[i]->isHeader() || - !m->getInterval()->contains_interval(update[i]->key, - x->forward[i]->key))) - { - newDemoted.insert(m->getInterval()); - } + if(x->forward[i]!=0 && + (update[i]->isHeader() || + !m->getInterval()->contains_interval(update[i]->key, + x->forward[i]->key))) + { + newDemoted.insert(m->getInterval()); + } } for(m=demoted.get_first(); m!= nullptr; m=demoted.get_next(m)){ - // Place mark on level i from x->forward[i] to x->forward[i+1]. - // Don't place a mark directly on x->forward[i+1] since it is already - // marked. - for(y=x->forward[i];y!=x->forward[i+1];y=y->forward[i]){ - y->eqMarkers->insert(m->getInterval()); - y->markers[i]->insert(m->getInterval()); - } + // Place mark on level i from x->forward[i] to x->forward[i+1]. + // Don't place a mark directly on x->forward[i+1] since it is already + // marked. + for(y=x->forward[i];y!=x->forward[i+1];y=y->forward[i]){ + y->eqMarkers->insert(m->getInterval()); + y->markers[i]->insert(m->getInterval()); + } - if(x->forward[i]!=0 && !update[i]->isHeader() && - m->getInterval()->contains_interval(update[i]->key, - x->forward[i]->key)) - { - tempRemoved.insert(m->getInterval()); - } + if(x->forward[i]!=0 && !update[i]->isHeader() && + m->getInterval()->contains_interval(update[i]->key, + x->forward[i]->key)) + { + tempRemoved.insert(m->getInterval()); + } } demoted.removeAll(&tempRemoved); demoted.copy(&newDemoted); @@ -945,8 +945,8 @@ template template bool Interval_skip_list::remove(const Interval& I) { - // arrays for maintaining update pointers - IntervalSLnode* update[MAX_FORWARD]; + // arrays for maintaining update pointers + IntervalSLnode* update[MAX_FORWARD]; IntervalSLnode* left = search(I.inf(),update); if(left==0 || left->ownerCount <= 0) { @@ -972,9 +972,9 @@ template } template - void - Interval_skip_list::remove(IntervalSLnode* x, - IntervalSLnode** update) + void + Interval_skip_list::remove(IntervalSLnode* x, + IntervalSLnode** update) { // Remove interval skip list node x. The markers that the interval // x belongs to have already been removed. @@ -991,13 +991,13 @@ template template - IntervalSLnode* + IntervalSLnode* Interval_skip_list::search(const Value& searchKey) { IntervalSLnode* x = header; for(int i=maxLevel; i >= 0; i--) { while (x->forward[i] != 0 && (x->forward[i]->key < searchKey)) { - x = x->forward[i]; + x = x->forward[i]; } } x = x->forward[0]; @@ -1008,16 +1008,16 @@ template } template - IntervalSLnode* - Interval_skip_list::search(const Value& searchKey, - IntervalSLnode** update) + IntervalSLnode* + Interval_skip_list::search(const Value& searchKey, + IntervalSLnode** update) { IntervalSLnode* x = header; // Find location of searchKey, building update vector indicating // pointers to change on insertion. for(int i=maxLevel; i >= 0; i--) { while (x->forward[i] != 0 && (x->forward[i]->key < searchKey)) { - x = x->forward[i]; + x = x->forward[i]; } update[i] = x; } @@ -1057,10 +1057,10 @@ template template - void - Interval_skip_list::placeMarkers(IntervalSLnode* left, - IntervalSLnode* right, - const Interval_handle& I) + void + Interval_skip_list::placeMarkers(IntervalSLnode* left, + IntervalSLnode* right, + const Interval_handle& I) { // Place markers for the interval I. left is the left endpoint // of I and right is the right endpoint of I, so it isn't necessary @@ -1071,45 +1071,45 @@ template int i = 0; // start at level 0 and go up while(x->forward[i]!=0 && I->contains_interval(x->key,x->forward[i]->key)){ // find level to put mark on - while(i!=x->level()-1 + while(i!=x->level()-1 && x->forward[i+1] != 0 && I->contains_interval(x->key,x->forward[i+1]->key)) - i++; + i++; // Mark current level i edge since it is the highest edge out of // x that contains I, except in the case where current level i edge // is null, in which case it should never be marked. - if (x->forward[i] != 0) { - x->markers[i]->insert(I); - x = x->forward[i]; - // Add I to eqMarkers set on node unless currently at right endpoint - // of I and I doesn't contain right endpoint. - if (I->contains(x->key)) x->eqMarkers->insert(I); + if (x->forward[i] != 0) { + x->markers[i]->insert(I); + x = x->forward[i]; + // Add I to eqMarkers set on node unless currently at right endpoint + // of I and I doesn't contain right endpoint. + if (I->contains(x->key)) x->eqMarkers->insert(I); } } // mark non-ascending path while(x->key != right->key) { // find level to put mark on - while(i!=0 && (x->forward[i] == 0 || - !I->contains_interval(x->key,x->forward[i]->key))) - i--; - // At this point, we can assert that i=0 or x->forward[i]!=0 and - // I contains - // (x->key,x->forward[i]->key). In addition, x is between left and + while(i!=0 && (x->forward[i] == 0 || + !I->contains_interval(x->key,x->forward[i]->key))) + i--; + // At this point, we can assert that i=0 or x->forward[i]!=0 and + // I contains + // (x->key,x->forward[i]->key). In addition, x is between left and // right so i=0 implies I contains (x->key,x->forward[i]->key). // Hence, the interval must be marked. Note that it is impossible // for us to be at the end of the list because x->key is not equal // to right->key. x->markers[i]->insert(I); x = x->forward[i]; - if (I->contains(x->key)) x->eqMarkers->insert(I); + if (I->contains(x->key)) x->eqMarkers->insert(I); } } // end placeMarkers template - typename Interval_skip_list::Interval_handle - Interval_skip_list::removeMarkers(IntervalSLnode* left, - const Interval& I) + typename Interval_skip_list::Interval_handle + Interval_skip_list::removeMarkers(IntervalSLnode* left, + const Interval& I) { // Remove markers for interval I, which has left as it's left // endpoint, following a staircase pattern. @@ -1120,55 +1120,55 @@ template IntervalSLnode* x = left; if (I.contains(x->key)) { if(x->eqMarkers->remove(I, tmp)){ - res = tmp; + res = tmp; } } int i = 0; // start at level 0 and go up while(x->forward[i]!=0 && I.contains_interval(x->key,x->forward[i]->key)) { // find level to take mark from - while(i!=x->level()-1 + while(i!=x->level()-1 && x->forward[i+1] != 0 && I.contains_interval(x->key,x->forward[i+1]->key)) - i++; + i++; // Remove mark from current level i edge since it is the highest edge out // of x that contains I, except in the case where current level i edge // is null, in which case there are no markers on it. - if (x->forward[i] != 0) { - if(x->markers[i]->remove(I, tmp)){ - res = tmp; - } - x = x->forward[i]; - // remove I from eqMarkers set on node unless currently at right - // endpoint of I and I doesn't contain right endpoint. - if (I.contains(x->key)){ - if(x->eqMarkers->remove(I, tmp)){ - res = tmp; - } - } + if (x->forward[i] != 0) { + if(x->markers[i]->remove(I, tmp)){ + res = tmp; + } + x = x->forward[i]; + // remove I from eqMarkers set on node unless currently at right + // endpoint of I and I doesn't contain right endpoint. + if (I.contains(x->key)){ + if(x->eqMarkers->remove(I, tmp)){ + res = tmp; + } + } } } // remove marks from non-ascending path while(x->key != I.sup()) { // find level to remove mark from - while(i!=0 && (x->forward[i] == 0 || - ! I.contains_interval(x->key,x->forward[i]->key))) - i--; - // At this point, we can assert that i=0 or x->forward[i]!=0 and - // I contains - // (x->key,x->forward[i]->key). In addition, x is between left and + while(i!=0 && (x->forward[i] == 0 || + ! I.contains_interval(x->key,x->forward[i]->key))) + i--; + // At this point, we can assert that i=0 or x->forward[i]!=0 and + // I contains + // (x->key,x->forward[i]->key). In addition, x is between left and // right so i=0 implies I contains (x->key,x->forward[i]->key). - // Hence, the interval is marked and the mark must be removed. - // Note that it is impossible for us to be at the end of the list + // Hence, the interval is marked and the mark must be removed. + // Note that it is impossible for us to be at the end of the list // because x->key is not equal to right->key. if(x->markers[i]->remove(I, tmp)){ - res = tmp; + res = tmp; } x = x->forward[i]; if (I.contains(x->key)){ - if(x->eqMarkers->remove(I, tmp)){ - res = tmp; - } + if(x->eqMarkers->remove(I, tmp)){ + res = tmp; + } } } CGAL_assertion(*res == I); @@ -1176,10 +1176,10 @@ template } template - void + void Interval_skip_list::removeMarkFromLevel(const Interval& m, int i, - IntervalSLnode *l, - IntervalSLnode* r) + IntervalSLnode *l, + IntervalSLnode* r) { IntervalSLnode *x; for(x=l; x!=0 && x!=r; x=x->forward[i]) { @@ -1196,7 +1196,7 @@ template { boost::geometric_distribution<> proba(0.5); boost::variate_generator > die(random, proba); - + return (std::min)(die(), (int)maxLevel)+1; } @@ -1219,24 +1219,24 @@ template os << "forward pointers:\n"; for(i=0; i<=topLevel; i++) { - os << "forward[" << i << "] = "; - if(forward[i] != nullptr) { - os << forward[i]->getValue(); - } else { - os << "nullptr"; - } - os << std::endl; + os << "forward[" << i << "] = "; + if(forward[i] != nullptr) { + os << forward[i]->getValue(); + } else { + os << "nullptr"; + } + os << std::endl; } os << "markers:\n"; for(i=0; i<=topLevel; i++) { - os << "markers[" << i << "] = "; - if(markers[i] != nullptr) { - markers[i]->print(os); - } else { - os << "nullptr"; - } - os << "\n"; + os << "markers[" << i << "] = "; + if(markers[i] != nullptr) { + markers[i]->print(os); + } else { + os << "nullptr"; + } + os << "\n"; } os << "EQ markers: "; eqMarkers->print(os); @@ -1263,7 +1263,7 @@ template while(x != nullptr && *(x->getInterval()) != I) { last = x; x = x->next; - } + } if(x==nullptr) { return false; } else if (last==nullptr) { @@ -1310,20 +1310,20 @@ template // We need the default constructor for the compact_container template - inline + inline IntervalListElt::IntervalListElt() : next(nullptr) {} template - inline + inline IntervalListElt::IntervalListElt(const Interval_handle& anInterval) : I(anInterval), next(nullptr) {} template - inline + inline IntervalListElt::~IntervalListElt() {} @@ -1338,7 +1338,7 @@ template template inline - + typename IntervalList::ILE_handle IntervalList::get_next(ILE_handle element) { @@ -1368,7 +1368,7 @@ template } template - inline + inline bool IntervalList::contains(const Interval_handle& I) const { ILE_handle x = header; diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index cea2e2405ba..0146470513f 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -208,7 +208,7 @@ public: { CGAL_precondition(facet>=0 && facet<4); char current_bits = bits_; - + while (!bits_.compare_exchange_weak(current_bits, current_bits | char(1 << facet))) { current_bits = bits_; @@ -319,7 +319,7 @@ public: #endif , surface_center_index_table_() , sliver_value_(FT(0.)) - , subdomain_index_() + , subdomain_index_() , sliver_cache_validity_(false) {} @@ -656,14 +656,14 @@ public: public: Cell_handle next_intrusive() const { return next_intrusive_; } void set_next_intrusive(Cell_handle c) - { - next_intrusive_ = c; + { + next_intrusive_ = c; } Cell_handle previous_intrusive() const { return previous_intrusive_; } void set_previous_intrusive(Cell_handle c) - { - previous_intrusive_ = c; + { + previous_intrusive_ = c; } #endif // CGAL_INTRUSIVE_LIST diff --git a/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp b/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp index 3158f09b096..4186c723d3e 100644 --- a/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp +++ b/STL_Extension/benchmark/compact_container_benchmark/cc_benchmark.cpp @@ -77,7 +77,7 @@ class Change_array_functor > public: Change_array_functor(std::vector &v) : m_v(v) {} - + Change_array_functor(const Change_array_functor &caf) : m_v(caf.m_v) {} @@ -161,7 +161,7 @@ double change_array(Array_t &v, Sequential_with_forward_access_tag) CGAL::Real_timer t; t.start(); typename Array_t::iterator it = v.begin(), it_end = v.end(); - + for ( ; it != it_end ; ++it) compute_the_thing(*it); @@ -213,14 +213,14 @@ void benchmark(Array_t &v) double seq_time_random = change_array(v, Sequential_with_random_access_tag()); std::cout << "* Parallel_for algorithm => "; double parallel_for_time = change_array(v, Parallel_for_tag()); - std::cout << "Speed-up parallel_for (operator[]) = " + std::cout << "Speed-up parallel_for (operator[]) = " << seq_time_random/parallel_for_time << std::endl << std::endl; - + std::cout << "* Sequential algorithm (forward access) => "; double seq_time_fw = change_array(v, Sequential_with_forward_access_tag()); std::cout << "* Parallel_do algorithm => "; double parallel_do_time = change_array(v, Parallel_do_tag()); - std::cout << "Speed-up parallel_do (iterators) = " + std::cout << "Speed-up parallel_do (iterators) = " << seq_time_fw/parallel_do_time << std::endl << std::endl; } diff --git a/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h b/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h index b29bdf8887c..98a1af5ceb6 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h +++ b/STL_Extension/doc/STL_Extension/CGAL/Compact_container.h @@ -9,32 +9,32 @@ namespace CGAL { -The class `Compact_container_base` can be used as a base class for -your own type `T`, so that `T` can be used directly within -`Compact_container`. This class stores a `void *` -pointer only for this purpose, so it may not be the most memory efficient -way to achieve this goal. The other ways are to provide in `T` the -necessary member functions so that the template -`Compact_container_traits` works, or to specialize it for the -particular type `T` that you want to use. +The class `Compact_container_base` can be used as a base class for +your own type `T`, so that `T` can be used directly within +`Compact_container`. This class stores a `void *` +pointer only for this purpose, so it may not be the most memory efficient +way to achieve this goal. The other ways are to provide in `T` the +necessary member functions so that the template +`Compact_container_traits` works, or to specialize it for the +particular type `T` that you want to use. */ class Compact_container_base { public: -/// \name Operations -/// @{ +/// \name Operations +/// @{ /*! -Returns the pointer necessary for `Compact_container_traits`. -*/ -void * for_compact_container() const; +Returns the pointer necessary for `Compact_container_traits`. +*/ +void * for_compact_container() const; /*! Sets the pointer necessary for `Compact_container_traits` to `p`. -*/ +*/ void for_compact_container(void* p); -/// @} +/// @} @@ -46,81 +46,81 @@ namespace CGAL { /*! \ingroup CompactContainer -An object of the class `Compact_container` -is a container of objects of type `T`. +An object of the class `Compact_container` +is a container of objects of type `T`. -This container matches all the -standard requirements for reversible containers, except that -the complexity of its iterator increment and decrement operations -is not always guaranteed to be amortized constant time. +This container matches all the +standard requirements for reversible containers, except that +the complexity of its iterator increment and decrement operations +is not always guaranteed to be amortized constant time. -This container is not a standard sequence nor associative container, -which means the elements are stored in no particular order, and it is not -possible to specify a particular place in the iterator sequence where to -insert new objects. However, all dereferenceable iterators are -still valid after calls to `insert()` and `erase()`, except those -that have been erased (it behaves similarly to `std::list`). +This container is not a standard sequence nor associative container, +which means the elements are stored in no particular order, and it is not +possible to specify a particular place in the iterator sequence where to +insert new objects. However, all dereferenceable iterators are +still valid after calls to `insert()` and `erase()`, except those +that have been erased (it behaves similarly to `std::list`). -The main feature of this container is that it is very memory efficient: -its memory size is `N*sizeof(T)+o(N)`, where `N` is the maximum size -that the container has had in its past history, its `capacity()` -(the memory of erased elements is not deallocated until destruction of the -container or a call to `clear()`). This container has been developed in -order to store large graph-like data structures like the triangulation and -the halfedge data structures. +The main feature of this container is that it is very memory efficient: +its memory size is `N*sizeof(T)+o(N)`, where `N` is the maximum size +that the container has had in its past history, its `capacity()` +(the memory of erased elements is not deallocated until destruction of the +container or a call to `clear()`). This container has been developed in +order to store large graph-like data structures like the triangulation and +the halfedge data structures. -It supports bidirectional iterators and allows a constant time amortized -`insert()` operation. You cannot specify where to insert new objects -(i.e.\ you don't know where they will end up in the iterator sequence, -although `insert()` returns an iterator pointing to the newly inserted -object). You can erase any element with a constant time complexity. +It supports bidirectional iterators and allows a constant time amortized +`insert()` operation. You cannot specify where to insert new objects +(i.e.\ you don't know where they will end up in the iterator sequence, +although `insert()` returns an iterator pointing to the newly inserted +object). You can erase any element with a constant time complexity. -Summary of the differences with `std::list`: it is more compact in -memory since it doesn't store two additional pointers for the iterator needs. -It doesn't deallocate elements until the destruction or `clear()` of the -container. The iterator does not have constant amortized time complexity for -the increment and decrement operations in all cases, only when not too many -elements have not been freed (i.e.\ when the `size()` is close to the -`capacity()`). Iterating from `begin()` to `end()` takes -`O(capacity())` time, not `size()`. In the case where the container -has a small `size()` compared to its `capacity()`, we advise to -"defragment the memory" by copying the container if the iterator performance -is needed. +Summary of the differences with `std::list`: it is more compact in +memory since it doesn't store two additional pointers for the iterator needs. +It doesn't deallocate elements until the destruction or `clear()` of the +container. The iterator does not have constant amortized time complexity for +the increment and decrement operations in all cases, only when not too many +elements have not been freed (i.e.\ when the `size()` is close to the +`capacity()`). Iterating from `begin()` to `end()` takes +`O(capacity())` time, not `size()`. In the case where the container +has a small `size()` compared to its `capacity()`, we advise to +"defragment the memory" by copying the container if the iterator performance +is needed. -The iterators themselves can be used as `T`, they provide the necessary -functions to be used by `Compact_container_traits`. Moreover, they -also provide a default constructor value which is not singular: it is -copyable, comparable, and guaranteed to be unique under comparison -(like `nullptr` for pointers). This makes them suitable for use in -geometric graphs like handles to vertices in triangulations. +The iterators themselves can be used as `T`, they provide the necessary +functions to be used by `Compact_container_traits`. Moreover, they +also provide a default constructor value which is not singular: it is +copyable, comparable, and guaranteed to be unique under comparison +(like `nullptr` for pointers). This makes them suitable for use in +geometric graphs like handles to vertices in triangulations. -In addition, in a way inspired from the Boost.Intrusive containers, it is -possible to construct iterators from references to values in containers -using the `iterator_to` and `s_iterator_to` functions. +In addition, in a way inspired from the Boost.Intrusive containers, it is +possible to construct iterators from references to values in containers +using the `iterator_to` and `s_iterator_to` functions. -The objects stored in the `Compact_container` can optionally store an +The objects stored in the `Compact_container` can optionally store an "erase counter". If it exists, i.e.\ if the object is a model of the -`ObjectWithEraseCounter` concept, each time an object is erased from the +`ObjectWithEraseCounter` concept, each time an object is erased from the container, the erase counter of the object will be incremented. -For example, this erase counter can be exploited using the `CC_safe_handle` +For example, this erase counter can be exploited using the `CC_safe_handle` helper class, so that one can know if a handle is still pointing to the same element. -Note that this is meaningful only because the -`CGAL::Compact_container` doesn't +Note that this is meaningful only because the +`CGAL::Compact_container` doesn't deallocate elements until the destruction or clear() of the container. \cgalHeading{Parameters} -The parameter `T` is required to have a copy constructor and an -assignment operator. It also needs to provide access to an internal -pointer via `Compact_container_traits`. +The parameter `T` is required to have a copy constructor and an +assignment operator. It also needs to provide access to an internal +pointer via `Compact_container_traits`. -The equality test and the relational order require the operators -`==` and `<` for `T` respectively. +The equality test and the relational order require the operators +`==` and `<` for `T` respectively. -The parameter `Allocator` has to match the standard allocator -requirements, with value type `T`. This parameter has the default -value `CGAL_ALLOCATOR(T)`. +The parameter `Allocator` has to match the standard allocator +requirements, with value type `T`. This parameter has the default +value `CGAL_ALLOCATOR(T)`. */ template< typename T, typename Allocator > @@ -128,388 +128,388 @@ class Compact_container { public: -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type value_type; -/// @} +*/ +typedef unspecified_type value_type; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type reference; -/// @} +*/ +typedef unspecified_type reference; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type const_reference; -/// @} +*/ +typedef unspecified_type const_reference; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type pointer; -/// @} +*/ +typedef unspecified_type pointer; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type const_pointer; -/// @} +*/ +typedef unspecified_type const_pointer; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type size_type; -/// @} +*/ +typedef unspecified_type size_type; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type difference_type; -/// @} +*/ +typedef unspecified_type difference_type; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type iterator; -/// @} +*/ +typedef unspecified_type iterator; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type const_iterator; -/// @} +*/ +typedef unspecified_type const_iterator; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type reverse_iterator; -/// @} +*/ +typedef unspecified_type reverse_iterator; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type const_reverse_iterator; -/// @} +*/ +typedef unspecified_type const_reverse_iterator; +/// @} -/// \name Types -/// @{ +/// \name Types +/// @{ /*! -*/ -typedef unspecified_type allocator_type; -/// @} +*/ +typedef unspecified_type allocator_type; +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -introduces an empty container `cc`, eventually specifying a particular -allocator `a` as well. -*/ -explicit Compact_container(const Allocator &a = Allocator()); +introduces an empty container `cc`, eventually specifying a particular +allocator `a` as well. +*/ +explicit Compact_container(const Allocator &a = Allocator()); -/// @} +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -a container with copies from the range [`first,last`), eventually -specifying a particular allocator. -*/ -template Compact_container( -InputIterator first, InputIterator last, -const Allocator &a = Allocator()); +a container with copies from the range [`first,last`), eventually +specifying a particular allocator. +*/ +template Compact_container( +InputIterator first, InputIterator last, +const Allocator &a = Allocator()); -/// @} +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -copy constructor. Each item in `cc2` is copied. The allocator -is copied. The iterator order is preserved. -*/ -Compact_container(const Compact_container &cc2); +copy constructor. Each item in `cc2` is copied. The allocator +is copied. The iterator order is preserved. +*/ +Compact_container(const Compact_container &cc2); -/// @} +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -assignment. Each item in `cc2` is copied. The allocator is copied. -Each item in `c` is deleted. The iterator order is preserved. -*/ -Compact_container & operator=(const -Compact_container &cc2); +assignment. Each item in `cc2` is copied. The allocator is copied. +Each item in `c` is deleted. The iterator order is preserved. +*/ +Compact_container & operator=(const +Compact_container &cc2); -/// @} +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -swaps the contents of `cc` and `cc2` in constant time -complexity. No exception is thrown. -*/ -void swap(Compact_container &cc2); +swaps the contents of `cc` and `cc2` in constant time +complexity. No exception is thrown. +*/ +void swap(Compact_container &cc2); -/// @} +/// @} -/// \name Creation -/// @{ +/// \name Creation +/// @{ /*! -if `value` is less than or equal to `capacity()`, this call -has no effect. Otherwise, it is a request for allocation of -additional memory so that then `capacity()` is greater than or -equal to value. `size()` is unchanged. -*/ -void reserve(size_type value); +if `value` is less than or equal to `capacity()`, this call +has no effect. Otherwise, it is a request for allocation of +additional memory so that then `capacity()` is greater than or +equal to value. `size()` is unchanged. +*/ +void reserve(size_type value); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns a mutable iterator referring to the first element in `cc`. -*/ -iterator begin(); +returns a mutable iterator referring to the first element in `cc`. +*/ +iterator begin(); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns a constant iterator referring to the first element in `cc`. -*/ -const_iterator begin() const; +returns a constant iterator referring to the first element in `cc`. +*/ +const_iterator begin() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns a mutable iterator which is the past-end-value of `cc`. -*/ -iterator end(); +returns a mutable iterator which is the past-end-value of `cc`. +*/ +iterator end(); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns a constant iterator which is the past-end-value of `cc`. -*/ -const_iterator end() const; +returns a constant iterator which is the past-end-value of `cc`. +*/ +const_iterator end() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -*/ -reverse_iterator rbegin(); +*/ +reverse_iterator rbegin(); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -*/ -const_reverse_iterator rbegin() const; +*/ +const_reverse_iterator rbegin() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -*/ -reverse_iterator rend(); +*/ +reverse_iterator rend(); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -*/ -const_reverse_iterator rend() const; +*/ +const_reverse_iterator rend() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns an iterator which points to `value`. -*/ -iterator iterator_to(reference value) const; +returns an iterator which points to `value`. +*/ +iterator iterator_to(reference value) const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns an iterator which points to `value`. -*/ -const_iterator iterator_to(const_reference value) const; +returns an iterator which points to `value`. +*/ +const_iterator iterator_to(const_reference value) const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns an iterator which points to `value`; -*/ -static iterator s_iterator_to(reference value); +returns an iterator which points to `value`; +*/ +static iterator s_iterator_to(reference value); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns an iterator which points to `value`; -*/ -static const_iterator s_iterator_to(const_reference value); +returns an iterator which points to `value`; +*/ +static const_iterator s_iterator_to(const_reference value); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns `true` iff `cc` is empty. -*/ -bool empty() const; +returns `true` iff `cc` is empty. +*/ +bool empty() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns the number of items in `cc`. -*/ -size_type size() const; +returns the number of items in `cc`. +*/ +size_type size() const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! returns the maximum possible size of the container `cc`. This is the allocator's max_size value. -*/ -size_type max_size() const; +*/ +size_type max_size() const; -/// @} - - -/// \name Access Member Functions -/// @{ -/*! -returns the total number of elements that `cc` can hold without requiring -reallocation. -*/ -size_type capacity() const; /// @} -/// \name Access Member Functions -/// @{ + +/// \name Access Member Functions +/// @{ +/*! +returns the total number of elements that `cc` can hold without requiring +reallocation. +*/ +size_type capacity() const; +/// @} + +/// \name Access Member Functions +/// @{ /*! returns true if the element `pos` is used (i.e.\ valid). @@ -525,243 +525,243 @@ returns true if the element at position `i` in the container is used bool is_used(size_type i) const; -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns the element at pos `i` in the container. +returns the element at pos `i` in the container. \pre `is_used(i) == true` and \f$ 0 \leq \f$ `i` \f$ < \f$ `capacity()` -*/ +*/ const T& operator[] (size_type i) const; /// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns the element at pos `i` in the container. +returns the element at pos `i` in the container. \pre `is_used(i) == true` and \f$ 0 \leq \f$ `i` \f$ < \f$ `capacity()` -*/ +*/ T& operator[] (size_type i); -/// @} +/// @} -/// \name Access Member Functions -/// @{ +/// \name Access Member Functions +/// @{ /*! -returns the allocator. -*/ -Allocator get_allocator() const; +returns the allocator. +*/ +Allocator get_allocator() const; -/// @} +/// @} -/// \name Insertion -/// @{ +/// \name Insertion +/// @{ /*! -inserts a copy of `t` in `cc` and returns the iterator pointing -to it. -*/ -iterator insert(const T& t); +inserts a copy of `t` in `cc` and returns the iterator pointing +to it. +*/ +iterator insert(const T& t); -/// @} +/// @} -/// \name Insertion -/// @{ +/// \name Insertion +/// @{ /*! -inserts the range [`first, last`) in `cc`. -*/ -template -void insert(InputIterator first, InputIterator last); +inserts the range [`first, last`) in `cc`. +*/ +template +void insert(InputIterator first, InputIterator last); -/// @} +/// @} -/// \name Insertion -/// @{ +/// \name Insertion +/// @{ /*! -erases all the elements of `cc`, then inserts the range -[`first, last`) in `cc`. -*/ -template -void assign(InputIterator first, InputIterator last); +erases all the elements of `cc`, then inserts the range +[`first, last`) in `cc`. +*/ +template +void assign(InputIterator first, InputIterator last); -/// @} +/// @} -/// \name Insertion -/// @{ +/// \name Insertion +/// @{ /*! -constructs an object of type `T` with the constructor that takes -`t1` as argument, inserts it in `cc`, and returns the iterator pointing -to it. Overloads of this member function are defined that take additional -arguments, up to 9. -*/ -template < class T1 > -iterator emplace(const T1& t1); +constructs an object of type `T` with the constructor that takes +`t1` as argument, inserts it in `cc`, and returns the iterator pointing +to it. Overloads of this member function are defined that take additional +arguments, up to 9. +*/ +template < class T1 > +iterator emplace(const T1& t1); -/// @} +/// @} -/// \name Removal -/// @{ +/// \name Removal +/// @{ /*! -removes the item pointed by `pos` from `cc`. -*/ -void erase(iterator pos); +removes the item pointed by `pos` from `cc`. +*/ +void erase(iterator pos); -/// @} +/// @} -/// \name Removal -/// @{ +/// \name Removal +/// @{ /*! -removes the items from the range [`first, last`) from `cc`. -*/ -void erase(iterator first, iterator last); +removes the items from the range [`first, last`) from `cc`. +*/ +void erase(iterator first, iterator last); -/// @} +/// @} -/// \name Removal -/// @{ +/// \name Removal +/// @{ /*! -all items in `cc` are deleted, and the memory is deallocated. -After this call, `cc` is in the same state as if just default -constructed. -*/ -void clear(); +all items in `cc` are deleted, and the memory is deallocated. +After this call, `cc` is in the same state as if just default +constructed. +*/ +void clear(); -/// @} +/// @} -/// \name Ownership testing -/// The following functions are mostly helpful for efficient debugging, since -/// their complexity is \f$ O(\sqrt{\mathrm{c.capacity()}})\f$. -/// @{ +/// \name Ownership testing +/// The following functions are mostly helpful for efficient debugging, since +/// their complexity is \f$ O(\sqrt{\mathrm{c.capacity()}})\f$. +/// @{ /*! * returns whether `pos` is in the range `[cc.begin(), cc.end()]` (`cc.end()` included). - */ -bool owns(const_iterator pos); + */ +bool owns(const_iterator pos); /*! - * returns whether `pos` is in the range `[cc.begin(), cc`.end())` (`cc.end()` excluded). - */ -bool owns_dereferencable(const_iterator pos); + * returns whether `pos` is in the range `[cc.begin(), cc`.end())` (`cc.end()` excluded). + */ +bool owns_dereferencable(const_iterator pos); -/// @} +/// @} -/// \name Merging -/// @{ +/// \name Merging +/// @{ /*! -adds the items of `cc2` to the end of `cc` and `cc2` becomes empty. -The time complexity is O(`cc`.`capacity()`-`cc`.`size()`). -\pre `cc2` must not be the same as `cc`, and the allocators of `cc` and `cc2` must be compatible: `cc.get_allocator() == cc2.get_allocator()`. -*/ -void merge(Compact_container &cc); +adds the items of `cc2` to the end of `cc` and `cc2` becomes empty. +The time complexity is O(`cc`.`capacity()`-`cc`.`size()`). +\pre `cc2` must not be the same as `cc`, and the allocators of `cc` and `cc2` must be compatible: `cc.get_allocator() == cc2.get_allocator()`. +*/ +void merge(Compact_container &cc); -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! -test for equality: Two containers are equal, iff they have the -same size and if their corresponding elements are equal. -*/ -bool operator==(const Compact_container &cc) const; +test for equality: Two containers are equal, iff they have the +same size and if their corresponding elements are equal. +*/ +bool operator==(const Compact_container &cc) const; -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! -test for inequality: returns `!(c == cc)`. -*/ -bool operator!=(const Compact_container &cc) const; +test for inequality: returns `!(c == cc)`. +*/ +bool operator!=(const Compact_container &cc) const; -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! -compares in lexicographical order. -*/ -bool operator<(const Compact_container &cc2) const; +compares in lexicographical order. +*/ +bool operator<(const Compact_container &cc2) const; -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! -returns `cc2 (const Compact_container &cc2) const; +returns `cc2 (const Compact_container &cc2) const; -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! - returns `!(cc > cc2)`. -*/ -bool operator<=(const Compact_container &cc2) const; + returns `!(cc > cc2)`. +*/ +bool operator<=(const Compact_container &cc2) const; -/// @} +/// @} -/// \name Comparison Operations -/// @{ +/// \name Comparison Operations +/// @{ /*! -returns `!(cc < cc2)`. -*/ -bool operator>=(const Compact_container &cc2) const; +returns `!(cc < cc2)`. +*/ +bool operator>=(const Compact_container &cc2) const; -/// @} +/// @} @@ -775,68 +775,68 @@ namespace CGAL { -The traits class `Compact_container_traits` provides -the way to access the internal pointer required for `T` to be -used in a `Compact_container`. Note that this -pointer needs to be accessible even when the object is not constructed, -which means it has to reside in the same memory place as `T`. +The traits class `Compact_container_traits` provides +the way to access the internal pointer required for `T` to be +used in a `Compact_container`. Note that this +pointer needs to be accessible even when the object is not constructed, +which means it has to reside in the same memory place as `T`. -You can specialize this class for your own type `T` -if the default template is not suitable. +You can specialize this class for your own type `T` +if the default template is not suitable. -You can also use `Compact_container_base` as base class for your own -types `T` to make them usable with the default `Compact_container_traits`. +You can also use `Compact_container_base` as base class for your own +types `T` to make them usable with the default `Compact_container_traits`. \cgalHeading{Parameters} -`T` is any type providing the following member functions: +`T` is any type providing the following member functions: -`void * t.for_compact_container() const;` +`void * t.for_compact_container() const;` -`void t.for_compact_container(void *);`. +`void t.for_compact_container(void *);`. */ template< typename T > struct Compact_container_traits { -/// \name Operations -/// @{ +/// \name Operations +/// @{ /*! -Returns the pointer held by `t`. +Returns the pointer held by `t`. The template version defines this function as: `return t.for_compact_container(); ` -*/ -static void * pointer(const T &t); +*/ +static void * pointer(const T &t); -/// @} +/// @} -/// \name Operations -/// @{ +/// \name Operations +/// @{ /*! -Sets the pointer held by `t` to `p`. -The template version defines this function as: `t.for_compact_container(p);` +Sets the pointer held by `t` to `p`. +The template version defines this function as: `t.for_compact_container(p);` -*/ - static void set_pointer(T &t, void* p); +*/ + static void set_pointer(T &t, void* p); -/// @} +/// @} }; /* end Compact_container_traits */ /*! -returns a hash value for the pointee of `i`. +returns a hash value for the pointee of `i`. \relates Compact_container -*/ +*/ template std::size_t hash_value(const Compact_container::iterator i); diff --git a/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h b/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h index 8f55b19bb7f..65e853f489a 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/doc/STL_Extension/CGAL/Concurrent_compact_container.h @@ -6,47 +6,47 @@ namespace CGAL { /*! \ingroup CompactContainer -The traits class `Concurrent_compact_container_traits` provides -the way to access the internal pointer required for `T` to be -used in a `Concurrent_compact_container`. Note that this -pointer needs to be accessible even when the object is not constructed, -which means it has to reside in the same memory place as `T`. +The traits class `Concurrent_compact_container_traits` provides +the way to access the internal pointer required for `T` to be +used in a `Concurrent_compact_container`. Note that this +pointer needs to be accessible even when the object is not constructed, +which means it has to reside in the same memory place as `T`. -You can specialize this class for your own type `T` -if the default template is not suitable. +You can specialize this class for your own type `T` +if the default template is not suitable. -You can also use `Compact_container_base` as base class for your own -types `T` to make them usable with the default `Concurrent_compact_container`. +You can also use `Compact_container_base` as base class for your own +types `T` to make them usable with the default `Concurrent_compact_container`. \cgalHeading{Parameters} -`T` is any type providing the following member functions: -`void * t.for_compact_container() const;` +`T` is any type providing the following member functions: +`void * t.for_compact_container() const;` `void t.for_compact_container(void *);`. */ template< typename T > struct Concurrent_compact_container_traits { -/// \name Operations -/// @{ - /*! - Returns the pointer held by `t`. - The template version defines this function as: `return t.for_compact_container(); - */ - static void * pointer(const T &t); +/// \name Operations +/// @{ + /*! + Returns the pointer held by `t`. + The template version defines this function as: `return t.for_compact_container(); + */ + static void * pointer(const T &t); -/// @} +/// @} -/// \name Operations -/// @{ - /*! +/// \name Operations +/// @{ + /*! Sets the pointer held by `t` to `p`. The template version defines this function as: `t.for_compact_container(p);` - */ + */ static void set_pointer(T &t, void* p); -/// @} +/// @} }; /* end Concurrent_compact_container_traits */ @@ -54,82 +54,82 @@ struct Concurrent_compact_container_traits { /*! \ingroup CompactContainer -An object of the class `Concurrent_compact_container` +An object of the class `Concurrent_compact_container` is a container of objects of type `T`, which allows to call `insert` and `erase` operations concurrently. Other operations are not concurrency-safe. For example, one should not parse the container while others are modifying it. -It matches all the -standard requirements for reversible containers, except that -the complexity of its iterator increment and decrement operations -is not always guaranteed to be amortized constant time. +It matches all the +standard requirements for reversible containers, except that +the complexity of its iterator increment and decrement operations +is not always guaranteed to be amortized constant time. -This container is not a standard sequence nor associative container, -which means the elements are stored in no particular order, and it is not -possible to specify a particular place in the iterator sequence where to -insert new objects. However, all dereferenceable iterators are -still valid after calls to `insert()` and `erase()`, except those -that have been erased (it behaves similarly to `std::list`). +This container is not a standard sequence nor associative container, +which means the elements are stored in no particular order, and it is not +possible to specify a particular place in the iterator sequence where to +insert new objects. However, all dereferenceable iterators are +still valid after calls to `insert()` and `erase()`, except those +that have been erased (it behaves similarly to `std::list`). -The main feature of this container is that it is very memory efficient: -its memory size is `N*sizeof(T)+o(N)`, where `N` is the maximum size -that the container has had in its past history, its `capacity()` -(the memory of erased elements is not deallocated until destruction of the -container or a call to `clear()`). This container has been developed in -order to store large graph-like data structures like the triangulation and -the halfedge data structures. +The main feature of this container is that it is very memory efficient: +its memory size is `N*sizeof(T)+o(N)`, where `N` is the maximum size +that the container has had in its past history, its `capacity()` +(the memory of erased elements is not deallocated until destruction of the +container or a call to `clear()`). This container has been developed in +order to store large graph-like data structures like the triangulation and +the halfedge data structures. -It supports bidirectional iterators and allows a constant time amortized -`insert()` operation. You cannot specify where to insert new objects -(i.e.\ you don't know where they will end up in the iterator sequence, -although `insert()` returns an iterator pointing to the newly inserted -object). You can erase any element with a constant time complexity. +It supports bidirectional iterators and allows a constant time amortized +`insert()` operation. You cannot specify where to insert new objects +(i.e.\ you don't know where they will end up in the iterator sequence, +although `insert()` returns an iterator pointing to the newly inserted +object). You can erase any element with a constant time complexity. -Summary of the differences with `std::list`: it is more compact in -memory since it doesn't store two additional pointers for the iterator needs. -It doesn't deallocate elements until the destruction or `clear()` of the -container. The iterator does not have constant amortized time complexity for -the increment and decrement operations in all cases, only when not too many -elements have not been freed (i.e.\ when the `size()` is close to the -`capacity()`). Iterating from `begin()` to `end()` takes -`O(capacity())` time, not `size()`. In the case where the container -has a small `size()` compared to its `capacity()`, we advise to -\"defragment the memory\" by copying the container if the iterator performance -is needed. +Summary of the differences with `std::list`: it is more compact in +memory since it doesn't store two additional pointers for the iterator needs. +It doesn't deallocate elements until the destruction or `clear()` of the +container. The iterator does not have constant amortized time complexity for +the increment and decrement operations in all cases, only when not too many +elements have not been freed (i.e.\ when the `size()` is close to the +`capacity()`). Iterating from `begin()` to `end()` takes +`O(capacity())` time, not `size()`. In the case where the container +has a small `size()` compared to its `capacity()`, we advise to +\"defragment the memory\" by copying the container if the iterator performance +is needed. -The iterators themselves can be used as `T`, they provide the necessary -functions to be used by `Compact_container_traits`. Moreover, they -also provide a default constructor value which is not singular: it is -copyable, comparable, and guaranteed to be unique under comparison -(like `NULL` for pointers). This makes them suitable for use in -geometric graphs like handles to vertices in triangulations. +The iterators themselves can be used as `T`, they provide the necessary +functions to be used by `Compact_container_traits`. Moreover, they +also provide a default constructor value which is not singular: it is +copyable, comparable, and guaranteed to be unique under comparison +(like `NULL` for pointers). This makes them suitable for use in +geometric graphs like handles to vertices in triangulations. -In addition, in a way inspired from the Boost.Intrusive containers, it is -possible to construct iterators from references to values in containers -using the `iterator_to` and `s_iterator_to` functions. +In addition, in a way inspired from the Boost.Intrusive containers, it is +possible to construct iterators from references to values in containers +using the `iterator_to` and `s_iterator_to` functions. -The objects stored in the `Concurrent_compact_container` can optionally store an +The objects stored in the `Concurrent_compact_container` can optionally store an "erase counter". If it exists, i.e.\ if the object is a model of the -`ObjectWithEraseCounter` concept, each time an object is erased from the +`ObjectWithEraseCounter` concept, each time an object is erased from the container, the erase counter of the object will be incremented. -For example, this erase counter can be exploited using the `CC_safe_handle` +For example, this erase counter can be exploited using the `CC_safe_handle` helper class, so that one can know if a handle is still pointing to the same element. -Note that this is meaningful only because the -`CGAL::Concurrent_compact_container` doesn't +Note that this is meaningful only because the +`CGAL::Concurrent_compact_container` doesn't deallocate elements until the destruction or clear() of the container. \cgalHeading{Parameters} -The parameter `T` is required to have a copy constructor and an -assignment operator. It also needs to provide access to an internal -pointer via `Compact_container_traits`. +The parameter `T` is required to have a copy constructor and an +assignment operator. It also needs to provide access to an internal +pointer via `Compact_container_traits`. -The equality test and the relational order require the operators -`==` and `<` for `T` respectively. +The equality test and the relational order require the operators +`==` and `<` for `T` respectively. -The parameter `Allocator` has to match the standard allocator -requirements, with value type `T`. This parameter has the default +The parameter `Allocator` has to match the standard allocator +requirements, with value type `T`. This parameter has the default value `CGAL_ALLOCATOR(T)`. */ @@ -138,8 +138,8 @@ template < class T, class Allocator > class Concurrent_compact_container { public: -/// \name Types -/// @{ +/// \name Types +/// @{ typedef unspecified_type value_type; typedef unspecified_type allocator_type; typedef unspecified_type reference; @@ -152,48 +152,48 @@ public: typedef unspecified_type const_iterator; typedef unspecified_type reverse_iterator; typedef unspecified_type const_reverse_iterator; -/// @} +/// @} -/// \name Creation -/// @{ -/*! -introduces an empty container `ccc`, eventually specifying a particular -allocator `a` as well. -*/ +/// \name Creation +/// @{ +/*! +introduces an empty container `ccc`, eventually specifying a particular +allocator `a` as well. +*/ explicit Concurrent_compact_container(const Allocator &a = Allocator()); -/*! -a container with copies from the range [`first,last`), eventually -specifying a particular allocator. -*/ +/*! +a container with copies from the range [`first,last`), eventually +specifying a particular allocator. +*/ template < class InputIterator > Concurrent_compact_container(InputIterator first, InputIterator last, const Allocator & a = Allocator()); -/*! -copy constructor. Each item in `ccc2` is copied. The allocator -is copied. The iterator order is preserved. -*/ +/*! +copy constructor. Each item in `ccc2` is copied. The allocator +is copied. The iterator order is preserved. +*/ // The copy constructor and assignment operator preserve the iterator order Concurrent_compact_container(const Concurrent_compact_container &ccc2); - -/*! -assignment. Each item in `ccc2` is copied. The allocator is copied. -Each item in `ccc` is deleted. The iterator order is preserved. -*/ + +/*! +assignment. Each item in `ccc2` is copied. The allocator is copied. +Each item in `ccc` is deleted. The iterator order is preserved. +*/ Concurrent_compact_container & operator=(const Concurrent_compact_container &ccc2); -/*! -swaps the contents of `ccc` and `ccc2` in constant time -complexity. No exception is thrown. -*/ +/*! +swaps the contents of `ccc` and `ccc2` in constant time +complexity. No exception is thrown. +*/ void swap(Self &ccc2); - -/// @} -/// \name Access Member Functions -/// @{ +/// @} + +/// \name Access Member Functions +/// @{ /*! returns true if the element `pos` is used (i.e.\ valid). @@ -206,16 +206,16 @@ complexity. No exception is thrown. const_iterator begin() const; /// returns a mutable iterator which is the past-end-value of `ccc`. iterator end(); - /// returns a constant iterator which is the past-end-value of `ccc`. + /// returns a constant iterator which is the past-end-value of `ccc`. const_iterator end(); - /// returns a mutable reverse iterator referring to the reverse beginning in `ccc`. + /// returns a mutable reverse iterator referring to the reverse beginning in `ccc`. reverse_iterator rbegin(); /// returns a constant reverse iterator referring to the reverse beginning in `ccc`. const_reverse_iterator rbegin() const; /// returns a mutable reverse iterator which is the reverse past-end-value of `ccc`. reverse_iterator rend(); - /// returns a constant reverse iterator which is the reverse past-end-value of `ccc`. + /// returns a constant reverse iterator which is the reverse past-end-value of `ccc`. const_reverse_iterator rend() const; /// returns an iterator which points to `value`. @@ -227,106 +227,106 @@ complexity. No exception is thrown. /// returns a constant iterator which points to `value`. static const_iterator s_iterator_to(const_reference value); - /// returns `true` iff `ccc` is empty. + /// returns `true` iff `ccc` is empty. bool empty() const; - /// returns the number of items in `ccc`. + /// returns the number of items in `ccc`. /// Note: do not call this function while others are inserting/erasing elements size_type size() const; /// returns the maximum possible size of the container `ccc`. /// This is the allocator's max_size value - size_type max_size() const; - /// returns the total number of elements that `ccc` can hold without requiring reallocation. + size_type max_size() const; + /// returns the total number of elements that `ccc` can hold without requiring reallocation. size_type capacity() const; /// returns the allocator - Allocator get_allocator() const; + Allocator get_allocator() const; -/// @} +/// @} -/// \name Insertion -/// @{ - /*! - constructs an object of type `T` with the constructor that takes - `t1` as argument, inserts it in `ccc`, and returns the iterator pointing - to it. Overloads of this member function are defined that take additional - arguments, up to 9. - */ - template < class T1 > - iterator emplace(const T1& t1); - - /*! - inserts a copy of `t` in `ccc` and returns the iterator pointing - to it. - */ +/// \name Insertion +/// @{ + /*! + constructs an object of type `T` with the constructor that takes + `t1` as argument, inserts it in `ccc`, and returns the iterator pointing + to it. Overloads of this member function are defined that take additional + arguments, up to 9. + */ + template < class T1 > + iterator emplace(const T1& t1); + + /*! + inserts a copy of `t` in `ccc` and returns the iterator pointing + to it. + */ iterator insert(const T &t); /// inserts the range [`first, last`) in `ccc`. template < class InputIterator > void insert(InputIterator first, InputIterator last); - /*! - erases all the elements of `ccc`, then inserts the range - [`first, last`) in `ccc`. + /*! + erases all the elements of `ccc`, then inserts the range + [`first, last`) in `ccc`. */ template < class InputIterator > void assign(InputIterator first, InputIterator last); -/// @} +/// @} -/// \name Removal +/// \name Removal /// @{ /// removes the item pointed by `pos` from `ccc`. void erase(iterator x); /// removes the items from the range [`first, last`) from `ccc`. void erase(iterator first, iterator last); - /*! - all items in `ccc` are deleted, and the memory is deallocated. - After this call, `ccc` is in the same state as if just default - constructed. - */ + /*! + all items in `ccc` are deleted, and the memory is deallocated. + After this call, `ccc` is in the same state as if just default + constructed. + */ void clear(); -/// @} +/// @} -/// \name Ownership testing -/// The following functions are mostly helpful for efficient debugging, since -/// their complexity is \f$ O(\sqrt{\mathrm{c.capacity()}})\f$. -/// @{ +/// \name Ownership testing +/// The following functions are mostly helpful for efficient debugging, since +/// their complexity is \f$ O(\sqrt{\mathrm{c.capacity()}})\f$. +/// @{ /// returns whether `pos` is in the range `[ccc.begin(), ccc.end()]` (`ccc.end()` included). - bool owns(const_iterator pos); - /// returns whether `pos` is in the range `[ccc.begin(), ccc`.end())` (`ccc.end()` excluded). - bool owns_dereferencable(const_iterator pos); - -/// @} - -/// \name Merging -/// @{ -/*! -adds the items of `ccc2` to the end of `ccc` and `ccc2` becomes empty. -The time complexity is O(`ccc`.`capacity()`-`ccc`.`size()`). -\pre `ccc2` must not be the same as `ccc`, and the allocators of `ccc` and `ccc2` must be compatible: `ccc.get_allocator() == ccc2.get_allocator()`. -*/ -void merge(Concurrent_compact_container &ccc2); + bool owns(const_iterator pos); + /// returns whether `pos` is in the range `[ccc.begin(), ccc`.end())` (`ccc.end()` excluded). + bool owns_dereferencable(const_iterator pos); /// @} - -/// \name Comparison Operations -/// @{ - /*! - test for equality: Two containers are equal, iff they have the - same size and if their corresponding elements are equal. - */ - bool operator==(const Concurrent_compact_container &ccc2) const; - /// test for inequality: returns `!(ccc == ccc2)`. + +/// \name Merging +/// @{ +/*! +adds the items of `ccc2` to the end of `ccc` and `ccc2` becomes empty. +The time complexity is O(`ccc`.`capacity()`-`ccc`.`size()`). +\pre `ccc2` must not be the same as `ccc`, and the allocators of `ccc` and `ccc2` must be compatible: `ccc.get_allocator() == ccc2.get_allocator()`. +*/ +void merge(Concurrent_compact_container &ccc2); + +/// @} + +/// \name Comparison Operations +/// @{ + /*! + test for equality: Two containers are equal, iff they have the + same size and if their corresponding elements are equal. + */ + bool operator==(const Concurrent_compact_container &ccc2) const; + /// test for inequality: returns `!(ccc == ccc2)`. bool operator!=(const Concurrent_compact_container &ccc2) const; - /// compares in lexicographical order. - bool operator<(const Concurrent_compact_container &ccc2) const; + /// compares in lexicographical order. + bool operator<(const Concurrent_compact_container &ccc2) const; /// returns `ccc2 < ccc`. bool operator>(const Concurrent_compact_container &ccc2) const; /// returns `!(ccc > ccc2)`. bool operator<=(const Concurrent_compact_container &ccc2) const; /// returns `!(ccc < ccc2)`. bool operator>=(const Concurrent_compact_container &ccc2) const; -/// @} +/// @} }; /* end Concurrent_compact_container */ } /* end namespace CGAL */ diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 4d644e547b8..e14d57eb739 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -71,7 +71,7 @@ struct Concurrent_compact_container_traits { namespace CCC_internal { CGAL_GENERATE_MEMBER_DETECTOR(increment_erase_counter); - + // A basic "no erase counter" strategy template class Erase_counter_strategy { diff --git a/STL_Extension/test/STL_Extension/test_Compact_container.cpp b/STL_Extension/test/STL_Extension/test_Compact_container.cpp index e84d79fecfc..7be7166feff 100644 --- a/STL_Extension/test/STL_Extension/test_Compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Compact_container.cpp @@ -238,7 +238,7 @@ void test(const Cont &) c11.reserve(v1.size()); for(typename Vect::const_iterator it = v1.begin(); it != v1.end(); ++it) c11.insert(*it); - + assert(c11.size() == v1.size()); assert(c10 == c11); diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 95f92dba74c..d4fa4a1467a 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -6,7 +6,7 @@ int main() { - std::cout << + std::cout << "NOTICE: this test needs CGAL_LINKED_WITH_TBB, and will not be tested." << std::endl; return 0; @@ -56,7 +56,7 @@ class Node_2 }; public: - + int rnd; Node_2() @@ -85,9 +85,9 @@ class Insert_in_CCC_functor public: Insert_in_CCC_functor( const Values_vec &values, Cont &cont, Iterators_vec &iterators) - : m_values(values), m_cont(cont), m_iterators(iterators) + : m_values(values), m_cont(cont), m_iterators(iterators) {} - + void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) @@ -109,9 +109,9 @@ class Erase_in_CCC_functor public: Erase_in_CCC_functor( Cont &cont, Iterators_vec &iterators) - : m_cont(cont), m_iterators(iterators) + : m_cont(cont), m_iterators(iterators) {} - + void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) @@ -137,7 +137,7 @@ public: : m_values(values), m_cont(cont), m_iterators(iterators), m_free_elements(free_elements), m_num_erasures(num_erasures) {} - + void operator() (const tbb::blocked_range& r) const { for( size_t i = r.begin() ; i != r.end() ; ++i) @@ -318,7 +318,7 @@ void test(const Cont &) c11.reserve(v1.size()); for(typename Vect::const_iterator it = v1.begin(); it != v1.end(); ++it) c11.insert(*it); - + assert(c11.size() == v1.size()); assert(c10 == c11);*/ @@ -336,7 +336,7 @@ void test(const Cont &) c9.erase(c9.begin(), c9.end()); assert(check_empty(c9)); - + std::cout << "Testing parallel insertion" << std::endl; { Cont c11; @@ -347,7 +347,7 @@ void test(const Cont &) Insert_in_CCC_functor(v11, c11, iterators) ); assert(c11.size() == v11.size()); - + std::cout << "Testing parallel erasure" << std::endl; tbb::parallel_for( tbb::blocked_range( 0, v11.size() ), @@ -361,13 +361,13 @@ void test(const Cont &) Cont c12; Vect v12(1000000); std::vector > free_elements(v12.size()); - for(typename std::vector >::iterator - it = free_elements.begin(), end = free_elements.end(); it != end; ++it) + for(typename std::vector >::iterator + it = free_elements.begin(), end = free_elements.end(); it != end; ++it) { *it = true; } - - std::atomic num_erasures; + + std::atomic num_erasures; num_erasures = 0; std::vector iterators(v12.size()); tbb::parallel_for( @@ -425,7 +425,7 @@ int main() n.rnd = i; cc2.insert(n); } - + std::cout << "cc1 capacity: " << cc1.capacity() << std::endl; std::cout << "cc1 size: " << cc1.size() << std::endl; for(CCC::const_iterator it = cc1.begin(), end = cc1.end(); it != end; ++it) { diff --git a/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h b/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h index 71ae4e585af..edb509658cd 100644 --- a/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h +++ b/TDS_2/doc/TDS_2/Concepts/TriangulationDSFaceBase_2.h @@ -5,53 +5,53 @@ \cgalRefines `TriangulationDataStructure_2::Face` -The concept `TriangulationDSFaceBase_2` describes the requirements for +The concept `TriangulationDSFaceBase_2` describes the requirements for the face base class of a `CGAL::Triangulation_data_structure_2`. -Note that if the `CGAL::Triangulation_data_structure_2` -is plugged into a triangulation class, -the face base class may have additional geometric -requirements depending on the triangulation class. +Note that if the `CGAL::Triangulation_data_structure_2` +is plugged into a triangulation class, +the face base class may have additional geometric +requirements depending on the triangulation class. -At the base level, +At the base level, (see Sections \ref Section_2D_Triangulations_Software_Design -and \ref TDS_2D_default ), -a face stores handles -on its three vertices and on the three neighboring faces. -The vertices and neighbors are indexed 0,1 and 2. -Neighbor `i` lies opposite to vertex `i`. +and \ref TDS_2D_default ), +a face stores handles +on its three vertices and on the three neighboring faces. +The vertices and neighbors are indexed 0,1 and 2. +Neighbor `i` lies opposite to vertex `i`. -Since the `CGAL::Triangulation_data_structure_2` is the class -which defines the handle -types, the face base class has to be somehow -parameterized by the triangulation -data structure. But since the `CGAL::Triangulation_data_structure_2` -itself is parameterized by the face and vertex -base classes, there is a cycle in the definition of these classes. -In order -to break the cycle, the base classes for faces and vertices -which are plugged in to instantiate a -`CGAL::Triangulation_data_structure_2` +Since the `CGAL::Triangulation_data_structure_2` is the class +which defines the handle +types, the face base class has to be somehow +parameterized by the triangulation +data structure. But since the `CGAL::Triangulation_data_structure_2` +itself is parameterized by the face and vertex +base classes, there is a cycle in the definition of these classes. +In order +to break the cycle, the base classes for faces and vertices +which are plugged in to instantiate a +`CGAL::Triangulation_data_structure_2` use `void` as triangulation -data structure parameter. Then, -the `CGAL::Triangulation_data_structure_2` -uses a rebind mechanism (similar to the one specified in -`std::allocator`) in order to plug itself -as parameter in the face and vertex base classes. -This mechanism requires that the base class provides -a templated nested class `Rebind_TDS` that -itself provides -the subtype `Rebind_TDS::Other` -which is the rebound version of the base class. -This rebound base class is the class -that the `CGAL::Triangulation_data_structure_2` -actually uses as a base class for the class -`CGAL::Triangulation_data_structure_2::Face`. +data structure parameter. Then, +the `CGAL::Triangulation_data_structure_2` +uses a rebind mechanism (similar to the one specified in +`std::allocator`) in order to plug itself +as parameter in the face and vertex base classes. +This mechanism requires that the base class provides +a templated nested class `Rebind_TDS` that +itself provides +the subtype `Rebind_TDS::Other` +which is the rebound version of the base class. +This rebound base class is the class +that the `CGAL::Triangulation_data_structure_2` +actually uses as a base class for the class +`CGAL::Triangulation_data_structure_2::Face`. \cgalHasModel `CGAL::Triangulation_ds_face_base_2` -\sa `TriangulationDSVertexBase_2` -\sa `CGAL::Triangulation_data_structure_2` +\sa `TriangulationDSVertexBase_2` +\sa `CGAL::Triangulation_data_structure_2` */ @@ -59,60 +59,60 @@ class TriangulationDSFaceBase_2 { public: -/// \name Types +/// \name Types /// The concept `TriangulationDSFaceBase_2` has to provide the /// following types. /// @{ /*! -This template class has to define a type `Rebind_TDS::%Other` which is the -rebound face base, where the -`CGAL::Triangulation_data_structure_2` is actually plugged in. -This type `Other` will be the actual base -of the class `CGAL::Triangulation_data_structure_2::Face`. +This template class has to define a type `Rebind_TDS::%Other` which is the +rebound face base, where the +`CGAL::Triangulation_data_structure_2` is actually plugged in. +This type `Other` will be the actual base +of the class `CGAL::Triangulation_data_structure_2::Face`. \note It can be implemented using a nested template class. \sa Section \ref TDS_2TheRebindMechanism -*/ -template +*/ +template using Rebind_TDS = unspecified_type; /*! -*/ -typedef TriangulationDataStructure_2 Triangulation_data_structure; +*/ +typedef TriangulationDataStructure_2 Triangulation_data_structure; /*! -*/ -typedef TriangulationDataStructure_2::Vertex_handle Vertex_handle; +*/ +typedef TriangulationDataStructure_2::Vertex_handle Vertex_handle; /*! -*/ -typedef TriangulationDataStructure_2::Face_handle Face_handle; +*/ +typedef TriangulationDataStructure_2::Face_handle Face_handle; -/// @} +/// @} -/// \name Creation +/// \name Creation /// @{ /*! -default constructor. -*/ +default constructor. +*/ TriangulationDSFaceBase_2(); /*! -Initializes the vertices with `v0, v1, v2` and the neighbors -with `Face_handle()`. -*/ +Initializes the vertices with `v0, v1, v2` and the neighbors +with `Face_handle()`. +*/ TriangulationDSFaceBase_2(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2); /*! -initializes the vertices with `v0,v1, v2` and the neighbors with -`n0, n1, n2`. -*/ +initializes the vertices with `v0,v1, v2` and the neighbors with +`n0, n1, n2`. +*/ TriangulationDSFaceBase_2(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, @@ -120,55 +120,55 @@ TriangulationDSFaceBase_2(Vertex_handle v0, Face_handle n1, Face_handle n2); -/// @} +/// @} -/// \name Access Functions +/// \name Access Functions /// @{ /*! -returns the dimension. -*/ -int dimension(); +returns the dimension. +*/ +int dimension(); -/// @} +/// @} -/// \name Orientation +/// \name Orientation /// @{ /*! -Changes the orientation of the face by exchanging `vertex(0)` -with `vertex(1)` and `neighbor(0)` with `neighbor(1)`. -*/ -void reorient(); +Changes the orientation of the face by exchanging `vertex(0)` +with `vertex(1)` and `neighbor(0)` with `neighbor(1)`. +*/ +void reorient(); /*! -performs a counterclockwise permutation of the -vertices and neighbors of the face. -*/ -void ccw_permute(); +performs a counterclockwise permutation of the +vertices and neighbors of the face. +*/ +void ccw_permute(); /*! -performs a clockwise permutation of the -vertices and neighbors of the face. -*/ -void cw_permute(); +performs a clockwise permutation of the +vertices and neighbors of the face. +*/ +void cw_permute(); -/// @} +/// @} -/// \name Checking +/// \name Checking /// @{ /*! -performs any required test on a face. +performs any required test on a face. -If `verbose` is set to `true`, messages are printed to give -a precise indication of the kind of invalidity encountered. -*/ -bool is_valid(bool verbose = false) const; +If `verbose` is set to `true`, messages are printed to give +a precise indication of the kind of invalidity encountered. +*/ +bool is_valid(bool verbose = false) const; -/// @} +/// @} -/// \name Various +/// \name Various /// These member functions are required by /// `CGAL::Triangulation_data_structure_2` because it uses /// `CGAL::Compact_container` to store its faces. See the documentation of @@ -177,12 +177,12 @@ bool is_valid(bool verbose = false) const; /*! -*/ -void * for_compact_container() const; +*/ +void * for_compact_container() const; /*! -*/ +*/ void for_compact_container(void *p); /// @} diff --git a/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h b/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h index dcd30aa9f07..37f979d4717 100644 --- a/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h +++ b/TDS_2/doc/TDS_2/Concepts/TriangulationDSVertexBase_2.h @@ -5,49 +5,49 @@ \cgalRefines `TriangulationDataStructure_2::Vertex` -The concept `TriangulationDSVertexBase_2` describes the requirements for the +The concept `TriangulationDSVertexBase_2` describes the requirements for the vertex base class of a `CGAL::Triangulation_data_structure_2`. -Note that if the `CGAL::Triangulation_data_structure_2` -is plugged into a triangulation class, -the vertex base class may have additional geometric -requirements depending on the triangulation class. +Note that if the `CGAL::Triangulation_data_structure_2` +is plugged into a triangulation class, +the vertex base class may have additional geometric +requirements depending on the triangulation class. -At the base level, -provides access to one of its incident -faces through a `Face_handle`. +At the base level, +provides access to one of its incident +faces through a `Face_handle`. -Since the `CGAL::Triangulation_data_structure_2` is the class -which defines the handle -types, the vertex base class has to be somehow -parameterized by the triangulation -data structure. But since the `CGAL::Triangulation_data_structure_2` -itself is parameterized by the face and vertex -base classes, there is a cycle in the definition of these classes. -In order -to break the cycle, the base classes for faces and vertices -which are plugged in to instantiate a -`Triangulation_data_structure_2` -use `void` as triangulation -data structure parameter. Then, -the `CGAL::Triangulation_data_structure_2` -uses a rebind mechanism (similar to the one specified in -`std::allocator`) in order to plug itself -as parameter in the face and vertex base classes. -This mechanism requires that the base class provides -a templated nested class `Rebind_TDS` that -itself provides -the subtype `Rebind_TDS::Other` -which is the rebound version of the base class. -This rebound base class is the class -that the `CGAL::Triangulation_data_structure_2` -actually uses as a base class for the class -of `CGAL::Triangulation_data_structure_2::Vertex`. +Since the `CGAL::Triangulation_data_structure_2` is the class +which defines the handle +types, the vertex base class has to be somehow +parameterized by the triangulation +data structure. But since the `CGAL::Triangulation_data_structure_2` +itself is parameterized by the face and vertex +base classes, there is a cycle in the definition of these classes. +In order +to break the cycle, the base classes for faces and vertices +which are plugged in to instantiate a +`Triangulation_data_structure_2` +use `void` as triangulation +data structure parameter. Then, +the `CGAL::Triangulation_data_structure_2` +uses a rebind mechanism (similar to the one specified in +`std::allocator`) in order to plug itself +as parameter in the face and vertex base classes. +This mechanism requires that the base class provides +a templated nested class `Rebind_TDS` that +itself provides +the subtype `Rebind_TDS::Other` +which is the rebound version of the base class. +This rebound base class is the class +that the `CGAL::Triangulation_data_structure_2` +actually uses as a base class for the class +of `CGAL::Triangulation_data_structure_2::Vertex`. \cgalHasModel `CGAL::Triangulation_ds_vertex_base_2` -\sa `TriangulationDSFaceBase_2` -\sa `CGAL::Triangulation_data_structure_2` +\sa `TriangulationDSFaceBase_2` +\sa `CGAL::Triangulation_data_structure_2` */ @@ -55,55 +55,55 @@ class TriangulationDSVertexBase_2 { public: -/// \name Types +/// \name Types /// The concept `TriangulationDSVertexBase_2` has to provide the following types. /// @{ /*! -This template class has to define a type `Rebind_TDS::%Other` which is the -rebound vertex base , where the actual -`CGAL::Triangulation_data_structure_2` is plugged in. -This type `Other` will be the actual base -of the class `CGAL::Triangulation_data_structure_2::Vertex`. +This template class has to define a type `Rebind_TDS::%Other` which is the +rebound vertex base , where the actual +`CGAL::Triangulation_data_structure_2` is plugged in. +This type `Other` will be the actual base +of the class `CGAL::Triangulation_data_structure_2::Vertex`. \note It can be implemented using a nested template class. \sa Section \ref TDS_2TheRebindMechanism -*/ -template +*/ +template using Rebind_TDS = unspecified_type; /*! -*/ -typedef TriangulationDataStructure_2 Triangulation_data_structure; +*/ +typedef TriangulationDataStructure_2 Triangulation_data_structure; /*! -*/ -typedef TriangulationDataStructure_2::Vertex_handle Vertex_handle; +*/ +typedef TriangulationDataStructure_2::Vertex_handle Vertex_handle; /*! -*/ -typedef TriangulationDataStructure_2::Face_handle Face_handle; +*/ +typedef TriangulationDataStructure_2::Face_handle Face_handle; -/// @} +/// @} -/// \name Creation +/// \name Creation /// @{ /*! -default constructor. -*/ -TriangulationDSVertexBase_2(); +default constructor. +*/ +TriangulationDSVertexBase_2(); /*! -Constructs a vertex pointing to face `f`. -*/ -TriangulationDSVertexBase_2(Face_handle f); +Constructs a vertex pointing to face `f`. +*/ +TriangulationDSVertexBase_2(Face_handle f); -/// @} +/// @} -/// \name Various +/// \name Various /// These member functions are required by /// `CGAL::Triangulation_data_structure_2` because it uses /// `CGAL::Compact_container` to store its faces. See the documentation of @@ -112,12 +112,12 @@ TriangulationDSVertexBase_2(Face_handle f); /*! -*/ -void * for_compact_container() const; +*/ +void * for_compact_container() const; /*! -*/ +*/ void for_compact_container(void* p); /// @} diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index 680ab3579e9..a62f800c697 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Mariette Yvinec @@ -29,7 +29,7 @@ #include #include #include - + #include #include @@ -40,11 +40,11 @@ #include #include -namespace CGAL { +namespace CGAL { -template < class Vb = Triangulation_ds_vertex_base_2<>, +template < class Vb = Triangulation_ds_vertex_base_2<>, class Fb = Triangulation_ds_face_base_2<> > -class Triangulation_data_structure_2 +class Triangulation_data_structure_2 :public Triangulation_cw_ccw_2 { typedef Triangulation_data_structure_2 Tds; @@ -71,7 +71,7 @@ public: typedef Vertex_base Vertex; typedef Face_base Face; - + typedef Compact_container Face_range; typedef Compact_container Vertex_range; @@ -89,7 +89,7 @@ public: typedef Iterator_range > Vertex_handles; typedef Iterator_range > Face_handles; typedef Iterator_range Edges; - + typedef Vertex_iterator Vertex_handle; typedef Face_iterator Face_handle; typedef std::pair Edge; @@ -103,7 +103,7 @@ protected: //CREATORS - DESTRUCTORS public: - Triangulation_data_structure_2(); + Triangulation_data_structure_2(); Triangulation_data_structure_2(const Tds &tds); Triangulation_data_structure_2(Triangulation_data_structure_2&& tds) noexcept(noexcept(Face_range(std::move(tds._faces))) && @@ -117,7 +117,7 @@ public: //ACCESS FUNCTIONS // We need the const_cast<>s because TDS is not const-correct. Face_range& faces() { return _faces;} - Face_range& faces() const + Face_range& faces() const { return const_cast(this)->_faces;} Vertex_range& vertices() {return _vertices;} Vertex_range& vertices() const @@ -128,21 +128,21 @@ public: size_type number_of_faces() const ; size_type number_of_edges() const; size_type number_of_full_dim_faces() const; //number of faces stored by tds - + // TEST FEATURES bool is_vertex(Vertex_handle v) const; bool is_edge(Face_handle fh, int i) const; bool is_edge(Vertex_handle va, Vertex_handle vb) const; - bool is_edge(Vertex_handle va, Vertex_handle vb, - Face_handle& fr, int& i) const; + bool is_edge(Vertex_handle va, Vertex_handle vb, + Face_handle& fr, int& i) const; bool is_face(Face_handle fh) const; - bool is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3) const; - bool is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle& fr) const; + bool is_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3) const; + bool is_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Face_handle& fr) const; // ITERATORS AND CIRCULATORS public: @@ -163,7 +163,7 @@ public: if (dimension() < 2) return faces_end(); return faces().begin(); } - + Face_iterator faces_end() const { return faces().end(); } @@ -171,7 +171,7 @@ public: Face_handles face_handles() const { return make_prevent_deref_range(faces_begin(),faces_end()); } - + Vertex_iterator vertices_begin() const { return vertices().begin(); } @@ -183,7 +183,7 @@ public: Vertex_handles vertex_handles() const { return make_prevent_deref_range(vertices_begin(),vertices_end()); } - + Edge_iterator edges_begin() const { return Edge_iterator(this); } @@ -196,18 +196,18 @@ public: return Edges(edges_begin(),edges_end()); } - Face_circulator incident_faces(Vertex_handle v, - Face_handle f = Face_handle()) const{ + Face_circulator incident_faces(Vertex_handle v, + Face_handle f = Face_handle()) const{ return Face_circulator(v,f); } - Vertex_circulator incident_vertices(Vertex_handle v, - Face_handle f = Face_handle()) const - { - return Vertex_circulator(v,f); + Vertex_circulator incident_vertices(Vertex_handle v, + Face_handle f = Face_handle()) const + { + return Vertex_circulator(v,f); } - Edge_circulator incident_edges(Vertex_handle v, - Face_handle f = Face_handle()) const{ + Edge_circulator incident_edges(Vertex_handle v, + Face_handle f = Face_handle()) const{ return Edge_circulator(v,f); } @@ -215,19 +215,19 @@ public: int count = 0; Vertex_circulator vc = incident_vertices(v), done(vc); if ( ! vc.is_empty()) { - do { - count += 1; + do { + count += 1; } while (++vc != done); } return count; } - + Vertex_handle mirror_vertex(Face_handle f, int i) const { CGAL_triangulation_precondition ( f->neighbor(i) != Face_handle() - && f->dimension() >= 1); + && f->dimension() >= 1); return f->neighbor(i)->vertex(mirror_index(f,i)); } @@ -236,7 +236,7 @@ public: { // return the index of opposite vertex in neighbor(i); CGAL_triangulation_precondition (f->neighbor(i) != Face_handle() && - f->dimension() >= 1); + f->dimension() >= 1); if (f->dimension() == 1) { CGAL_assertion(i<=1); const int j = f->neighbor(i)->index(f->vertex((i==0) ? 1 : 0)); @@ -246,8 +246,8 @@ public: return ccw( f->neighbor(i)->index(f->vertex(ccw(i)))); } - Edge - mirror_edge(const Edge e) const + Edge + mirror_edge(const Edge e) const { CGAL_triangulation_precondition(e.first->neighbor(e.second) != Face_handle() && e.first->dimension() >= 1); @@ -257,17 +257,17 @@ public: // MODIFY void flip(Face_handle f, int i); - + Vertex_handle insert_first(); Vertex_handle insert_second(); Vertex_handle insert_in_face(Face_handle f); Vertex_handle insert_in_edge(Face_handle f, int i); - Vertex_handle insert_dim_up(Vertex_handle w = Vertex_handle(), - bool orient=true); + Vertex_handle insert_dim_up(Vertex_handle w = Vertex_handle(), + bool orient=true); void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle()); - void remove_1D(Vertex_handle v); - + void remove_1D(Vertex_handle v); + void remove_second(Vertex_handle v); void remove_first(Vertex_handle v); void remove_dim_down(Vertex_handle v); @@ -279,45 +279,45 @@ public: // template< class EdgeIt> // Vertex_handle star_hole(EdgeIt edge_begin,EdgeIt edge_end); - + // template< class EdgeIt> // void star_hole(Vertex_handle v, EdgeIt edge_begin, EdgeIt edge_end); // template< class EdgeIt, class FaceIt> -// Vertex_handle star_hole(EdgeIt edge_begin, -// EdgeIt edge_end, -// FaceIt face_begin, -// FaceIt face_end); - +// Vertex_handle star_hole(EdgeIt edge_begin, +// EdgeIt edge_end, +// FaceIt face_begin, +// FaceIt face_end); + // template< class EdgeIt, class FaceIt> // void star_hole(Vertex_handle v, -// EdgeIt edge_begin, -// EdgeIt edge_end, -// FaceIt face_begin, -// FaceIt face_end); - +// EdgeIt edge_begin, +// EdgeIt edge_end, +// FaceIt face_begin, +// FaceIt face_end); + Vertex_handle create_vertex(); Vertex_handle create_vertex(const Vertex &v); - Vertex_handle create_vertex(Vertex_handle v); //calls copy constructor + Vertex_handle create_vertex(Vertex_handle v); //calls copy constructor Face_handle create_face(); Face_handle create_face(const Face& f); - Face_handle create_face(Face_handle f); //calls copy constructor + Face_handle create_face(Face_handle f); //calls copy constructor - Face_handle create_face(Face_handle f1, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3); - Face_handle create_face(Face_handle f1, int i1, - Face_handle f2, int i2); + Face_handle create_face(Face_handle f1, int i1, + Face_handle f2, int i2, + Face_handle f3, int i3); + Face_handle create_face(Face_handle f1, int i1, + Face_handle f2, int i2); Face_handle create_face(Face_handle f1, int i1, Vertex_handle v); - Face_handle create_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3); - Face_handle create_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle f1, - Face_handle f2, - Face_handle f3); + Face_handle create_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3); + Face_handle create_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Face_handle f1, + Face_handle f2, + Face_handle f3); void set_adjacency(Face_handle f0, int i0, Face_handle f1, int i1) const; @@ -357,14 +357,14 @@ public: // CHECKING bool is_valid(bool verbose = false, int level = 0) const; - + // HELPING private: typedef std::pair Vh_pair; public: - void set_adjacency(Face_handle fh, - int ih, - std::map< Vh_pair, Edge>& edge_map); + void set_adjacency(Face_handle fh, + int ih, + std::map< Vh_pair, Edge>& edge_map); void reorient_faces(); private: bool dim_down_precondition(Face_handle f, int i); @@ -422,12 +422,12 @@ public: // I/O Vertex_handle file_input(std::istream& is, bool skip_first=false); void file_output(std::ostream& os, - Vertex_handle v = Vertex_handle(), - bool skip_first=false) const; + Vertex_handle v = Vertex_handle(), + bool skip_first=false) const; Vertex_handle off_file_input(std::istream& is, bool verbose=false); void vrml_output(std::ostream& os, - Vertex_handle v = Vertex_handle(), - bool skip_first=false) const; + Vertex_handle v = Vertex_handle(), + bool skip_first=false) const; // SETTING (had to make them public for use in remove from Triangulations) void set_dimension (int n) {_dimension = n ;} @@ -438,7 +438,7 @@ public: /************* START OF MODIFICATIONS ***************/ template< class FaceIt > - Vertex_handle insert_in_hole(FaceIt face_begin, FaceIt face_end) + Vertex_handle insert_in_hole(FaceIt face_begin, FaceIt face_end) { Vertex_handle newv = create_vertex(); insert_in_hole(newv, face_begin, face_end); @@ -447,7 +447,7 @@ public: template< class FaceIt > - void insert_in_hole(Vertex_handle v, FaceIt face_begin, FaceIt face_end) + void insert_in_hole(Vertex_handle v, FaceIt face_begin, FaceIt face_end) { CGAL_triangulation_precondition(dimension() == 2); @@ -468,8 +468,8 @@ public: ii = newi; } } while(!found_boundary); - // Now we have found ONE edge on the boundary. - // From that one edge we must walk on the boundary + // Now we have found ONE edge on the boundary. + // From that one edge we must walk on the boundary // of the hole until we've covered the whole thing. bool complete_walk = false; @@ -491,14 +491,14 @@ public: } while (!complete_walk); // At this point, bdry_edges contains the edges that define // the boundary of the hole with a specific ordering: for any - // two consecutive edges in the vector e1 = (f1, i1), - // e2 = (f2, i2) it holds that + // two consecutive edges in the vector e1 = (f1, i1), + // e2 = (f2, i2) it holds that // f1->vertex(cw(i1)) == f2->vertex(ccw(i2)) for (unsigned int jj = 0; jj < bdry_edges.size(); jj++) { Face_handle fh = bdry_edges[jj].first; int idx = bdry_edges[jj].second; - + Vertex_handle v1 = fh->vertex(ccw(idx)); Vertex_handle v2 = fh->vertex(cw(idx)); @@ -536,7 +536,7 @@ public: template< class EdgeIt> Vertex_handle star_hole(EdgeIt edge_begin, EdgeIt edge_end) - // creates a new vertex + // creates a new vertex // and stars from it // the hole described by the range [edge_begin,edge_end[ // the triangulation is assumed to have dim=2 @@ -546,30 +546,30 @@ public: star_hole(newv, edge_begin, edge_end); return newv; } - + template< class EdgeIt> void star_hole(Vertex_handle v, EdgeIt edge_begin, EdgeIt edge_end) // uses vertex v // to star the hole described by the range [edge_begin,edge_end[ // the triangulation is assumed to have dim=2 // the hole is supposed to be ccw oriented - { + { std::list empty_list; - star_hole(v, - edge_begin, - edge_end, - empty_list.begin(), - empty_list.end()); - return; + star_hole(v, + edge_begin, + edge_end, + empty_list.begin(), + empty_list.end()); + return; } template< class EdgeIt, class FaceIt> - Vertex_handle star_hole(EdgeIt edge_begin, - EdgeIt edge_end, - FaceIt face_begin, - FaceIt face_end) - // creates a new vertex + Vertex_handle star_hole(EdgeIt edge_begin, + EdgeIt edge_end, + FaceIt face_begin, + FaceIt face_end) + // creates a new vertex // and stars from it // the hole described by the range [edge_begin,edge_end[ // reusing the faces in the range [face_begin,face_end[ @@ -580,13 +580,13 @@ public: star_hole(newv, edge_begin, edge_end, face_begin, face_end); return newv; } - + template< class EdgeIt, class FaceIt> void star_hole(Vertex_handle newv, - EdgeIt edge_begin, - EdgeIt edge_end, - FaceIt face_begin, - FaceIt face_end) + EdgeIt edge_begin, + EdgeIt edge_end, + FaceIt face_begin, + FaceIt face_end) // uses vertex v // to star the hole described by the range [edge_begin,edge_end[ // reusing the faces in the range [face_begin,face_end[ @@ -602,7 +602,7 @@ public: fn->vertex(cw(in))->set_face(fn); Face_handle first_f = reset_or_create_face(fn, in , newv, fit, face_end); Face_handle previous_f=first_f, next_f; - ++eit; + ++eit; for( ; eit != edge_end ; eit++) { fn = (*eit).first; @@ -615,35 +615,35 @@ public: set_adjacency(next_f, 0, first_f, 1); newv->set_face(first_f); - return; + return; } private: template< class FaceIt> - Face_handle reset_or_create_face(Face_handle fn, - int in, - Vertex_handle v, - FaceIt& fit, - const FaceIt& face_end) + Face_handle reset_or_create_face(Face_handle fn, + int in, + Vertex_handle v, + FaceIt& fit, + const FaceIt& face_end) { if (fit == face_end) return create_face(fn, in, v); (*fit)->set_vertices(fn->vertex(cw(in)), fn->vertex(ccw(in)), v); (*fit)->set_neighbors(Face_handle(),Face_handle(),fn); fn->set_neighbor(in, *fit); - return *fit++; + return *fit++; } }; //for backward compatibility template < class Gt , class Vb, class Fb> -class Triangulation_default_data_structure_2 +class Triangulation_default_data_structure_2 : public Triangulation_data_structure_2 { public: typedef Triangulation_data_structure_2 Tds; typedef Triangulation_default_data_structure_2 Tdds; - typedef Gt Geom_traits; + typedef Gt Geom_traits; Triangulation_default_data_structure_2(const Geom_traits& = Geom_traits()) : Tds() {} @@ -658,13 +658,13 @@ public: typedef Triangulation_data_structure_2 Tds; typedef Triangulation_data_structure_using_list_2 Tdsul; - Triangulation_data_structure_using_list_2(): Tds() {} + Triangulation_data_structure_using_list_2(): Tds() {} }; - + template < class Vb, class Fb> Triangulation_data_structure_2 :: -Triangulation_data_structure_2() +Triangulation_data_structure_2() : _dimension(-2) { } @@ -693,7 +693,7 @@ Triangulation_data_structure_2 :: clear(); } -//copy-assignment +//copy-assignment template < class Vb, class Fb> Triangulation_data_structure_2& Triangulation_data_structure_2 :: @@ -701,9 +701,9 @@ operator= (const Tds &tds) { copy_tds(tds); return *this; -} +} -//move-assignment +//move-assignment template < class Vb, class Fb> Triangulation_data_structure_2& Triangulation_data_structure_2 :: @@ -713,7 +713,7 @@ operator= (Tds &&tds) noexcept(noexcept(Tds(std::move(tds)))) _vertices = std::move(tds._vertices); _dimension = std::exchange(tds._dimension, -2); return *this; -} +} template < class Vb, class Fb> void @@ -740,17 +740,17 @@ swap(Tds &tds) //ACCESS FUNCTIONS template -inline +inline typename Triangulation_data_structure_2::size_type Triangulation_data_structure_2 :: -number_of_faces() const +number_of_faces() const { if (dimension() < 2) return 0; return faces().size(); } template -inline +inline typename Triangulation_data_structure_2::size_type Triangulation_data_structure_2:: number_of_edges() const @@ -761,7 +761,7 @@ number_of_edges() const default: return 0; } } - + template typename Triangulation_data_structure_2::size_type Triangulation_data_structure_2:: @@ -804,23 +804,23 @@ is_edge(Vertex_handle va, Vertex_handle vb) const Vertex_circulator vc = incident_vertices(va), done(vc); if ( vc == 0) return false; do { - if( vb == vc ) {return true;} + if( vb == vc ) {return true;} } while (++vc != done); return false; } - + template bool Triangulation_data_structure_2:: -is_edge(Vertex_handle va, Vertex_handle vb, - Face_handle &fr, int & i) const +is_edge(Vertex_handle va, Vertex_handle vb, + Face_handle &fr, int & i) const // assume va is a vertex of t // returns true (false) if the line segment ab is (is not) an edge of t // if true is returned (fr,i) is the edge ab // with face fr on the right of a->b { - Face_handle fc = va->face(); + Face_handle fc = va->face(); Face_handle start = fc; if (fc == nullptr) return false; int inda, indb; @@ -838,7 +838,7 @@ is_edge(Vertex_handle va, Vertex_handle vb, } template -inline bool +inline bool Triangulation_data_structure_2:: is_face(Face_handle fh) const { @@ -849,23 +849,23 @@ is_face(Face_handle fh) const } template -inline bool +inline bool Triangulation_data_structure_2:: -is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3) const +is_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3) const { Face_handle f; return is_face(v1,v2,v3,f); } template -bool +bool Triangulation_data_structure_2:: -is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle &f) const +is_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Face_handle &f) const { if (dimension() != 2) return false; int i; @@ -876,7 +876,7 @@ is_face(Vertex_handle v1, int ind1= f->index(v1); int ind2= f->index(v2); if (v3 == f->vertex(3-ind1-ind2)) { return true;} - return false; + return false; } template @@ -887,19 +887,19 @@ flip(Face_handle f, int i) CGAL_triangulation_precondition( dimension()==2); Face_handle n = f->neighbor(i); int ni = mirror_index(f,i); //ni = n->index(f); - + Vertex_handle v_cw = f->vertex(cw(i)); Vertex_handle v_ccw = f->vertex(ccw(i)); // bl == bottom left, tr == top right Face_handle tr = f->neighbor(ccw(i)); - int tri = mirror_index(f,ccw(i)); + int tri = mirror_index(f,ccw(i)); Face_handle bl = n->neighbor(ccw(ni)); - int bli = mirror_index(n,ccw(ni)); - + int bli = mirror_index(n,ccw(ni)); + f->set_vertex(cw(i), n->vertex(ni)); n->set_vertex(cw(ni), f->vertex(i)); - + // update the neighborhood relations set_adjacency(f, i, bl, bli); set_adjacency(f, ccw(i), n, ccw(ni)); @@ -908,29 +908,29 @@ flip(Face_handle f, int i) if(v_cw->face() == f) { v_cw->set_face(n); } - + if(v_ccw->face() == n) { v_ccw->set_face(f); } } - + template < class Vb, class Fb> typename Triangulation_data_structure_2::Vertex_handle Triangulation_data_structure_2:: insert_first( ) { CGAL_triangulation_precondition( number_of_vertices() == 0 && - dimension()==-2 ); + dimension()==-2 ); return insert_dim_up(); } template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle +typename Triangulation_data_structure_2::Vertex_handle Triangulation_data_structure_2:: insert_second() { CGAL_triangulation_precondition( number_of_vertices() == 1 && - dimension()==-1 ); + dimension()==-1 ); return insert_dim_up(); } @@ -948,10 +948,10 @@ insert_in_face(Face_handle f) Vertex_handle v0 = f->vertex(0); Vertex_handle v2 = f->vertex(2); Vertex_handle v1 = f->vertex(1); - + Face_handle n1 = f->neighbor(1); Face_handle n2 = f->neighbor(2); - + Face_handle f1 = create_face(v0, v, v2, f, n1, Face_handle()); Face_handle f2 = create_face(v0, v1, v, f, Face_handle(), n2); @@ -981,11 +981,11 @@ Triangulation_data_structure_2:: insert_in_edge(Face_handle f, int i) //insert in the edge opposite to vertex i of face f { - CGAL_triangulation_precondition(f != Face_handle() && dimension() >= 1); + CGAL_triangulation_precondition(f != Face_handle() && dimension() >= 1); if (dimension() == 1) {CGAL_triangulation_precondition(i == 2);} - if (dimension() == 2) {CGAL_triangulation_precondition(i == 0 || - i == 1 || - i == 2);} + if (dimension() == 2) {CGAL_triangulation_precondition(i == 0 || + i == 1 || + i == 2);} Vertex_handle v; if (dimension() == 1) { v = create_vertex(); @@ -1002,7 +1002,7 @@ insert_in_edge(Face_handle f, int i) Face_handle n = f->neighbor(i); int in = mirror_index(f,i); //n->index(f); v = insert_in_face(f); - flip(n,in); + flip(n,in); } return v; @@ -1014,9 +1014,9 @@ typename Triangulation_data_structure_2::Vertex_handle Triangulation_data_structure_2:: insert_dim_up(Vertex_handle w, bool orient) { - // the following function insert + // the following function insert // a vertex v which is outside the affine hull of Tds - // The triangulation will be starred from v and w + // The triangulation will be starred from v and w // ( geometrically w= // the infinite vertex ) // w=nullptr for first and second insertions // orient governs the orientation of the resulting triangulation @@ -1027,8 +1027,8 @@ insert_dim_up(Vertex_handle w, bool orient) Face_handle f2; const int dim = dimension(); //it is the resulting dimension - - switch (dim) { + + switch (dim) { case -1: f1 = create_face(v,Vertex_handle(),Vertex_handle()); v->set_face(f1); @@ -1043,64 +1043,64 @@ insert_dim_up(Vertex_handle w, bool orient) case 2 : { std::list faces_list; - Face_iterator ib= face_iterator_base_begin(); + Face_iterator ib= face_iterator_base_begin(); Face_iterator ib_end = face_iterator_base_end(); for (; ib != ib_end ; ++ib){ - faces_list.push_back( ib); + faces_list.push_back( ib); } - + std::list to_delete; typename std::list::iterator lfit = faces_list.begin(); Face_handle f, g; for ( ; lfit != faces_list.end() ; ++lfit) { - f = * lfit; - g = create_face(f); //calls copy constructor of face - f->set_vertex(dim,v); - g->set_vertex(dim,w); - set_adjacency(f, dim, g, dim); - if (f->has_vertex(w)) to_delete.push_back(g); // flat face to delete + f = * lfit; + g = create_face(f); //calls copy constructor of face + f->set_vertex(dim,v); + g->set_vertex(dim,w); + set_adjacency(f, dim, g, dim); + if (f->has_vertex(w)) to_delete.push_back(g); // flat face to delete } lfit = faces_list.begin(); for ( ; lfit != faces_list.end() ; ++lfit) { - f = * lfit; - g = f->neighbor(dim); - for(int j = 0; j < dim ; ++j) { - g->set_neighbor(j, f->neighbor(j)->neighbor(dim)); - } + f = * lfit; + g = f->neighbor(dim); + for(int j = 0; j < dim ; ++j) { + g->set_neighbor(j, f->neighbor(j)->neighbor(dim)); + } } // couldn't unify the code for reorientation mater - lfit = faces_list.begin() ; + lfit = faces_list.begin() ; if (dim == 1){ - if (orient) { - (*lfit)->reorient(); ++lfit ; (*lfit)->neighbor(1)->reorient(); - } - else { - (*lfit)->neighbor(1)->reorient(); ++lfit ; (*lfit)->reorient(); - } + if (orient) { + (*lfit)->reorient(); ++lfit ; (*lfit)->neighbor(1)->reorient(); + } + else { + (*lfit)->neighbor(1)->reorient(); ++lfit ; (*lfit)->reorient(); + } } else { // dimension == 2 - for( ;lfit != faces_list.end(); ++lfit ) { - if (orient) {(*lfit)->neighbor(2)->reorient();} - else { (*lfit)->reorient();} - } + for( ;lfit != faces_list.end(); ++lfit ) { + if (orient) {(*lfit)->neighbor(2)->reorient();} + else { (*lfit)->reorient();} + } } lfit = to_delete.begin(); int i1, i2; for ( ;lfit != to_delete.end(); ++lfit){ - f = *lfit ; - int j ; - if (f->vertex(0) == w) {j=0;} - else {j=1;} - f1= f->neighbor(dim); i1= mirror_index(f,dim); //f1->index(f); - f2= f->neighbor(j); i2= mirror_index(f,j); //f2->index(f); - set_adjacency(f1, i1, f2, i2); - delete_face(f); + f = *lfit ; + int j ; + if (f->vertex(0) == w) {j=0;} + else {j=1;} + f1= f->neighbor(dim); i1= mirror_index(f,dim); //f1->index(f); + f2= f->neighbor(j); i2= mirror_index(f,j); //f2->index(f); + set_adjacency(f1, i1, f2, i2); + delete_face(f); } - + v->set_face( *(faces_list.begin())); } break; @@ -1122,42 +1122,42 @@ remove_degree_3(Vertex_handle v, Face_handle f) if (f == Face_handle()) {f= v->face();} else { CGAL_triangulation_assertion( f->has_vertex(v));} - + int i = f->index(v); Face_handle left = f->neighbor(cw(i)); - int li = mirror_index(f,cw(i)); + int li = mirror_index(f,cw(i)); Face_handle right = f->neighbor(ccw(i)); - int ri = mirror_index(f,ccw(i)); + int ri = mirror_index(f,ccw(i)); Face_handle ll, rr; Vertex_handle q = left->vertex(li); CGAL_triangulation_assertion( left->vertex(li) == right->vertex(ri)); - + ll = left->neighbor(cw(li)); if(ll != Face_handle()) { - int lli = mirror_index(left,cw(li)); + int lli = mirror_index(left,cw(li)); ll->set_neighbor(lli, f); - } + } f->set_neighbor(cw(i), ll); - if (f->vertex(ccw(i))->face() == left) f->vertex(ccw(i))->set_face(f); - + if (f->vertex(ccw(i))->face() == left) f->vertex(ccw(i))->set_face(f); + rr = right->neighbor(ccw(ri)); if(rr != Face_handle()) { int rri = mirror_index(right,ccw(ri)); //rr->index(right); rr->set_neighbor(rri, f); - } + } f->set_neighbor(ccw(i), rr); - if (f->vertex(cw(i))->face() == right) f->vertex(cw(i))->set_face(f); - + if (f->vertex(cw(i))->face() == right) f->vertex(cw(i))->set_face(f); + f->set_vertex(i, q); if (q->face() == right || q->face() == left) { q->set_face(f); } delete_face(right); delete_face(left); - + delete_vertex(v); -} +} template void @@ -1167,7 +1167,7 @@ dim_down(Face_handle f, int i) CGAL_triangulation_expensive_precondition( is_valid() ); CGAL_triangulation_precondition( dimension() == 2 ); CGAL_triangulation_precondition( number_of_vertices() > 3 ); - CGAL_triangulation_precondition( degree( f->vertex(i) ) == + CGAL_triangulation_precondition( degree( f->vertex(i) ) == number_of_vertices()-1 ); Vertex_handle v = f->vertex(i); @@ -1200,12 +1200,12 @@ dim_down(Face_handle f, int i) Vertex_handle v1 = f->vertex(1); f->set_vertex(1, v); Face_handle fl = create_face(v, v1, Vertex_handle(), - n0, f, Face_handle()); + n0, f, Face_handle()); f->set_neighbor(0, fl); n0->set_neighbor(1, fl); v->set_face(f); } - + template void Triangulation_data_structure_2:: @@ -1213,7 +1213,7 @@ remove_dim_down(Vertex_handle v) { Face_handle f; switch( dimension()){ - case -1: + case -1: delete_face(v->face()); break; case 0: @@ -1223,7 +1223,7 @@ remove_dim_down(Vertex_handle v) break; case 1: case 2: -// CGAL_triangulation_precondition ( +// CGAL_triangulation_precondition ( // (dimension() == 1 && number_of_vertices() == 3) || // (dimension() == 2 && number_of_vertices() > 3) ); // the faces incident to v are down graded one dimension @@ -1241,15 +1241,15 @@ remove_dim_down(Vertex_handle v) for( ; lfit != to_downgrade.end() ; ++lfit) { f = *lfit; j = f->index(v); if (dimension() == 1) { - if (j == 0) f->reorient(); - f->set_vertex(1,Vertex_handle()); - f->set_neighbor(1, Face_handle()); + if (j == 0) f->reorient(); + f->set_vertex(1,Vertex_handle()); + f->set_neighbor(1, Face_handle()); } else { //dimension() == 2 - if (j == 0) f->cw_permute(); - else if(j == 1) f->ccw_permute(); - f->set_vertex(2, Vertex_handle()); - f->set_neighbor(2, Face_handle()); + if (j == 0) f->cw_permute(); + else if(j == 1) f->ccw_permute(); + f->set_vertex(2, Vertex_handle()); + f->set_neighbor(2, Face_handle()); } f->vertex(0)->set_face(f); } @@ -1258,7 +1258,7 @@ remove_dim_down(Vertex_handle v) for( ; lfit != to_delete.end() ; ++lfit) { delete_face(*lfit); } - } + } delete_vertex(v); set_dimension(dimension() -1); return; @@ -1266,11 +1266,11 @@ remove_dim_down(Vertex_handle v) template < class Vb, class Fb> void -Triangulation_data_structure_2:: +Triangulation_data_structure_2:: remove_1D(Vertex_handle v) { CGAL_triangulation_precondition( dimension() == 1 && - number_of_vertices() > 3); + number_of_vertices() > 3); Face_handle f = v->face(); int i = f->index(v); if (i==0) {f = f->neighbor(1);} @@ -1292,21 +1292,21 @@ Triangulation_data_structure_2:: remove_second(Vertex_handle v) { CGAL_triangulation_precondition(number_of_vertices()== 2 && - dimension() == 0); + dimension() == 0); remove_dim_down(v); return; } - + template inline void Triangulation_data_structure_2:: remove_first(Vertex_handle v) { - CGAL_triangulation_precondition(number_of_vertices()== 1 && - dimension() == -1); + CGAL_triangulation_precondition(number_of_vertices()== 1 && + dimension() == -1); remove_dim_down(v); - return; + return; } template @@ -1328,9 +1328,9 @@ star_hole(Vertex_handle newv, List_edges& hole) // the triangulation is assumed to have dim=2 // hole is supposed to be ccw oriented { - + star_hole(newv, hole.begin(), hole.end()); - return; + return; } template @@ -1341,7 +1341,7 @@ make_hole(Vertex_handle v, List_edges& hole) // and return the dscription of the hole in hole { CGAL_triangulation_precondition(dimension() == 2); - std::list to_delete; + std::list to_delete; Face_handle f, fn; int i =0, in =0; @@ -1427,14 +1427,14 @@ create_face( Face_handle fh) template typename Triangulation_data_structure_2::Face_handle Triangulation_data_structure_2:: -create_face(Face_handle f1, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3) +create_face(Face_handle f1, int i1, + Face_handle f2, int i2, + Face_handle f3, int i3) { Face_handle newf = faces().emplace(f1->vertex(cw(i1)), - f2->vertex(cw(i2)), - f3->vertex(cw(i3)), - f2, f3, f1); + f2->vertex(cw(i2)), + f3->vertex(cw(i3)), + f2, f3, f1); f1->set_neighbor(i1,newf); f2->set_neighbor(i2,newf); f3->set_neighbor(i3,newf); @@ -1447,9 +1447,9 @@ Triangulation_data_structure_2:: create_face(Face_handle f1, int i1, Face_handle f2, int i2) { Face_handle newf = faces().emplace(f1->vertex(cw(i1)), - f2->vertex(cw(i2)), - f2->vertex(ccw(i2)), - f2, Face_handle(), f1); + f2->vertex(cw(i2)), + f2->vertex(ccw(i2)), + f2, Face_handle(), f1); f1->set_neighbor(i1,newf); f2->set_neighbor(i2,newf); return newf; @@ -1481,7 +1481,7 @@ template typename Triangulation_data_structure_2::Face_handle Triangulation_data_structure_2:: create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle f1, Face_handle f2, Face_handle f3) + Face_handle f1, Face_handle f2, Face_handle f3) { Face_handle newf = faces().emplace(v1, v2, v3, f1, f2, f3); @@ -1508,7 +1508,7 @@ delete_face(Face_handle f) CGAL_triangulation_expensive_precondition( dimension() != 2 || is_face(f)); CGAL_triangulation_expensive_precondition( dimension() != 1 || is_edge(f,2)); CGAL_triangulation_expensive_precondition( dimension() != 0 || - is_vertex(f->vertex(0)) ); + is_vertex(f->vertex(0)) ); faces().erase(f); } @@ -1660,7 +1660,7 @@ join_vertices(Face_handle f, int i, Vertex_handle v) CGAL_triangulation_precondition( i >= 0 && i <= 2 ); // this methods does the "join"-operation and preserves - // the vertex v among the two vertices that define the edge (f, i) + // the vertex v among the two vertices that define the edge (f, i) Vertex_handle v1 = f->vertex( ccw(i) ); Vertex_handle v2 = f->vertex( cw(i) ); @@ -1679,7 +1679,7 @@ join_vertices(Face_handle f, int i, Vertex_handle v) remove_degree_3(v2, f->neighbor(ccw(i))); return v1; } - + /* // The following drawing corrsponds to the variables // used in this part... @@ -1695,10 +1695,10 @@ join_vertices(Face_handle f, int i, Vertex_handle v) // / \ / \ // / \ g / \ // / bl \ / br \ - // / \ / \ + // / \ / \ // *---------*---------* // ibl j=v4 ibr - // + // // The situation after the "join"-operation is as follows: // // i @@ -1711,9 +1711,9 @@ join_vertices(Face_handle f, int i, Vertex_handle v) // * v1 // /|\ // / | \ - // / | \ + // / | \ // / bl|br \ - // / | \ + // / | \ // *-----*-----* // */ @@ -1735,7 +1735,7 @@ join_vertices(Face_handle f, int i, Vertex_handle v) int ibr = mirror_index(g, cw(j) ); // we need to store the faces adjacent to v2 as well as the - // indices of v2 w.r.t. these faces, so that afterwards we can set + // indices of v2 w.r.t. these faces, so that afterwards we can set // v1 to be the vertex for these faces std::vector star_faces_of_v2; std::vector star_indices_of_v2; @@ -1766,7 +1766,7 @@ join_vertices(Face_handle f, int i, Vertex_handle v) star_faces_of_v2[k]->set_vertex( id, v1 ); } - // then make sure that all the vertices have correct pointers to + // then make sure that all the vertices have correct pointers to // faces Vertex_handle v3 = f->vertex(i); Vertex_handle v4 = g->vertex(j); @@ -1812,7 +1812,7 @@ insert_degree_2(Face_handle f, int i) // i / \ // * / \ // / \ / f \ - // / \ / _____ \ + // / \ / _____ \ // / f \ / / f1 \ \ // / \ |/ v \| // v0=ccw(i) *---------* v1=cw(i) ===> v0 *----*----* v1 @@ -1893,16 +1893,16 @@ bool Triangulation_data_structure_2:: is_valid(bool verbose, int level) const { - if(number_of_vertices() == 0){ + if(number_of_vertices() == 0){ return (dimension() == -2); } - + bool result = (dimension()>= -1); CGAL_triangulation_assertion(result); //count and test the validity of the faces (for positive dimensions) - Face_iterator ib = face_iterator_base_begin(); + Face_iterator ib = face_iterator_base_begin(); Face_iterator ib_end = face_iterator_base_end(); size_type count_stored_faces =0; for ( ; ib != ib_end ; ++ib){ @@ -1912,11 +1912,11 @@ is_valid(bool verbose, int level) const CGAL_triangulation_assertion(result); } } - + result = result && (count_stored_faces == number_of_full_dim_faces()); CGAL_triangulation_assertion( - count_stored_faces == number_of_full_dim_faces()); - + count_stored_faces == number_of_full_dim_faces()); + // vertex count size_type vertex_count = 0; for(Vertex_iterator vit = vertices_begin(); vit != vertices_end(); @@ -1928,10 +1928,10 @@ is_valid(bool verbose, int level) const } result = result && (number_of_vertices() == vertex_count); CGAL_triangulation_assertion( number_of_vertices() == vertex_count ); - + //edge count size_type edge_count = 0; - for(Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) { + for(Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) { ++edge_count; } @@ -1940,9 +1940,9 @@ is_valid(bool verbose, int level) const for(Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) { ++face_count; } - + switch(dimension()) { - case -1: + case -1: result = result && vertex_count == 1 && face_count == 0 && edge_count == 0; CGAL_triangulation_assertion(result); @@ -1978,7 +1978,7 @@ copy_tds(const TDS_src& tds_src, const ConvertVertex& convert_vertex, const ConvertFace& convert_face) { - if (vert != typename TDS_src::Vertex_handle()) + if (vert != typename TDS_src::Vertex_handle()) CGAL_triangulation_precondition( tds_src.is_vertex(vert)); clear(); @@ -1987,9 +1987,9 @@ copy_tds(const TDS_src& tds_src, // Number of pointers to cell/vertex to copy per cell. int dim = (std::max)(1, dimension() + 1); - + if(n == 0) {return Vertex_handle();} - + //initializes maps Unique_hash_map vmap; Unique_hash_map fmap; @@ -2002,7 +2002,7 @@ copy_tds(const TDS_src& tds_src, convert_vertex(*vit1, *vh); } - //create faces + //create faces typename TDS_src::Face_iterator fit1 = tds_src.faces().begin(); for( ; fit1 != tds_src.faces_end(); ++fit1) { Face_handle fh = create_face( convert_face(*fit1) ); @@ -2010,7 +2010,7 @@ copy_tds(const TDS_src& tds_src, convert_face(*fit1, *fh); } - //link vertices to a cell + //link vertices to a cell vit1 = tds_src.vertices_begin(); for ( ; vit1 != tds_src.vertices_end(); vit1++) { vmap[vit1]->set_face(fmap[vit1->face()]); @@ -2020,11 +2020,11 @@ copy_tds(const TDS_src& tds_src, fit1 = tds_src.faces().begin(); for ( ; fit1 != tds_src.faces_end(); ++fit1) { for (int j = 0; j < dim ; ++j) { - fmap[fit1]->set_vertex(j, vmap[fit1->vertex(j)] ); - fmap[fit1]->set_neighbor(j, fmap[fit1->neighbor(j)]); + fmap[fit1]->set_vertex(j, vmap[fit1->vertex(j)] ); + fmap[fit1]->set_neighbor(j, fmap[fit1->neighbor(j)]); } } - + // remove the post condition because it is false when copying the // TDS of a regular triangulation because of hidden vertices // CGAL_triangulation_postcondition( is_valid() ); @@ -2039,7 +2039,7 @@ namespace internal { namespace TDS_2{ Vertex_tgt operator()(const Vertex_src& src) const { return Vertex_tgt( src.point() ); } - + void operator()(const Vertex_src&,Vertex_tgt&) const {} }; @@ -2048,27 +2048,27 @@ namespace internal { namespace TDS_2{ { Face_tgt operator()(const Face_src& /*src*/) const { return Face_tgt(); - } - + } + void operator()(const Face_src&,Face_tgt&) const {} }; - + template struct Default_vertex_converter { const Vertex& operator()(const Vertex& src) const { return src; } - + void operator()(const Vertex&,Vertex&) const {} }; - + template struct Default_face_converter{ const Face& operator()(const Face& src) const { return src; - } - + } + void operator()(const Face&,Face&) const {} }; } } //namespace internal::TDS_2 @@ -2095,7 +2095,7 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const // if non nullptr, v is the vertex to be output first // if skip_first is true, the point in the first vertex is not output // (it may be for instance the infinite vertex of the triangulation) - + size_type n = number_of_vertices(); size_type m = number_of_full_dim_faces(); if(is_ascii(os)) os << n << ' ' << m << ' ' << dimension() << std::endl; @@ -2106,7 +2106,7 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const Unique_hash_map F; - // first vertex + // first vertex int inum = 0; if ( v != Vertex_handle()) { V[v] = inum++; @@ -2116,14 +2116,14 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const if(is_ascii(os)) os << std::endl; } } - + // other vertices for( Vertex_iterator vit= vertices_begin(); vit != vertices_end() ; ++vit) { if ( v != vit ) { - V[vit] = inum++; - // os << vit->point(); - os << *vit; - if(is_ascii(os)) os << "\n"; + V[vit] = inum++; + // os << vit->point(); + os << *vit; + if(is_ascii(os)) os << "\n"; } } if(is_ascii(os)) os << "\n"; @@ -2142,7 +2142,7 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const if(is_ascii(os)) os << "\n"; } if(is_ascii(os)) os << "\n"; - + // neighbor pointers of the faces for( Face_iterator it = face_iterator_base_begin(); it != face_iterator_base_end(); ++it) { @@ -2167,7 +2167,7 @@ file_input( std::istream& is, bool skip_first) // if skip_first is true, a first vertex is added (infinite_vertex) //set this first vertex as infinite_Vertex if(number_of_vertices() != 0) clear(); - + size_type n, m; int d; is >> n >> m >> d; @@ -2189,7 +2189,7 @@ file_input( std::istream& is, bool skip_first) V[i] = create_vertex(); is >> *(V[i]); } - + // Creation of the faces int index; int dim = (dimension() == -1 ? 1 : dimension() + 1); @@ -2197,27 +2197,27 @@ file_input( std::istream& is, bool skip_first) for(i = 0; i < m; ++i) { F[i] = create_face() ; for(int j = 0; j < dim ; ++j){ - is >> index; - F[i]->set_vertex(j, V[index]); - // The face pointer of vertices is set too often, - // but otherwise we had to use a further map - V[index]->set_face(F[i]); + is >> index; + F[i]->set_vertex(j, V[index]); + // The face pointer of vertices is set too often, + // but otherwise we had to use a further map + V[index]->set_face(F[i]); } // read in non combinatorial info of the face is >> *(F[i]) ; } } - // Setting the neighbor pointers + // Setting the neighbor pointers { for(i = 0; i < m; ++i) { for(int j = 0; j < dimension()+1; ++j){ - is >> index; - F[i]->set_neighbor(j, F[index]); + is >> index; + F[i]->set_neighbor(j, F[index]); } } } - + return V[0]; } @@ -2266,11 +2266,11 @@ vrml_output( std::ostream& os, Vertex_handle v, bool skip_infinite) const // faces for(fit= faces_begin(); fit != faces_end(); ++fit) { if (!skip_infinite || !fit->has_vertex(v)) { - os << "\t\t\t"; - os << vmap[(*fit).vertex(0)] << ", "; - os << vmap[(*fit).vertex(1)] << ", "; - os << vmap[(*fit).vertex(2)] << ", "; - os << "-1, " << std::endl; + os << "\t\t\t"; + os << vmap[(*fit).vertex(0)] << ", "; + os << vmap[(*fit).vertex(1)] << ", "; + os << vmap[(*fit).vertex(2)] << ", "; + os << "-1, " << std::endl; } } os << "\t\t]" << std::endl; @@ -2294,8 +2294,8 @@ off_file_input( std::istream& is, bool verbose) if (! is) { if (scanner.verbose()) { std::cerr << " " << std::endl; - std::cerr << "TDS::off_file_input" << std::endl; - std::cerr << " input error: file format is not OFF." << std::endl; + std::cerr << "TDS::off_file_input" << std::endl; + std::cerr << " input error: file format is not OFF." << std::endl; } return vinf; } @@ -2330,10 +2330,10 @@ off_file_input( std::istream& is, bool verbose) scanner.scan_facet( no, i); if( ! is || no != 3) { if ( scanner.verbose()) { - std::cerr << " " << std::endl; - std::cerr << "TDS::off_file_input" << std::endl; - std::cerr << "facet " << i << "does not have 3 vertices." - << std::endl; + std::cerr << " " << std::endl; + std::cerr << "TDS::off_file_input" << std::endl; + std::cerr << "facet " << i << "does not have 3 vertices." + << std::endl; } is.clear( std::ios::badbit); return vinf; @@ -2347,7 +2347,7 @@ off_file_input( std::istream& is, bool verbose) } for (std::size_t ih = 0; ih < no; ++ih) { - set_adjacency(fh, ih, edge_map); + set_adjacency(fh, ih, edge_map); } } @@ -2358,9 +2358,9 @@ off_file_input( std::istream& is, bool verbose) while (!edge_map.empty()) { Face_handle fh = edge_map.begin()->second.first; int ih = edge_map.begin()->second.second; - Face_handle fn = create_face( vinf, - fh->vertex(cw(ih)), - fh->vertex(ccw(ih))); + Face_handle fn = create_face( vinf, + fh->vertex(cw(ih)), + fh->vertex(ccw(ih))); vinf->set_face(fn); set_adjacency(fn, 0, fh, ih); set_adjacency(fn, 1, inf_edge_map); @@ -2369,8 +2369,8 @@ off_file_input( std::istream& is, bool verbose) } CGAL_triangulation_assertion(inf_edge_map.empty()); } - - + + // coherent orientation reorient_faces(); return vinf; @@ -2380,16 +2380,16 @@ off_file_input( std::istream& is, bool verbose) template < class Vb, class Fb> void Triangulation_data_structure_2:: -set_adjacency(Face_handle fh, - int ih, - std::map< Vh_pair, Edge>& edge_map) +set_adjacency(Face_handle fh, + int ih, + std::map< Vh_pair, Edge>& edge_map) { // set adjacency to (fh,ih) using the the map edge_map // or insert (fh,ih) in edge map Vertex_handle vhcw = fh->vertex(cw(ih)); - Vertex_handle vhccw = fh->vertex(ccw(ih)); - Vh_pair vhp = vhcw < vhccw ? - std::make_pair(vhcw, vhccw) + Vertex_handle vhccw = fh->vertex(ccw(ih)); + Vh_pair vhp = vhcw < vhccw ? + std::make_pair(vhcw, vhccw) : std::make_pair(vhccw, vhcw) ; typename std::map::iterator emapit = edge_map.find(vhp); if (emapit == edge_map.end()) {// not found, insert edge @@ -2399,7 +2399,7 @@ set_adjacency(Face_handle fh, Edge e = emapit->second; set_adjacency( fh,ih, e.first, e.second); edge_map.erase(emapit); - } + } } @@ -2409,9 +2409,9 @@ void Triangulation_data_structure_2:: reorient_faces() { - // reorient the faces of a triangulation + // reorient the faces of a triangulation // needed for example in off_file_input - // because the genus is not known, the number of faces + // because the genus is not known, the number of faces std::set oriented_set; std::stack st; Face_iterator fit = faces_begin(); @@ -2419,7 +2419,7 @@ reorient_faces() while (0 != nf) { while ( !oriented_set.insert(fit).second ){ - ++fit; // find a germ for non oriented components + ++fit; // find a germ for non oriented components } // orient component --nf; @@ -2428,25 +2428,25 @@ reorient_faces() Face_handle fh = st.top(); st.pop(); for(int ih = 0 ; ih < 3 ; ++ih){ - Face_handle fn = fh->neighbor(ih); - if (oriented_set.insert(fn).second){ - int in = fn->index(fh); - if (fn->vertex(cw(in)) != fh->vertex(ccw(ih))) fn->reorient(); + Face_handle fn = fh->neighbor(ih); + if (oriented_set.insert(fn).second){ + int in = fn->index(fh); + if (fn->vertex(cw(in)) != fh->vertex(ccw(ih))) fn->reorient(); --nf; - st.push(fn); - } + st.push(fn); + } } } } return; } - + template < class Vb, class Fb> std::istream& -operator>>(std::istream& is, - Triangulation_data_structure_2& tds) +operator>>(std::istream& is, + Triangulation_data_structure_2& tds) { tds.file_input(is); return is; @@ -2455,14 +2455,14 @@ operator>>(std::istream& is, template < class Vb, class Fb> std::ostream& -operator<<(std::ostream& os, - const Triangulation_data_structure_2 &tds) +operator<<(std::ostream& os, + const Triangulation_data_structure_2 &tds) { tds.file_output(os); return os; } -} //namespace CGAL +} //namespace CGAL #endif //CGAL_TRIANGULATION_DATA_STRUCTURE_2_H diff --git a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h index 8aeb12f876e..aa69ccfef05 100644 --- a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h +++ b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Mariette Yvinec @@ -21,10 +21,10 @@ #include #include -namespace CGAL { +namespace CGAL { template < typename TDS = void> -class Triangulation_ds_face_base_2 +class Triangulation_ds_face_base_2 { public: typedef TDS Triangulation_data_structure; @@ -32,7 +32,7 @@ public: typedef typename TDS::Face_handle Face_handle; template - struct Rebind_TDS { typedef Triangulation_ds_face_base_2 Other; }; + struct Rebind_TDS { typedef Triangulation_ds_face_base_2 Other; }; private: Vertex_handle V[3]; @@ -40,21 +40,21 @@ private: public: Triangulation_ds_face_base_2(); - Triangulation_ds_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2); - Triangulation_ds_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Face_handle n0, - Face_handle n1, - Face_handle n2); + Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2); + Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2); Vertex_handle vertex(int i) const; bool has_vertex(Vertex_handle v) const; bool has_vertex(Vertex_handle v, int& i) const ; int index(Vertex_handle v) const ; - + Face_handle neighbor(int i) const ; bool has_neighbor(Face_handle n) const; bool has_neighbor(Face_handle n, int& i) const; @@ -69,14 +69,14 @@ public: void reorient(); void ccw_permute(); void cw_permute(); - + int dimension() const; //the following trivial is_valid to allow - // the user of derived face base classes + // the user of derived face base classes // to add their own purpose checking bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const {return true;} - + // For use by Compact_container. void * for_compact_container() const {return N[0].for_compact_container(); } void for_compact_container(void* p) { N[0].for_compact_container(p);} @@ -96,9 +96,9 @@ Triangulation_ds_face_base_2() template Triangulation_ds_face_base_2 :: -Triangulation_ds_face_base_2( Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2) +Triangulation_ds_face_base_2( Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) { set_vertices(v0, v1, v2); set_neighbors(); @@ -106,12 +106,12 @@ Triangulation_ds_face_base_2( Vertex_handle v0, template Triangulation_ds_face_base_2 :: -Triangulation_ds_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Face_handle n0, - Face_handle n1, - Face_handle n2) +Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) { set_vertices(v0, v1, v2); set_neighbors(n0, n1, n2); @@ -119,14 +119,14 @@ Triangulation_ds_face_base_2(Vertex_handle v0, template -inline +inline typename Triangulation_ds_face_base_2::Vertex_handle Triangulation_ds_face_base_2:: vertex(int i) const { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); return V[i]; -} +} template @@ -136,10 +136,10 @@ has_vertex(Vertex_handle v) const { return (V[0] == v) || (V[1] == v) || (V[2]== v); } - + template inline bool -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: has_vertex(Vertex_handle v, int& i) const { if (v == V[0]) { @@ -156,10 +156,10 @@ has_vertex(Vertex_handle v, int& i) const } return false; } - -template + +template inline int -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: index(Vertex_handle v) const { if (v == V[0]) return 0; @@ -168,27 +168,27 @@ index(Vertex_handle v) const return 2; } -template -inline -typename Triangulation_ds_face_base_2::Face_handle +template +inline +typename Triangulation_ds_face_base_2::Face_handle Triangulation_ds_face_base_2:: neighbor(int i) const { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); return N[i]; } - -template -inline bool + +template +inline bool Triangulation_ds_face_base_2 :: has_neighbor(Face_handle n) const { return (N[0] == n) || (N[1] == n) || (N[2] == n); } - - -template -inline bool + + +template +inline bool Triangulation_ds_face_base_2 :: has_neighbor(Face_handle n, int& i) const { @@ -207,10 +207,10 @@ has_neighbor(Face_handle n, int& i) const return false; } - - -template -inline int + + +template +inline int Triangulation_ds_face_base_2 :: index(Face_handle n) const { @@ -219,19 +219,19 @@ index(Face_handle n) const CGAL_triangulation_assertion( n == N[2] ); return 2; } - -template + +template inline void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: set_vertex(int i, Vertex_handle v) { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); V[i] = v; } - -template + +template inline void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: set_neighbor(int i, Face_handle n) { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); @@ -247,27 +247,27 @@ set_vertices() V[0] = V[1] = V[2] = Vertex_handle(); } -template +template inline void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) { V[0] = v0; V[1] = v1; V[2] = v2; } - -template + +template inline void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: set_neighbors() { N[0] = N[1] = N[2] = Face_handle(); } - -template + +template inline void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: set_neighbors(Face_handle n0,Face_handle n1, Face_handle n2) { CGAL_triangulation_precondition( this != &*n0 ); @@ -280,7 +280,7 @@ set_neighbors(Face_handle n0,Face_handle n1, Face_handle n2) template void -Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2 :: reorient() { //exchange the vertices 0 and 1 @@ -289,7 +289,7 @@ reorient() } template -inline void +inline void Triangulation_ds_face_base_2 :: ccw_permute() { @@ -299,7 +299,7 @@ ccw_permute() template -inline void +inline void Triangulation_ds_face_base_2 :: cw_permute() { @@ -309,7 +309,7 @@ cw_permute() template < class TDS> -inline int +inline int Triangulation_ds_face_base_2 :: dimension() const { @@ -349,6 +349,6 @@ public: -} //namespace CGAL +} //namespace CGAL #endif //CGAL_DS_TRIANGULATION_FACE_BASE_2_H diff --git a/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h b/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h index ceabf7c4294..ba0386f747f 100644 --- a/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h +++ b/TDS_2/include/CGAL/Triangulation_ds_vertex_base_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Mariette Yvinec @@ -24,7 +24,7 @@ namespace CGAL { template < class TDS = void > -class Triangulation_ds_vertex_base_2 +class Triangulation_ds_vertex_base_2 { public: @@ -42,7 +42,7 @@ public: void set_face(Face_handle f) { _f = f ;} //the following trivial is_valid to allow - // the user of derived face base classes + // the user of derived face base classes // to add their own purpose checking bool is_valid(bool /*verbose*/=false, int /*level*/= 0) const {return face() != Face_handle();} diff --git a/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h b/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h index 44d04c40a9c..619b959937e 100644 --- a/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h +++ b/TDS_2/test/TDS_2/include/CGAL/_test_cls_tds_2.h @@ -7,10 +7,10 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// +// // file : test/Triangulation/include/CGAL/_test_cls_tds_2.h // source : $URL$ // revision : $Id$ @@ -51,7 +51,7 @@ _test_cls_tds_2( const Tds &) typedef typename Tds::Vertex_range Vertex_range; typedef typename Tds::Face_range Face_range; - + typedef typename Tds::Vertex Vertex; typedef typename Tds::Face Face; typedef typename Tds::Edge Edge; @@ -61,7 +61,7 @@ _test_cls_tds_2( const Tds &) typedef typename Tds::Vertex_iterator Vertex_iterator; typedef typename Tds::Face_iterator Face_iterator; typedef typename Tds::Edge_iterator Edge_iterator; - + typedef typename Tds::Vertex_circulator Vertex_circulator; typedef typename Tds::Face_circulator Face_circulator; typedef typename Tds::Edge_circulator Edge_circulator; @@ -71,7 +71,7 @@ _test_cls_tds_2( const Tds &) CGAL_USE_TYPE(Edge); CGAL_USE_TYPE(Edge_iterator); CGAL_USE_TYPE(Edge_circulator); - + // Test subclasses CGAL::_test_cls_tds_vertex( Tds()); CGAL::_test_cls_tds_face( Tds()); @@ -80,17 +80,17 @@ _test_cls_tds_2( const Tds &) std::cout << " constructors" << std::endl; Tds tds0; Tds tds1; - Tds tds2(tds1); + Tds tds2(tds1); Tds tds3 = tds1; Tds tds4 ; tds4.swap(tds1); tds1.is_valid(); tds1.clear(); tds1.is_valid(); - // (), = and swap to be tested later again with non trivial tds + // (), = and swap to be tested later again with non trivial tds + - // misc. std::cout << " miscellaneous" << std::endl; assert( tds1.ccw(0) == 1 ); @@ -99,21 +99,21 @@ _test_cls_tds_2( const Tds &) assert( tds1.cw(0) == 2 ); assert( tds1.cw(1) == 0 ); assert( tds1.cw(2) == 1 ); - + // test insert, remove and flip - // tds1 , tds2 0 dim + // tds1 , tds2 0 dim // tds3 1 dim // tds4 2dim std::cout << " insert and flip" << std::endl; Vertex_handle w1 = tds1.insert_first(); - assert(tds1.dimension()== -1); + assert(tds1.dimension()== -1); assert(tds1.number_of_vertices() == 1); assert(tds1.is_valid() ); Vertex_handle w2 = tds2.insert_first(); Vertex_handle v2 = tds2.insert_second(); - assert(tds2.dimension()== 0); + assert(tds2.dimension()== 0); assert(tds2.number_of_vertices() == 2); assert(tds2.is_valid() ); @@ -161,7 +161,7 @@ _test_cls_tds_2( const Tds &) assert(tds12.is_valid()); assert(tds12.dimension()==1); } - + Vertex_handle w4 = tds4.insert_first(); Vertex_handle v4_1 = tds4.insert_second(); Vertex_handle v4_2 = tds4.insert_dim_up(w4,true); @@ -184,7 +184,7 @@ _test_cls_tds_2( const Tds &) // Find the edge v4_1v4_2 for insertion fc = tds4.incident_faces(v4_1); int ic; - while(! (fc->has_vertex(v4_2, ic ) && ic == tds4.ccw(fc->index(v4_1)))) + while(! (fc->has_vertex(v4_2, ic ) && ic == tds4.ccw(fc->index(v4_1)))) fc++; Vertex_handle v4_5 = tds4.insert_in_edge(fc, ic); assert(tds4.is_valid() ); @@ -199,17 +199,17 @@ _test_cls_tds_2( const Tds &) Vertex_handle u4 = tds4.insert_in_face(v4_1->face()); tds4.remove_degree_3(u4); assert(tds4.is_valid() ); - + Vertex_handle u3 = tds3.insert_in_edge(v3->face(),2); tds3.remove_1D(u3); assert(tds3.is_valid() ); - + //remove_second, remove first tds2.remove_second(v2); assert(tds2.is_valid() && tds2.number_of_vertices()==1); v2 = tds2.insert_second(); tds1.remove_first(w1); - assert(tds1.is_valid()&& tds1.number_of_vertices()==0); + assert(tds1.is_valid()&& tds1.number_of_vertices()==0); w1 = tds1.insert_first(); // make_hole, star_hole @@ -221,7 +221,7 @@ _test_cls_tds_2( const Tds &) // insert_in_hole - // Count also the faces with the vertex at infinity! + // Count also the faces with the vertex at infinity! // // 1 |------| 3 1 |------| 3 // |\ | |\ /| @@ -231,9 +231,9 @@ _test_cls_tds_2( const Tds &) // | \ | | / \ | // | \| |/ \| // 2 |------| 0 2 |------| 0 - // - // - + // + // + std::cout << " insert_in_hole" << std::endl; Tds td45; Vertex_handle v045 = td45.insert_first(); @@ -348,7 +348,7 @@ _test_cls_tds_2( const Tds &) assert(td5.dimension() == 1); assert(td5.is_valid()); Vertex_handle v5_4 = td5.insert_dim_up(); - Face_handle f5_1 = v5_4->face(); + Face_handle f5_1 = v5_4->face(); i = f5_1->index(v5_4); td5.dim_down(f5_1, i); assert(td5.dimension() == 1); @@ -357,20 +357,20 @@ _test_cls_tds_2( const Tds &) //access std::cout << " test access" << std::endl; assert(tds0.dimension() <= -1 && tds0.number_of_vertices() == 0 && - tds0.number_of_faces()== 0 && tds0.number_of_edges() == 0 && - tds0.number_of_full_dim_faces() == 0); + tds0.number_of_faces()== 0 && tds0.number_of_edges() == 0 && + tds0.number_of_full_dim_faces() == 0); assert(tds1.dimension() == -1 && tds1.number_of_vertices() == 1 && - tds1.number_of_faces()== 0 && tds1.number_of_edges() == 0 && - tds1.number_of_full_dim_faces() == 1); + tds1.number_of_faces()== 0 && tds1.number_of_edges() == 0 && + tds1.number_of_full_dim_faces() == 1); assert(tds2.dimension() == 0 && tds2.number_of_vertices() == 2 && - tds2.number_of_faces()== 0 && tds2.number_of_edges() == 0 && - tds2.number_of_full_dim_faces() == 2); + tds2.number_of_faces()== 0 && tds2.number_of_edges() == 0 && + tds2.number_of_full_dim_faces() == 2); assert(tds3.dimension() == 1 && tds3.number_of_vertices() == 4 && - tds3.number_of_faces()== 0 && tds3.number_of_edges() == 4 && - tds3.number_of_full_dim_faces() == 4); + tds3.number_of_faces()== 0 && tds3.number_of_edges() == 4 && + tds3.number_of_full_dim_faces() == 4); assert(tds4.dimension() == 2 && tds4.number_of_vertices() == 6 && - tds4.number_of_faces()== 8 && tds4.number_of_edges() == 12 && - tds4.number_of_full_dim_faces() == 8); + tds4.number_of_faces()== 8 && tds4.number_of_edges() == 12 && + tds4.number_of_full_dim_faces() == 8); // Containers Vertex_range & vertex_c = tds4.vertices(); @@ -378,7 +378,7 @@ _test_cls_tds_2( const Tds &) assert(vertex_c.size() == 6); assert(face_c.size() == 8); - + //clear(), swap() and copy_constructor and copy std::cout << " clear, swap, assign and copy " << std::endl; Tds tds1b(tds1); @@ -447,7 +447,7 @@ _test_cls_tds_2( const Tds &) assert (tds4.is_vertex(v4_5)); assert (tds3.is_vertex(v3)); assert (tds2.is_vertex(v2)); - + // test compatibility of iterators and circulators with handle() Vertex_iterator vit=tds4.vertices_begin(); assert(tds4.is_vertex(vit)); @@ -465,43 +465,43 @@ _test_cls_tds_2( const Tds &) std::cout << " output to a file" << std::endl; std::ofstream of0("file_tds0"); - CGAL::set_ascii_mode(of0); - of0 << tds0 ; + CGAL::set_ascii_mode(of0); + of0 << tds0 ; of0.close(); std::ofstream of1("file_tds1"); - CGAL::set_ascii_mode(of1); - of1 << tds1 ; + CGAL::set_ascii_mode(of1); + of1 << tds1 ; of1.close(); std::ofstream of2("file_tds2"); - CGAL::set_ascii_mode(of2); - of2 << tds2 ; + CGAL::set_ascii_mode(of2); + of2 << tds2 ; of2.close(); std::ofstream of3("file_tds3"); - CGAL::set_ascii_mode(of3); - of3 << tds3 ; + CGAL::set_ascii_mode(of3); + of3 << tds3 ; of3.close(); std::ofstream of4("file_tds4"); - CGAL::set_ascii_mode(of4); - of4 << tds4 ; + CGAL::set_ascii_mode(of4); + of4 << tds4 ; of4.close(); std::cout << " input from a file" << std::endl; std::ifstream if0("file_tds0"); CGAL::set_ascii_mode(if0); Tds tds0f; if0 >> tds0f ; assert( tds0f.is_valid()); std::ifstream if1("file_tds1"); CGAL::set_ascii_mode(if1); - Tds tds1f; if1 >> tds1f; + Tds tds1f; if1 >> tds1f; assert( tds1f.is_valid()); - std::ifstream if2("file_tds2"); + std::ifstream if2("file_tds2"); CGAL::set_ascii_mode(if2); - Tds tds2f; if2 >> tds2f ; + Tds tds2f; if2 >> tds2f ; assert( tds2f.is_valid()); - std::ifstream if3("file_tds3"); + std::ifstream if3("file_tds3"); CGAL::set_ascii_mode(if3); - Tds tds3f; if3 >> tds3f ; + Tds tds3f; if3 >> tds3f ; assert( tds3f.is_valid()); - std::ifstream if4("file_tds4"); + std::ifstream if4("file_tds4"); CGAL::set_ascii_mode(if4); - Tds tds4f; if4 >> tds4f ; + Tds tds4f; if4 >> tds4f ; assert( tds4f.is_valid()); // vrml input-output @@ -542,17 +542,17 @@ _test_tds_circulators( const Tds& tds) Vertex_handle vh; for( Vertex_iterator vit = tds.vertices_begin(); - vit != tds.vertices_end(); vit++) { - + vit != tds.vertices_end(); vit++) { + Face_circulator fc = tds.incident_faces(vit), fdone(fc); Face_circulator fc2 = tds.incident_faces(vit); assert(fc2 == fc); if (! fc.is_empty()) { do { - f = *fc; - fh = fc; - vh = fc->vertex(0); - countf +=1; + f = *fc; + fh = fc; + vh = fc->vertex(0); + countf +=1; } while (++fc != fdone); } @@ -561,9 +561,9 @@ _test_tds_circulators( const Tds& tds) if (! ec.is_empty()) assert( ec2 == ec); if (! ec.is_empty()) { do { - e = *ec; - fh = ec->first; - counte +=1; + e = *ec; + fh = ec->first; + counte +=1; } while (++ec != edone); } @@ -573,21 +573,21 @@ _test_tds_circulators( const Tds& tds) if (! vc.is_empty()) assert( vc == vc2); if (! vc.is_empty()) { do { - v = *vc; - vh = vc; - fh = vc->face(); - countv +=1; - countvv +=1; + v = *vc; + vh = vc; + fh = vc->face(); + countv +=1; + countvv +=1; } while (++vc != vdone); } assert( tds.degree(vit) == countvv); - } - + } + assert( countf == 3 * tds.number_of_faces()); assert( counte == 2 * tds.number_of_edges()); assert( countv == counte); - + } template< class Tds> @@ -631,7 +631,7 @@ _test_tds_iterators( const Tds& tds) } assert(nv == 0); - + for (Face_iterator fitp = tds.faces_begin(); fitp != tds.faces_end(); ++fitp) { diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h index 9b9bffacd71..0c7108a3d67 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDSCellBase_3.h @@ -13,29 +13,29 @@ is plugged into a triangulation class, the face base class may have additional geometric requirements depending on the triangulation class. -At the base level -(see the Software Design sections of the Chapters \ref Triangulation3secdesign "Triangulation" -and \ref TDS3secdesign "Triangulation Datastructure"), -a cell stores handles to its four vertices and to its four neighbor cells. -The vertices and neighbors are indexed 0, 1, 2 and 3. Neighbor `i` -lies opposite to vertex `i`. +At the base level +(see the Software Design sections of the Chapters \ref Triangulation3secdesign "Triangulation" +and \ref TDS3secdesign "Triangulation Datastructure"), +a cell stores handles to its four vertices and to its four neighbor cells. +The vertices and neighbors are indexed 0, 1, 2 and 3. Neighbor `i` +lies opposite to vertex `i`. -Since the Triangulation data structure is the class which defines the handle -types, the cell base class has to be somehow parameterized by the Triangulation -data structure. But since it is itself parameterized by the cell and vertex -base classes, there is a cycle in the definition of these classes. In order -to break the cycle, the base classes for vertex and cell which are given as -arguments for the Triangulation data structure use `void` as Triangulation -data structure parameter, and the Triangulation data structure then uses a -rebind-like mechanism (similar to the one specified in -`std::allocator`) in order to put itself as parameter to the vertex and -cell classes. The rebound base classes so obtained are the classes -which are used as base classes for the final vertex and cell classes. -More information can be found in Section \ref TDS3secdesign. +Since the Triangulation data structure is the class which defines the handle +types, the cell base class has to be somehow parameterized by the Triangulation +data structure. But since it is itself parameterized by the cell and vertex +base classes, there is a cycle in the definition of these classes. In order +to break the cycle, the base classes for vertex and cell which are given as +arguments for the Triangulation data structure use `void` as Triangulation +data structure parameter, and the Triangulation data structure then uses a +rebind-like mechanism (similar to the one specified in +`std::allocator`) in order to put itself as parameter to the vertex and +cell classes. The rebound base classes so obtained are the classes +which are used as base classes for the final vertex and cell classes. +More information can be found in Section \ref TDS3secdesign. \cgalHasModel `CGAL::Triangulation_ds_cell_base_3` -\sa `TriangulationDSVertexBase_3` +\sa `TriangulationDSVertexBase_3` \sa `CGAL::Triangulation_data_structure_3` */ @@ -44,13 +44,13 @@ class TriangulationDSCellBase_3 { public: -/// \name Types +/// \name Types /// A model of the concept `TriangulationDSCellBase_3` has to provide the following types. /// @{ /*! This template class has to define a type `Rebind_TDS::%Other` which is the -rebound cell, that is, the one whose `Triangulation_data_structure` +rebound cell, that is, the one whose `Triangulation_data_structure` will be the actually used one. `Rebind_TDS::%Other` will be the real base class of `Triangulation_data_structure_3::Cell`. \note It can be implemented using a nested template class. @@ -61,63 +61,63 @@ using Rebind_TDS = unspecified_type; /*! -*/ -typedef TriangulationDataStructure_3 Triangulation_data_structure; +*/ +typedef TriangulationDataStructure_3 Triangulation_data_structure; /*! -*/ -typedef TriangulationDataStructure_3::Vertex_handle Vertex_handle; +*/ +typedef TriangulationDataStructure_3::Vertex_handle Vertex_handle; /*! -*/ -typedef TriangulationDataStructure_3::Cell_handle Cell_handle; +*/ +typedef TriangulationDataStructure_3::Cell_handle Cell_handle; -/// @} +/// @} -/// \name Creation +/// \name Creation /// @{ /*! -Default constructor -*/ +Default constructor +*/ TriangulationDSCellBase_3(); /*! -Initializes the vertices with `v0, v1, v2, v3`. Neighbors are -initialized to the default constructed handle. -*/ +Initializes the vertices with `v0, v1, v2, v3`. Neighbors are +initialized to the default constructed handle. +*/ TriangulationDSCellBase_3( Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3); /*! -Initializes the vertices with `v0, v1, v2, v3` and the neighbors with -`n0, n1, n2, n3`. -*/ +Initializes the vertices with `v0, v1, v2, v3` and the neighbors with +`n0, n1, n2, n3`. +*/ TriangulationDSCellBase_3( Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, Cell_handle n0, Cell_handle n1, Cell_handle n2, Cell_handle n3); -/// @} +/// @} -/// \name Checking +/// \name Checking /// @{ /*! -Performs any desired geometric test on a cell. +Performs any desired geometric test on a cell. \cgalDebugFunction \cgalDebugBegin -When `verbose` is set to `true`, messages are printed to give -a precise indication of the kind of invalidity encountered. `level` -increases the level of testing. +When `verbose` is set to `true`, messages are printed to give +a precise indication of the kind of invalidity encountered. `level` +increases the level of testing. \cgalDebugEnd -*/ -bool is_valid(bool verbose = false, int level = 0) const; +*/ +bool is_valid(bool verbose = false, int level = 0) const; -/// @} +/// @} /// \name Members for Compact_container /// \cgalAdvancedBegin @@ -130,12 +130,12 @@ bool is_valid(bool verbose = false, int level = 0) const; /*! -*/ -void * for_compact_container() const; +*/ +void * for_compact_container() const; /*! -*/ +*/ void for_compact_container(void *p); /// @} @@ -144,14 +144,14 @@ void for_compact_container(void *p); /// @{ /*! -Inputs the possible non combinatorial information given by the cell. -*/ -istream& operator>> (istream& is, TriangulationDSCellBase_3 & c); +Inputs the possible non combinatorial information given by the cell. +*/ +istream& operator>> (istream& is, TriangulationDSCellBase_3 & c); /*! -Outputs the possible non combinatorial information given by the cell. -*/ -ostream& operator<< (ostream& os, const TriangulationDSCellBase_3 & c); +Outputs the possible non combinatorial information given by the cell. +*/ +ostream& operator<< (ostream& os, const TriangulationDSCellBase_3 & c); /// @} diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h index c7b68ec9175..9435ee7e9e5 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDSVertexBase_3.h @@ -11,22 +11,22 @@ of a CGAL::Triangulation_data_structure_3. Note that if the `CGAL::Triangulation_data_structure_3` is plugged into a triangulation class, the vertex base class may have additional geometric requirements depending on the triangulation class. -At the bottom level of 3D-triangulations -(see Sections \ref Triangulation3secdesign and \ref TDS3secdesign), -a vertex provides access to one of its incident cells through a handle. +At the bottom level of 3D-triangulations +(see Sections \ref Triangulation3secdesign and \ref TDS3secdesign), +a vertex provides access to one of its incident cells through a handle. -Since the Triangulation data structure is the class which defines the handle -types, the vertex base class has to be somehow parameterized by the -Triangulation data structure. But since it is itself parameterized by the cell -and vertex base classes, there is a cycle in the definition of these classes. -In order to break the cycle, the base classes for vertex and cell which are -given as arguments for the Triangulation data structure use `void` as -Triangulation data structure parameter, and the Triangulation data structure -then uses a rebind-like mechanism (similar to the one specified in -`std::allocator`) in order to put itself as parameter to the vertex and -cell classes. The rebound base classes so obtained are the classes which -are used as base classes for the final vertex and cell classes. -More information can be found in Section \ref TDS3secdesign. +Since the Triangulation data structure is the class which defines the handle +types, the vertex base class has to be somehow parameterized by the +Triangulation data structure. But since it is itself parameterized by the cell +and vertex base classes, there is a cycle in the definition of these classes. +In order to break the cycle, the base classes for vertex and cell which are +given as arguments for the Triangulation data structure use `void` as +Triangulation data structure parameter, and the Triangulation data structure +then uses a rebind-like mechanism (similar to the one specified in +`std::allocator`) in order to put itself as parameter to the vertex and +cell classes. The rebound base classes so obtained are the classes which +are used as base classes for the final vertex and cell classes. +More information can be found in Section \ref TDS3secdesign. \cgalHasModel `CGAL::Triangulation_ds_vertex_base_3` @@ -39,65 +39,65 @@ class TriangulationDSVertexBase_3 { public: -/// \name Types +/// \name Types /// @{ /*! This template class has to define a type `Rebind_TDS::%Other` which is the -rebound vertex, that is, the one whose `Triangulation_data_structure` +rebound vertex, that is, the one whose `Triangulation_data_structure` will be the actually used one. `Rebind_TDS::%Other` will be the real base class of `Triangulation_data_structure_3::Vertex`. \note It can be implemented using a nested template class. \sa Section \ref tds3cyclic -*/ +*/ template -using Rebind_TDS = unspecified_type; +using Rebind_TDS = unspecified_type; /*! -*/ -typedef TriangulationDataStructure_3 Triangulation_data_structure; +*/ +typedef TriangulationDataStructure_3 Triangulation_data_structure; /*! -*/ -typedef TriangulationDataStructure_3::Vertex_handle Vertex_handle; +*/ +typedef TriangulationDataStructure_3::Vertex_handle Vertex_handle; /*! -*/ -typedef TriangulationDataStructure_3::Cell_handle Cell_handle; +*/ +typedef TriangulationDataStructure_3::Cell_handle Cell_handle; -/// @} +/// @} -/// \name Creation +/// \name Creation /// @{ /*! -Default constructor. -*/ +Default constructor. +*/ TriangulationDSVertexBase_3(); /*! -Constructs a vertex pointing to cell `c`. -*/ +Constructs a vertex pointing to cell `c`. +*/ TriangulationDSVertexBase_3(Cell_handle c); -/// @} +/// @} -/// \name Checking +/// \name Checking /// @{ /*! \cgalDebugFunction \cgalDebugBegin -Performs any desired test on a vertex. Checks that the -pointer to an incident cell is not the default constructed handle. +Performs any desired test on a vertex. Checks that the +pointer to an incident cell is not the default constructed handle. \cgalDebugEnd -*/ -bool is_valid(bool verbose=false, int level=0) const; +*/ +bool is_valid(bool verbose=false, int level=0) const; -/// @} +/// @} /// \name Members for Compact_container /// \cgalAdvancedBegin @@ -110,23 +110,23 @@ bool is_valid(bool verbose=false, int level=0) const; /*! -*/ -void * for_compact_container() const; +*/ +void * for_compact_container() const; /*! -*/ +*/ void for_compact_container(void *); /*! -Inputs the non-combinatorial information given by the vertex. -*/ -istream& operator>> (istream& is, TriangulationDSVertexBase_3 & v); +Inputs the non-combinatorial information given by the vertex. +*/ +istream& operator>> (istream& is, TriangulationDSVertexBase_3 & v); /*! -Outputs the non-combinatorial information given by the vertex. -*/ -ostream& operator<< (ostream& os, const TriangulationDSVertexBase_3 & v); +Outputs the non-combinatorial information given by the vertex. +*/ +ostream& operator<< (ostream& os, const TriangulationDSVertexBase_3 & v); /// @} diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 82744371605..b97d7487663 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -118,7 +118,7 @@ private: friend class internal::Triangulation_ds_facet_circulator_3; public: - + // Cells // N.B.: Concurrent_compact_container requires TBB #ifdef CGAL_LINKED_WITH_TBB @@ -147,7 +147,7 @@ public: typedef Compact_container Vertex_range; #endif - + typedef typename Cell_range::size_type size_type; typedef typename Cell_range::difference_type difference_type; @@ -165,7 +165,7 @@ public: typedef Iterator_range Facets; typedef Iterator_range Edges; - + //private: // In 2D only : typedef internal::Triangulation_ds_face_circulator_3 Face_circulator; @@ -217,7 +217,7 @@ public: a6=v6; } }; -//#endif +//#endif public: @@ -595,7 +595,7 @@ public: //INSERTION - + // Create a finite cell with v1, v2, v3 and v4 // Precondition: v1, v2, v3 and v4 MUST BE positively oriented Vertex_handle insert_first_finite_cell( @@ -656,9 +656,9 @@ public: Cell_handles cell_handles() const { - return make_prevent_deref_range(cells_begin(), cells_end()); + return make_prevent_deref_range(cells_begin(), cells_end()); } - + Cell_iterator raw_cells_begin() const { return cells().begin(); @@ -685,7 +685,7 @@ public: { return Facets(facets_begin(), facets_end()); } - + Edge_iterator edges_begin() const { if ( dimension() < 1 ) @@ -702,7 +702,7 @@ public: { return Edges(edges_begin(), edges_end()); } - + Vertex_iterator vertices_begin() const { return vertices().begin(); @@ -715,9 +715,9 @@ public: Vertex_handles vertex_handles() const { - return make_prevent_deref_range(vertices_begin(), vertices_end()); + return make_prevent_deref_range(vertices_begin(), vertices_end()); } - + // CIRCULATOR METHODS // cells around an edge @@ -796,16 +796,16 @@ private: IncidentFacetIterator> it) const { CGAL_triangulation_precondition(dimension() == 3); - + std::stack cell_stack; cell_stack.push(d); d->tds_data().mark_in_conflict(); *it.first++ = d; - + do { Cell_handle c = cell_stack.top(); cell_stack.pop(); - + for (int i=0; i<4; ++i) { if (c->vertex(i) == v) continue; @@ -852,7 +852,7 @@ private: ++head; } while(head != tail); } - + void just_incident_cells_3(Vertex_handle v, std::vector& cells) const { @@ -1002,7 +1002,7 @@ public: Filter filter; public: Vertex_extractor(Vertex_handle _v, OutputIterator _output, const Tds* _t, Filter _filter): - v(_v), treat(_output), t(_t), filter(_filter) + v(_v), treat(_output), t(_t), filter(_filter) { #if ( BOOST_VERSION >= 105000 ) tmp_vertices.reserve(64); @@ -1046,15 +1046,15 @@ public: void operator()(Cell_handle c) { for (int j=0; j<= t->dimension(); ++j) { - Vertex_handle w = c->vertex(j); - if(filter(w)) - continue; - if (w != v){ + Vertex_handle w = c->vertex(j); + if(filter(w)) + continue; + if (w != v){ if(! w->visited_for_vertex_extractor){ w->visited_for_vertex_extractor = true; tmp_vertices.push_back(w); - treat(c, v, j); + treat(c, v, j); } } } @@ -1134,7 +1134,7 @@ public: void incident_cells_3(Vertex_handle v, std::vector& cells) const { - just_incident_cells_3(v, cells); + just_incident_cells_3(v, cells); typename std::vector::iterator cit,end; for(cit = cells.begin(), end = cells.end(); cit != end; @@ -1143,7 +1143,7 @@ public: (*cit)->tds_data().clear(); } } - + template OutputIterator incident_cells_threadsafe(Vertex_handle v, OutputIterator cells, Filter f = Filter()) const @@ -1176,7 +1176,7 @@ public: { return incident_facets(v, facets); } - + template OutputIterator incident_facets_threadsafe(Vertex_handle v, OutputIterator facets, Filter f = Filter()) const @@ -1235,7 +1235,7 @@ public: template OutputIterator incident_edges_threadsafe(Vertex_handle v, OutputIterator edges, - Filter f = Filter()) const + Filter f = Filter()) const { CGAL_triangulation_precondition( v != Vertex_handle() ); CGAL_triangulation_precondition( dimension() >= 1 ); @@ -1346,11 +1346,11 @@ public: { (*cit)->tds_data().clear(); visit(*cit); - } + } return visit.result(); } - + template OutputIterator visit_incident_cells_threadsafe( @@ -1378,14 +1378,14 @@ public: ++cit) { visit(*cit); - } + } return visit.result(); } - + template OutputIterator - visit_incident_cells(Vertex_handle v, OutputIterator output, + visit_incident_cells(Vertex_handle v, OutputIterator output, std::vector &cells, Filter f) const { CGAL_triangulation_precondition( v != Vertex_handle() ); @@ -1442,7 +1442,7 @@ public: } return visit.result(); } - + // For dimension 3 only template OutputVertexIterator @@ -1455,12 +1455,12 @@ public: CGAL_triangulation_expensive_precondition( is_vertex(v) ); CGAL_triangulation_expensive_precondition( is_valid() ); - return + return visit_incident_cells < Vertex_extractor, - OutputVertexIterator, - VertexFilter, + OutputVertexIterator, + VertexFilter, internal::Has_member_visited::value>, OutputVertexIterator >(v, vertices, cells, f); @@ -1497,7 +1497,7 @@ public: template Vertex_handle copy_tds(const TDS_src&, typename TDS_src::Vertex_handle,const ConvertVertex&,const ConvertCell&); - + void swap(Tds & tds); void clear(); @@ -1708,9 +1708,9 @@ non_recursive_create_star_3(Vertex_handle v, Cell_handle c, int li, int prev_ind cnew->set_vertex(li, v); Cell_handle c_li = c->neighbor(li); set_adjacency(cnew, li, c_li, c_li->index(c)); - + std::stack adjacency_info_stack; - + int ii=0; do { @@ -1751,14 +1751,14 @@ non_recursive_create_star_3(Vertex_handle v, Cell_handle c, int li, int prev_ind cnew = create_cell(c->vertex(0),c->vertex(1),c->vertex(2),c->vertex(3)); cnew->set_vertex(li, v); c_li = c->neighbor(li); - set_adjacency(cnew, li, c_li, c_li->index(c)); + set_adjacency(cnew, li, c_li, c_li->index(c)); continue; } set_adjacency(nnn, zzz, cnew, ii); } while (++ii==4){ if ( adjacency_info_stack.empty() ) return cnew; - Cell_handle nnn=cnew; + Cell_handle nnn=cnew; int zzz; adjacency_info_stack.top().update_variables(zzz,cnew,ii,c,li,prev_ind2); adjacency_info_stack.pop(); @@ -2615,7 +2615,7 @@ Triangulation_data_structure_3::insert_first_finite_cell( Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, Vertex_handle &v3, Vertex_handle v_infinite) { - CGAL_triangulation_precondition( + CGAL_triangulation_precondition( (v_infinite == Vertex_handle() && dimension() == -2) || (v_infinite != Vertex_handle() && dimension() == -1)); @@ -2965,32 +2965,32 @@ insert_increase_dimension(Vertex_handle star) CGAL_assertion(i==0 || i==1); int j = (i == 0) ? 1 : 0; Cell_handle d = c->neighbor(j); - + c->set_vertex(2,v); Cell_handle e = c->neighbor(i); Cell_handle cnew = c; Cell_handle enew = Cell_handle(); - + while( e != d ){ enew = create_cell(); enew->set_vertex(i,e->vertex(j)); enew->set_vertex(j,e->vertex(i)); enew->set_vertex(2,star); - + set_adjacency(enew, i, cnew, j); // false at the first iteration of the loop where it should // be neighbor 2 // it is corrected after the loop set_adjacency(enew, 2, e, 2); // neighbor j will be set during next iteration of the loop - + e->set_vertex(2,v); e = e->neighbor(i); cnew = enew; } - + d->set_vertex(2,v); set_adjacency(enew, j, d, 2); @@ -3308,7 +3308,7 @@ decrease_dimension(Cell_handle c, int i) for( ; lfit != to_downgrade.end(); ++lfit) { Cell_handle f = *lfit; int j = f->index(w); - int k; + int k; if (f->has_vertex(v, k)) f->set_vertex(k, w); if (j != dimension()) { f->set_vertex(j, f->vertex(dimension())); @@ -3337,13 +3337,13 @@ decrease_dimension(Cell_handle c, int i) Vertex_handle v0 = c->vertex(0); Vertex_handle v1 = c->vertex(1); Vertex_handle v2 = c->vertex(2); - + int i0 = 0, i1 = 0, i2 = 0; - + for(int i=0; i<3; i++) if(n0->neighbor(i) == c) { i0 = i; break; } for(int i=0; i<3; i++) if(n1->neighbor(i) == c) { i1 = i; break; } for(int i=0; i<3; i++) if(n2->neighbor(i) == c) { i2 = i; break; } - + Cell_handle c1 = create_cell(v, v0, v1, Vertex_handle()); Cell_handle c2 = create_cell(v, v1, v2, Vertex_handle()); @@ -3354,42 +3354,42 @@ decrease_dimension(Cell_handle c, int i) //Cell_handle c3 = create_cell(v, v2, v0, Vertex_handle()); Cell_handle c3 = c; - + c1->set_neighbor(0, n2); n2->set_neighbor(i2, c1); - c1->set_neighbor(1, c2); + c1->set_neighbor(1, c2); c1->set_neighbor(2, c3); c1->set_neighbor(3, Cell_handle()); - + c2->set_neighbor(0, n0); n0->set_neighbor(i0, c2); - c2->set_neighbor(1, c3); + c2->set_neighbor(1, c3); c2->set_neighbor(2, c1); c2->set_neighbor(3, Cell_handle()); - + c3->set_neighbor(0, n1); n1->set_neighbor(i1, c3); - c3->set_neighbor(1, c1); + c3->set_neighbor(1, c1); c3->set_neighbor(2, c2); c3->set_neighbor(3, Cell_handle()); - + v->set_cell(c1); v0->set_cell(c1); v1->set_cell(c1); v2->set_cell(c2); } - + if(dimension() == 1) { Cell_handle n0 = c->neighbor(0); Cell_handle n1 = c->neighbor(1); Vertex_handle v0 = c->vertex(0); Vertex_handle v1 = c->vertex(1); - + int i0 = 0 , i1 = 0; - + for(int i=0; i<2; i++) if(n0->neighbor(i) == c) { i0 = i; break; } for(int i=0; i<2; i++) if(n1->neighbor(i) == c) { i1 = i; break; } - + Cell_handle c1 = create_cell(v0, v, Vertex_handle(), Vertex_handle()); - + c->set_vertex(0, v); c->set_vertex(1, v1); c->set_vertex(2, Vertex_handle()); @@ -3397,22 +3397,22 @@ decrease_dimension(Cell_handle c, int i) //Cell_handle c2 = create_cell(v, v1, Vertex_handle(), Vertex_handle()); Cell_handle c2 = c; - - c1->set_neighbor(0, c2); + + c1->set_neighbor(0, c2); c1->set_neighbor(1, n1); n1->set_neighbor(i1, c1); c1->set_neighbor(2, Cell_handle()); c1->set_neighbor(3, Cell_handle()); - + c2->set_neighbor(0, n0); n0->set_neighbor(i0, c2); - c2->set_neighbor(1, c1); + c2->set_neighbor(1, c1); c2->set_neighbor(2, Cell_handle()); c2->set_neighbor(3, Cell_handle()); - + v->set_cell(c1); v0->set_cell(c1); v1->set_cell(c2); } - + CGAL_triangulation_postcondition(is_valid()); } @@ -3435,14 +3435,14 @@ is_valid(bool verbose, int level ) const switch ( dimension() ) { case 3: { - + if(number_of_vertices() <= 4) { if (verbose) std::cerr << "wrong number of vertices" << std::endl; CGAL_triangulation_assertion(false); return false; } - + size_type vertex_count; if ( ! count_vertices(vertex_count,verbose,level) ) return false; @@ -3475,16 +3475,16 @@ is_valid(bool verbose, int level ) const } case 2: { - + if(number_of_vertices() <= 3) { if (verbose) std::cerr << "wrong number of vertices" << std::endl; CGAL_triangulation_assertion(false); return false; } - + size_type vertex_count; - + if ( ! count_vertices(vertex_count,verbose,level) ) return false; if ( number_of_vertices() != vertex_count ) { @@ -3521,14 +3521,14 @@ is_valid(bool verbose, int level ) const } case 1: { - + if(number_of_vertices() <= 1) { if (verbose) std::cerr << "wrong number of vertices" << std::endl; CGAL_triangulation_assertion(false); return false; } - + size_type vertex_count; if ( ! count_vertices(vertex_count,verbose,level) ) return false; @@ -3815,7 +3815,7 @@ is_valid(Cell_handle c, bool verbose, int level) const CGAL_triangulation_assertion(false); return false; } - + int j1n=4,j2n=4,j3n=4; if ( ! n->has_vertex(c->vertex((i+1)&3),j1n) ) { if (verbose) { std::cerr << "vertex " << ((i+1)&3) @@ -3838,14 +3838,14 @@ is_valid(Cell_handle c, bool verbose, int level) const CGAL_triangulation_assertion(false); return false; } - + if ( in+j1n+j2n+j3n != 6) { if (verbose) { std::cerr << "sum of the indices != 6 " << std::endl; } CGAL_triangulation_assertion(false); return false; } - + // tests whether the orientations of this and n are consistent if ( ((i+in)&1) == 0 ) { // i and in have the same parity if ( j1n == ((in+1)&3) ) { @@ -3928,7 +3928,7 @@ copy_tds(const TDS_src& tds, size_type n = tds.number_of_vertices(); set_dimension(tds.dimension()); - if (n == 0) return Vertex_handle(); + if (n == 0) return Vertex_handle(); // Number of pointers to cell/vertex to copy per cell. int dim = (std::max)(1, dimension() + 1); @@ -3945,7 +3945,7 @@ copy_tds(const TDS_src& tds, Unique_hash_map< typename TDS_src::Vertex_handle,Vertex_handle > V; Unique_hash_map< typename TDS_src::Cell_handle,Cell_handle > F; - + for (i=0; i <= n-1; ++i){ Vertex_handle vh=create_vertex( convert_vertex(*TV[i]) ); V[ TV[i] ] = vh; @@ -3987,7 +3987,7 @@ namespace internal { namespace TDS_3{ Vertex_tgt operator()(const Vertex_src& src) const { return Vertex_tgt(src.point()); } - + void operator()(const Vertex_src&,Vertex_tgt&) const {} }; @@ -3997,26 +3997,26 @@ namespace internal { namespace TDS_3{ Cell_tgt operator()(const Cell_src&) const { return Cell_tgt(); } - + void operator()(const Cell_src&,Cell_tgt&) const {} }; - + template struct Default_vertex_converter { const Vertex& operator()(const Vertex& src) const { return src; } - + void operator()(const Vertex&,Vertex&) const {} }; - + template struct Default_cell_converter{ const Cell& operator()(const Cell& src) const { return src; - } - + } + void operator()(const Cell&,Cell&) const {} }; } } //namespace internal::TDS_3 diff --git a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h index f8449c7eb8c..63607e3cb02 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h @@ -38,7 +38,7 @@ public: template struct Rebind_TDS { typedef Triangulation_ds_cell_base_3 Other; }; - Triangulation_ds_cell_base_3() + Triangulation_ds_cell_base_3() { #ifdef SHOW_REMAINING_BAD_ELEMENT_IN_RED mark = -1; @@ -185,7 +185,7 @@ public: // TDS internal data access functions. TDS_data& tds_data() { return _tds_data; } const TDS_data& tds_data() const { return _tds_data; } - + #ifdef SHOW_REMAINING_BAD_ELEMENT_IN_RED int mark; int mark2; diff --git a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h index f338340b50a..3322157b797 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h @@ -31,17 +31,17 @@ public: template struct Rebind_TDS { typedef Triangulation_ds_vertex_base_3 Other; }; - + Triangulation_ds_vertex_base_3() - : _c(), visited_for_vertex_extractor(false) + : _c(), visited_for_vertex_extractor(false) {} Triangulation_ds_vertex_base_3(Cell_handle c) - : _c(c), visited_for_vertex_extractor(false) + : _c(c), visited_for_vertex_extractor(false) {} - Cell_handle cell() const - { return _c; } + Cell_handle cell() const + { return _c; } void set_cell(Cell_handle c) { diff --git a/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h b/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h index bdf03c645d8..1364bf8b137 100644 --- a/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h +++ b/TDS_3/test/TDS_3/include/CGAL/_test_cls_tds_3.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Francois Rebufat // Monique Teillaud @@ -69,14 +69,14 @@ _test_cls_tds_3( const Tds &) _test_cell_tds_3(Tds()); std::cout << " Testing TDS " << std::endl; - + // Test constructors std::cout << " constructors" << std::endl; Tds tds1; Tds tds2; // Test I/O for dimension -2 - // the other dimensions are not tested here + // the other dimensions are not tested here // (they are implicitely tested in triangulation) Tds tdsfromfile; std::cout << " I/O" << std::endl; @@ -191,7 +191,7 @@ _test_cls_tds_3( const Tds &) std::vector Cell_v; for (cit = tds6.cells_begin(); cit != tds6.cells_end(); ++cit) Cell_v.push_back(cit); - + for (typename std::vector::const_iterator ccit = Cell_v.begin(); ccit != Cell_v.end(); ++ccit) { for ( i=0; i<4; i++ ) { @@ -203,30 +203,30 @@ _test_cls_tds_3( const Tds &) tds6.incident_vertices( (*ccit)->vertex(i), std::inserter(set_of_vertices_old, set_of_vertices_old.begin() ) ); - if ( set_of_vertices_old.find(tds6.mirror_vertex(*ccit, i)) - == set_of_vertices_old.end() ) { - nbflips++; - tds6.flip_flippable( *ccit, i ); - assert(tds6.is_valid()); -// if ( tds6.flip( cit, i ) ) { -// tds6.is_valid(true); -// nbflips++; -// } + if ( set_of_vertices_old.find(tds6.mirror_vertex(*ccit, i)) + == set_of_vertices_old.end() ) { + nbflips++; + tds6.flip_flippable( *ccit, i ); + assert(tds6.is_valid()); +// if ( tds6.flip( cit, i ) ) { +// tds6.is_valid(true); +// nbflips++; +// } } - // correct name + // correct name std::set< Vertex_handle > set_of_vertices; tds6.adjacent_vertices( (*ccit)->vertex(i), std::inserter(set_of_vertices, set_of_vertices.begin() ) ); - if ( set_of_vertices.find(tds6.mirror_vertex(*ccit, i)) - == set_of_vertices.end() ) { - nbflips++; - tds6.flip_flippable( *ccit, i ); - assert(tds6.is_valid()); -// if ( tds6.flip( cit, i ) ) { -// tds6.is_valid(true); -// nbflips++; -// } + if ( set_of_vertices.find(tds6.mirror_vertex(*ccit, i)) + == set_of_vertices.end() ) { + nbflips++; + tds6.flip_flippable( *ccit, i ); + assert(tds6.is_valid()); +// if ( tds6.flip( cit, i ) ) { +// tds6.is_valid(true); +// nbflips++; +// } } } } @@ -241,13 +241,13 @@ _test_cls_tds_3( const Tds &) // old name (up to CGAL 3.4) // kept for backwards compatibility but not documented tds6.incident_vertices - ( (*ccit)->vertex(i), std::back_inserter(vector_of_vertices_old)); - // correct name + ( (*ccit)->vertex(i), std::back_inserter(vector_of_vertices_old)); + // correct name tds6.adjacent_vertices - ( (*ccit)->vertex(i), std::back_inserter(vector_of_vertices)); + ( (*ccit)->vertex(i), std::back_inserter(vector_of_vertices)); tds6.incident_edges - ( (*ccit)->vertex(i), std::back_inserter(vector_of_edges)); + ( (*ccit)->vertex(i), std::back_inserter(vector_of_edges)); assert(vector_of_edges.size() == vector_of_vertices_old.size()); assert(vector_of_edges.size() == vector_of_vertices.size()); @@ -259,7 +259,7 @@ _test_cls_tds_3( const Tds &) assert(tds6.number_of_vertices()==8); // std::cout << tds6.number_of_cells()<< " cells" << std::endl; - nbflips=0; + nbflips=0; bool flipped; int j; cit = tds6.cells_begin(); @@ -272,13 +272,13 @@ _test_cls_tds_3( const Tds &) next_cell = ++cit; --cit; while ( (! flipped) && (i<4) ) { if ( (i!=j) ) { - // The Intel compiler has a bug and needs the explicit handle. - Cell_handle ch = cit; - flipped = tds6.flip( ch, i, j ) ; - if (flipped) { - nbflips++; - assert(tds6.is_valid()); - } + // The Intel compiler has a bug and needs the explicit handle. + Cell_handle ch = cit; + flipped = tds6.flip( ch, i, j ) ; + if (flipped) { + nbflips++; + assert(tds6.is_valid()); + } } if ( j==3 ) { i++; j=0; } else j++; @@ -311,44 +311,44 @@ _test_cls_tds_3( const Tds &) assert(tds7.dimension() == 1); assert(tds7.is_valid()); Vertex_handle v7_4 = tds7.insert_increase_dimension(v7_3); - Cell_handle fb = v7_4->cell(); + Cell_handle fb = v7_4->cell(); i7 = fb->index(v7_4); tds7.decrease_dimension(fb, i7); assert(tds7.dimension() == 1); assert(tds7.is_valid()); - Vertex_handle v7_5 = tds7.insert_increase_dimension(v7_4); + Vertex_handle v7_5 = tds7.insert_increase_dimension(v7_4); assert(tds7.dimension() == 2); assert(tds7.is_valid()); - Vertex_handle v7_6 = tds7.insert_increase_dimension(v7_5); + Vertex_handle v7_6 = tds7.insert_increase_dimension(v7_5); assert(tds7.dimension() == 3); assert(tds7.is_valid()); - Cell_handle fc = v7_6->cell(); + Cell_handle fc = v7_6->cell(); i7 = fc->index(v7_6); tds7.decrease_dimension(fc, i7); assert(tds7.dimension() == 2); - assert(tds7.is_valid()); - Vertex_handle v7_7 = tds7.insert_increase_dimension(v7_6); + assert(tds7.is_valid()); + Vertex_handle v7_7 = tds7.insert_increase_dimension(v7_6); assert(tds7.dimension() == 3); - assert(tds7.is_valid()); - Cell_handle fd = v7_7->cell(); + assert(tds7.is_valid()); + Cell_handle fd = v7_7->cell(); i7 = fd->index(v7_7); tds7.decrease_dimension(fd, i7); assert(tds7.dimension() == 2); assert(tds7.is_valid()); Cell_handle fe = v7_7->cell(); - i7 = fe->index(v7_7); + i7 = fe->index(v7_7); tds7.insert_in_facet(fe, i7); assert(tds7.dimension() == 2); assert(tds7.is_valid()); - Vertex_handle v7_8 = tds7.insert_increase_dimension(v7_7); + Vertex_handle v7_8 = tds7.insert_increase_dimension(v7_7); assert(tds7.dimension() == 3); - assert(tds7.is_valid()); - Cell_handle ff = v7_8->cell(); + assert(tds7.is_valid()); + Cell_handle ff = v7_8->cell(); i7 = ff->index(v7_8); tds7.decrease_dimension(ff, i7); assert(tds7.dimension() == 2); assert(tds7.is_valid()); - + // tds1.clear(); // tds2.clear(); // tds3.clear(); diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h b/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h index b25a2a7a81c..3c32f97f7c5 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationDSFullCell.h @@ -3,35 +3,35 @@ \ingroup PkgTriangulationsConcepts \cgalConcept -The concept `TriangulationDSFullCell` describes the requirements for the +The concept `TriangulationDSFullCell` describes the requirements for the full cell class of a `CGAL::Triangulation_data_structure`. It refines the concept `TriangulationDataStructure::FullCell`. -Since the `CGAL::Triangulation_data_structure` is the class +Since the `CGAL::Triangulation_data_structure` is the class which defines the handle types, the full cell base class has to be somehow parameterized by the triangulation -data structure. But since the `CGAL::Triangulation_data_structure` -itself is parameterized by the cell and vertex -base classes, there is a cycle in the definition of these classes. -In order -to break the cycle, the base classes for cells and vertices -which are plugged in to instantiate a -`Triangulation_data_structure` -use a `void` as triangulation -data structure parameter. Then, -the `CGAL::Triangulation_data_structure` -uses a rebind mechanism (similar to the one specified in -`std::allocator`) in order to plug itself -as parameter in the full cell and vertex base classes. -This mechanism requires that the base class provides -a templated nested class `Rebind_TDS` that -itself provides -the subtype `Rebind_TDS::Other` -which is the rebound version of the base class. -This rebound base class is the class -that the `CGAL::Triangulation_data_structure` -actually uses as a base class for the class +data structure. But since the `CGAL::Triangulation_data_structure` +itself is parameterized by the cell and vertex +base classes, there is a cycle in the definition of these classes. +In order +to break the cycle, the base classes for cells and vertices +which are plugged in to instantiate a +`Triangulation_data_structure` +use a `void` as triangulation +data structure parameter. Then, +the `CGAL::Triangulation_data_structure` +uses a rebind mechanism (similar to the one specified in +`std::allocator`) in order to plug itself +as parameter in the full cell and vertex base classes. +This mechanism requires that the base class provides +a templated nested class `Rebind_TDS` that +itself provides +the subtype `Rebind_TDS::Other` +which is the rebound version of the base class. +This rebound base class is the class +that the `CGAL::Triangulation_data_structure` +actually uses as a base class for the class of `CGAL::Triangulation_data_structure::Vertex`. \cgalRefines `TriangulationDataStructure::FullCell` @@ -42,7 +42,7 @@ of `CGAL::Triangulation_data_structure::Vertex`. \sa `TriangulationDSVertex` \sa `TriangulationDSFace` \sa `TriangulationDataStructure` -\sa `TriangulationDataStructure::FullCell` +\sa `TriangulationDataStructure::FullCell` */ class TriangulationDSFullCell { @@ -50,7 +50,7 @@ public: /// \name Types /// @{ - + /*! The `Triangulation_data_structure` in which the `TriangulationDSFullCell` is defined/used. @@ -59,15 +59,15 @@ Must be a model of the `TriangulationDataStructure` concept. typedef unspecified_type Triangulation_data_structure; /*! -This nested template class has to define a type `Rebind_TDS::%Other` -which is the rebound vertex, that is, the one +This nested template class has to define a type `Rebind_TDS::%Other` +which is the rebound vertex, that is, the one that will be actually used by `Triangulation_data_structure`. -The `Rebind_TDS::%Other` type will be the real +The `Rebind_TDS::%Other` type will be the real base class of `Triangulation_data_structure::Full_cell`. \note It can be implemented using a nested template class. */ -template -using Rebind_TDS = unspecified_type; +template +using Rebind_TDS = unspecified_type; /// @} diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h b/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h index 903da560d1c..5e3def7d9bd 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationDSVertex.h @@ -3,35 +3,35 @@ \ingroup PkgTriangulationsConcepts \cgalConcept -The concept `TriangulationDSVertex` describes the requirements for the +The concept `TriangulationDSVertex` describes the requirements for the vertex base class of a `CGAL::Triangulation_data_structure`. It refines the concept `TriangulationDataStructure::Vertex`. -Since the `CGAL::Triangulation_data_structure` is the class +Since the `CGAL::Triangulation_data_structure` is the class which defines the handle types, the vertex base class has to be somehow parameterized by the triangulation -data structure. But since the `CGAL::Triangulation_data_structure` -itself is parameterized by the cell and vertex -base classes, there is a cycle in the definition of these classes. -In order -to break the cycle, the base classes for cells and vertices -which are plugged in to instantiate a -`Triangulation_data_structure` -use a `void` as triangulation -data structure parameter. Then, -the `CGAL::Triangulation_data_structure` -uses a rebind mechanism (similar to the one specified in -`std::allocator`) in order to plug itself -as parameter in the full cell and vertex base classes. -This mechanism requires that the base class provides -a templated nested class `Rebind_TDS` that -itself provides -the subtype `Rebind_TDS::Other` -which is the rebound version of the base class. -This rebound base class is the class -that the `CGAL::Triangulation_data_structure` -actually uses as a base class for the class +data structure. But since the `CGAL::Triangulation_data_structure` +itself is parameterized by the cell and vertex +base classes, there is a cycle in the definition of these classes. +In order +to break the cycle, the base classes for cells and vertices +which are plugged in to instantiate a +`Triangulation_data_structure` +use a `void` as triangulation +data structure parameter. Then, +the `CGAL::Triangulation_data_structure` +uses a rebind mechanism (similar to the one specified in +`std::allocator`) in order to plug itself +as parameter in the full cell and vertex base classes. +This mechanism requires that the base class provides +a templated nested class `Rebind_TDS` that +itself provides +the subtype `Rebind_TDS::Other` +which is the rebound version of the base class. +This rebound base class is the class +that the `CGAL::Triangulation_data_structure` +actually uses as a base class for the class of `CGAL::Triangulation_data_structure::Vertex`. \cgalRefines `TriangulationDataStructure::Vertex` @@ -42,15 +42,15 @@ of `CGAL::Triangulation_data_structure::Vertex`. \sa `TriangulationDSFullCell` \sa `TriangulationDSFace` \sa `TriangulationDataStructure` -\sa `TriangulationDataStructure::Vertex` +\sa `TriangulationDataStructure::Vertex` */ class TriangulationDSVertex { public: - + /// \name Types /// @{ - + /*! The `Triangulation_data_structure` in which the vertex is @@ -61,15 +61,15 @@ Must be a model of the `TriangulationDataStructure` concept. typedef unspecified_type Triangulation_data_structure; /*! -This nested template class has to define a type `Rebind_TDS::%Other` -which is the rebound vertex, that is, the one -that will be actually used by `Triangulation_data_structure`. +This nested template class has to define a type `Rebind_TDS::%Other` +which is the rebound vertex, that is, the one +that will be actually used by `Triangulation_data_structure`. The `Rebind_TDS::%Other` type will be the real base class of `Triangulation_data_structure::Vertex`. \note It can be implemented using a nested template class. */ -template -using Rebind_TDS = unspecified_type; +template +using Rebind_TDS = unspecified_type; /// @} diff --git a/Triangulation/include/CGAL/Triangulation_ds_vertex.h b/Triangulation/include/CGAL/Triangulation_ds_vertex.h index c57bfbed51a..aaa1e2067fc 100644 --- a/Triangulation/include/CGAL/Triangulation_ds_vertex.h +++ b/Triangulation/include/CGAL/Triangulation_ds_vertex.h @@ -26,7 +26,7 @@ namespace CGAL { * 'Triangulation_ds_vertex' */ template< class TDS = void > -class Triangulation_ds_vertex +class Triangulation_ds_vertex { typedef Triangulation_ds_vertex Self; diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 00128211057..a061c6b66b3 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Andreas Fabri, Mariette Yvinec @@ -56,25 +56,25 @@ public: } }; // end class template Pct2_vertex_handle_less_xy -// Tr the base triangulation class +// Tr the base triangulation class // Tr has to be Constrained or Constrained_Delaunay with Constrained_triangulation_plus_vertex_base template < class Tr_ = Default > -class Constrained_triangulation_plus_2 - : public -Default::Get< Tr_, Constrained_Delaunay_triangulation_2< +class Constrained_triangulation_plus_2 + : public +Default::Get< Tr_, Constrained_Delaunay_triangulation_2< Exact_predicates_inexact_constructions_kernel - , Triangulation_data_structure_2< + , Triangulation_data_structure_2< Triangulation_vertex_base_2 , Constrained_triangulation_face_base_2 > , CGAL::Exact_predicates_tag > >::type { - typedef typename - Default::Get< Tr_, Constrained_Delaunay_triangulation_2< + typedef typename + Default::Get< Tr_, Constrained_Delaunay_triangulation_2< Exact_predicates_inexact_constructions_kernel - , Triangulation_data_structure_2< + , Triangulation_data_structure_2< Triangulation_vertex_base_2 , Constrained_triangulation_face_base_2 > @@ -88,7 +88,7 @@ Default::Get< Tr_, Constrained_Delaunay_triangulation_2< typedef typename CDT::Vertex_handle Vertex_handle; typedef typename CDT::Face_handle Face_handle; private: - typedef boost::tuple TFace; + typedef boost::tuple TFace; std::vector faces; CDT& cdt; @@ -110,8 +110,8 @@ Default::Get< Tr_, Constrained_Delaunay_triangulation_2< void write_faces(OutputIterator out) { - for(typename std::vector::reverse_iterator - it = faces.rbegin(); it != faces.rend(); ++it) { + for(typename std::vector::reverse_iterator + it = faces.rbegin(); it != faces.rend(); ++it) { Face_handle fh; if(cdt.is_face(boost::get<0>(*it), boost::get<1>(*it), boost::get<2>(*it), fh)){ *out++ = fh; @@ -126,7 +126,7 @@ public: typedef Constrained_triangulation_plus_2 Self; typedef Tr Base; - + #ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 using Triangulation::vertices_begin; using Triangulation::vertices_end; @@ -169,29 +169,29 @@ public: typedef Tag_false Periodic_tag; // for user interface with the constraint hierarchy - typedef typename Constraint_hierarchy::Vertex_it + typedef typename Constraint_hierarchy::Vertex_it Vertices_in_constraint_iterator; typedef Iterator_range Vertices_in_constraint; - + typedef typename Constraint_hierarchy::Point_it Points_in_constraint_iterator; typedef Iterator_range Points_in_constraint; - + typedef typename Constraint_hierarchy::Context Context; typedef typename Constraint_hierarchy::Context_iterator Context_iterator; typedef Iterator_range Contexts; - + typedef typename Constraint_hierarchy::C_iterator Constraint_iterator; typedef Iterator_range Constraints; - + typedef typename Constraint_hierarchy::Subconstraint_iterator Subconstraint_iterator; typedef Iterator_range Subconstraints; - - typedef typename Constraint_hierarchy::Constraint_id Constraint_id; - + + typedef typename Constraint_hierarchy::Constraint_id Constraint_id; + typedef std::pair Subconstraint; - + using Triangulation::geom_traits; using Triangulation::cw; using Triangulation::ccw; @@ -199,14 +199,14 @@ public: protected: Constraint_hierarchy hierarchy; - + public: Constraint_hierarchy& hierarchy_ref() { return hierarchy; } - Constrained_triangulation_plus_2(const Geom_traits& gt=Geom_traits()) + Constrained_triangulation_plus_2(const Geom_traits& gt=Geom_traits()) : Triangulation(gt) , hierarchy(Vh_less_xy(this)) { } @@ -230,8 +230,8 @@ public: template Constrained_triangulation_plus_2(InputIterator first, - InputIterator last, - const Geom_traits& gt=Geom_traits() ) + InputIterator last, + const Geom_traits& gt=Geom_traits() ) : Triangulation(gt) , hierarchy(Vh_less_xy(this)) { @@ -241,7 +241,7 @@ public: Constrained_triangulation_plus_2(const std::list > &constraints, - const Geom_traits& gt=Geom_traits() ) + const Geom_traits& gt=Geom_traits() ) : Triangulation(gt) , hierarchy(Vh_less_xy(this)) { @@ -254,12 +254,12 @@ public: void swap(Constrained_triangulation_plus_2 &ctp); // INSERTION - Vertex_handle insert(const Point& a, - Face_handle start = Face_handle() ); + Vertex_handle insert(const Point& a, + Face_handle start = Face_handle() ); Vertex_handle insert(const Point& p, - Locate_type lt, - Face_handle loc, int li ); - + Locate_type lt, + Face_handle loc, int li ); + Constraint_id insert_constraint(const Point& a, const Point& b) { Vertex_handle va= insert(a); @@ -267,14 +267,14 @@ public: // close to point a // Otherwise, to start here is as good as elsewhere Vertex_handle vb = insert(b, va->face()); - return insert_constraint(va, vb); + return insert_constraint(va, vb); } - Constraint_id insert_constraint(const Constraint& c) + Constraint_id insert_constraint(const Constraint& c) { return insert_constraint(c.first, c.second); } - + Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb) { // protects against inserting a zero length constraint @@ -283,7 +283,7 @@ public: } // protects against inserting twice the same constraint Constraint_id cid = hierarchy.insert_constraint_old_API(va, vb); - if (va != vb && (cid != Constraint_id(nullptr)) ) insert_subconstraint(va,vb); + if (va != vb && (cid != Constraint_id(nullptr)) ) insert_subconstraint(va,vb); return cid; } @@ -330,7 +330,7 @@ public: } // for backward compatibility - // not const Point&, because otherwise VC6/7 messes it up with + // not const Point&, because otherwise VC6/7 messes it up with // the insert that takes an iterator range Constraint_id insert(Point a, Point b) { return insert_constraint(a, b); } Constraint_id insert(Vertex_handle va, Vertex_handle vb) { return insert_constraint(va,vb); } @@ -357,8 +357,8 @@ public: Vertices_in_constraint_iterator - insert_vertex_in_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, - Vertex_handle vh) + insert_vertex_in_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, + Vertex_handle vh) { return insert_vertex_in_constraint(cid, pos, vh, Emptyset_iterator()); } @@ -372,8 +372,8 @@ public: template Vertices_in_constraint_iterator - remove_vertex_from_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, - OutputIterator out) + remove_vertex_from_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, + OutputIterator out) { if(pos == vertices_in_constraint_begin(cid)){ ++pos; @@ -414,7 +414,7 @@ public: ++pos; tail = hierarchy.split(cid,pos); } - + Constraint_id aux = insert_constraint(a, b, std::back_inserter(fc)); pos = vertices_in_constraint_end(aux); --pos; @@ -439,8 +439,8 @@ public: // Writes the modified faces to out template Vertices_in_constraint_iterator - insert_vertex_in_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, - Vertex_handle vh, OutputIterator out) + insert_vertex_in_constraint(Constraint_id cid, Vertices_in_constraint_iterator pos, + Vertex_handle vh, OutputIterator out) { // Insertion before the first vertex if(pos == vertices_in_constraint_begin(cid)){ @@ -448,7 +448,7 @@ public: Constraint_id head = insert_constraint(vh, *pos, out); hierarchy.concatenate2(head, cid); return vertices_in_constraint_begin(cid); - } + } // Insertion after the last vertex if(pos == vertices_in_constraint_end(cid)){ @@ -461,7 +461,7 @@ public: return pos; } Vertex_handle b = *pos; - --pos; + --pos; Vertex_handle a = *pos; ++pos; Face_container fc(*this); @@ -470,7 +470,7 @@ public: vcit = beg; ++beg; // If the constraint consists only of a segment, and we want to insert - // in the middle + // in the middle if((pos == vcit) && (beg == vertices_in_constraint_end(cid))){ //std::cout << "insertion in constraint which is a segment" << std::endl; Constraint_id aux1 = insert_constraint(a, vh, std::back_inserter(fc)); @@ -481,7 +481,7 @@ public: remove_constraint(aux1, std::back_inserter(fc)); fc.write_faces(out); return pos; - + } Constraint_id head = nullptr, tail = nullptr; Vertices_in_constraint_iterator bit = vertices_in_constraint_begin(cid); @@ -500,9 +500,9 @@ public: --eit; if(pos != eit){ //std::cout << "split tail" << std::endl; - tail = split(cid, pos); + tail = split(cid, pos); } - + // make the new constraint Constraint_id aux1 = insert_constraint(a, vh, std::back_inserter(fc)); Constraint_id aux2 = insert_constraint(vh, b, std::back_inserter(fc)); @@ -538,7 +538,7 @@ public: hint = vh->face(); // no duplicates if(vertices.empty() || (vertices.back() != vh)){ - vertices.push_back(vh); + vertices.push_back(vh); } } int n = vertices.size(); @@ -546,24 +546,24 @@ public: return nullptr; } Constraint_id ca = hierarchy.insert_constraint(vertices[0],vertices[1]); - insert_subconstraint(vertices[0],vertices[1], std::back_inserter(fc)); + insert_subconstraint(vertices[0],vertices[1], std::back_inserter(fc)); if(n>2){ for(int j=1; jfixed() = true; // Vertices_in_constraint_iterator end = boost::prior(vertices_in_constraint_end(ca)); // end->fixed() = true; fc.write_faces(out); - + return ca; } @@ -579,7 +579,7 @@ private: hint = vh->face(); // no duplicates if(vertices.empty() || (vertices.back() != vh)){ - vertices.push_back(vh); + vertices.push_back(vh); } } if(is_polygon && (vertices.size()>1) && (vertices.front() != vertices.back())){ @@ -591,26 +591,26 @@ private: return nullptr; } CGAL_assertion(n >= 2); - + Constraint_id ca = hierarchy.insert_constraint(vertices[0],vertices[1]); - insert_subconstraint(vertices[0],vertices[1]); + insert_subconstraint(vertices[0],vertices[1]); if(n>2){ for(std::size_t j=1; jfixed() = true; // vertices.back()->fixed() = true; return ca; } - + public: - + void file_output(std::ostream& os) const { @@ -635,9 +635,9 @@ public: void file_input(std::istream& is) { - + is >> static_cast(*this); - + std::vector V; V.reserve(number_of_vertices()); for(Vertex_iterator vit = vertices_begin(); vit != vertices_end() ; ++vit){ @@ -650,7 +650,7 @@ public: while(is >> n){ is >> i0 >> i1; cid = insert_constraint(V[i0],V[i1]); - + for(int i = 2; i < n; i++){ i0 = i1; is >> i1; @@ -660,7 +660,7 @@ public: } } - + template typename Constrained_triangulation_plus_2::Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb, OutputIterator out) @@ -671,11 +671,11 @@ public: } // protects against inserting twice the same constraint Constraint_id cid = hierarchy.insert_constraint(va, vb); - if (va != vb && (cid != nullptr) ) insert_subconstraint(va,vb,out); - + if (va != vb && (cid != nullptr) ) insert_subconstraint(va,vb,out); + for(Vertices_in_constraint_iterator vcit = vertices_in_constraint_begin(cid); - vcit != vertices_in_constraint_end(cid); - vcit++){ + vcit != vertices_in_constraint_end(cid); + vcit++){ insert_incident_faces(vcit, out); } return cid; @@ -700,26 +700,26 @@ public: Vertex_handle vaa, Vertex_handle vbb, Exact_predicates_tag); - + // REMOVAL template void remove_constraint(Constraint_id cid, OutputIterator out) { std::list vertices(hierarchy.vertices_in_constraint_begin(cid), - hierarchy.vertices_in_constraint_end(cid)); + hierarchy.vertices_in_constraint_end(cid)); hierarchy.remove_constraint(cid); - for(typename std::list::iterator it = vertices.begin(), - succ = it; - ++succ != vertices.end(); - ++it){ + for(typename std::list::iterator it = vertices.begin(), + succ = it; + ++succ != vertices.end(); + ++it){ if(! is_subconstraint(*it, *succ)){ // this checks whether other constraints pass - Face_handle fh; - int i; - bool b = Triangulation::is_edge(*it, *succ, fh, i); - CGAL_assume(b); - Triangulation::remove_constrained_edge(fh,i, out); // this does also flipping if necessary. + Face_handle fh; + int i; + bool b = Triangulation::is_edge(*it, *succ, fh, i); + CGAL_assume(b); + Triangulation::remove_constrained_edge(fh,i, out); // this does also flipping if necessary. } } } @@ -728,18 +728,18 @@ public: remove_constraint(cid, Emptyset_iterator()); } - + void simplify(Vertices_in_constraint_iterator v) { Vertices_in_constraint_iterator u = boost::prior(v); Vertices_in_constraint_iterator w = boost::next(v); bool unew = (*u != *w); hierarchy.simplify(u,v,w); - + Triangulation::remove_incident_constraints(*v); - + Triangulation::remove(*v); - + if(unew){ Triangulation::insert_constraint(*u, *w); } @@ -763,10 +763,10 @@ public: // split a constraint in two constraints, so that vcit becomes the first // vertex of the new constraint - // returns the new constraint + // returns the new constraint Constraint_id split(Constraint_id first, Vertices_in_constraint_iterator vcit); - + // Query of the constraint hierarchy Constraint_iterator constraints_begin() const; Constraint_iterator constraints_end() const; @@ -774,7 +774,7 @@ public: { return Constraints(constraints_begin(),constraints_end()); } - + Subconstraint_iterator subconstraints_begin() const; Subconstraint_iterator subconstraints_end() const; @@ -782,31 +782,31 @@ public: { return Subconstraints(subconstraints_begin(),subconstraints_end()); } - - Context context(Vertex_handle va, Vertex_handle vb); //AF: const; - bool is_subconstraint(Vertex_handle va, - Vertex_handle vb); - size_type number_of_enclosing_constraints(Vertex_handle va, + Context context(Vertex_handle va, Vertex_handle vb); //AF: const; + + bool is_subconstraint(Vertex_handle va, + Vertex_handle vb); + size_type number_of_enclosing_constraints(Vertex_handle va, Vertex_handle vb) const; - Context_iterator contexts_begin(Vertex_handle va, - Vertex_handle vb) const; - Context_iterator contexts_end(Vertex_handle va, - Vertex_handle vb) const; + Context_iterator contexts_begin(Vertex_handle va, + Vertex_handle vb) const; + Context_iterator contexts_end(Vertex_handle va, + Vertex_handle vb) const; Contexts contexts(Vertex_handle va, Vertex_handle vb) const { return Contexts(contexts_begin(va,vb),contexts_end(va,vb)); } - + Vertices_in_constraint_iterator vertices_in_constraint_begin(Constraint_id cid) const; Vertices_in_constraint_iterator vertices_in_constraint_end(Constraint_id cid) const; - + Vertices_in_constraint vertices_in_constraint(Constraint_id cid) const { return Vertices_in_constraint(vertices_in_constraint_begin(cid), vertices_in_constraint_end(cid)); } - + Points_in_constraint_iterator points_in_constraint_begin(Constraint_id cid) const; Points_in_constraint_iterator points_in_constraint_end(Constraint_id cid) const ; @@ -842,12 +842,12 @@ protected: fc++; }while(fc != done); } - } + } void insert_subconstraint(Vertex_handle vaa, - Vertex_handle vbb) + Vertex_handle vbb) { insert_subconstraint(vaa,vbb,Emptyset_iterator()); } @@ -858,9 +858,9 @@ insert_subconstraint(Vertex_handle vaa, template void insert_subconstraint(Vertex_handle vaa, - Vertex_handle vbb, - OutputItertator out) - // insert the subconstraint [vaa vbb] + Vertex_handle vbb, + OutputItertator out) + // insert the subconstraint [vaa vbb] // it will eventually be split into several subconstraints { std::stack > stack; @@ -870,7 +870,7 @@ insert_subconstraint(Vertex_handle vaa, boost::tie(vaa,vbb) = stack.top(); stack.pop(); CGAL_triangulation_precondition( vaa != vbb); - + Vertex_handle vi; Face_handle fr; @@ -883,11 +883,11 @@ insert_subconstraint(Vertex_handle vaa, } continue; } - + List_faces intersected_faces; List_edges conflict_boundary_ab, conflict_boundary_ba; - - bool intersection = this->find_intersected_faces( + + bool intersection = this->find_intersected_faces( vaa, vbb, intersected_faces, conflict_boundary_ab, @@ -897,10 +897,10 @@ insert_subconstraint(Vertex_handle vaa, if ( intersection) { if (vi != vaa && vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); - stack.push(std::make_pair(vaa,vi)); - stack.push(std::make_pair(vi,vbb)); + stack.push(std::make_pair(vaa,vi)); + stack.push(std::make_pair(vi,vbb)); } - else stack.push(std::make_pair(vaa,vbb)); + else stack.push(std::make_pair(vaa,vbb)); continue; } @@ -941,7 +941,7 @@ insert_subconstraint(Vertex_handle vaa, if (vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); - stack.push(std::make_pair(vi,vbb)); + stack.push(std::make_pair(vi,vbb)); } } } @@ -958,7 +958,7 @@ public: #if defined(_MSC_VER) std::ptrdiff_t insert(InputIterator first, InputIterator last, int i = 0) #else - std::ptrdiff_t insert(InputIterator first, InputIterator last) + std::ptrdiff_t insert(InputIterator first, InputIterator last) #endif { #if defined(_MSC_VER) @@ -987,7 +987,7 @@ copy_triangulation(const Constrained_triangulation_plus_2 &ctp) { Base::copy_triangulation(ctp); //the following assumes that the triangulation and its copy - // iterate on their vertices in the same order + // iterate on their vertices in the same order std::map vmap; Vertex_iterator vit = ctp.vertices_begin(); Vertex_iterator vvit = this->vertices_begin(); @@ -1008,7 +1008,7 @@ swap(Constrained_triangulation_plus_2 &ctp) } template < class Tr > -inline +inline typename Constrained_triangulation_plus_2::Vertex_handle Constrained_triangulation_plus_2:: insert(const Point& a, Face_handle start) @@ -1046,17 +1046,17 @@ insert(const Point& a, Locate_type lt, Face_handle loc, int li) } template -typename Constrained_triangulation_plus_2:: Vertex_handle +typename Constrained_triangulation_plus_2:: Vertex_handle Constrained_triangulation_plus_2:: -intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb) +intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb) { return intersect(f, i, vaa, vbb, Intersection_tag()); } template -typename Constrained_triangulation_plus_2:: Vertex_handle +typename Constrained_triangulation_plus_2:: Vertex_handle Constrained_triangulation_plus_2:: intersect(Face_handle, int, Vertex_handle, @@ -1080,13 +1080,13 @@ intersect(Face_handle, int, } template -typename Constrained_triangulation_plus_2:: Vertex_handle +typename Constrained_triangulation_plus_2:: Vertex_handle Constrained_triangulation_plus_2:: -intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_intersections_tag) -// compute the intersection of the constraint edge (f,i) +intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_intersections_tag) +// compute the intersection of the constraint edge (f,i) // with the subconstraint (vaa,vbb) being inserted // insert the intersection point // (the constraint edge (f,i) will be split in hierarchy by insert) @@ -1114,16 +1114,16 @@ intersect(Face_handle f, int i, CGAL_triangulation_assertion(ok); Vertex_handle vi = insert(pi, Triangulation::EDGE, f, i); - return vi; + return vi; } template -typename Constrained_triangulation_plus_2::Vertex_handle +typename Constrained_triangulation_plus_2::Vertex_handle Constrained_triangulation_plus_2:: -intersect(Face_handle f, int i, - Vertex_handle vaa, - Vertex_handle vbb, - Exact_predicates_tag) +intersect(Face_handle f, int i, + Vertex_handle vaa, + Vertex_handle vbb, + Exact_predicates_tag) { Vertex_handle vcc, vdd; vcc = f->vertex(cw(i)); @@ -1145,7 +1145,7 @@ intersect(Face_handle f, int i, case 0 : vi = vaa; break; case 1 : vi = vbb; break; case 2 : vi = vcc; break; - case 3 : vi = vdd; break; + case 3 : vi = vdd; break; } if(vi == vaa || vi == vbb) { Triangulation::remove_constrained_edge(f, i); @@ -1158,15 +1158,15 @@ intersect(Face_handle f, int i, // vi == vc or vi == vd may happen even if intersection==true // due to approximate construction of the intersection - if (vi != vcc && vi != vdd) { + if (vi != vcc && vi != vdd) { hierarchy.split_constraint(vcc,vdd,vi); - insert_subconstraint(vcc,vi); + insert_subconstraint(vcc,vi); insert_subconstraint(vi, vdd); - } + } else { insert_subconstraint(vcc,vdd); } - return vi; + return vi; } // CONCATENATE AND SPLIT @@ -1181,7 +1181,7 @@ Constrained_triangulation_plus_2::concatenate(Constraint_id first, Constrain // split a constraint in two constraints, so that vcit becomes the first // vertex of the new constraint - // returns the new constraint + // returns the new constraint template typename Constrained_triangulation_plus_2::Constraint_id Constrained_triangulation_plus_2::split(Constraint_id first, Vertices_in_constraint_iterator vcit) @@ -1192,8 +1192,8 @@ Constrained_triangulation_plus_2::split(Constraint_id first, Vertices_in_con template std::ostream & -operator<<(std::ostream& os, - const Constrained_triangulation_plus_2 &ct) +operator<<(std::ostream& os, + const Constrained_triangulation_plus_2 &ct) { ct.file_output(os); return os ; @@ -1201,8 +1201,8 @@ operator<<(std::ostream& os, template std::istream & -operator>>(std::istream& is, - Constrained_triangulation_plus_2 &ct) +operator>>(std::istream& is, + Constrained_triangulation_plus_2 &ct) { ct.file_input(is); return is ; @@ -1262,13 +1262,13 @@ context(Vertex_handle va, Vertex_handle vb) // AF: const template -inline +inline typename Constrained_triangulation_plus_2::size_type Constrained_triangulation_plus_2:: number_of_enclosing_constraints(Vertex_handle va, Vertex_handle vb) const { - return static_cast - (hierarchy.number_of_enclosing_constraints(va,vb)); + return static_cast + (hierarchy.number_of_enclosing_constraints(va,vb)); } template @@ -1276,7 +1276,7 @@ inline bool Constrained_triangulation_plus_2:: is_subconstraint(Vertex_handle va, Vertex_handle vb) { - return hierarchy.is_subconstrained_edge(va,vb); + return hierarchy.is_subconstrained_edge(va,vb); } diff --git a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h index dd85df9acb0..c8fc845f01b 100644 --- a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h @@ -327,10 +327,10 @@ public: #ifndef CGAL_TRIANGULATION_2_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO private: - + using Triangulation::top_get_first; using Triangulation::top_get_second; - + template std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last) { diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index bf89ead3c58..c3c26ce2470 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Andreas Fabri, Olivier Billet, Mariette Yvinec @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -57,11 +57,11 @@ private: typedef std::list Constraint_list; public: - // the base line is always - class Point_it + // the base line is always + class Point_it : public boost::iterator_adaptor< Point_it - , typename Vertex_list::all_iterator + , typename Vertex_list::all_iterator , const Point > { @@ -74,10 +74,10 @@ public: }; // only nodes with a vertex_handle that is still in the triangulation - class Vertex_it + class Vertex_it : public boost::iterator_adaptor< Vertex_it - , typename Vertex_list::skip_iterator + , typename Vertex_list::skip_iterator , Vertex_handle , boost::use_default , Vertex_handle> @@ -106,11 +106,11 @@ public: Vertex_list* vl_ptr() const {return second;} operator std::pair,Vertex_list*>() - { + { if (second!=nullptr){ return std::make_pair(std::make_pair(second->front().vertex(), second->back().vertex()),second); - } + } return std::make_pair(std::make_pair(Vertex_handle(),Vertex_handle()),second); } @@ -159,24 +159,24 @@ public: Vertex_it vertices_end()const {return enclosing->skip_end();} Constraint_id id() { return enclosing; } std::size_t number_of_vertices() const {return enclosing->skip_size(); } - }; + }; typedef std::list Context_list; typedef typename Context_list::iterator Context_iterator; typedef std::set Constraint_set; typedef std::map Sc_to_c_map; + Pair_compare> Sc_to_c_map; typedef typename Constraint_set::iterator C_iterator; typedef typename Sc_to_c_map::const_iterator Sc_iterator; typedef Sc_iterator Subconstraint_iterator; - + private: // data for the 1d hierarchy Compare comp; Constraint_set constraint_set; Sc_to_c_map sc_to_c_map; - + public: Polyline_constraint_hierarchy_2(const Compare& comp) : comp(comp) @@ -189,7 +189,7 @@ public: Polyline_constraint_hierarchy_2& operator=(const Polyline_constraint_hierarchy_2& ch); Polyline_constraint_hierarchy_2& operator=(Polyline_constraint_hierarchy_2&& ch) = default; - // Query + // Query bool is_subconstrained_edge(T va, T vb) const; bool is_constrained_edge(T va, T vb) const; bool is_constrained_vertex(T v) const; @@ -217,7 +217,7 @@ public: Context_iterator contexts_end(T va, T vb) const; std::size_t number_of_constraints() const { return constraint_set.size();} std::size_t number_of_subconstraints()const {return sc_to_c_map.size();} - + // insert/remove void add_Steiner(T va, T vb, T vx); @@ -246,31 +246,31 @@ public: // iterators Subconstraint_iterator subconstraint_begin() const - { - return sc_to_c_map.begin(); + { + return sc_to_c_map.begin(); } Subconstraint_iterator subconstraint_end() const - { - return sc_to_c_map.end(); + { + return sc_to_c_map.end(); } Sc_iterator sc_begin() const{ return sc_to_c_map.begin(); } Sc_iterator sc_end() const{ return sc_to_c_map.end(); } C_iterator c_begin() const{ return constraint_set.begin(); } C_iterator c_end() const{ return constraint_set.end(); } - + // Helper functions void copy(const Polyline_constraint_hierarchy_2& ch); void copy(const Polyline_constraint_hierarchy_2& ch, std::map& vmap); void swap(Polyline_constraint_hierarchy_2& ch); -private: +private: Edge make_edge(T va, T vb) const; Vertex_it get_pos(T va, T vb) const; - bool get_contexts(T va, T vb, - Context_iterator& ctxt, - Context_iterator& past) const; + bool get_contexts(T va, T vb, + Context_iterator& ctxt, + Context_iterator& past) const; bool get_contexts(T va, T vb, Context_list*&) const; @@ -347,8 +347,8 @@ copy(const Polyline_constraint_hierarchy_2& ch1, std::mapskip_begin(); Vertex_it aux = cit1->enclosing->skip_begin(); while( aux != cit1->pos) { - ++aux; - ++ctxt2.pos; + ++aux; + ++ctxt2.pos; } hcl2->push_back(ctxt2); } @@ -435,8 +435,8 @@ enclosing_constraints(T vaa, T vbb , Constraint_list& hcl) const Context_iterator hcit, past; if ( !get_contexts(vaa,vbb, hcit ,past)) return false; for (; hcit!=past; hcit++) { - hcl.push_back(make_edge(hcit->enclosing->front(), - hcit->enclosing->back())); + hcl.push_back(make_edge(hcit->enclosing->front(), + hcit->enclosing->back())); } return true; } @@ -452,7 +452,7 @@ context(T va, T vb) } template -std::size_t +std::size_t Polyline_constraint_hierarchy_2:: number_of_enclosing_constraints(T va, T vb) const { @@ -476,19 +476,19 @@ template typename Polyline_constraint_hierarchy_2::Context_iterator Polyline_constraint_hierarchy_2:: contexts_end(T va, T vb) const -{ +{ Context_iterator first, last; if( !get_contexts(va,vb,first,last)) CGAL_triangulation_assertion(false); return last; -} +} template void Polyline_constraint_hierarchy_2:: swap(Constraint_id first, Constraint_id second){ // We have to look at all subconstraints - for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -497,14 +497,14 @@ swap(Constraint_id first, Constraint_id second){ // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->enclosing = nullptr; - break; + ctit->enclosing = nullptr; + break; } } } // We have to look at all subconstraints - for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = second.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = second.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -513,14 +513,14 @@ swap(Constraint_id first, Constraint_id second){ // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == second.vl_ptr()){ - ctit->enclosing = first.vl_ptr(); - break; + ctit->enclosing = first.vl_ptr(); + break; } } - } + } // We have to look at all subconstraints - for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -529,8 +529,8 @@ swap(Constraint_id first, Constraint_id second){ // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == nullptr){ - ctit->enclosing = second.vl_ptr(); - break; + ctit->enclosing = second.vl_ptr(); + break; } } } @@ -543,10 +543,10 @@ void Polyline_constraint_hierarchy_2:: remove_constraint(Constraint_id cid){ constraint_set.erase(cid); - + // We have to look at all subconstraints - for(Vertex_it it = cid.vl_ptr()->skip_begin(), succ = it, end = cid.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = cid.vl_ptr()->skip_begin(), succ = it, end = cid.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -555,8 +555,8 @@ remove_constraint(Constraint_id cid){ // and remove the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == cid.vl_ptr()){ - hcl->erase(ctit); - break; + hcl->erase(ctit); + break; } } // If the constraint passes several times through the same subconstraint, @@ -603,12 +603,12 @@ void Polyline_constraint_hierarchy_2::simplify(Vertex_it uc, CGAL_assertion_msg( vw_sc_iter != sc_to_c_map.end(), "not a subconstraint" ); Context_list* vw_hcl = vw_sc_iter->second; CGAL_assertion_msg((u == w) || (vw_hcl->size() == 1), "more than one constraint passing through the subconstraint" ); - + Vertex_list* vertex_list = uv_hcl->front().id().vl_ptr(); CGAL_assertion_msg(vertex_list == vw_hcl->front().id().vl_ptr(), "subconstraints from different polyline constraints" ); // Remove the list item which points to v vertex_list->skip(vc.base()); - + if(u != w){ // Remove the entries for [u,v] and [v,w] sc_to_c_map.erase(uv_sc_iter); @@ -628,8 +628,8 @@ std::size_t Polyline_constraint_hierarchy_2::remove_points_without_corresponding_vertex(Constraint_id cid) { std::size_t n = 0; - for(Point_it it = points_in_constraint_begin(cid); - it != points_in_constraint_end(cid); ++it) { + for(Point_it it = points_in_constraint_begin(cid); + it != points_in_constraint_end(cid); ++it) { if(cid.vl_ptr()->is_skipped(it.base())) { it = cid.vl_ptr()->erase(it.base()); ++n; @@ -657,8 +657,8 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id firs constraint_set.erase(first); constraint_set.erase(second); // We have to look at all subconstraints - for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = second.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = second.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -667,8 +667,8 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id firs // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == second.vl_ptr()){ - ctit->enclosing = first.vl_ptr(); - break; + ctit->enclosing = first.vl_ptr(); + break; } } } @@ -682,8 +682,8 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id firs // Note that for VC8 with iterator debugging the iterators pointing into second // are NOT valid So we have to update them - for(Vertex_it it = back_it, succ = it, end = first.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = back_it, succ = it, end = first.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -692,8 +692,8 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id firs // and update pos in the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->pos = it; - break; + ctit->pos = it; + break; } } } @@ -706,12 +706,12 @@ Polyline_constraint_hierarchy_2::concatenate(Constraint_id firs template typename Polyline_constraint_hierarchy_2::Constraint_id Polyline_constraint_hierarchy_2::concatenate2(Constraint_id first, Constraint_id second) -{ +{ constraint_set.erase(first); constraint_set.erase(second); // We have to look at all subconstraints - for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); - ++succ != end; + for(Vertex_it it = first.vl_ptr()->skip_begin(), succ = it, end = first.vl_ptr()->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -720,8 +720,8 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id fir // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->enclosing = second.vl_ptr(); - break; + ctit->enclosing = second.vl_ptr(); + break; } } } @@ -734,8 +734,8 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id fir // Note that for VC8 with iterator debugging the iterators pointing into second // are NOT valid So we have to update them - for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = back_it; - ++succ != end; + for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = back_it; + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -744,8 +744,8 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id fir // and update pos in the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == second.vl_ptr()){ - ctit->pos = it; - break; + ctit->pos = it; + break; } } } @@ -758,7 +758,7 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id fir // split a constraint in two constraints, so that vcit becomes the first // vertex of the new constraint - // returns the new constraint + // returns the new constraint template typename Polyline_constraint_hierarchy_2::Constraint_id Polyline_constraint_hierarchy_2::split(Constraint_id first, Vertex_it vcit) @@ -775,8 +775,8 @@ Polyline_constraint_hierarchy_2::split(Constraint_id first, Ver constraint_set.insert(first); constraint_set.insert(second); // We have to look at all subconstraints - for(Vertex_it it = second->skip_begin(), succ = it, end = second->skip_end(); - ++succ != end; + for(Vertex_it it = second->skip_begin(), succ = it, end = second->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -785,8 +785,8 @@ Polyline_constraint_hierarchy_2::split(Constraint_id first, Ver // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->enclosing = second; - break; + ctit->enclosing = second; + break; } } } @@ -809,8 +809,8 @@ Polyline_constraint_hierarchy_2::split2(Constraint_id first, Ve constraint_set.insert(first); constraint_set.insert(second); // We have to look at all subconstraints - for(Vertex_it it = second->skip_begin(), succ = it, end = second->skip_end(); - ++succ != end; + for(Vertex_it it = second->skip_begin(), succ = it, end = second->skip_end(); + ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); CGAL_triangulation_assertion(scit != sc_to_c_map.end()); @@ -819,8 +819,8 @@ Polyline_constraint_hierarchy_2::split2(Constraint_id first, Ve // and replace the context of the constraint for(Context_iterator ctit=hcl->begin(); ctit != hcl->end(); ctit++) { if(ctit->enclosing == first.vl_ptr()){ - ctit->enclosing = second; - break; + ctit->enclosing = second; + break; } } } @@ -837,7 +837,7 @@ typename Polyline_constraint_hierarchy_2::Vertex_list* Polyline_constraint_hierarchy_2:: insert_constraint(T va, T vb){ Edge he = make_edge(va, vb); - Vertex_list* children = new Vertex_list; + Vertex_list* children = new Vertex_list; Context_list* fathers; typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); @@ -859,14 +859,14 @@ insert_constraint(T va, T vb){ return children; } - + template typename Polyline_constraint_hierarchy_2::Vertex_list* Polyline_constraint_hierarchy_2:: insert_constraint_old_API(T va, T vb){ Edge he = make_edge(va, vb); - Vertex_list* children = new Vertex_list; + Vertex_list* children = new Vertex_list; Context_list* fathers; typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); @@ -970,7 +970,7 @@ remove_Steiner(T v, T va, T vb) { // remove a Steiner point CGAL_precondition(!is_constrained_vertex(v)); - + Context_list* hcl1; Context_list* hcl2; if(!get_contexts(va,v,hcl1)) CGAL_triangulation_assertion(false); @@ -994,7 +994,7 @@ remove_Steiner(T v, T va, T vb) /* same as add_Steiner - precondition : va,vb est une souscontrainte. + precondition : va,vb est une souscontrainte. */ template void Polyline_constraint_hierarchy_2:: @@ -1004,7 +1004,7 @@ split_constraint(T va, T vb, T vc){ template -void +void Polyline_constraint_hierarchy_2:: add_Steiner(T va, T vb, T vc){ Context_list* hcl=nullptr; @@ -1020,11 +1020,11 @@ add_Steiner(T va, T vb, T vc){ ++pos; pos = ctit->enclosing->insert(pos.base(), Node(vc)); --pos; - + // set ctxt to the context of (vc,vb) // change *ctit in hcl to the context of (va,vc) // add ctxt to hcl2 list - ctxt.enclosing = ctit->enclosing; + ctxt.enclosing = ctit->enclosing; if(*pos == va) { ctit->pos = pos; ctxt.pos = ++pos; @@ -1049,8 +1049,8 @@ add_Steiner(T va, T vb, T vc){ delete hcl2; } else sc_to_c_map.insert(std::make_pair(make_edge(vc,vb), hcl2)); - - + + sc_to_c_map.erase(make_edge(va,vb)); return; } @@ -1081,15 +1081,15 @@ template inline bool Polyline_constraint_hierarchy_2:: -get_contexts(T va, T vb, - Context_iterator& ctxt, - Context_iterator& past) const +get_contexts(T va, T vb, + Context_iterator& ctxt, + Context_iterator& past) const { Context_list* hcl; if (!get_contexts(va,vb,hcl)) return false; ctxt = hcl->begin(); past = hcl->end(); - return true; + return true; } @@ -1122,7 +1122,7 @@ template void Polyline_constraint_hierarchy_2:: print() const -{ +{ C_iterator hcit; std::map vertex_num; int num = 0; @@ -1138,7 +1138,7 @@ print() const // for(; vnit != vertex_num.end(); vnit++) { // vnit->second = ++num; // std::cerr << "vertex num " << num << " " << vnit->first->point() -// << std::endl; +// << std::endl; // } C_iterator cit=c_begin(); @@ -1161,19 +1161,19 @@ print() const std::cout << std::endl ; for(;scit != sc_end(); scit++){ std::cout << "subconstraint " ; - std::cout << vertex_num[scit->first.first] << " " - << vertex_num[scit->first.second]; + std::cout << vertex_num[scit->first.first] << " " + << vertex_num[scit->first.second]; Context_iterator cb, ce; get_contexts(scit->first.first, scit->first.second, cb, ce); - + std::cout << " enclosing " ; - for(; cb != ce; cb++) { + for(; cb != ce; cb++) { std::cout << cb->id().vl_ptr(); std::cout << " " ; } std::cout << std::endl ; } - return; + return; } diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 1fbe3957270..d776047064a 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Olivier Devillers // Mariette Yvinec @@ -105,10 +105,10 @@ public: template Triangulation_hierarchy_2(InputIterator first, InputIterator beyond, - const Geom_traits& traits = Geom_traits()) + const Geom_traits& traits = Geom_traits()) : Tr_Base(traits) - { - hierarchy[0] = this; + { + hierarchy[0] = this; for(int i=1;i std::ptrdiff_t insert(InputIterator first, InputIterator last) { @@ -205,26 +205,26 @@ protected: // some internal methods // GIVING NEW FACES template - Vertex_handle insert_and_give_new_faces(const Point &p, + Vertex_handle insert_and_give_new_faces(const Point &p, OutputItFaces fit, Face_handle start = Face_handle() ); template Vertex_handle insert_and_give_new_faces(const Point& p, Locate_type lt, - Face_handle loc, int li, + Face_handle loc, int li, OutputItFaces fit); template - void remove_and_give_new_faces(Vertex_handle v, + void remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit); - + template - Vertex_handle move_if_no_collision_and_give_new_faces(Vertex_handle v, - const Point &p, OutputItFaces fit); + Vertex_handle move_if_no_collision_and_give_new_faces(Vertex_handle v, + const Point &p, OutputItFaces fit); public: - + //LOCATE Face_handle locate(const Point& p, @@ -273,18 +273,18 @@ private: // systematique instanciation template void add_hidden_vertices_into_map(Tag, - std::map& V) + std::map& V) { - for (typename Tr_Base::Hidden_vertices_iterator - it=hierarchy[0]->hidden_vertices_begin(); - it != hierarchy[0]->hidden_vertices_end(); ++it) { + for (typename Tr_Base::Hidden_vertices_iterator + it=hierarchy[0]->hidden_vertices_begin(); + it != hierarchy[0]->hidden_vertices_end(); ++it) { if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; } } - - + + void add_hidden_vertices_into_map(Tag_false , - std::map& ) + std::map& ) {return;} }; @@ -294,8 +294,8 @@ template Triangulation_hierarchy_2:: Triangulation_hierarchy_2(const Geom_traits& traits) : Tr_Base(traits) -{ - hierarchy[0] = this; +{ + hierarchy[0] = this; for(int i=1;i Triangulation_hierarchy_2:: Triangulation_hierarchy_2(const Triangulation_hierarchy_2 &tr) : Tr_Base() -{ +{ // create an empty triangulation to be able to delete it ! - hierarchy[0] = this; + hierarchy[0] = this; for(int i=1;i @@ -335,14 +335,14 @@ copy_triangulation(const Triangulation_hierarchy_2 &tr) for(int i=0;icopy_triangulation(*tr.hierarchy[i]); } - + //up and down have been copied in straightforward way // compute a map at lower level std::map V; { - for( Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin(); - it != hierarchy[0]->finite_vertices_end(); ++it) { + for( Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) { if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; } } @@ -351,15 +351,15 @@ copy_triangulation(const Triangulation_hierarchy_2 &tr) { for(int i=1;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) { - // down pointer goes in original instead in copied triangulation - it->set_down(V[it->down()]); - // make reverse link - it->down()->set_up(it); - // I think the next line is unnecessary (my) - // make map for next level - if (it->up()!= Vertex_handle() ) V[ it->up()->down() ] = it; + for( Finite_vertices_iterator it=hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) { + // down pointer goes in original instead in copied triangulation + it->set_down(V[it->down()]); + // make reverse link + it->down()->set_up(it); + // I think the next line is unnecessary (my) + // make map for next level + if (it->up()!= Vertex_handle() ) V[ it->up()->down() ] = it; } } } @@ -369,7 +369,7 @@ copy_triangulation(const Triangulation_hierarchy_2 &tr) /* void */ /* Triangulation_hierarchy_2:: */ /* add_hidden_vertices_into_map(Tag_false, */ -/* std::map& V) { */ +/* std::map& V) { */ /* return; */ /* } */ @@ -378,10 +378,10 @@ copy_triangulation(const Triangulation_hierarchy_2 &tr) /* void */ /* Triangulation_hierarchy_2:: */ /* add_hidden_vertices_into_map(Tag_true, */ -/* std::map& V) */ +/* std::map& V) */ /* { */ /* for (typename Tr_Base::Hidden_vertices_iterator */ -/* it=hierarchy[0]->hidden_vertices_begin(); */ +/* it=hierarchy[0]->hidden_vertices_begin(); */ /* it != hierarchy[0]->hidden_vertices_end(); ++it) { */ /* if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; */ /* } */ @@ -407,7 +407,7 @@ Triangulation_hierarchy_2:: ~Triangulation_hierarchy_2() { clear(); - for(int i= 1; inumber_of_vertices() << std::endl; + std::cout << "number_of_vertices " + << hierarchy[i]->number_of_vertices() << std::endl; result = result && hierarchy[i]->is_valid(verbose,level); } //verify that lower level has no down pointers - for( it = hierarchy[0]->finite_vertices_begin(); - it != hierarchy[0]->finite_vertices_end(); ++it) + for( it = hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) result = result && ( it->down() == Vertex_handle()); //verify that other levels have down pointer and reciprocal link is fine for(i=1;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) - result = result && - ( &*(it->down()->up()) == &*(it) ); + for( it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) + result = result && + ( &*(it->down()->up()) == &*(it) ); //verify that levels have up pointer and reciprocal link is fine for(i=0;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) + for( it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) result = result && ( it->up() == Vertex_handle() || - &*it == &*(it->up())->down() ); + &*it == &*(it->up())->down() ); return result; } - + template typename Triangulation_hierarchy_2::Vertex_handle Triangulation_hierarchy_2:: @@ -471,7 +471,7 @@ insert(const Point &p, Face_handle loc) Vertex_handle vertex=hierarchy[0]->Tr_Base::insert(p,lt,positions[0],i); Vertex_handle previous=vertex; Vertex_handle first = vertex; - + int level = 1; while (level <= vertex_level ){ vertex=hierarchy[level]->Tr_Base::insert(p,positions[level]); @@ -488,7 +488,7 @@ typename Triangulation_hierarchy_2::Vertex_handle Triangulation_hierarchy_2:: insert(const Point& p, Locate_type lt, - Face_handle loc, + Face_handle loc, int li ) { int vertex_level = random_level(); @@ -526,7 +526,7 @@ push_back(const Point &p) } template -void +void Triangulation_hierarchy_2:: remove(Vertex_handle v ) { @@ -534,7 +534,7 @@ remove(Vertex_handle v ) int l = 0 ; while(1){ hierarchy[l++]->remove(v); - if (u == Vertex_handle()) break; + if (u == Vertex_handle()) break; if (l >= Triangulation_hierarchy_2__maxlevel) break; v=u; u=v->up(); } @@ -551,15 +551,15 @@ remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit) while(1){ if(l==0) hierarchy[l++]->remove_and_give_new_faces(v, fit); else hierarchy[l++]->remove(v); - if (u == Vertex_handle()) break; + if (u == Vertex_handle()) break; if (l >= Triangulation_hierarchy_2__maxlevel) break; v=u; u=v->up(); - } + } } template -inline void +inline void Triangulation_hierarchy_2:: remove_degree_3(Vertex_handle v ) { @@ -567,7 +567,7 @@ remove_degree_3(Vertex_handle v ) } template -inline void +inline void Triangulation_hierarchy_2:: remove_first(Vertex_handle v ) { @@ -575,7 +575,7 @@ remove_first(Vertex_handle v ) } template -inline void +inline void Triangulation_hierarchy_2:: remove_second(Vertex_handle v ) { @@ -591,7 +591,7 @@ move_if_no_collision(Vertex_handle v, const Point &p) { while(1) { Vertex_handle w = hierarchy[l++]->move_if_no_collision(v, p); if(w != v) return w; - if (u == Vertex_handle()) break; + if (u == Vertex_handle()) break; if (l >= Triangulation_hierarchy_2__maxlevel) break; v=u; u=v->up(); } @@ -615,21 +615,21 @@ template template typename Triangulation_hierarchy_2::Vertex_handle Triangulation_hierarchy_2:: -move_if_no_collision_and_give_new_faces(Vertex_handle v, const Point &p, +move_if_no_collision_and_give_new_faces(Vertex_handle v, const Point &p, OutputItFaces oif) { Vertex_handle u=v->up(), norm = v; int l = 0 ; while(1){ Vertex_handle w; - if(l == 0) - w = + if(l == 0) + w = hierarchy[l++]->move_if_no_collision_and_give_new_faces(v, p, oif); else w = hierarchy[l++]->move_if_no_collision(v, p); if(w != v) return w; - if (u == Vertex_handle()) break; + if (u == Vertex_handle()) break; if (l >= Triangulation_hierarchy_2__maxlevel) break; v=u; u=v->up(); } @@ -654,7 +654,7 @@ Triangulation_hierarchy_2::insert_and_give_new_faces(const Point &p, hierarchy[0]->Tr_Base::insert_and_give_new_faces(p,lt,positions[0],i,oif); Vertex_handle previous=vertex; Vertex_handle first = vertex; - + int level = 1; while (level <= vertex_level ){ vertex=hierarchy[level]->Tr_Base::insert(p,positions[level]); @@ -674,7 +674,7 @@ Triangulation_hierarchy_2:: insert_and_give_new_faces(const Point &p, Locate_type lt, Face_handle loc, - int li, + int li, OutputItFaces oif) { int vertex_level = random_level(); @@ -739,14 +739,14 @@ locate_in_all(const Point& p, typename Geom_traits::Construct_point_2 construct_point = geom_traits().construct_point_2_object(); - + // find the highest level with enough vertices that is at the same time 2D - while ( (hierarchy[--level]->number_of_vertices() - < static_cast (Triangulation_hierarchy_2__minsize )) - || (hierarchy[level]->dimension()<2) ){ + while ( (hierarchy[--level]->number_of_vertices() + < static_cast (Triangulation_hierarchy_2__minsize )) + || (hierarchy[level]->dimension()<2) ){ if ( ! level) break; // do not go below 0 } - if((level>0) && (hierarchy[level]->dimension()<2)){ + if((level>0) && (hierarchy[level]->dimension()<2)){ level--; } @@ -772,10 +772,10 @@ locate_in_all(const Point& p, } // compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is nullptr if ( (hierarchy[level]->dimension()==2) && (! hierarchy[level]->is_infinite(position->vertex(2)))){ - if ( closer( construct_point(p), - construct_point(position->vertex(2)->point()), - construct_point(nearest->point())) == SMALLER ){ - nearest = position->vertex(2); + if ( closer( construct_point(p), + construct_point(position->vertex(2)->point()), + construct_point(nearest->point())) == SMALLER ){ + nearest = position->vertex(2); } } // go at the same vertex on level below @@ -783,7 +783,7 @@ locate_in_all(const Point& p, position = nearest->face(); // incident face --level; } - pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0 + pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0 } template diff --git a/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h b/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h index 65f15868cbf..e1e30c53706 100644 --- a/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Olivier Devillers // Mariette Yvinec diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h index 25e9cac0432..ccc193bad99 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_Del_triangulation_2.h @@ -9,10 +9,10 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// +// // file : test/Triangulation/include/CGAL/_test_cls_const_Del_tr.. // source : $URL$ // revision : $Id$ @@ -27,7 +27,7 @@ #include template -void +void _test_cls_const_Del_triangulation(const Triangul&) { // The following assertion is commented, because, in CT_plus_2, @@ -74,7 +74,7 @@ _test_cls_const_Del_triangulation(const Triangul&) Point(0,2), Point(1,2), Point(2,2), Point(3,2),Point(4,2), Point(4,3), Point(3,3), Point(2,3), Point(1,3),Point(0,3) }; - for (int m=0; m<19; m++) + for (int m=0; m<19; m++) l.push_back(Constraint(lpt[m],lpt[m+1])); Triangul T2(l); assert( T2.dimension() == 2 ); @@ -88,22 +88,22 @@ _test_cls_const_Del_triangulation(const Triangul&) std::back_insert_iterator > c_inserter(conflicts); std::back_insert_iterator > be_inserter(hole_bd); std::pair >, - std::back_insert_iterator > > + std::back_insert_iterator > > pit(c_inserter,be_inserter); c_inserter = T2.get_conflicts(Point(1,1,2), std::back_inserter(conflicts)); conflicts.clear(); - pit = T2.get_conflicts_and_boundary(Point(1,1,2), - std::back_inserter(conflicts), - std::back_inserter(hole_bd)); + pit = T2.get_conflicts_and_boundary(Point(1,1,2), + std::back_inserter(conflicts), + std::back_inserter(hole_bd)); c_inserter = pit.first; be_inserter = pit.second; assert(hole_bd.size() == conflicts.size() + 2); conflicts.clear(); hole_bd.clear(); - T2.get_conflicts(Point(0,1,2), - std::back_inserter(conflicts)); - T2.get_boundary_of_conflicts(Point(0,1,2), - std::back_inserter(hole_bd)); + T2.get_conflicts(Point(0,1,2), + std::back_inserter(conflicts)); + T2.get_boundary_of_conflicts(Point(0,1,2), + std::back_inserter(hole_bd)); assert(hole_bd.size() == conflicts.size() + 2); conflicts.clear(); std::size_t nch = hole_bd.size(); @@ -119,14 +119,14 @@ _test_cls_const_Del_triangulation(const Triangul&) // test insertion through get_conflicts + star_hole conflicts.clear(); hole_bd.clear(); - T2.get_conflicts_and_boundary(Point(0,1,2), - std::back_inserter(conflicts), - std::back_inserter(hole_bd)); - T2.star_hole(Point(0,1,2), - hole_bd.begin(), - hole_bd.end(), - conflicts.begin(), - conflicts.end()); + T2.get_conflicts_and_boundary(Point(0,1,2), + std::back_inserter(conflicts), + std::back_inserter(hole_bd)); + T2.star_hole(Point(0,1,2), + hole_bd.begin(), + hole_bd.end(), + conflicts.begin(), + conflicts.end()); assert(T2.is_valid()); //test remove_constrained_edge diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index 0d854e4188e..76512ccb669 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -9,10 +9,10 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// +// // file : test/Triangulation/include/CGAL/_test_cls_constrained... // source : $URL$ // revision : $Id$ @@ -89,7 +89,7 @@ _test_cdt_throwing(const Pt& p0, const Pt& p1, const Pt& p2, const Pt& p3, } template -void +void _test_cls_constrained_triangulation(const Triang &) { // The following assertion is commented, because, in CT_plus_2, @@ -142,7 +142,7 @@ _test_cls_constrained_triangulation(const Triang &) assert( T0_1.dimension() == -1 ); assert( T0_1.number_of_vertices() == 0 ); assert( T0_1.is_valid() ); - + l.push_back(Constraint(Point(0,0),Point(0,0))); Triang T0_2(l); assert( T0_2.dimension() == 0 ); @@ -159,7 +159,7 @@ _test_cls_constrained_triangulation(const Triang &) assert( T1_1.dimension() == 1 ); assert( T1_1.number_of_vertices() == 4 ); assert( T1_1.is_valid() ); - + l.erase(l.begin(),l.end()); for (m=0; m<4; m++) l.push_back(Constraint(Point(3*m, 2*m),Point(3*(m+1),2*(m+1)) )); @@ -178,7 +178,7 @@ _test_cls_constrained_triangulation(const Triang &) assert( T2_1.dimension() == 2 ); assert( T2_1.number_of_vertices() == 5); assert( T2_1.is_valid() ); - + l.erase(l.begin(),l.end()); Point lpt[20] = { @@ -187,14 +187,14 @@ _test_cls_constrained_triangulation(const Triang &) Point(0,2), Point(1,2), Point(2,2), Point(3,2),Point(4,2), Point(4,3), Point(3,3), Point(2,3), Point(1,3),Point(0,3) }; - for (m=0;m<19;m++) + for (m=0;m<19;m++) l.push_back(Constraint(lpt[m],lpt[m+1])); Triang T2_2(l); assert( T2_2.dimension() == 2 ); assert( T2_2.number_of_vertices() == 20); assert( T2_2.is_valid() ); - + // Build triangulation with iterator std::cout << " with input iterator" << std::endl; list_iterator first=l.begin(); @@ -237,7 +237,7 @@ _test_cls_constrained_triangulation(const Triang &) std::ofstream of1_2("T12.triangulation"); CGAL::set_ascii_mode(of1_2); of1_2 << T1_2; of1_2.close(); - + std::ofstream of2_1("T21.triangulation"); CGAL::set_ascii_mode(of2_1); of2_1 << T2_1; of2_1.close(); @@ -273,18 +273,18 @@ _test_cls_constrained_triangulation(const Triang &) All_faces_iterator fit2 = T2_2.all_faces_begin(); All_faces_iterator fit2_bis = T2_4.all_faces_begin(); for( ; fit2 != T2_2.all_faces_end(); ++fit2, ++fit2_bis) { - for(int i=0; i<3 ; i++) + for(int i=0; i<3 ; i++) assert( fit2->is_constrained(i) == fit2_bis->is_constrained(i) ); } - - - + + + // remove_constraint and remove _1 dim std::cout << "remove_constrained_edge and remove 1-dim" << std::endl; Face_handle fh; int ih; Vertex_handle vha, vhb; - Locate_type lt; + Locate_type lt; int li; fh = T1_2.locate(Point(0,0),lt,li); assert( lt == Triang::VERTEX ); vha = fh->vertex(li); @@ -305,14 +305,14 @@ _test_cls_constrained_triangulation(const Triang &) vha = fh->vertex(li); List_edges edges; assert(T1_2.are_there_incident_constraints(vha, - std::back_inserter(edges))); + std::back_inserter(edges))); List_edges ic_edges; std::back_insert_iterator inserter(ic_edges); inserter = T1_2.incident_constraints(vha, inserter); - assert(ic_edges.size() == 1); + assert(ic_edges.size() == 1); T1_2.remove_incident_constraints(vha); inserter = T1_2.incident_constraints(vha, inserter ); - assert(ic_edges.size() == 1); + assert(ic_edges.size() == 1); T1_2.remove(vha); assert(T1_2.is_valid()); @@ -330,7 +330,7 @@ _test_cls_constrained_triangulation(const Triang &) T2_2.insert(lpt[m], lpt[m+1]); assert(T2_2.is_valid()); fh = T2_2.locate(lpt[m+1],lt,li); assert( lt == Triang::VERTEX ); - vhb = fh->vertex(li); + vhb = fh->vertex(li); assert(T2_2.are_there_incident_constraints(vhb)); T2_2.remove_incident_constraints(vhb); T2_2.remove(vhb); @@ -341,12 +341,12 @@ _test_cls_constrained_triangulation(const Triang &) edges.clear(); ic_edges.clear(); assert(T2_2.are_there_incident_constraints(vha)); - assert(T2_2.are_there_incident_constraints(vha, - std::back_inserter(edges))); + assert(T2_2.are_there_incident_constraints(vha, + std::back_inserter(edges))); ic_edges.clear(); inserter = std::back_insert_iterator(ic_edges); inserter = T2_2.incident_constraints(vha,inserter); - assert(ic_edges.size() == 2); + assert(ic_edges.size() == 2); T2_2.remove_incident_constraints(vha); inserter = T2_2.incident_constraints(vha, inserter); assert(ic_edges.size() == 2); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h index f9cc6fcb2aa..3d116c10900 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h @@ -7,10 +7,10 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// +// // source : $URL$ // file : include/CGAL/_test_cls_delaunay_triangulation_2.C // revision : $Id$ @@ -64,14 +64,14 @@ _test_cls_delaunay_triangulation_2( const Del & ) for (m=0; m<20; m++) T1.insert( Point(3*m, 2*m) ); assert( T1.is_valid() ); - + Del T2; for (m=0; m<20; m++) for (p=0; p<20; p++) - // T2.insert( Point(3*m+p, m-2*p) ); - T2.insert(Point(m,p)); + // T2.insert( Point(3*m+p, m-2*p) ); + T2.insert(Point(m,p)); assert( T2.is_valid() ); - + Del T3; // All these points are on a circle of radius 325 Point pt[28] = { @@ -84,15 +84,15 @@ _test_cls_delaunay_triangulation_2( const Del & ) Point(-36,323), Point(-80,315), Point(-91,312), Point(-125,300), Point(-165,280), Point(-195,260), Point(-204,253) }; - for (m=0; m<28; m++) + for (m=0; m<28; m++) T3.insert( Point(pt[m]) ); assert( T3.is_valid() ); - + // test nearest_vertex Vertex_handle vnn; Face_handle cible; - int i; + int i; Locate_type lt; cible = T2.locate(Point(0,0,1),lt,i); assert( lt == Del::VERTEX); @@ -112,21 +112,21 @@ _test_cls_delaunay_triangulation_2( const Del & ) std::back_insert_iterator > c_inserter(conflicts); std::back_insert_iterator > be_inserter(hole_bd); std::pair >, - std::back_insert_iterator > > + std::back_insert_iterator > > pit(c_inserter,be_inserter); c_inserter = T2.get_conflicts(Point(1,1,2), std::back_inserter(conflicts)); conflicts.clear(); - pit = T2.get_conflicts_and_boundary(Point(1,1,2), - std::back_inserter(conflicts), - std::back_inserter(hole_bd)); + pit = T2.get_conflicts_and_boundary(Point(1,1,2), + std::back_inserter(conflicts), + std::back_inserter(hole_bd)); c_inserter = pit.first; be_inserter = pit.second; assert(hole_bd.size() == conflicts.size() + 2); conflicts.clear(); hole_bd.clear(); T2.get_conflicts(Point(0,1,2), std::back_inserter(conflicts)); - T2.get_boundary_of_conflicts(Point(0,1,2), - std::back_inserter(hole_bd)); + T2.get_boundary_of_conflicts(Point(0,1,2), + std::back_inserter(hole_bd)); assert(hole_bd.size() == conflicts.size() + 2); conflicts.clear(); hole_bd.clear(); @@ -160,7 +160,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) while(curr != hole_bd.end()); T2.star_hole (Point(1,1,2), hole_bd.begin(), hole_bd.end(), - conflicts.begin(), conflicts.end() ); + conflicts.begin(), conflicts.end() ); assert(T2.is_valid()); @@ -208,7 +208,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) std::cout << " displacements" << std::endl; std::cout << " degenerate cases: " << std::endl; - + Del TM_0, TM_1; Vertex_handle tmv1 = TM_0.insert(Point(0,0)); Vertex_handle tmv2 = TM_0.insert(Point(1,0)); @@ -234,7 +234,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) TM_0.move_if_no_collision(tmv3, Point(2, 0)); assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); - assert(TM_0.dimension() == 1); + assert(TM_0.dimension() == 1); Vertex_handle tmv4 = TM_0.insert(Point(1,1)); assert(TM_0.dimension() == 2); @@ -308,7 +308,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) TM_0.move_if_no_collision(tmv4, Point(1, 2)); assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); - assert(TM_0.dimension() == 1); + assert(TM_0.dimension() == 1); TM_0.move_if_no_collision(tmv4, Point(3, 0)); assert(TM_0.tds().is_valid()); @@ -334,7 +334,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) TM_1.insert(points.begin(), points.end()); Vertex_handle vTM_1; for(int i=0; i<5; i++) { - for(typename Del::Finite_vertices_iterator + for(typename Del::Finite_vertices_iterator fvi = TM_1.finite_vertices_begin(); fvi != TM_1.finite_vertices_end(); fvi++) { Point p = Point(rand()%30000, rand()%30000); @@ -345,7 +345,7 @@ _test_cls_delaunay_triangulation_2( const Del & ) // A simple test to see if move return the good vertex // when there is a collision - assert(TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) == vTM_1); + assert(TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) == vTM_1); } @@ -362,10 +362,10 @@ _test_delaunay_duality( const Del &T ) Face_iterator fit; for (fit = T.finite_faces_begin(); fit != T.finite_faces_end(); ++fit) { - assert( T.side_of_oriented_circle(fit, T.dual(fit)) == - CGAL::ON_POSITIVE_SIDE ); + assert( T.side_of_oriented_circle(fit, T.dual(fit)) == + CGAL::ON_POSITIVE_SIDE ); } - + // Test dual(edge iterator) Edge_iterator eit; for (eit = T.finite_edges_begin(); eit != T.finite_edges_end(); ++eit) @@ -376,11 +376,11 @@ _test_delaunay_duality( const Del &T ) typename Gt::Line_2 l; if ( CGAL::assign(s,o) ) { assert( ! T.is_infinite((*eit).first) ); - assert( ! T.is_infinite(((*eit).first)->neighbor((*eit).second )) ); - } + assert( ! T.is_infinite(((*eit).first)->neighbor((*eit).second )) ); + } else if ( CGAL::assign(l,o) ) { assert( T.dimension() == 1 ); - } + } else { assert( CGAL::assign(r,o) ); } @@ -388,15 +388,15 @@ _test_delaunay_duality( const Del &T ) // Test dual(edge circulator) Edge_circulator ec=T.incident_edges(T.finite_vertices_begin()), done(ec); - if ( !ec.is_empty() ) - do + if ( !ec.is_empty() ) + do { if (! T.is_infinite(ec)){ - CGAL::Object o = T.dual(ec); - typename Gt::Ray_2 r; + CGAL::Object o = T.dual(ec); + typename Gt::Ray_2 r; typename Gt::Segment_2 s; - typename Gt::Line_2 l; - assert( CGAL::assign(s,o) || CGAL::assign(r,o) || CGAL::assign(l,o) ); + typename Gt::Line_2 l; + assert( CGAL::assign(s,o) || CGAL::assign(r,o) || CGAL::assign(l,o) ); } ++ec; } while ( ec == done); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h index 498ff9139be..ebfa74d1bb0 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h @@ -7,14 +7,14 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// -// source : +// +// source : // file : include/CGAL/_test_cls_triangulation_2.C -// revision : -// revision_date : +// revision : +// revision_date : // author(s) : Herve Bronnimann (Herve.Bronnimann@sophia.inria.fr) @@ -62,7 +62,7 @@ _test_cls_triangulation_2( const Triangul & ) typedef std::pair Edge; - typedef typename Triangul::Finite_vertices_iterator + typedef typename Triangul::Finite_vertices_iterator Finite_vertices_iterator; typedef typename Triangul::Finite_faces_iterator Finite_faces_iterator; typedef typename Triangul::Finite_edges_iterator Finite_edges_iterator; @@ -74,7 +74,7 @@ _test_cls_triangulation_2( const Triangul & ) typedef typename Triangul::Line_face_circulator Line_face_circulator; typedef typename Triangul::Locate_type Locate_type; - + CGAL_USE_TYPE(Gt); CGAL_USE_TYPE(Vertex); CGAL_USE_TYPE(Face); @@ -116,19 +116,19 @@ _test_cls_triangulation_2( const Triangul & ) l.push_back(p1); l.push_back(p2); l.push_back(p3); l.push_back(p4); l.push_back(p5); l.push_back(p6); l.push_back(p7); l.push_back(p8); l.push_back(p9); - + std::vector v; v.push_back(p0); v.push_back(p1); v.push_back(p2); v.push_back(p3); v.push_back(p4); v.push_back(p5); v.push_back(p6); v.push_back(p7); v.push_back(p8); v.push_back(p9); - - + + /*****************************/ /***** CONSTRUCTORS (1) ******/ std::cout << " constructors(1)" << std::endl; Triangul T1; - assert( T1.dimension() == -1 ); + assert( T1.dimension() == -1 ); assert( T1.number_of_vertices() == 0 ); Triangul T3(T1); @@ -138,7 +138,7 @@ _test_cls_triangulation_2( const Triangul & ) /**************************/ /******* INSERTIONS *******/ - + // Tk denotes a k-dimensional triangulation // the handle returned when inserting pj into Tk_n is called vk_n_j // the asserts at the end of the insert() are to avoid compiler @@ -148,14 +148,14 @@ _test_cls_triangulation_2( const Triangul & ) /******* 0-dimensional triangulations ******/ std::cout << " insertions 0-dim" << std::endl; - + Triangul T0_0; assert( T0_0.dimension() == -1 ); assert( T0_0.number_of_vertices() == 0 ); assert( T0_0.number_of_faces() == 0); assert( T0_0.is_valid() ); - Triangul T0_1; + Triangul T0_1; Vertex_handle v0_1_0 = T0_1.insert(p0); assert( v0_1_0 != NULL ); assert( T0_1.dimension() == 0 ); assert( T0_1.number_of_vertices() == 1 ); @@ -163,19 +163,19 @@ _test_cls_triangulation_2( const Triangul & ) assert( T0_1.is_valid() ); // test insert_first() - Triangul T0_2; + Triangul T0_2; Vertex_handle v0_2_0 = T0_2.insert_first(p0); assert( v0_2_0 != NULL ); assert( T0_2.dimension() == 0 ); assert( T0_2.number_of_vertices() == 1 ); assert( T0_2.number_of_faces() == 0); assert( T0_2.is_valid() ); - + /******** 1-dimensional triangulations ******/ // T1_n denotes a 1-dimensional triangulation with n vertices // when there are several, we use T1_n_p std::cout << " insertions 1-dim" << std::endl; - + Triangul T1_2; Vertex_handle v1_2_1 = T1_2.insert(p1); Vertex_handle v1_2_2 = T1_2.insert(p2); @@ -183,7 +183,7 @@ _test_cls_triangulation_2( const Triangul & ) assert( T1_2.number_of_vertices() == 2 ); assert( T1_2.number_of_faces() == 0 ); assert( T1_2.is_valid() ); - + // p1,p3,p2 [endpoints first] Triangul T1_3_0; Vertex_handle v1_3_0_1 = T1_3_0.insert(p1); assert( v1_3_0_1 != NULL ); @@ -193,7 +193,7 @@ _test_cls_triangulation_2( const Triangul & ) assert( T1_3_0.number_of_vertices() == 3 ); assert( T1_3_0.number_of_faces() == 0 ); assert( T1_3_0.is_valid() ); - + // p1,p2,p3 [middle point first] Triangul T1_3_1; Vertex_handle v1_3_1_1 = T1_3_1.insert(p1); assert( v1_3_1_1 != NULL ); @@ -216,38 +216,38 @@ _test_cls_triangulation_2( const Triangul & ) assert( T1_5.is_valid() ); // test insert_second() - Triangul T1_6 = T0_2; + Triangul T1_6 = T0_2; Vertex_handle v1_6_2 = T1_6.insert_second(p3); assert( v1_6_2 != NULL ); assert( T1_6.dimension() == 1 ); assert( T1_6.number_of_vertices() == 2 ); - assert( T1_6.is_valid() ); - - /******** 2-dimensional triangulations ******/ + assert( T1_6.is_valid() ); + + /******** 2-dimensional triangulations ******/ std::cout << " insertions 2-dim" << std::endl; - + Triangul T2_1; Vertex_handle v2_1_0 = T2_1.insert(p0); Vertex_handle v2_1_1 = T2_1.insert(p1); Vertex_handle v2_1_2 = T2_1.insert(p2); Vertex_handle v2_1_3 = T2_1.insert(p3); // on the edge p1,p2, on the convex hull Vertex_handle v2_1_4 = T2_1.insert(p4); // outside, with two visible collineaar edges - Vertex_handle v2_1_5 = T2_1.insert(p5); + Vertex_handle v2_1_5 = T2_1.insert(p5); Vertex_handle v2_1_6 = T2_1.insert(p6); // outside, collinear with p2,p5 Vertex_handle v2_1_7 = T2_1.insert(p7); // outside with two visible collinear edges - // but also collinear with and extending p0,p5 - Vertex_handle v2_1_8 = T2_1.insert(p8); + // but also collinear with and extending p0,p5 + Vertex_handle v2_1_8 = T2_1.insert(p8); Vertex_handle v2_1_9 = T2_1.insert(p9); // inside, on the edge p6,p7 Vertex_handle v2_1_10 = T2_1.insert(p10); // inside the face p2,p4,p6 assert( T2_1.dimension() == 2 ); assert( T2_1.number_of_vertices() == 11 ); #ifndef CGAL_NO_DEPRECATED_CODE - assert( T2_1.number_of_faces() == 2 * 12 - 4 + assert( T2_1.number_of_faces() == 2 * 12 - 4 - T2_1.infinite_vertex()->degree() ); #endif - assert( T2_1.number_of_faces() == 2 * 12 - 4 + assert( T2_1.number_of_faces() == 2 * 12 - 4 - T2_1.degree(T2_1.infinite_vertex()) ); - + // test is_valid for 2-triangulations assert( T2_1.is_valid() ); @@ -272,7 +272,7 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_3.dimension() == 2 ); assert( T2_3.number_of_vertices() == 11 ); assert( T2_3.is_valid() ); - + // make sure inserting on a previous point does not insert it again assert( T2_3.insert(p10) == v2_3_10 ); assert( T2_3.number_of_vertices() == 11 ); @@ -303,7 +303,7 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_6.dimension() == 2 ); assert( T2_6.number_of_vertices() == 10 ); assert( T2_6.is_valid() ); - + // test grid insert Triangul T2_7; int m, p; @@ -328,7 +328,7 @@ _test_cls_triangulation_2( const Triangul & ) int fli = ff->index(f2); T2_8.flip(ff,fli); assert( T2_8.is_valid() ); - + //make_hole star_hole std::list hole; T2_3.make_hole(v2_3_10, hole); @@ -341,7 +341,7 @@ _test_cls_triangulation_2( const Triangul & ) std::cout << " displacements" << std::endl; std::cout << " degenerate cases: " << std::endl; - + Triangul TM_0, TM_1; Vertex_handle tmv1 = TM_0.insert(Point(0,0)); Vertex_handle tmv2 = TM_0.insert(Point(1,0)); @@ -418,7 +418,7 @@ _test_cls_triangulation_2( const Triangul & ) TM_0.move_if_no_collision(tmv4, Point(1, 2)); assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); - assert(TM_0.dimension() == 1); + assert(TM_0.dimension() == 1); TM_0.move_if_no_collision(tmv4, Point(3, 0)); assert(TM_0.tds().is_valid()); @@ -442,9 +442,9 @@ _test_cls_triangulation_2( const Triangul & ) points.push_back(Point(rand()%30000, rand()%30000)); } TM_1.insert(points.begin(), points.end()); - Vertex_handle vTM_1; + Vertex_handle vTM_1; for(int i=0; i<5; i++) { - for(typename Triangul::Finite_vertices_iterator + for(typename Triangul::Finite_vertices_iterator fvi = TM_1.finite_vertices_begin(); fvi != TM_1.finite_vertices_end(); fvi++) { Point p = Point(rand()%30000, rand()%30000); @@ -486,13 +486,13 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_1_1.dimension() == 2 ); assert( T2_1_1.number_of_vertices() == 11 ); assert( T2_1_1.is_valid() ); - + // test assignment operator Triangul T2_1_4 = T2_1; assert( T2_1_4.dimension() == 2 ); assert( T2_1_4.number_of_vertices() == 11 ); assert( T2_1_4.is_valid() ); - + /*********************************************/ /****** FINITE/INFINITE VERTICES/FACES *******/ @@ -538,16 +538,16 @@ _test_cls_triangulation_2( const Triangul & ) /******** POINT LOCATIONS ************/ // Locate_type lt; // see above - + // Check point location in 0-dimensional triangulations // No need because of precondition (at least two vertices) - + // Check point location in 1-dimensional triangulations std::cout << " point locations 1-dim" << std::endl; Triangul T1_3_2; T1_3_2.insert(p1); T1_3_2.insert(p2); - T1_3_2.insert(p9); + T1_3_2.insert(p9); f = T1_3_2.locate(p1,lt,li); assert( lt == Triangul::VERTEX ); assert( T1_3_2.xy_equal(f->vertex(li)->point(), p1) ); f = T1_3_2.locate(p2,lt,li); assert( lt == Triangul::VERTEX ); @@ -566,7 +566,7 @@ _test_cls_triangulation_2( const Triangul & ) f = T1_3_2.locate(p5,lt,li); assert( lt == Triangul::OUTSIDE_AFFINE_HULL ); f = T1_3_2.locate(p4,lt,li); assert( lt == Triangul::OUTSIDE_AFFINE_HULL ); f = T1_3_2.locate(p6,lt,li); assert( lt == Triangul::OUTSIDE_AFFINE_HULL ); - + // Check point location in 2-dimensional triangulations std::cout << " point locations 2-dim" << std::endl; @@ -601,35 +601,35 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_1.oriented_side(f,p12) == CGAL::ON_POSITIVE_SIDE ); f = T2_1.locate(p13,lt,li,f); assert( lt == Triangul::OUTSIDE_CONVEX_HULL ); assert( T2_1.orientation(p13, - f->vertex(f->ccw(li))->point(), - f->vertex(f->cw(li))->point()) - == CGAL::COUNTERCLOCKWISE); + f->vertex(f->ccw(li))->point(), + f->vertex(f->cw(li))->point()) + == CGAL::COUNTERCLOCKWISE); f = T2_1.locate(p14,lt,li); assert( lt == Triangul::OUTSIDE_CONVEX_HULL ); assert( T2_1.orientation(p14, - f->vertex(f->ccw(li))->point(), - f->vertex(f->cw(li))->point()) - == CGAL::COUNTERCLOCKWISE); + f->vertex(f->ccw(li))->point(), + f->vertex(f->cw(li))->point()) + == CGAL::COUNTERCLOCKWISE); f = T2_1.locate(p15,lt,li); assert( lt == Triangul::OUTSIDE_CONVEX_HULL ); assert( T2_1.orientation(p15, - f->vertex(f->ccw(li))->point(), - f->vertex(f->cw(li))->point()) - == CGAL::COUNTERCLOCKWISE); + f->vertex(f->ccw(li))->point(), + f->vertex(f->cw(li))->point()) + == CGAL::COUNTERCLOCKWISE); // test grid locate for (m=0; m<1; m++) for (p=0; p<1; p++) { - Point q= Point(m*px+p*qx, m*py+p*qy, 1); - f = T2_7.locate(q,lt,li); assert( lt == Triangul::VERTEX ); - assert( T2_7.xy_equal(f->vertex(li)->point(), q) ); + Point q= Point(m*px+p*qx, m*py+p*qy, 1); + f = T2_7.locate(q,lt,li); assert( lt == Triangul::VERTEX ); + assert( T2_7.xy_equal(f->vertex(li)->point(), q) ); } for (m=0; m<1; m++) for (p=0; p<1; p++) { - Point q= Point(2*m*px+(2*p+1)*qx, 2*m*py+(2*p+1)*qy, 2); - Point r= Point(m*px+p*qx, m*py+p*qy, 1); - Point s= Point(m*px+(p+1)*qx, m*py+(p+1)*qy, 1); - f = T2_7.locate(q,lt,li); assert( lt == Triangul::EDGE ); + Point q= Point(2*m*px+(2*p+1)*qx, 2*m*py+(2*p+1)*qy, 2); + Point r= Point(m*px+p*qx, m*py+p*qy, 1); + Point s= Point(m*px+(p+1)*qx, m*py+(p+1)*qy, 1); + f = T2_7.locate(q,lt,li); assert( lt == Triangul::EDGE ); assert( (T2_7.xy_equal(f->vertex(f->ccw(li))->point(), r) && T2_7.xy_equal(f->vertex(f->cw(li))->point(), s)) || (T2_7.xy_equal(f->vertex(f->ccw(li))->point(), s) @@ -639,9 +639,9 @@ _test_cls_triangulation_2( const Triangul & ) for (m=0; m<1; m++) for (p=0; p<1; p++) { - Point q= Point((50*m+1)*px+(50*p+1)*qx, (50*m+1)*py+(50*p+1)*qy, 50); - f = T2_7.locate(q,lt,li); assert( lt == Triangul::FACE ); - assert( T2_7.oriented_side(f,q) == CGAL::ON_POSITIVE_SIDE ); + Point q= Point((50*m+1)*px+(50*p+1)*qx, (50*m+1)*py+(50*p+1)*qy, 50); + f = T2_7.locate(q,lt,li); assert( lt == Triangul::FACE ); + assert( T2_7.oriented_side(f,q) == CGAL::ON_POSITIVE_SIDE ); } /*************************/ @@ -664,7 +664,7 @@ _test_cls_triangulation_2( const Triangul & ) Finite_faces_iterator fit = T2_7.finite_faces_begin(); assert(!T2_7.is_infinite(fit)); while(!T2_7.is_infinite(fit->neighbor(0)) ) ++fit; - + /***************************/ /******* Circulators *******/ @@ -681,7 +681,7 @@ _test_cls_triangulation_2( const Triangul & ) _test_circulators(T2_5); _test_circulators(T2_6); _test_circulators(T2_7); - + // Line_face_circulator std::cout << " line face circulator " << std::endl; _test_line_face_circulator(Triangul()); @@ -735,9 +735,9 @@ _test_cls_triangulation_2( const Triangul & ) assert(fc==fc2); //fc.print(); n=0; - do { - //fc2.print(); - fc2++ ; + do { + //fc2.print(); + fc2++ ; n = n+1;} while (fc2 != fc); assert(n==3); @@ -770,75 +770,75 @@ _test_cls_triangulation_2( const Triangul & ) /******** I/O *******/ std::cout << " output to a file" << std::endl; std::ofstream of0_0("T00.triangulation", std::ios::out); - CGAL::set_ascii_mode(of0_0); + CGAL::set_ascii_mode(of0_0); of0_0 << T0_0; of0_0.close(); std::ofstream of0_1("T01.triangulation"); - CGAL::set_ascii_mode(of0_1); + CGAL::set_ascii_mode(of0_1); of0_1 << T0_1; of0_1.close(); std::ofstream of1_2("T12.triangulation"); - CGAL::set_ascii_mode(of1_2); + CGAL::set_ascii_mode(of1_2); of1_2 << T1_2; of1_2.close(); std::ofstream of1_5("T15.triangulation"); - CGAL::set_ascii_mode(of1_5); + CGAL::set_ascii_mode(of1_5); of1_5 << T1_5; of1_5.close(); std::ofstream of1_6("T16.triangulation"); - CGAL::set_ascii_mode(of1_6); + CGAL::set_ascii_mode(of1_6); of1_6 << T1_6; of1_6.close(); std::ofstream of2_1("T21.triangulation"); - CGAL::set_ascii_mode(of2_1); + CGAL::set_ascii_mode(of2_1); of2_1 << T2_1; of2_1.close(); std::ofstream of2_3("T23.triangulation"); - CGAL::set_ascii_mode(of2_3); + CGAL::set_ascii_mode(of2_3); of2_3 << T2_3; of2_3.close(); std::ofstream of2_5("T25.triangulation"); - CGAL::set_ascii_mode(of2_5); + CGAL::set_ascii_mode(of2_5); of2_5 << T2_5; of2_5.close(); std::ofstream of2_6("T26.triangulation"); - CGAL::set_ascii_mode(of2_6); + CGAL::set_ascii_mode(of2_6); of2_6 << T2_6; of2_6.close(); std::cout << " input from a file" << std::endl; std::ifstream if0_0("T00.triangulation"); CGAL::set_ascii_mode(if0_0); Triangul T0_0_copy; if0_0 >> T0_0_copy; assert( T0_0_copy.is_valid() && - T0_0_copy.number_of_vertices() == T0_0.number_of_vertices() ); + T0_0_copy.number_of_vertices() == T0_0.number_of_vertices() ); std::ifstream if0_1("T01.triangulation"); CGAL::set_ascii_mode(if0_1); Triangul T0_1_copy; if0_1 >> T0_1_copy; assert( T0_1_copy.is_valid() && - T0_1_copy.number_of_vertices() == T0_1.number_of_vertices() ); - std::ifstream if1_2("T12.triangulation"); CGAL::set_ascii_mode(if1_2); + T0_1_copy.number_of_vertices() == T0_1.number_of_vertices() ); + std::ifstream if1_2("T12.triangulation"); CGAL::set_ascii_mode(if1_2); Triangul T1_2_copy; if1_2 >> T1_2_copy; assert( T1_2_copy.is_valid() && - T1_2_copy.number_of_vertices() == T1_2.number_of_vertices() ); - std::ifstream if1_5("T15.triangulation"); CGAL::set_ascii_mode(if1_5); + T1_2_copy.number_of_vertices() == T1_2.number_of_vertices() ); + std::ifstream if1_5("T15.triangulation"); CGAL::set_ascii_mode(if1_5); Triangul T1_5_copy; if1_5 >> T1_5_copy; assert( T1_5_copy.is_valid() && - T1_5_copy.number_of_vertices() == T1_5.number_of_vertices() ); + T1_5_copy.number_of_vertices() == T1_5.number_of_vertices() ); std::ifstream if1_6("T16.triangulation"); CGAL::set_ascii_mode(if1_6); Triangul T1_6_copy; if1_6 >> T1_6_copy; assert( T1_6_copy.is_valid() && - T1_6_copy.number_of_vertices() == T1_6.number_of_vertices() ); + T1_6_copy.number_of_vertices() == T1_6.number_of_vertices() ); std::ifstream if2_1("T21.triangulation"); CGAL::set_ascii_mode(if2_1); Triangul T2_1_copy; if2_1 >> T2_1_copy; assert( T2_1_copy.is_valid() && - T2_1_copy.number_of_vertices() == T2_1.number_of_vertices() ); + T2_1_copy.number_of_vertices() == T2_1.number_of_vertices() ); std::ifstream if2_3("T23.triangulation"); CGAL::set_ascii_mode(if2_3); Triangul T2_3_copy; if2_3 >> T2_3_copy; assert( T2_3_copy.is_valid() && - T2_3_copy.number_of_vertices() == T2_3.number_of_vertices() ); - std::ifstream if2_5("T25.triangulation"); CGAL::set_ascii_mode(if2_5); + T2_3_copy.number_of_vertices() == T2_3.number_of_vertices() ); + std::ifstream if2_5("T25.triangulation"); CGAL::set_ascii_mode(if2_5); Triangul T2_5_copy; if2_5 >> T2_5_copy; assert( T2_5_copy.is_valid() && - T2_5_copy.number_of_vertices() == T2_5.number_of_vertices() ); + T2_5_copy.number_of_vertices() == T2_5.number_of_vertices() ); std::ifstream if2_6("T26.triangulation"); CGAL::set_ascii_mode(if2_6); Triangul T2_6_copy; if2_6 >> T2_6_copy; assert( T2_6_copy.is_valid() && - T2_6_copy.number_of_vertices() == T2_6.number_of_vertices() ); + T2_6_copy.number_of_vertices() == T2_6.number_of_vertices() ); + - /**********************/ - /***** REMOVALS *******/ + /***** REMOVALS *******/ std::cout << " removals" << std::endl; // test remove_first() @@ -882,13 +882,13 @@ _test_cls_triangulation_2( const Triangul & ) T2_3.remove(v2_3_0); assert(T2_3.is_valid()); T2_3.remove(v2_3_1); assert(T2_3.is_valid()); T2_3.remove(v2_3_9); assert(T2_3.is_valid()); - T2_3.remove(v2_3_8); assert(T2_3.is_valid()); - T2_3.remove(v2_3_5); assert(T2_3.is_valid()); + T2_3.remove(v2_3_8); assert(T2_3.is_valid()); + T2_3.remove(v2_3_5); assert(T2_3.is_valid()); T2_3.remove(v2_3_3); assert(T2_3.is_valid()); T2_3.remove(v2_3_4); assert(T2_3.is_valid()); T2_3.remove(v2_3_2); assert(T2_3.is_valid()); T2_3.remove(v2_3_6); assert(T2_3.is_valid()); - T2_3.remove(v2_3_7); assert(T2_3.is_valid()); + T2_3.remove(v2_3_7); assert(T2_3.is_valid()); T2_3.remove(v2_3_10); assert(T2_3.is_valid()); assert( T2_3.number_of_vertices() == 0 ); @@ -896,7 +896,7 @@ _test_cls_triangulation_2( const Triangul & ) for (i=T2_4.number_of_vertices(); i>0; i--) T2_4.remove(T2_4.finite_vertex()); assert( T2_4.number_of_vertices() == 0 ); - + T2_5.clear(); assert( T2_5.number_of_vertices() == 0 ); @@ -905,7 +905,7 @@ _test_cls_triangulation_2( const Triangul & ) T2_6.remove(T2_6.finite_vertex()); } assert( T2_6.number_of_vertices() == 0 ); - + for (i=T2_7.number_of_vertices(); i>0; i--) T2_7.remove(T2_7.finite_vertex()); assert( T2_7.number_of_vertices() == 0 ); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h index 4eaf0541a29..b472c7fc8d2 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_traits.h @@ -7,14 +7,14 @@ // intended for general use. // // ---------------------------------------------------------------------------- -// +// // release : // release_date : -// -// source : +// +// source : // file : include/CGAL/_test_types.h -// revision : -// revision_date : +// revision : +// revision_date : // author(s) : Herve Bronnimann (Herve.Bronnimann@sophia.inria.fr) // // coordinator : INRIA Sophia-Antipolis @@ -38,12 +38,12 @@ public: Triangulation_test_point() {} Triangulation_test_point(double x, double y) : _x(x), _y(y) {} Triangulation_test_point(double hx, double hy, double hw) : - _x(hx/hw), _y(hy/hw) + _x(hx/hw), _y(hy/hw) {} TESTFT test_x() const { return _x; } TESTFT test_y() const { return _y; } - bool compare(const Point &p) const + bool compare(const Point &p) const { return test_x()==p.test_x() && test_y()==p.test_y(); } bool uncompare(const Point &p) const { return !compare(p); } void test_set(TESTFT x, TESTFT y) { _x=x; _y=y; } @@ -61,7 +61,7 @@ class Triangulation_test_segment { : _p(p), _q(q) {} void test_set(const Point &p, const Point &q) { _p=p; _q=q; } - + }; class Triangulation_test_line { @@ -78,10 +78,10 @@ class Triangulation_test_line { Point second_point() const {return _q;} // Triangulation_test_direction direction() { -// return Triangulation_test_direction(_p,_q); +// return Triangulation_test_direction(_p,_q); // } // Triangulation_test_line opposite() { -// return Triangulation_test_line(_q, _p); +// return Triangulation_test_line(_q, _p); // } // void test_set(const Point &p, const Point &q) { _p=p; _q=q; } }; @@ -96,10 +96,10 @@ public: Triangulation_test_direction() {} Triangulation_test_direction(const Point &p, const Point &q) : _p(p), _q(q) {} - Triangulation_test_direction(const Line &l) + Triangulation_test_direction(const Line &l) : _p(l.first_point()), _q(l.second_point()) {} // Triangulation_test_direction perpendicular(const CGAL::Orientation &) const { -// return *this; +// return *this; // } // void test_set(const Point &p, const Point &q) { _p=p; _q=q; } }; @@ -143,7 +143,7 @@ public: typedef Triangulation_test_point Point; typedef bool result_type; - bool operator()( const Point& p, const Point& q) const + bool operator()( const Point& p, const Point& q) const { return (p.test_x() < q.test_x()); } @@ -166,7 +166,7 @@ public: typedef Triangulation_test_point Point; typedef CGAL::Comparison_result result_type; - CGAL::Comparison_result operator()( const Point& p, const Point& q) const + CGAL::Comparison_result operator()( const Point& p, const Point& q) const { if (p.test_x() < q.test_x()) return CGAL::SMALLER; else if (p.test_x() > q.test_x()) return CGAL::LARGER; @@ -180,7 +180,7 @@ public: typedef Triangulation_test_point Point; typedef CGAL::Comparison_result result_type; - CGAL::Comparison_result operator()( const Point& p, const Point& q) const + CGAL::Comparison_result operator()( const Point& p, const Point& q) const { if (p.test_y() < q.test_y()) return CGAL::SMALLER; else if (p.test_y() > q.test_y()) return CGAL::LARGER; @@ -195,11 +195,11 @@ public: typedef CGAL::Orientation result_type; CGAL::Orientation - operator()( const Point& p, const Point& q, const Point& r) const + operator()( const Point& p, const Point& q, const Point& r) const { typedef Point::TESTFT RT; - RT det = (q.test_x()-p.test_x()) * (r.test_y()-p.test_y()) - - (r.test_x()-p.test_x()) * (q.test_y()-p.test_y()); + RT det = (q.test_x()-p.test_x()) * (r.test_y()-p.test_y()) + - (r.test_x()-p.test_x()) * (q.test_y()-p.test_y()); if ( det < RT(0) ) return CGAL::CLOCKWISE; if ( RT(0) < det ) return CGAL::COUNTERCLOCKWISE; return CGAL::COLLINEAR; @@ -213,10 +213,10 @@ public: typedef Triangulation_test_point Point; typedef CGAL::Orientation result_type; - CGAL::Oriented_side operator() (const Point &p, - const Point &q, - const Point &r, - const Point &t) const + CGAL::Oriented_side operator() (const Point &p, + const Point &q, + const Point &r, + const Point &t) const { typedef Point::TESTFT RT; @@ -228,17 +228,17 @@ public: RT ry( r.test_y()); RT tx( t.test_x()); RT ty( t.test_y()); - + RT RT0(0); RT RT1(1); RT det = CGAL::determinant(px, py, px*px + py*py, RT1, - qx, qy, qx*qx + qy*qy, RT1, - rx, ry, rx*rx + ry*ry, RT1, - tx, ty, tx*tx + ty*ty, RT1); + qx, qy, qx*qx + qy*qy, RT1, + rx, ry, rx*rx + ry*ry, RT1, + tx, ty, tx*tx + ty*ty, RT1); return (det @@ -406,7 +406,7 @@ public: private: using Tr_Base::top_get_first; using Tr_Base::top_get_second; - + template std::ptrdiff_t insert_with_info(InputIterator first, InputIterator last) { diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 7c4239af9b2..14fc74d8490 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -86,12 +86,12 @@ public: } Delaunay_triangulation_cell_base_with_circumcenter_3( - Vertex_handle v0, Vertex_handle v1, + Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) : Cb(v0, v1, v2, v3), circumcenter_(nullptr) {} Delaunay_triangulation_cell_base_with_circumcenter_3( - Vertex_handle v0, Vertex_handle v1, + Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, Cell_handle n0, Cell_handle n1, Cell_handle n2, Cell_handle n3) diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index dfa28cf61e6..bbb71277314 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -429,7 +429,7 @@ public: #ifndef CGAL_TRIANGULATION_3_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO private: - + //top stands for tuple-or-pair template const Weighted_point& top_get_first(const std::pair& pair) const { return pair.first; } @@ -442,7 +442,7 @@ private: template const Info& top_get_second(const boost::tuple& tuple) const { return boost::get<1>(tuple); } - + // Functor to go from an index of a container of Weighted_point to // the corresponding Bare_point template diff --git a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index a395e1c13e9..dbfa04367b0 100644 --- a/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -228,7 +228,7 @@ public: for (int level = 1; level <= vertex_level; ++level) { v = hints[level] = hierarchy[level]->insert (*p, hints[level]); - set_up_down(v, prev); + set_up_down(v, prev); prev = v; } } @@ -392,34 +392,34 @@ public: // some internal methods // GIVING NEW FACES template - Vertex_handle insert_and_give_new_cells(const Point &p, + Vertex_handle insert_and_give_new_cells(const Point &p, OutputItCells fit, Cell_handle start = Cell_handle() ); - + template Vertex_handle insert_and_give_new_cells(const Point& p, OutputItCells /* fit */, Vertex_handle hint) { - return insert_and_give_new_cells(p, hint == Vertex_handle() ? - this->infinite_cell() : hint->cell()); + return insert_and_give_new_cells(p, hint == Vertex_handle() ? + this->infinite_cell() : hint->cell()); } template Vertex_handle insert_and_give_new_cells(const Point& p, Locate_type lt, - Cell_handle c, int li, int lj, + Cell_handle c, int li, int lj, OutputItCells fit); template - void remove_and_give_new_cells(Vertex_handle v, + void remove_and_give_new_cells(Vertex_handle v, OutputItCells fit); template - Vertex_handle move_if_no_collision_and_give_new_cells(Vertex_handle v, + Vertex_handle move_if_no_collision_and_give_new_cells(Vertex_handle v, const Point &p, OutputItCells fit); - -public: + +public: //LOCATE @@ -451,7 +451,7 @@ protected: }; void locate(const Point& p, Locate_type& lt, int& li, int& lj, - locs pos[maxlevel], Cell_handle start = Cell_handle ()) const; + locs pos[maxlevel], Cell_handle start = Cell_handle ()) const; int random_level(); }; @@ -489,12 +489,12 @@ Triangulation_hierarchy_3(const Triangulation_hierarchy_3 &tr) for(int j=1; jfinite_vertices_begin(), - end = hierarchy[j]->finite_vertices_end(); it != end; ++it) { - // current it->down() pointer goes in original instead in copied triangulation - set_up_down(it, V[it->down()]); - // make map for next level - if (it->up() != Vertex_handle()) - V[ it->up()->down() ] = it; + end = hierarchy[j]->finite_vertices_end(); it != end; ++it) { + // current it->down() pointer goes in original instead in copied triangulation + set_up_down(it, V[it->down()]); + // make map for next level + if (it->up() != Vertex_handle()) + V[ it->up()->down() ] = it; } } } @@ -517,7 +517,7 @@ is_valid(bool verbose, int level) const // verify correctness of triangulation at all levels for(int i=0; iis_valid(verbose, level); + result = result && hierarchy[i]->is_valid(verbose, level); // verify that lower level has no down pointers for( Finite_vertices_iterator it = hierarchy[0]->finite_vertices_begin(), @@ -527,15 +527,15 @@ is_valid(bool verbose, int level) const // verify that other levels has down pointer and reciprocal link is fine for(int j=1; jfinite_vertices_begin(), - end = hierarchy[j]->finite_vertices_end(); it != end; ++it) + end = hierarchy[j]->finite_vertices_end(); it != end; ++it) result = result && &*(it) == &*(it->down()->up()); // verify that other levels has down pointer and reciprocal link is fine for(int k=0; kfinite_vertices_begin(), - end = hierarchy[k]->finite_vertices_end(); it != end; ++it) + end = hierarchy[k]->finite_vertices_end(); it != end; ++it) result = result && ( it->up() == Vertex_handle() || - &*it == &*(it->up())->down() ); + &*it == &*(it->up())->down() ); return result; } @@ -553,10 +553,10 @@ insert(const Point &p, Cell_handle start) locate(p, lt, i, j, positions, start); // insert at level 0 Vertex_handle vertex = hierarchy[0]->insert(p, - positions[0].lt, - positions[0].pos, - positions[0].li, - positions[0].lj); + positions[0].lt, + positions[0].pos, + positions[0].li, + positions[0].lj); Vertex_handle previous = vertex; Vertex_handle first = vertex; @@ -566,10 +566,10 @@ insert(const Point &p, Cell_handle start) vertex = hierarchy[level]->insert(p); else vertex = hierarchy[level]->insert(p, - positions[level].lt, - positions[level].pos, - positions[level].li, - positions[level].lj); + positions[level].lt, + positions[level].pos, + positions[level].li, + positions[level].lj); set_up_down(vertex, previous); previous=vertex; level++; @@ -636,13 +636,13 @@ insert(const Point &p, Locate_type lt, Cell_handle loc, int li, int lj) int level = 1; while (level <= vertex_level ){ if (positions[level].pos == Cell_handle()) - vertex = hierarchy[level]->insert(p); + vertex = hierarchy[level]->insert(p); else - vertex = hierarchy[level]->insert(p, - positions[level].lt, - positions[level].pos, - positions[level].li, - positions[level].lj); + vertex = hierarchy[level]->insert(p, + positions[level].lt, + positions[level].pos, + positions[level].li, + positions[level].lj); set_up_down(vertex, previous); previous=vertex; level++; @@ -655,12 +655,12 @@ template template typename Triangulation_hierarchy_3::Vertex_handle Triangulation_hierarchy_3:: -insert_and_give_new_cells(const Point &p, Locate_type lt, Cell_handle loc, +insert_and_give_new_cells(const Point &p, Locate_type lt, Cell_handle loc, int li, int lj, OutputItCells fit) { int vertex_level = random_level(); // insert at level 0 - Vertex_handle vertex = + Vertex_handle vertex = hierarchy[0]->insert_and_give_new_cells(p,lt,loc,li,lj,fit); Vertex_handle previous = vertex; Vertex_handle first = vertex; @@ -675,9 +675,9 @@ insert_and_give_new_cells(const Point &p, Locate_type lt, Cell_handle loc, int level = 1; while (level <= vertex_level ){ if (positions[level].pos == Cell_handle()) - vertex = hierarchy[level]->insert(p); + vertex = hierarchy[level]->insert(p); else - vertex = hierarchy[level]->insert(p, + vertex = hierarchy[level]->insert(p, positions[level].lt, positions[level].pos, positions[level].li, @@ -700,7 +700,7 @@ remove(Vertex_handle v) Vertex_handle u = v->up(); hierarchy[l]->remove(v); if (u == Vertex_handle()) - break; + break; v = u; } } @@ -718,7 +718,7 @@ remove_and_give_new_cells(Vertex_handle v, OutputItCells fit) if(l) hierarchy[l]->remove(v); else hierarchy[l]->remove_and_give_new_cells(v, fit); if (u == Vertex_handle()) - break; + break; v = u; } } @@ -728,7 +728,7 @@ typename Triangulation_hierarchy_3::Vertex_handle Triangulation_hierarchy_3:: move_if_no_collision(Vertex_handle v, const Point & p) { - CGAL_triangulation_precondition(!this->is_infinite(v)); + CGAL_triangulation_precondition(!this->is_infinite(v)); if(v->point() == p) return v; Vertex_handle ans; for (int l = 0; l < maxlevel; ++l) { @@ -765,13 +765,13 @@ Triangulation_hierarchy_3:: move_if_no_collision_and_give_new_cells( Vertex_handle v, const Point & p, OutputItCells fit) { - CGAL_triangulation_precondition(!is_infinite(v)); + CGAL_triangulation_precondition(!is_infinite(v)); if(v->point() == p) return v; Vertex_handle ans; for (int l = 0; l < maxlevel; ++l) { Vertex_handle u = v->up(); if(l) hierarchy[l]->move_if_no_collision(v, p); - else ans = + else ans = hierarchy[l]->move_if_no_collision_and_give_new_cells(v, p, fit); if(ans != v) return ans; if (u == Vertex_handle()) @@ -818,7 +818,7 @@ locate(const Point& p, Locate_type& lt, int& li, int& lj, // find the highest level with enough vertices while (hierarchy[--level]->number_of_vertices() < (size_type) minsize) { if ( ! level) - break; // do not go below 0 + break; // do not go below 0 } for (int i=level+1; ilocate(p, - pos[level].lt, - pos[level].li, - pos[level].lj, - position); + pos[level].lt, + pos[level].li, + pos[level].lj, + position); // find the nearest vertex. Vertex_handle nearest = hierarchy[level]->nearest_vertex_in_cell(p, position); diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h index a6b5ded18a7..f7d4579828c 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Francois Rebufat, Monique Teillaud, Sylvain Pion // Mariette Yvinec @@ -38,12 +38,12 @@ template < typename T, typename Weighted_tag = typename T::Weighted_tag > struct Test_location_policy { - typedef typename T::Location_policy Location_policy; + typedef typename T::Location_policy Location_policy; }; template < typename T > struct Test_location_policy { - struct Location_policy{}; + struct Location_policy{}; }; template < typename T, typename P > @@ -156,8 +156,8 @@ void test_conflicts(T& T3_13, const P *q) T3_13.insert_in_hole(q[i], C.begin(), C.end(), F.begin()->first, F.begin()->second); else { - // alternately test the overload which takes a Vertex_handle. - Vertex_handle v = T3_13.tds().create_vertex(); + // alternately test the overload which takes a Vertex_handle. + Vertex_handle v = T3_13.tds().create_vertex(); T3_13.insert_in_hole(q[i], C.begin(), C.end(), F.begin()->first, F.begin()->second, v); } @@ -203,7 +203,7 @@ _test_cls_delaunay_3(const Triangulation &) typedef typename Cls::size_type size_type; typedef typename Cls::Vertex_handle Vertex_handle; - typedef typename Cls::Cell_handle Cell_handle; + typedef typename Cls::Cell_handle Cell_handle; typedef typename Cls::Vertex_iterator Vertex_iterator; typedef typename Cls::Cell_iterator Cell_iterator; typedef typename Cls::Locate_type Locate_type; @@ -243,22 +243,22 @@ _test_cls_delaunay_3(const Triangulation &) l3.push_back(ppp[i]); // Points for T2_0 : - Point p1=Point(5,5,0); + Point p1=Point(5,5,0); Point p2=Point(4,4,0); Point p3=Point(6,6,0); // 1- dimensional until this point Point p4=Point(5,3,0); // 2-dimensional - Point p5=Point(5,7,0); - Point p6=Point(5,4,0); - Point p7=Point(5,6,0); - Point p8=Point(0,0,0); - Point p9=Point(5,5,0); + Point p5=Point(5,7,0); + Point p6=Point(5,4,0); + Point p7=Point(5,6,0); + Point p8=Point(0,0,0); + Point p9=Point(5,5,0); // Points for T3_1 : - Point q[22] = + Point q[22] = { Point(0,0,0), Point(4,4,0), Point(0,4,0), Point(4,0,0), Point(1,3,1), Point(3,1,1), Point(3,3,1), Point(1,1,1), Point(2,2,2), - Point(1,3,3), Point(3,1,3), Point(3,3,3), Point(1,1,3), + Point(1,3,3), Point(3,1,3), Point(3,3,3), Point(1,1,3), Point(0,0,4), Point(4,4,4), Point(0,4,4), Point(4,0,4), Point(1,3,5), Point(3,1,5), Point(3,3,5), Point(1,1,5), Point(2,2,6)}; @@ -269,14 +269,14 @@ _test_cls_delaunay_3(const Triangulation &) // for (a=0;a!=10;a++) // for (b=0;b!=10;b++) // for (d=0;d!=10;d++) -// lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, -// a*a-d*d+b)); +// lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, +// a*a-d*d+b)); for (a=0;a!=10;a++) for (b=0;b!=10;b++) for (d=0;d!=5;d++) - lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, - a*a-d*d+b)); + lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, + a*a-d*d+b)); // Points for T3_2 : @@ -284,8 +284,8 @@ _test_cls_delaunay_3(const Triangulation &) for (a=0;a!=4;a++) for (b=0;b!=4;b++) for (d=0;d!=4;d++) - lp2.push_back(Point((a*b-d*a)*10 +a ,(a-b+d +5*b)*100, - a*a-d*d-b)); + lp2.push_back(Point((a*b-d*a)*10 +a ,(a-b+d +5*b)*100, + a*a-d*d-b)); //######################################################################## @@ -296,7 +296,7 @@ _test_cls_delaunay_3(const Triangulation &) std::cout << " Constructor " << std::endl; // Beginning with an empty triangulation and adding point until reaching // 3-dimentional triangulation. - Cls T0; + Cls T0; assert(T0.dimension() == -1); assert(T0.number_of_vertices() == 0); assert(T0.is_valid()); @@ -326,7 +326,7 @@ _test_cls_delaunay_3(const Triangulation &) Cls Tfromfile; std::cout << " I/O" << std::endl; { - std::ofstream oFileT2("Test2_triangulation_IO_3",std::ios::out); + std::ofstream oFileT2("Test2_triangulation_IO_3",std::ios::out); oFileT2 << T0 << std::endl; } std::ifstream iFileT2("Test2_triangulation_IO_3",std::ios::in); @@ -409,13 +409,13 @@ _test_cls_delaunay_3(const Triangulation &) assert(T0.dimension() == 3); assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); - + // copy constructor Cls T1(T0); assert(T1.dimension() == 3); assert(T1.number_of_vertices() == 4); assert(T1.is_valid()); - + T1.clear(); assert(T1.dimension() == -1); assert(T1.number_of_vertices() == 0); @@ -424,7 +424,7 @@ _test_cls_delaunay_3(const Triangulation &) // Affectation : - T1=T0; + T1=T0; assert(T1.dimension() == 3); assert(T1.number_of_vertices() == 4); assert(T1.is_valid()); @@ -439,7 +439,7 @@ _test_cls_delaunay_3(const Triangulation &) assert(T0.number_of_vertices() == 0); assert(T0.is_valid()); T0.swap(T1); - + assert(T0.dimension() == 3); assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); @@ -484,7 +484,7 @@ _test_cls_delaunay_3(const Triangulation &) } std::cout << " Constructor9 " << std::endl; - // 2-dimensional triangulations + // 2-dimensional triangulations Cls T2_0; v0=T2_0.insert(p1); @@ -538,8 +538,8 @@ _test_cls_delaunay_3(const Triangulation &) for (m=0; m<20; m++) for (n=0; n<20; n++) { - qq[m+20*n] = Point(m*px+(int)n*qx, m*py+(int)n*qy, 1); - T2_1.insert( qq[m+20*n] ); + qq[m+20*n] = Point(m*px+(int)n*qx, m*py+(int)n*qy, 1); + T2_1.insert( qq[m+20*n] ); } assert( T2_1.number_of_vertices() == m*n ); assert( T2_1.dimension()==2 ); @@ -553,30 +553,30 @@ _test_cls_delaunay_3(const Triangulation &) Point r[225]; for (z=0 ; z<5 ; z++) for (y=0 ; y<5 ; y++) - for (x=0 ; x<5 ; x++) - { - r[x+5*y+25*z] = Point(x,y,z); - v0=T3_0.insert(r[x+5*y+25*z]); - } + for (x=0 ; x<5 ; x++) + { + r[x+5*y+25*z] = Point(x,y,z); + v0=T3_0.insert(r[x+5*y+25*z]); + } assert(T3_0.is_valid()); assert(T3_0.number_of_vertices()==125); assert(T3_0.dimension()==3); if (del) { std::cout << " deletion in Delaunay - grid case - (dim 3) " << - std::endl; + std::endl; Cls Tdel( T3_0 ); - + std::vector vertices; for (Finite_vertices_iterator vi = Tdel.finite_vertices_begin(); - vi != Tdel.finite_vertices_end(); ++vi) + vi != Tdel.finite_vertices_end(); ++vi) vertices.push_back(vi); size_type n = Tdel.number_of_vertices(); size_type m = Tdel.remove(vertices.begin(), vertices.end()); assert(m == n - Tdel.number_of_vertices()); assert(Tdel.is_valid(false)); - std::cout << " successfull" << std::endl; + std::cout << " successfull" << std::endl; } @@ -650,33 +650,33 @@ _test_cls_delaunay_3(const Triangulation &) Cell_handle c2 = T3_13.infinite_vertex()->cell(); for (int x = -1; x < 7; ++x) for (int y = -1; y < 7; ++y) - for (int z = -1; z < 7; ++z) { - Point p(x, y, z); - Vertex_handle v = nearest_vertex(T3_13, p); - for (typename Cls::Finite_vertices_iterator - fvit = T3_13.finite_vertices_begin(); - fvit != T3_13.finite_vertices_end(); ++fvit){ - - assert(CGAL::squared_distance(p, + for (int z = -1; z < 7; ++z) { + Point p(x, y, z); + Vertex_handle v = nearest_vertex(T3_13, p); + for (typename Cls::Finite_vertices_iterator + fvit = T3_13.finite_vertices_begin(); + fvit != T3_13.finite_vertices_end(); ++fvit){ + + assert(CGAL::squared_distance(p, v->point()) <= CGAL::squared_distance(p, fvit->point())); } Vertex_handle v1 = nearest_vertex_in_cell(T3_13, p, c1) ; - int i1 = c1->index(v1); - for(int i=0; i<4; ++i) { - if (i != i1) - assert(CGAL::squared_distance(p, v1->point()) <= + int i1 = c1->index(v1); + for(int i=0; i<4; ++i) { + if (i != i1) + assert(CGAL::squared_distance(p, v1->point()) <= CGAL::squared_distance(p, c1->vertex(i)->point())); - } - Vertex_handle v2 = nearest_vertex_in_cell(T3_13, p, c2); - int i2 = c2->index(v2); - for(int i=0; i<4; ++i) { - if (i != i2 && c2->vertex(i) != T3_13.infinite_vertex()) - assert(CGAL::squared_distance(p, v2->point()) <= + } + Vertex_handle v2 = nearest_vertex_in_cell(T3_13, p, c2); + int i2 = c2->index(v2); + for(int i=0; i<4; ++i) { + if (i != i2 && c2->vertex(i) != T3_13.infinite_vertex()) + assert(CGAL::squared_distance(p, v2->point()) <= CGAL::squared_distance(p, c2->vertex(i)->point())); - } - } + } + } } { @@ -737,19 +737,19 @@ _test_cls_delaunay_3(const Triangulation &) else if (count < 100) std::cout << count << '\b' << '\b' ; - else + else if (count < 1000) std::cout << count << '\b' << '\b' << '\b' ; else - std::cout << count << std::endl; + std::cout << count << std::endl; std::cout.flush(); } std::cout << std::endl; assert(T3_2.is_valid()); assert(T3_2.dimension()==3); assert(T3_2.number_of_vertices()==500); - - + + Point p110(-5,5,0), p111(-2,-5,2), p112(-2,-9,6), p113(4,8,9), p114(5,-6,0), p115(3,0,5), p116(-9,0,-10), p117(1,6,-2), p118(-3,2,-4), p119(3,-3,-1); @@ -774,16 +774,16 @@ _test_cls_delaunay_3(const Triangulation &) Vertex_handle v; while ( T3_5.number_of_vertices() >= 1 ) { if ( T3_5.dimension() == 3 ) - v = T3_5.infinite_cell()->vertex - ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )&3 ); + v = T3_5.infinite_cell()->vertex + ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )&3 ); else if ( T3_5.dimension() == 2 ) - v = T3_5.infinite_cell()->vertex - ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )%3 ); + v = T3_5.infinite_cell()->vertex + ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )%3 ); else if ( T3_5.dimension() == 1 ) - v = T3_5.infinite_cell()->vertex - ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )%2 ); - else - v = T3_5.infinite_cell()->neighbor(0)->vertex(0); + v = T3_5.infinite_cell()->vertex + ( (T3_5.infinite_cell()->index( T3_5.infinite_vertex() ) +1 )%2 ); + else + v = T3_5.infinite_cell()->neighbor(0)->vertex(0); T3_5.remove( v ); } @@ -809,18 +809,18 @@ _test_cls_delaunay_3(const Triangulation &) // bool success(true); // if (del) { // std::cout << " deletion in a Delaunay of " -// << T3_4.number_of_vertices() << " random points"; +// << T3_4.number_of_vertices() << " random points"; // Vertex_handle v; // while ( T3_4.number_of_vertices() >= 1 ) { // if ( T3_4.dimension() > 1 ) -// v = T3_4.infinite_cell()->vertex -// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )&3 ); +// v = T3_4.infinite_cell()->vertex +// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )&3 ); // else -// if ( T3_4.dimension() == 1 ) -// v = T3_4.infinite_cell()->vertex -// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )%2 ); -// else -// v = T3_4.infinite_cell()->neighbor(0)->vertex(0); +// if ( T3_4.dimension() == 1 ) +// v = T3_4.infinite_cell()->vertex +// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )%2 ); +// else +// v = T3_4.infinite_cell()->neighbor(0)->vertex(0); // success = T3_4.remove( v ); // } @@ -847,10 +847,10 @@ _test_cls_delaunay_3(const Triangulation &) _test_vertex_iterator(T3_1); _test_triangulation_iterator(T3_1); _test_vertex_iterator(T3_0); - _test_triangulation_iterator(T3_0); - _test_vertex_iterator(T3_2); - _test_triangulation_iterator(T3_2); - + _test_triangulation_iterator(T3_0); + _test_vertex_iterator(T3_2); + _test_triangulation_iterator(T3_2); + std::cout << " Testing Circulator "<< std::endl; _test_circulator(T0); @@ -886,7 +886,7 @@ _test_cls_delaunay_3(const Triangulation &) assert(T4.is_Gabriel(e)); assert(T4.is_edge(v2,v3,c,i,j)); assert(T4.is_Gabriel(c,i,j)); - + std::cout <<" Test dual (minimal test for now)" << std::endl; // We only test return types and instantiation, basically. @@ -915,32 +915,32 @@ _test_cls_delaunay_3(const Triangulation &) Cls Ta (q, q+22), Tb(q, q+22); assert(Ta == Tb); for (Finite_vertices_iterator ita = Ta.finite_vertices_begin(), - itb = Tb.finite_vertices_begin(), - end = Ta.finite_vertices_end(); - ita != end; ++ita, ++itb) + itb = Tb.finite_vertices_begin(), + end = Ta.finite_vertices_end(); + ita != end; ++ita, ++itb) assert(ita->point() == itb->point()); for (Finite_cells_iterator ita = Ta.finite_cells_begin(), - itb = Tb.finite_cells_begin(), - end = Ta.finite_cells_end(); - ita != end; ++ita, ++itb) { + itb = Tb.finite_cells_begin(), + end = Ta.finite_cells_end(); + ita != end; ++ita, ++itb) { assert(ita->vertex(0)->point() == itb->vertex(0)->point()); assert(ita->vertex(1)->point() == itb->vertex(1)->point()); assert(ita->vertex(2)->point() == itb->vertex(2)->point()); assert(ita->vertex(3)->point() == itb->vertex(3)->point()); } } - + /**********************/ /******* MOVE *********/ std::cout << " displacements" << std::endl; std::cout << " degenerate cases: " << std::endl; - + Cls TM_0; Vertex_handle tmv1 = TM_0.insert(Point(0,0,0)); Vertex_handle tmv2 = TM_0.insert(Point(0,1,0)); - TM_0.move_if_no_collision(tmv1, Point(0, 2, 1)); + TM_0.move_if_no_collision(tmv1, Point(0, 2, 1)); assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); assert(TM_0.dimension() == 1); @@ -1056,7 +1056,7 @@ _test_cls_delaunay_3(const Triangulation &) TM_0.move_if_no_collision(tmv4, Point(0, 1, 2)); assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); - assert(TM_0.dimension() == 1); + assert(TM_0.dimension() == 1); TM_0.move_if_no_collision(tmv4, Point(0, 3, 0)); assert(TM_0.tds().is_valid()); @@ -1133,7 +1133,7 @@ _test_cls_delaunay_3(const Triangulation &) TM_1.insert(points.begin(), points.end()); Vertex_handle vTM_1; for(int i=0; i<2; i++) { - for(typename Cls::Finite_vertices_iterator + for(typename Cls::Finite_vertices_iterator fvi = TM_1.finite_vertices_begin(); fvi != TM_1.finite_vertices_end(); fvi++) { Point p = Point(0, 0, rand()%30000); @@ -1151,9 +1151,9 @@ _test_cls_delaunay_3(const Triangulation &) points.push_back(Point(0, rand()%30000, rand()%30000)); } TM_2.insert(points.begin(), points.end()); - Vertex_handle vTM_2; + Vertex_handle vTM_2; for(int i=0; i<2; i++) { - for(typename Cls::Finite_vertices_iterator + for(typename Cls::Finite_vertices_iterator fvi = TM_2.finite_vertices_begin(); fvi != TM_2.finite_vertices_end(); fvi++) { Point p = Point(0, rand()%30000, rand()%30000); @@ -1164,7 +1164,7 @@ _test_cls_delaunay_3(const Triangulation &) assert(TM_2.is_valid()); std::cout << " random 3D: " << std::endl; - Cls TM_3; + Cls TM_3; // non-degenerate cases points.clear(); TM_3.clear(); for(int count=0; count<50; count++) { @@ -1173,10 +1173,10 @@ _test_cls_delaunay_3(const Triangulation &) TM_3.insert(points.begin(), points.end()); assert(TM_3.is_valid()); - + Vertex_handle vTM_3; for(int i=0; i<2; i++) { - for(typename Cls::Finite_vertices_iterator + for(typename Cls::Finite_vertices_iterator fvi = TM_3.finite_vertices_begin(); fvi != TM_3.finite_vertices_end(); fvi++) { Point p = Point(rand()%30000, rand()%30000, rand()%30000); @@ -1191,7 +1191,7 @@ _test_cls_delaunay_3(const Triangulation &) // Test remove cluster { - _test_remove_cluster(); + _test_remove_cluster(); } } diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h index 6c5793d0de2..fba2db023fd 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_regular_3.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Monique Teillaud (Monique.Teillaud@sophia.inria.fr) @@ -48,7 +48,7 @@ _test_cls_regular_3(const Triangulation &) Cls T1; std::cout << " number of inserted points : " ; for ( m=0; m<5; m++) { - if ( (m%2)== 0 ) + if ( (m%2)== 0 ) T1.insert( Weighted_point( Bare_point( 2*m,0,0 ), 2 ) ); else T1.insert( Weighted_point( Bare_point( -2*m+1,0,0 ), 2 ) ); count++; @@ -56,18 +56,18 @@ _test_cls_regular_3(const Triangulation &) std::cout << count << '\b' ; else if (count < 100) - std::cout << count << '\b' << '\b' ; + std::cout << count << '\b' << '\b' ; else - std::cout << count << '\b' << '\b' << '\b' ; + std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } assert( T1.is_valid() ); - std::cout << std::endl << " number of vertices : " - << T1.number_of_vertices() << std::endl; + std::cout << std::endl << " number of vertices : " + << T1.number_of_vertices() << std::endl; std::cout << " number of inserted points : " ; for ( m=0; m<5; m++) { - if ( (m%2)== 0 ) + if ( (m%2)== 0 ) T1.insert( Weighted_point( Bare_point( 2*m+1,0,0 ), 5 ) ); else T1.insert( Weighted_point( Bare_point( -2*m+1,0,0 ), 5 ) ); count++; @@ -75,18 +75,18 @@ _test_cls_regular_3(const Triangulation &) std::cout << count << '\b' ; else if (count < 100) - std::cout << count << '\b' << '\b' ; + std::cout << count << '\b' << '\b' ; else - std::cout << count << '\b' << '\b' << '\b' ; - std::cout.flush(); + std::cout << count << '\b' << '\b' << '\b' ; + std::cout.flush(); } assert( T1.is_valid() ); - std::cout << std::endl << " number of vertices : " - << T1.number_of_vertices() << std::endl; + std::cout << std::endl << " number of vertices : " + << T1.number_of_vertices() << std::endl; std::cout << " number of inserted points : " ; for ( m=0; m<10; m++) { - if ( (m%2)== 0 ) + if ( (m%2)== 0 ) T1.insert( Weighted_point( Bare_point( m,0,0 ), 1 ) ); else T1.insert( Weighted_point( Bare_point( -m,0,0 ), 1 ) ); count++; @@ -94,14 +94,14 @@ _test_cls_regular_3(const Triangulation &) std::cout << count << '\b' ; else if (count < 100) - std::cout << count << '\b' << '\b' ; + std::cout << count << '\b' << '\b' ; else - std::cout << count << '\b' << '\b' << '\b' ; - std::cout.flush(); + std::cout << count << '\b' << '\b' << '\b' ; + std::cout.flush(); } assert( T1.is_valid() ); - std::cout << std::endl << " number of vertices : " - << T1.number_of_vertices() << std::endl; + std::cout << std::endl << " number of vertices : " + << T1.number_of_vertices() << std::endl; assert( T1.dimension()==1 ); std::cout << " test dimension 2 " << std::endl; @@ -116,12 +116,12 @@ _test_cls_regular_3(const Triangulation &) T2.insert( Weighted_point( Bare_point(m*px+n*qx, m*py+n*qy, 0), 1 ) ); count++; if (count <10) - std::cout << count << '\b' ; + std::cout << count << '\b' ; else - if (count < 100) - std::cout << count << '\b' << '\b' ; - else - std::cout << count << '\b' << '\b' << '\b' ; + if (count < 100) + std::cout << count << '\b' << '\b' ; + else + std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=10; m<20; m++) @@ -129,12 +129,12 @@ _test_cls_regular_3(const Triangulation &) T2.insert( Weighted_point( Bare_point(m*px+n*qx, m*py+n*qy, 0), -1 ) ); count++; if (count <10) - std::cout << count << '\b' ; + std::cout << count << '\b' ; else - if (count < 100) - std::cout << count << '\b' << '\b' ; - else - std::cout << count << '\b' << '\b' << '\b' ; + if (count < 100) + std::cout << count << '\b' << '\b' ; + else + std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=0; m<10; m++) @@ -142,12 +142,12 @@ _test_cls_regular_3(const Triangulation &) T2.insert( Weighted_point( Bare_point(m*px+n*qx, m*py+n*qy, 0), -2 ) ); count++; if (count <10) - std::cout << count << '\b' ; + std::cout << count << '\b' ; else - if (count < 100) - std::cout << count << '\b' << '\b' ; - else - std::cout << count << '\b' << '\b' << '\b' ; + if (count < 100) + std::cout << count << '\b' << '\b' ; + else + std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=10; m<20; m++) @@ -155,17 +155,17 @@ _test_cls_regular_3(const Triangulation &) T2.insert( Weighted_point( Bare_point(m*px+n*qx, m*py+n*qy, 0), 5 ) ); count++; if (count <10) - std::cout << count << '\b' ; + std::cout << count << '\b' ; else - if (count < 100) - std::cout << count << '\b' << '\b' ; - else - std::cout << count << '\b' << '\b' << '\b' ; + if (count < 100) + std::cout << count << '\b' << '\b' ; + else + std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } - - std::cout << std::endl << " number of vertices : " - << T2.number_of_vertices() << std::endl; + + std::cout << std::endl << " number of vertices : " + << T2.number_of_vertices() << std::endl; assert( T2.dimension()==2 ); assert( T2.is_valid() ); @@ -178,10 +178,10 @@ _test_cls_regular_3(const Triangulation &) for (a=0;a!=10;a++) for (b=0;b!=10;b++) for (d=0;d!=10;d++) - lp.push_back(Weighted_point( Bare_point(a*b-d*a + (a-b)*10 +a , - a-b+d +5*b, - a*a-d*d+b), - a*b-a*d) ); + lp.push_back(Weighted_point( Bare_point(a*b-d*a + (a-b)*10 +a , + a-b+d +5*b, + a*a-d*d+b), + a*b-a*d) ); typename list_point::iterator it; count = 0 ; std::cout << " number of inserted points : " ; @@ -193,16 +193,16 @@ _test_cls_regular_3(const Triangulation &) else if (count < 100) std::cout << count << '\b' << '\b' ; - else + else if (count < 1000) std::cout << count << '\b' << '\b' << '\b' ; else - std::cout << count << std::endl; + std::cout << count << std::endl; std::cout.flush(); } - std::cout << " number of vertices : " - << T.number_of_vertices() << std::endl; + std::cout << " number of vertices : " + << T.number_of_vertices() << std::endl; assert(T.is_valid()); assert(T.dimension()==3); } diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index b73de19db78..ded18a9175f 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Francois Rebufat @@ -25,7 +25,7 @@ #include template -bool check_all_are_finite(Triangulation* tr, const Container& cont) +bool check_all_are_finite(Triangulation* tr, const Container& cont) { for(typename Container::const_iterator it = cont.begin(), end = cont.end(); it != end; ++it) @@ -38,7 +38,7 @@ bool check_all_are_finite(Triangulation* tr, const Container& cont) template void _test_cls_triangulation_3_input_output(const Triangulation & T, - const char* filename) + const char* filename) { const int dim = T.dimension(); const typename Triangulation::size_type n = T.number_of_vertices(); @@ -102,7 +102,7 @@ _test_cls_triangulation_3(const Triangulation &) typedef typename Cls::difference_type difference_type; typedef typename Cls::Vertex_handle Vertex_handle; - typedef typename Cls::Cell_handle Cell_handle; + typedef typename Cls::Cell_handle Cell_handle; typedef typename Cls::Vertex_iterator Vertex_iterator; typedef typename Cls::Cell_iterator Cell_iterator; // typedef typename Cls::Point_iterator Point_iterator; @@ -142,22 +142,22 @@ _test_cls_triangulation_3(const Triangulation &) l3.push_back(ppp[i]); // Points for T2_0 : - Point p1=Point(5,5,0); + Point p1=Point(5,5,0); Point p2=Point(4,4,0); Point p3=Point(6,6,0); // 1- dimensional until this point Point p4=Point(5,3,0); // 2-dimensional - Point p5=Point(5,7,0); - Point p6=Point(5,4,0); - Point p7=Point(5,6,0); - Point p8=Point(0,0,0); - Point p9=Point(5,5,0); + Point p5=Point(5,7,0); + Point p6=Point(5,4,0); + Point p7=Point(5,6,0); + Point p8=Point(0,0,0); + Point p9=Point(5,5,0); // Points for T3_1 : - Point q[22] = + Point q[22] = { Point(0,0,0), Point(4,4,0), Point(0,4,0), Point(4,0,0), Point(1,3,1), Point(3,1,1), Point(3,3,1), Point(1,1,1), Point(2,2,2), - Point(1,3,3), Point(3,1,3), Point(3,3,3), Point(1,1,3), + Point(1,3,3), Point(3,1,3), Point(3,3,3), Point(1,1,3), Point(0,0,4), Point(4,4,4), Point(0,4,4), Point(4,0,4), Point(1,3,5), Point(3,1,5), Point(3,3,5), Point(1,1,5), Point(2,2,6)}; @@ -168,14 +168,14 @@ _test_cls_triangulation_3(const Triangulation &) // for (a=0;a!=10;a++) // for (b=0;b!=10;b++) // for (d=0;d!=10;d++) -// lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, -// a*a-d*d+b)); +// lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, +// a*a-d*d+b)); for (a=0;a!=10;a++) for (b=0;b!=10;b++) for (d=0;d!=5;d++) - lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, - a*a-d*d+b)); + lp.push_back(Point(a*b-d*a + (a-b)*10 +a ,a-b+d +5*b, + a*a-d*d+b)); // Points for T3_2 : @@ -183,8 +183,8 @@ _test_cls_triangulation_3(const Triangulation &) for (a=0;a!=4;a++) for (b=0;b!=4;b++) for (d=0;d!=4;d++) - lp2.push_back(Point((a*b-d*a)*10 +a ,(a-b+d +5*b)*100, - a*a-d*d-b)); + lp2.push_back(Point((a*b-d*a)*10 +a ,(a-b+d +5*b)*100, + a*a-d*d-b)); //######################################################################## @@ -195,13 +195,13 @@ _test_cls_triangulation_3(const Triangulation &) std::cout << " Constructor " << std::endl; // Beginning with an empty triangulation and adding points until reaching // 3-dimensional triangulation. - Cls T0; + Cls T0; assert(T0.dimension() == -1); assert(T0.number_of_vertices() == 0); assert(T0.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T0, "Test1_triangulation_IO_3"); } @@ -214,7 +214,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T0, "Test2_triangulation_IO_3"); } @@ -228,7 +228,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T0, "Test3_triangulation_IO_3"); } @@ -242,7 +242,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T0, "Test4_triangulation_IO_3"); } @@ -256,7 +256,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T0, "Test5_triangulation_IO_3"); } @@ -268,7 +268,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.dimension() == 3); assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); - + // copy constructor Cls T1(T0); assert(T1.dimension() == 3); @@ -280,7 +280,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0 == T1); assert(T1 == T0); assert(T1 == T1); - + T1.clear(); assert(T1.dimension() == -1); assert(T1.number_of_vertices() == 0); @@ -289,7 +289,7 @@ _test_cls_triangulation_3(const Triangulation &) // Assignment - T1=T0; + T1=T0; assert(T1.dimension() == 3); assert(T1.number_of_vertices() == 4); assert(T1.is_valid()); @@ -304,7 +304,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.number_of_vertices() == 0); assert(T0.is_valid()); T0.swap(T1); - + assert(T0.dimension() == 3); assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); @@ -344,13 +344,13 @@ _test_cls_triangulation_3(const Triangulation &) assert(T1_2.is_valid()); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T1_2, "Test6_triangulation_IO_3"); } std::cout << " Constructor9 " << std::endl; - // 2-dimensional triangulations + // 2-dimensional triangulations Cls T2_0; v0=T2_0.insert(p1); @@ -381,7 +381,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T2_0.number_of_vertices()==8); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T2_0, "Test7_triangulation_IO_3"); } @@ -396,8 +396,8 @@ _test_cls_triangulation_3(const Triangulation &) for (m=0; m<20; m++) for (n=0; n<20; n++) { - qq[m+20*n] = Point(m*px+(int)n*qx, m*py+(int)n*qy, 1); - T2_1.insert( qq[m+20*n] ); + qq[m+20*n] = Point(m*px+(int)n*qx, m*py+(int)n*qy, 1); + T2_1.insert( qq[m+20*n] ); } assert( T2_1.number_of_vertices() == m*n ); assert( T2_1.dimension()==2 ); @@ -411,11 +411,11 @@ _test_cls_triangulation_3(const Triangulation &) Point r[225]; for (z=0 ; z<5 ; z++) for (y=0 ; y<5 ; y++) - for (x=0 ; x<5 ; x++) - { - r[x+5*y+25*z] = Point(x,y,z); - v0=T3_0.insert(r[x+5*y+25*z]); - } + for (x=0 ; x<5 ; x++) + { + r[x+5*y+25*z] = Point(x,y,z); + v0=T3_0.insert(r[x+5*y+25*z]); + } assert(T3_0.is_valid()); assert(T3_0.number_of_vertices()==125); assert(T3_0.dimension()==3); @@ -430,7 +430,7 @@ _test_cls_triangulation_3(const Triangulation &) assert(T3_1.dimension()==3); if (! del) // to avoid doing the following tests for both Delaunay - // and non Delaunay triangulations + // and non Delaunay triangulations { _test_cls_triangulation_3_input_output(T3_1, "Test8_triangulation_IO_3"); } @@ -470,19 +470,19 @@ _test_cls_triangulation_3(const Triangulation &) else if (count < 100) std::cout << count << '\b' << '\b' ; - else + else if (count < 1000) std::cout << count << '\b' << '\b' << '\b' ; else - std::cout << count << std::endl; + std::cout << count << std::endl; std::cout.flush(); } std::cout << std::endl; assert(T3_2.is_valid()); assert(T3_2.dimension()==3); assert(T3_2.number_of_vertices()==500); - - + + Point p110(-5,5,0), p111(-2,-5,2), p112(-2,-9,6), p113(4,8,9), p114(5,-6,0), p115(3,0,5), p116(-9,0,-10), p117(1,6,-2), p118(-3,2,-4), p119(3,-3,-1); @@ -497,7 +497,7 @@ _test_cls_triangulation_3(const Triangulation &) v0=T3_5.insert(p117); v0=T3_5.insert(p118, v0->cell()); // testing with the hint v0=T3_5.insert(p119, v0); // testing with the hint - + assert(T3_5.is_valid()); assert(T3_5.number_of_vertices()==10); @@ -519,18 +519,18 @@ _test_cls_triangulation_3(const Triangulation &) // bool success(true); // if (del) { // std::cout << " deletion in a Delaunay of " -// << T3_4.number_of_vertices() << " random points"; +// << T3_4.number_of_vertices() << " random points"; // Vertex_handle v; // while ( T3_4.number_of_vertices() >= 1 ) { // if ( T3_4.dimension() > 1 ) -// v = T3_4.infinite_cell()->vertex -// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )&3 ); +// v = T3_4.infinite_cell()->vertex +// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )&3 ); // else -// if ( T3_4.dimension() == 1 ) -// v = T3_4.infinite_cell()->vertex -// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )%2 ); -// else -// v = T3_4.infinite_cell()->neighbor(0)->vertex(0); +// if ( T3_4.dimension() == 1 ) +// v = T3_4.infinite_cell()->vertex +// ( (T3_4.infinite_cell()->index( T3_4.infinite_vertex() ) +1 )%2 ); +// else +// v = T3_4.infinite_cell()->neighbor(0)->vertex(0); // success = T3_4.remove( v ); // } @@ -594,10 +594,10 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.dimension() == 3); assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); - + c= Ti.locate(Point(50,50,50),lt,li,lj); - + Point p24(50,50,50); v0= Ti.insert_outside_convex_hull(p24,c); assert(Ti.is_valid()); @@ -621,7 +621,7 @@ _test_cls_triangulation_3(const Triangulation &) // ################## Operations + newly created cells ################ // Small test for inserting and returning the newly created cells - // (the code is mainly the usual insert + incident_{edges,facets,cells} + // (the code is mainly the usual insert + incident_{edges,facets,cells} // depending on the dimension) std::cout << " Test insertion + newly created cells: " << std::endl; @@ -630,7 +630,7 @@ _test_cls_triangulation_3(const Triangulation &) // dimension 1 Cls TAI1; for(int i=0; i<50; i++) - { + { double x = (double) (2*i); TAI1.insert(Point(x, x, x)); } @@ -639,9 +639,9 @@ _test_cls_triangulation_3(const Triangulation &) { lis_tai1.clear(); double x = (double) (2*i - 1); - Vertex_handle taiv = + Vertex_handle taiv = TAI1.insert_and_give_new_cells( - Point(x, x, x), + Point(x, x, x), std::back_inserter(lis_tai1)); CGAL_USE(taiv); assert(TAI1.is_valid()); @@ -652,16 +652,16 @@ _test_cls_triangulation_3(const Triangulation &) Cell_handle c = lis_tai1.front(); lis_tai1.pop_front(); assert(TAI1.tds().is_simplex(c)); - } + } } TAI1.clear(); - std::cout << " 2 dimensions" << std::endl; + std::cout << " 2 dimensions" << std::endl; CGAL::Random grand; for(int i=0; i<50; i++) - { + { double x = grand.get_double(); - double y = grand.get_double(); + double y = grand.get_double(); TAI1.insert(Point(x, y, 0)); } for(int i=0; i<50; i++) @@ -669,9 +669,9 @@ _test_cls_triangulation_3(const Triangulation &) lis_tai1.clear(); double x = grand.get_double(); double y = grand.get_double(); - Vertex_handle taiv = + Vertex_handle taiv = TAI1.insert_and_give_new_cells( - Point(x, y, 0), + Point(x, y, 0), std::back_inserter(lis_tai1)); CGAL_USE(taiv); assert(TAI1.is_valid()); @@ -681,16 +681,16 @@ _test_cls_triangulation_3(const Triangulation &) Cell_handle c = lis_tai1.front(); lis_tai1.pop_front(); assert(TAI1.tds().is_simplex(c)); - } - } + } + } TAI1.clear(); - std::cout << " 3 dimensions" << std::endl; + std::cout << " 3 dimensions" << std::endl; for(int i=0; i<50; i++) - { + { double x = grand.get_double(); - double y = grand.get_double(); - double z = grand.get_double(); + double y = grand.get_double(); + double z = grand.get_double(); TAI1.insert(Point(x, y, z)); } for(int i=0; i<50; i++) @@ -698,10 +698,10 @@ _test_cls_triangulation_3(const Triangulation &) lis_tai1.clear(); double x = grand.get_double(); double y = grand.get_double(); - double z = grand.get_double(); - Vertex_handle taiv = + double z = grand.get_double(); + Vertex_handle taiv = TAI1.insert_and_give_new_cells( - Point(x, y, z), + Point(x, y, z), std::back_inserter(lis_tai1)); CGAL_USE(taiv); assert(TAI1.is_valid()); @@ -711,20 +711,20 @@ _test_cls_triangulation_3(const Triangulation &) Cell_handle c = lis_tai1.front(); lis_tai1.pop_front(); assert(TAI1.tds().is_simplex(c)); - } - } - TAI1.clear(); + } + } + TAI1.clear(); // the other two insertion methods is exactly the same // with different version of the basic insert method // Vertex_handle insert_and_give_new_cells(const Point& p, // OutputItCells fit, - // Vertex_handle hint) + // Vertex_handle hint) // Vertex_handle insert_and_give_new_cells(const Point& p, - // Locate_type lt, Cell_handle c, int li, int lj, + // Locate_type lt, Cell_handle c, int li, int lj, // OutputItCells fit - - + + // ################################################################## @@ -734,9 +734,9 @@ _test_cls_triangulation_3(const Triangulation &) c=T0.infinite_cell(); assert(T0.is_infinite(c)); int ind=c->index(T0.infinite_vertex()); - - Facet f ; - for (i=0;i<4;i++) + + Facet f ; + for (i=0;i<4;i++) if (i!=ind) { assert(T0.is_infinite(c,i)); f=Facet(c,i); @@ -744,11 +744,11 @@ _test_cls_triangulation_3(const Triangulation &) } int j; - for (i=0;i<4;i++) - for (j=0;i<4;i++) + for (i=0;i<4;i++) + for (j=0;i<4;i++) if ((i!=j) && ((i==ind) || (j==ind))) { - assert(T0.is_infinite(c,i,j)); - assert(T0.is_infinite(Edge(c,i,j))); + assert(T0.is_infinite(c,i,j)); + assert(T0.is_infinite(Edge(c,i,j))); } @@ -768,9 +768,9 @@ _test_cls_triangulation_3(const Triangulation &) assert(d->vertex(j) == T0.mirror_vertex(c,i)); assert(Facet(d,j) == T0.mirror_facet(Facet(c,i))); } - - - + + + // geometric functions std::cout << "Geometric functions " << std::endl; c= T0.locate(Point(50,0,1),lt,li,lj); @@ -796,7 +796,7 @@ _test_cls_triangulation_3(const Triangulation &) c= T0.locate(Point(20,0,2),lt,li,lj); Point pt3 = c->vertex(0)->point(); assert(pt2==pt3); - + if (! del) { // Delaunay should not be flipped // or it will not be Delaunay any longer --> not valid std::cout << " Test flip " << std::endl; @@ -812,15 +812,15 @@ _test_cls_triangulation_3(const Triangulation &) flipped = false; i=0; j=1; next_cell = ++cit; --cit; while ( (! flipped) && (i<4) ) { - if ( (i!=j) ) { - flipped = T3_1.flip( cit, i, j ) ; - if (flipped) { - nbflips++; - assert(T3_1.is_valid()); - } - } - if ( j==3 ) { i++; j=0; } - else j++; + if ( (i!=j) ) { + flipped = T3_1.flip( cit, i, j ) ; + if (flipped) { + nbflips++; + assert(T3_1.is_valid()); + } + } + if ( j==3 ) { i++; j=0; } + else j++; } cit = next_cell; } @@ -831,22 +831,22 @@ _test_cls_triangulation_3(const Triangulation &) // NOTE : the triangulation is modified during loop // --> the cell_iterator does not mean a lot for ( i=0; i<4; i++ ) { - flipped = T3_1.flip( cit, i ); - if (flipped) { - nbflips++; - assert(T3_1.is_valid()); - } + flipped = T3_1.flip( cit, i ); + if (flipped) { + nbflips++; + assert(T3_1.is_valid()); + } } } std::cout << nbflips << " flips 2-3" << std::endl; } - + // Finite incident_* in dimension 2 test std::cout << " Testing finite_incident_* in dim 2 "<< std::endl; Cls* T2[2]; T2[0] = &T2_0; T2[1] = &T2_1; - + for(int k = 0; k < 2; ++k) { std::cout << " with triangulation " << k + 1 << ": "; @@ -860,13 +860,13 @@ _test_cls_triangulation_3(const Triangulation &) f_edges.clear(); f_facets.clear(); f_cells.clear(); - + for(Finite_vertices_iterator i = T2[k]->finite_vertices_begin(); - i != T2[k]->finite_vertices_end(); ++i) { + i != T2[k]->finite_vertices_end(); ++i) { // old name (up to CGAL 3.4) // kept for backwards compatibility but not documented T2[k]->finite_incident_vertices(i, std::back_inserter(f_vertices_old)); - // correct name + // correct name T2[k]->finite_adjacent_vertices(i, std::back_inserter(f_vertices)); assert(check_all_are_finite(T2[k], f_vertices)); T2[k]->finite_incident_edges(i, std::back_inserter(f_edges)); @@ -896,14 +896,14 @@ _test_cls_triangulation_3(const Triangulation &) assert(2*nb_f_edges == f_edges.size()); assert(3*nb_f_facets == f_facets.size()); assert(3*nb_f_facets == f_cells.size()); - + typename Cls::size_type nb_f_vertices = T2[k]->number_of_vertices(); - + // Euler relation assert(nb_f_vertices - nb_f_edges + nb_f_facets == 1); std::cout << "ok\n"; } - + // Finite incident_* to vertex test std::cout << " Testing finite_incident_* in dim 3 "<< std::endl; @@ -928,13 +928,13 @@ _test_cls_triangulation_3(const Triangulation &) f_edges.clear(); f_facets.clear(); f_cells.clear(); - + for(Finite_vertices_iterator i = T3[k]->finite_vertices_begin(); - i != T3[k]->finite_vertices_end(); ++i) { + i != T3[k]->finite_vertices_end(); ++i) { // old name (up to CGAL 3.4) // kept for backwards compatibility but not documented T3[k]->finite_incident_vertices(i, std::back_inserter(f_vertices_old)); - // correct name + // correct name T3[k]->finite_adjacent_vertices(i, std::back_inserter(f_vertices)); assert(check_all_are_finite(T3[k], f_vertices)); T3[k]->finite_incident_edges(i, std::back_inserter(f_edges)); @@ -963,16 +963,16 @@ _test_cls_triangulation_3(const Triangulation &) ++nb_f_cells; ++fcit; } - + // incidences assert(f_edges.size() == f_vertices_old.size()); assert(f_edges.size() == f_vertices.size()); assert(2*nb_f_edges == f_edges.size()); assert(3*nb_f_facets == f_facets.size()); assert(4*nb_f_cells == f_cells.size()); - + typename Cls::size_type nb_f_vertices = T3[k]->number_of_vertices(); - + // Euler relation assert(nb_f_vertices - nb_f_edges + nb_f_facets - nb_f_cells == 1); std::cout << "ok\n"; @@ -995,11 +995,11 @@ _test_cls_triangulation_3(const Triangulation &) _test_vertex_iterator(T3_1); _test_triangulation_iterator(T3_1); _test_vertex_iterator(T3_0); - _test_triangulation_iterator(T3_0); - _test_vertex_iterator(T3_2); - _test_triangulation_iterator(T3_2); + _test_triangulation_iterator(T3_0); + _test_vertex_iterator(T3_2); + _test_triangulation_iterator(T3_2); _test_vertex_iterator(T3_3); - _test_triangulation_iterator(T3_3); + _test_triangulation_iterator(T3_3); std::cout << " Testing Circulator "<< std::endl; _test_circulator(T0); From 319383c9631b1418be20ac0998b290b401318778 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 20 May 2020 09:47:58 +0200 Subject: [PATCH 23/24] Revert "Merge pull request #4519 from lrineau/Kernel_23-Epeck_objects_in_Compact_container-lrineau_gdamiand" This reverts commit bcab082f8272a45d68a3bdf09fed7c053f0bcaf1, reversing changes made to 2d3e126450991ab7a42d067d30f613b883d6802e. --- .../CGAL/Arr_point_location/Td_X_trapezoid.h | 10 ++-- .../CGAL/Arr_point_location/Td_active_edge.h | 8 ++-- .../Td_active_fictitious_vertex.h | 8 ++-- .../Arr_point_location/Td_active_trapezoid.h | 8 ++-- .../Arr_point_location/Td_active_vertex.h | 8 ++-- .../include/CGAL/Arr_point_location/Td_dag.h | 18 +++---- .../CGAL/Arr_point_location/Td_dag_node.h | 18 +++---- .../Arr_point_location/Td_inactive_edge.h | 6 +-- .../Td_inactive_fictitious_vertex.h | 6 +-- .../Arr_point_location/Td_inactive_vertex.h | 6 +-- .../include/CGAL/IO/Tee_for_output_iterator.h | 4 +- Filtered_kernel/include/CGAL/Lazy.h | 8 ++-- STL_Extension/include/CGAL/Handle.h | 48 ++++++++----------- 13 files changed, 75 insertions(+), 81 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_X_trapezoid.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_X_trapezoid.h index a52f91db9d2..e7202ffe935 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_X_trapezoid.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_X_trapezoid.h @@ -142,7 +142,7 @@ public: private: - Trpz_parameter_space* ptr() const { return (Trpz_parameter_space*)(PTR.p); } + Trpz_parameter_space* ptr() const { return (Trpz_parameter_space*)(PTR); } #ifndef CGAL_TD_DEBUG @@ -323,7 +323,7 @@ public: { //define the initial trapezoid: left, right, btm, top are at infinity. // its type is TD_TRAPEZOID ,it is on all boundaries, and has no neighbours - PTR.p = new Trpz_parameter_space + PTR = new Trpz_parameter_space (Traits::vtx_at_left_infinity(), Traits::vtx_at_right_infinity(), Traits::he_at_bottom_infinity(), @@ -353,7 +353,7 @@ public: else //tp == TD_VERTEX type_flag |= CGAL_TD_VERTEX; - PTR.p = new Trpz_parameter_space + PTR = new Trpz_parameter_space (l, r, b, t, type_flag | boundness_flag, lb, lt, rb, rt); m_dag_node = node; } @@ -370,7 +370,7 @@ public: Self* rb = 0, Self* rt = 0, Dag_node* node = 0) { - PTR.p = new Trpz_parameter_space + PTR = new Trpz_parameter_space (l ? *l : Traits::vtx_at_left_infinity(), r ? *r : Traits::vtx_at_right_infinity(), b ? *b : Traits::he_at_bottom_infinity(), @@ -436,7 +436,7 @@ public: /*! Access the trapezoid id (PTR). */ CGAL_TD_INLINE unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } /*! Access trapezoid left. */ diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_edge.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_edge.h index 2cdeee6bca5..61259f33547 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_edge.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_edge.h @@ -135,7 +135,7 @@ public: private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } #ifndef CGAL_TD_DEBUG @@ -194,7 +194,7 @@ public: Td_active_edge () { - PTR.p = new Data + PTR = new Data (Traits::empty_he_handle(), Td_map_item(0), nullptr); //m_dag_node = nullptr; } @@ -204,7 +204,7 @@ public: boost::optional next = boost::none) { - PTR.p = new Data(he, (next) ? *next : Td_map_item(0), node); + PTR = new Data(he, (next) ? *next : Td_map_item(0), node); //m_dag_node = node; } @@ -261,7 +261,7 @@ public: /*! Access the trapezoid id (PTR). */ CGAL_TD_INLINE unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_fictitious_vertex.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_fictitious_vertex.h index 6bfb3d5e6f2..b75de1b9d97 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_fictitious_vertex.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_fictitious_vertex.h @@ -129,7 +129,7 @@ public: }; private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } Curve_end vtx_to_ce(Vertex_const_handle v) const { @@ -180,14 +180,14 @@ public: Td_active_fictitious_vertex() { - PTR.p = new Data(Traits::empty_vtx_handle(), Traits::empty_he_handle(), nullptr); + PTR = new Data(Traits::empty_vtx_handle(), Traits::empty_he_handle(), nullptr); } /*! Constructor given Vertex & Halfedge handles. */ Td_active_fictitious_vertex(Vertex_const_handle v, Halfedge_const_handle cw_he, Dag_node* node = 0) - { PTR.p = new Data(v, cw_he, node); } + { PTR = new Data(v, cw_he, node); } /*! Copy constructor. */ @@ -224,7 +224,7 @@ public: inline const Self& self() const { return *this; } /*! Access the trapezoid id (PTR). */ - inline unsigned long id() const { return (unsigned long) PTR.p; } + inline unsigned long id() const { return (unsigned long) PTR; } /*! Access trapezoid left. * filters out the infinite case which returns predefined dummy values diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_trapezoid.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_trapezoid.h index 2b565adba74..8b92b739626 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_trapezoid.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_trapezoid.h @@ -144,7 +144,7 @@ public: private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } public: @@ -255,7 +255,7 @@ private: { //define the initial trapezoid: left, right, btm, top are at infinity. // has no neighbours - PTR.p = new Data + PTR = new Data (Traits::empty_vtx_handle(), Traits::empty_vtx_handle(), Traits::empty_he_handle(), @@ -274,7 +274,7 @@ private: boost::optional rt = boost::none, Dag_node* node = 0) { - PTR.p = new Data (l, r, b, t, (lb) ? *lb : Td_map_item(0), (lt) ? *lt : Td_map_item(0), + PTR = new Data (l, r, b, t, (lb) ? *lb : Td_map_item(0), (lt) ? *lt : Td_map_item(0), (rb) ? *rb : Td_map_item(0), (rt) ? *rt : Td_map_item(0), node); //m_dag_node = node; } @@ -332,7 +332,7 @@ private: /*! Access the trapezoid id (PTR). */ inline unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } /*! Access trapezoid left. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_vertex.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_vertex.h index de4000ebfd9..3b3e86aa0c6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_vertex.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_active_vertex.h @@ -134,7 +134,7 @@ public: }; private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } Curve_end vtx_to_ce(Vertex_const_handle v) const { @@ -184,14 +184,14 @@ public: Td_active_vertex() { - PTR.p = new Data(Traits::empty_vtx_handle(), Traits::empty_he_handle(), nullptr); + PTR = new Data(Traits::empty_vtx_handle(), Traits::empty_he_handle(), nullptr); } /*! Constructor given Vertex & Halfedge handles. */ Td_active_vertex(Vertex_const_handle v, Halfedge_const_handle cw_he, Dag_node* node = 0) - { PTR.p = new Data(v, cw_he, node); } + { PTR = new Data(v, cw_he, node); } /*! Copy constructor. */ @@ -228,7 +228,7 @@ public: inline const Self& self() const { return *this; } /*! Access the trapezoid id (PTR). */ - inline unsigned long id() const { return (unsigned long) PTR.p; } + inline unsigned long id() const { return (unsigned long) PTR; } inline Vertex_const_handle vertex() const { return ptr()->v; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag.h index e5eee91e724..f8a47536c85 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag.h @@ -41,14 +41,14 @@ public: //iddo (for CC-7.2) maybe protected? typedef const T & const_reference; protected: - void init() { PTR.p = 0; } + void init() { PTR = 0; } public: Td_dag_base() {init();} Td_dag_base(const Td_dag_base & x) : Handle(x) {} Td_dag_base & operator=(const Td_dag_base & x) {Handle::operator=(x); return *this; } - bool operator!() const { return PTR.p == 0; } + bool operator!() const { return PTR == 0; } }; template @@ -96,9 +96,9 @@ public: Td_dag(){} Td_dag(const Td_dag_handle& dag):Td_dag_handle(dag){} Td_dag(const Self& dag):Td_dag_handle(dag){} - Td_dag(const T& rootValue){PTR.p = new node(rootValue);} + Td_dag(const T& rootValue){PTR = new node(rootValue);} Td_dag(const T& rootValue, const Self& left, const Self& right) - {PTR.p = new node(rootValue, left, right); rebalance_depth();} + {PTR = new node(rootValue, left, right); rebalance_depth();} ~Td_dag(){} /* --------information retrieval -------*/ @@ -145,7 +145,7 @@ public: } bool operator==(const Self& b) const { - return PTR.p==b.PTR.p; + return PTR==b.PTR; } bool operator!=(const Self& b) const { @@ -189,7 +189,7 @@ public: // detach left son,redirect to dummy set_left(dummy); // set left son pointer to 0 - ptr()->leftPtr.PTR.p=0; + ptr()->leftPtr.PTR=0; // delete dummy Td_dag delete dummy.ptr(); } @@ -204,7 +204,7 @@ public: // detach right son,redirect to dummy set_right(dummy); // set right son pointer to 0 - ptr()->rightPtr.PTR.p=0; + ptr()->rightPtr.PTR=0; // delete dummy Td_dag delete dummy.ptr(); } @@ -371,7 +371,7 @@ protected: } #endif private: - node* ptr() const {return (node*)PTR.p;} + node* ptr() const {return (node*)PTR;} }; template @@ -441,7 +441,7 @@ template std::ostream& operator<<(std::ostream& out, tech notes: The code is Handle designed. left(),right() are designed to cope with Handle(Handle& x) - precondition x.PTR.p!=0 + precondition x.PTR!=0 operator=() performs shallow copy operator*() returns data type output is done as a binary tree. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag_node.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag_node.h index bbf45831519..ec4a961d8f1 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag_node.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_dag_node.h @@ -39,7 +39,7 @@ template class Td_dag_node_base : public Handle { protected: - void init() { PTR.p = 0; } //MICHAL: I think it is not used - so need to be removed + void init() { PTR = 0; } //MICHAL: I think it is not used - so need to be removed public: //c'tors @@ -57,12 +57,12 @@ public: return *this; } - //bool operator!() const { return PTR.p == 0; } //MICHAL: maybe use ptr(), and also can change to is_null or something similar - bool is_null() const { return PTR.p == 0; } - Rep * ptr() const { return (Rep*) PTR.p; } + //bool operator!() const { return PTR == 0; } //MICHAL: maybe use ptr(), and also can change to is_null or something similar + bool is_null() const { return PTR == 0; } + Rep * ptr() const { return (Rep*) PTR; } protected: - //Rep *& ptr() { return (Rep*) PTR.p; } - void set_ptr(Rep* rep) { PTR.p = rep; } + //Rep *& ptr() { return (Rep*) PTR; } + void set_ptr(Rep* rep) { PTR = rep; } }; @@ -94,7 +94,7 @@ public: #ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 public: - //using Td_dag_node_handle::PTR.p; + //using Td_dag_node_handle::PTR; //using Td_dag_node_handle::operator!; #endif //CGAL_CFG_USING_BASE_MEMBER_BUG_2 @@ -549,7 +549,7 @@ protected: private: - Node* node() const { return (Node*)Base::PTR.p; } + Node* node() const { return (Node*)Base::PTR; } }; @@ -629,7 +629,7 @@ std::ostream& operator<< (std::ostream& out, tech notes: The code is Handle designed. left_child(),right_child() are designed to cope with Handle(Handle& x) - precondition x.PTR.p!=0 + precondition x.PTR!=0 operator=() performs shallow copy operator*() returns data type output is done as a binary tree. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_edge.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_edge.h index 0d85f93f148..bb57f7c6d1c 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_edge.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_edge.h @@ -128,7 +128,7 @@ public: private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } #ifndef CGAL_TD_DEBUG @@ -161,7 +161,7 @@ public: /*! Constructor given Vertex & Halfedge handles. */ Td_inactive_edge (boost::shared_ptr& cv, Dag_node* node = nullptr) { - PTR.p = new Data(cv,node); + PTR = new Data(cv,node); } /*! Copy constructor. */ @@ -215,7 +215,7 @@ public: /*! Access the trapezoid id (PTR). */ inline unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } inline X_monotone_curve_2& curve() const diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_fictitious_vertex.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_fictitious_vertex.h index cf2d75d79ec..03ca8d563c7 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_fictitious_vertex.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_fictitious_vertex.h @@ -133,7 +133,7 @@ public: private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } Curve_end vtx_to_ce(Vertex_const_handle v) const { @@ -185,7 +185,7 @@ public: { Curve_end v_ce(vtx_to_ce(v_before_rem)); - PTR.p = new Data( v_ce.cv(), v_ce.ce(), node); + PTR = new Data( v_ce.cv(), v_ce.ce(), node); } @@ -241,7 +241,7 @@ public: /*! Access the trapezoid id (PTR). */ inline unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_vertex.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_vertex.h index 0c42b1e7669..409a6f576ee 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_vertex.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Td_inactive_vertex.h @@ -127,7 +127,7 @@ public: private: - Data* ptr() const { return (Data*)(PTR.p); } + Data* ptr() const { return (Data*)(PTR); } #ifndef CGAL_TD_DEBUG @@ -162,7 +162,7 @@ public: /*! Constructor given Vertex & Halfedge handles. */ Td_inactive_vertex (Vertex_const_handle v_before_rem, Dag_node* node = nullptr) { - PTR.p = new Data(v_before_rem->point(), node); + PTR = new Data(v_before_rem->point(), node); } @@ -217,7 +217,7 @@ public: /*! Access the trapezoid id (PTR). */ inline unsigned long id() const { - return (unsigned long) PTR.p; + return (unsigned long) PTR; } inline Point& point() const diff --git a/Convex_hull_2/include/CGAL/IO/Tee_for_output_iterator.h b/Convex_hull_2/include/CGAL/IO/Tee_for_output_iterator.h index 3a298f6b6c0..26aee3bba75 100644 --- a/Convex_hull_2/include/CGAL/IO/Tee_for_output_iterator.h +++ b/Convex_hull_2/include/CGAL/IO/Tee_for_output_iterator.h @@ -39,7 +39,7 @@ class Tee_for_output_iterator public: Tee_for_output_iterator(const OutputIterator& o) : o_it(o) - { PTR.p = (Rep*) new _Tee_for_output_iterator_rep(); } + { PTR = (Rep*) new _Tee_for_output_iterator_rep(); } Tee_for_output_iterator& operator=(const T& value) @@ -82,7 +82,7 @@ public: _Tee_for_output_iterator_rep* ptr() - { return (_Tee_for_output_iterator_rep*)(PTR.p); } + { return (_Tee_for_output_iterator_rep*)PTR; } protected: OutputIterator o_it; diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index df94fc2de19..067fbe57463 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -718,17 +718,17 @@ public : Lazy(Self_rep *r) { - PTR.p = r; + PTR = r; } Lazy(const ET& e) { - PTR.p = new Lazy_rep_0(e); + PTR = new Lazy_rep_0(e); } Lazy(ET&& e) { - PTR.p = new Lazy_rep_0(std::move(e)); + PTR = new Lazy_rep_0(std::move(e)); } friend void swap(Lazy& a, Lazy& b) noexcept @@ -768,7 +768,7 @@ public : return z; } - Self_rep * ptr() const { return (Self_rep*) PTR.p; } + Self_rep * ptr() const { return (Self_rep*) PTR; } }; // The magic functor for Construct_bbox_[2,3], as there is no Lazy diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index ca3366524cb..af5297ae2e5 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -40,31 +40,31 @@ class Handle typedef std::ptrdiff_t Id_type ; Handle() noexcept - : PTR{static_cast(0)} {} + : PTR(static_cast(0)) {} // FIXME: if the precondition throws in a noexcept function, the program terminates Handle(const Handle& x) noexcept { - CGAL_precondition( x.PTR.p != static_cast(0) ); - PTR.p = x.PTR.p; - CGAL_assume (PTR.p->count > 0); - PTR.p->count++; + CGAL_precondition( x.PTR != static_cast(0) ); + PTR = x.PTR; + CGAL_assume (PTR->count > 0); + PTR->count++; } ~Handle() { - if ( PTR.p && (--PTR.p->count == 0)) - delete PTR.p; + if ( PTR && (--PTR->count == 0)) + delete PTR; } Handle& operator=(const Handle& x) noexcept { - CGAL_precondition( x.PTR.p != static_cast(0) ); - x.PTR.p->count++; - if ( PTR.p && (--PTR.p->count == 0)) - delete PTR.p; - PTR.p = x.PTR.p; + CGAL_precondition( x.PTR != static_cast(0) ); + x.PTR->count++; + if ( PTR && (--PTR->count == 0)) + delete PTR; + PTR = x.PTR; return *this; } @@ -72,29 +72,23 @@ class Handle void reset() { - if (PTR.p) + if (PTR) { - if (--PTR.p->count==0) - delete PTR.p; - PTR.p=0; + if (--PTR->count==0) + delete PTR; + PTR=0; } } - int refs() const noexcept { return PTR.p->count; } + int + refs() const noexcept { return PTR->count; } - Id_type id() const noexcept { return PTR.p - static_cast(0); } + Id_type id() const noexcept { return PTR - static_cast(0); } - bool identical(const Handle& h) const noexcept { return PTR.p == h.PTR.p; } - - void* for_compact_container() const { return PTR.vp; } - void*& for_compact_container() { return PTR.vp; } + bool identical(const Handle& h) const noexcept { return PTR == h.PTR; } protected: - - union { - Rep* p; - void* vp; - } PTR; + Rep* PTR; }; //inline Handle::Id_type id(const Handle& x) { return x.id() ; } From 8b474ddf59f5a9872969baafbd3cc0da86d8fd6a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 20 May 2020 10:32:03 +0200 Subject: [PATCH 24/24] Re-add the use of Lazy objects in Compact_container --- STL_Extension/include/CGAL/Handle.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index af5297ae2e5..0d652ccb4cb 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -87,6 +87,8 @@ class Handle bool identical(const Handle& h) const noexcept { return PTR == h.PTR; } + void * for_compact_container() const { return PTR; } + void for_compact_container(void* p) { PTR = static_cast(p); } protected: Rep* PTR; };