diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 58254547e33..2d0d651a023 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -85,22 +85,22 @@ namespace CGAL { public Add_id { template - friend class Combinatorial_map_storage_1; + friend class CGAL::Combinatorial_map_storage_1; template - friend class Generalized_map_storage_1; + friend class CGAL::Generalized_map_storage_1; template - friend class CMap_linear_cell_complex_storage_1; + friend class CGAL::CMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_1; + friend class CGAL::GMap_linear_cell_complex_storage_1; template - friend class Compact_container; + friend class CGAL::Compact_container; template - friend class Concurrent_compact_container; + friend class CGAL::Concurrent_compact_container; template friend struct internal::Init_id; @@ -195,22 +195,22 @@ namespace CGAL { OnMerge, OnSplit, WithID>: public Add_id { template - friend class Combinatorial_map_storage_1; + friend class CGAL::Combinatorial_map_storage_1; template - friend class Generalized_map_storage_1; + friend class CGAL::Generalized_map_storage_1; template - friend class CMap_linear_cell_complex_storage_1; + friend class CGAL::CMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_1; + friend class CGAL::GMap_linear_cell_complex_storage_1; template - friend class Compact_container; + friend class CGAL::Compact_container; template - friend class Concurrent_compact_container; + friend class CGAL::Concurrent_compact_container; template friend struct internal::Init_id; @@ -311,22 +311,22 @@ namespace CGAL { public Cell_attribute_without_info { template - friend class Combinatorial_map_storage_1; + friend class CGAL::Combinatorial_map_storage_1; template - friend class Generalized_map_storage_1; + friend class CGAL::Generalized_map_storage_1; template - friend class CMap_linear_cell_complex_storage_1; + friend class CGAL::CMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_1; + friend class CGAL::GMap_linear_cell_complex_storage_1; template - friend class Compact_container; + friend class CGAL::Compact_container; template - friend class Concurrent_compact_container; + friend class CGAL::Concurrent_compact_container; public: typedef Tag_ Supports_cell_dart; @@ -351,22 +351,22 @@ namespace CGAL { public Info_for_cell_attribute { template - friend class Combinatorial_map_storage_1; + friend class CGAL::Combinatorial_map_storage_1; template - friend class Generalized_map_storage_1; + friend class CGAL::Generalized_map_storage_1; template - friend class CMap_linear_cell_complex_storage_1; + friend class CGAL::CMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_1; + friend class CGAL::GMap_linear_cell_complex_storage_1; template - friend class Compact_container; + friend class CGAL::Compact_container; template - friend class Concurrent_compact_container; + friend class CGAL::Concurrent_compact_container; public: typedef Cell_attribute Self; diff --git a/Combinatorial_map/include/CGAL/Cell_attribute_with_index.h b/Combinatorial_map/include/CGAL/Cell_attribute_with_index.h index 2489aeab7c1..84f40b6f380 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute_with_index.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute_with_index.h @@ -25,6 +25,15 @@ namespace CGAL { template class Combinatorial_map_storage_2; + template + class Generalized_map_storage_2; + + template + class CMap_linear_cell_complex_storage_2; + + template + class GMap_linear_cell_complex_storage_2; + namespace Index { // Versions to use with containers using index @@ -38,11 +47,20 @@ namespace CGAL { class Cell_attribute_without_info { + template + friend class CGAL::Compact_container_with_index_2; + template friend class CGAL::Combinatorial_map_storage_2; - template - friend class CGAL::Compact_container_with_index_2; + template + friend class CGAL::Generalized_map_storage_2; + + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; public: typedef Tag_false Supports_cell_dart; @@ -83,7 +101,7 @@ namespace CGAL { bool operator!=(const Cell_attribute_without_info& other) const { return !operator==(other); } - // protected: + protected: /// Contructor without parameter. Cell_attribute_without_info(): mrefcounting(0) {} @@ -130,11 +148,20 @@ namespace CGAL { class Cell_attribute_without_info { + template + friend class CGAL::Compact_container_with_index_2; + template friend class CGAL::Combinatorial_map_storage_2; - template - friend class CGAL::Compact_container_with_index; + template + friend class CGAL::Generalized_map_storage_2; + + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; public: typedef Tag_true Supports_cell_dart; @@ -166,7 +193,7 @@ namespace CGAL { void set_dart(Dart_handle adart) { mdart = adart; } /// Test if the cell is valid. - /// A cell is valid if its dart is not NULL. + /// A cell is valid if its dart is not null_handle. bool is_valid() const { return mdart!=Refs::null_handle; } @@ -212,11 +239,11 @@ namespace CGAL { { return mdart.for_compact_container_with_index(); } private: - /// Reference counting: the number of darts linked to this cell. - std::size_t mrefcounting; - /// The dart handle associated with the cell. Dart_handle mdart; + + /// Reference counting: the number of darts linked to this cell. + std::size_t mrefcounting; }; /// Cell associated with an attribute, with or without info depending @@ -234,12 +261,21 @@ namespace CGAL { public Cell_attribute_without_info { - template < unsigned int, class, class, class, class > - friend class CGAL::Combinatorial_map_base; - template friend class CGAL::Compact_container_with_index_2; + template + friend class CGAL::Combinatorial_map_storage_2; + + template + friend class CGAL::Generalized_map_storage_2; + + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; + public: typedef Tag_ Supports_cell_dart; typedef typename Refs::Dart_handle Dart_handle; @@ -249,7 +285,7 @@ namespace CGAL { typedef OnSplit On_split; typedef void Info; - // protected: + protected: /// Default contructor. Cell_attribute() {} @@ -263,12 +299,21 @@ namespace CGAL { OnMerge, OnSplit>, public CGAL::Info_for_cell_attribute { - template < unsigned int, class, class, class, class > - friend class CGAL::Combinatorial_map_base; - template friend class CGAL::Compact_container_with_index_2; + template + friend class CGAL::Combinatorial_map_storage_2; + + template + friend class CGAL::Generalized_map_storage_2; + + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; + public: typedef Cell_attribute Self; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index c13684894fb..c1d77c5ea71 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -34,9 +34,6 @@ namespace CGAL { struct Container_type; } - /** @file Combinatorial_map_storages.h - * Definition of storages for dD Combinatorial map. - */ // Storage of darts with compact container, beta with handles template class Combinatorial_map_storage_1 diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h index 333363ecb01..41d01115d90 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -31,14 +30,6 @@ namespace CGAL { template struct Container_type; - - struct Index_hash_function { - typedef std::size_t result_type; - template - std::size_t operator() (const H& h) const { - return h; - } - }; } // Storage with combinatorial maps using index @@ -192,6 +183,8 @@ namespace CGAL { CGAL_assertion(i <= dimension); return mdarts[dh].mf[i]==null_dart_handle; } + bool is_perforated(Dart_const_handle /*dh*/) const + { return false; } /// Set simultaneously all the marks of this dart to a given value. void set_dart_marks(Dart_const_handle ADart, @@ -225,24 +218,24 @@ namespace CGAL { // Access to beta maps Dart_handle get_beta(Dart_handle ADart, int B1) { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } Dart_const_handle get_beta(Dart_const_handle ADart, int B1) const { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } template Dart_handle get_beta(Dart_handle ADart) { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } template Dart_const_handle get_beta(Dart_const_handle ADart) const { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } @@ -417,11 +410,11 @@ namespace CGAL { protected: // Set the handle on the i th attribute template - void basic_set_dart_attribute(Dart_handle ADart, + void basic_set_dart_attribute(Dart_handle dh, typename Attribute_handle::type ah) { std::get::value> - (mdarts[ADart].mattribute_handles) = ah; + (mdarts[dh].mattribute_handles) = ah; } /** Link a dart with a given dart for a given dimension. @@ -467,6 +460,9 @@ namespace CGAL { /// Dart container. Dart_container mdarts; Dart_range mdarts_range; + + /// Container for the null_dart_handle: unused; to be compatible with handle version + Dart_container mnull_dart_container; /// Tuple of attributes containers typename Helper::Attribute_containers mattribute_containers; diff --git a/Combinatorial_map/include/CGAL/Compact_container_with_index_2.h b/Combinatorial_map/include/CGAL/Compact_container_with_index_2.h index fc65a712a80..064904b538e 100644 --- a/Combinatorial_map/include/CGAL/Compact_container_with_index_2.h +++ b/Combinatorial_map/include/CGAL/Compact_container_with_index_2.h @@ -71,6 +71,17 @@ namespace CGAL { +namespace internal +{ +struct Index_hash_function { + typedef std::size_t result_type; + template + std::size_t operator() (const H& h) const { + return h; + } +}; +} + template < class T, class Allocator_, class Increment_policy, class IndexType = std::size_t > class Compact_container_with_index_2 @@ -347,6 +358,12 @@ public: return alloc; } + size_type index(const_iterator cit) const + { return static_cast(cit); } + + size_type index(Index idx) const + { return static_cast(idx); } + // Returns whether the iterator "cit" is in the range [begin(), end()]. // Complexity : O(#blocks) = O(sqrt(capacity())). // This function is mostly useful for purposes of efficient debugging at diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 71dccadf745..1dd4898f3f9 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -36,6 +36,9 @@ namespace CGAL { template class CMap_linear_cell_complex_storage_1; + template + class CMap_linear_cell_complex_storage_2; + template class GMap_linear_cell_complex_storage_1; @@ -70,6 +73,9 @@ namespace CGAL { template friend class CMap_linear_cell_complex_storage_1; + template + friend class CMap_linear_cell_complex_storage_2; + template friend class GMap_linear_cell_complex_storage_1; @@ -217,6 +223,9 @@ namespace CGAL { template friend class CMap_linear_cell_complex_storage_1; + template + friend class CMap_linear_cell_complex_storage_2; + template friend class GMap_linear_cell_complex_storage_1; diff --git a/Combinatorial_map/include/CGAL/Dart_with_index.h b/Combinatorial_map/include/CGAL/Dart_with_index.h index e172b417ea9..fb59b254ec7 100644 --- a/Combinatorial_map/include/CGAL/Dart_with_index.h +++ b/Combinatorial_map/include/CGAL/Dart_with_index.h @@ -20,19 +20,40 @@ namespace CGAL { - namespace Index +template +class Compact_container_with_index_2; + +template +class Combinatorial_map_storage_2; + +template +class Generalized_map_storage_2; + +template +class CMap_linear_cell_complex_storage_2; + +template +class GMap_linear_cell_complex_storage_2; + +namespace Index { template struct Dart_without_info { + template + friend class CGAL::Compact_container_with_index_2; + template friend class CGAL::Combinatorial_map_storage_2; - // TODO template - // friend class CGAL::CMap_linear_cell_complex_storage_2; + template + friend class CGAL::Generalized_map_storage_2; - template - friend class CGAL::Compact_container_with_index_2; + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; typedef Dart_without_info Self; typedef typename Refs::Dart_handle Dart_handle; @@ -159,14 +180,20 @@ namespace CGAL { struct Dart : public Dart_without_info { public: + template + friend class CGAL::Compact_container_with_index_2; + template friend class CGAL::Combinatorial_map_storage_2; - /* TODO template - friend class CMap_linear_cell_complex_storage_2; */ + template + friend class CGAL::Generalized_map_storage_2; - template - friend class CGAL::Compact_container_with_index_2; + template + friend class CGAL::CMap_linear_cell_complex_storage_2; + + template + friend class CGAL::GMap_linear_cell_complex_storage_2; typedef Dart Self; typedef Info_ Info; diff --git a/Generalized_map/include/CGAL/Generalized_map.h b/Generalized_map/include/CGAL/Generalized_map.h index f8cef4ff7fa..f0b0f8a007e 100644 --- a/Generalized_map/include/CGAL/Generalized_map.h +++ b/Generalized_map/include/CGAL/Generalized_map.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -38,8 +39,6 @@ #include #include -#include - #if defined( __INTEL_COMPILER ) // Workarounf for warning in function basic_link_beta_0 #pragma warning disable 1017 @@ -102,6 +101,8 @@ namespace CGAL { typedef typename Base::Items Items; typedef typename Base::Alloc Alloc; typedef typename Base::Use_index Use_index; + typedef typename Base::Dart_range Dart_range; + typedef typename Base::Dart_const_range Dart_const_range; static const size_type NB_MARKS = Base::NB_MARKS; static const size_type INVALID_MARK = NB_MARKS; @@ -128,10 +129,9 @@ namespace CGAL { using Base::info_of_attribute; using Base::info; using Base::dart; - - /// Typedef for Dart_range, a range through all the darts of the map. - typedef Dart_container Dart_range; - typedef const Dart_container Dart_const_range; + using Base::darts; + using Base::number_of_darts; + using Base::is_empty; /// Typedef for attributes template @@ -262,7 +262,7 @@ namespace CGAL { internal::Copy_dart_info_functor ::run - (static_cast(amap), static_cast(*this), + (static_cast(amap), static_cast(*this), it, new_dart, dartinfoconverter); } } @@ -545,6 +545,7 @@ namespace CGAL { */ void clear() { + this->clear_storage(); mdarts.clear(); for ( size_type i = 0; i < NB_MARKS; ++i) this->mnb_marked_darts[i] = 0; @@ -553,12 +554,6 @@ namespace CGAL { this->init_storage(); } - /** Test if the map is empty. - * @return true iff the map is empty. - */ - bool is_empty() const - { return mdarts.empty(); } - friend std::ostream& operator<< (std::ostream& os, const Self& amap) { save_generalized_map(amap, os); @@ -604,26 +599,43 @@ namespace CGAL { mdarts.erase(adart); } + /** Erase a dart from the list of darts. Restricted version + * which do not delete attribute having no more dart associated. + * @param adart the dart to erase. + */ + void restricted_erase_dart(Dart_handle adart) + { + // 1) We update the number of marked darts. + for ( size_type i = 0; i < mnb_used_marks; ++i) + { + if (is_marked(adart, mused_marks_stack[i])) + --mnb_marked_darts[mused_marks_stack[i]]; + } + + // 2) We update the attribute_ref_counting. + Helper::template Foreach_enabled_attributes + >::run(*this,adart); + + // 3) We erase the dart. + mdarts.erase(adart); + } + /// @return true if dh points to a used dart (i.e. valid). bool is_dart_used(Dart_const_handle dh) const { return mdarts.is_used(dh); } - /// @return a Dart_range (range through all the darts of the map). - Dart_range& darts() { return mdarts;} - Dart_const_range& darts() const { return mdarts; } - /** Get the first dart of this map. * @return the first dart. */ Dart_handle first_dart() { if (darts().begin() == darts().end()) return null_handle; - return mdarts.begin(); + return darts().begin(); } Dart_const_handle first_dart() const { if (darts().begin() == darts().end()) return null_handle; - return mdarts.begin(); + return darts().begin(); } /// @return the Dart_handle corresponding to the given dart. @@ -669,6 +681,31 @@ namespace CGAL { return null_handle; } + // Set the handle on the i th attribute + // Restricted version which do not use delete attributes when their ref + // counting become null, nor that update the dart of attribute. + template + void restricted_set_dart_attribute(Dart_handle dh, + typename Attribute_handle::type ah) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "set_dart_attribute called but i-attributes are disabled."); + + if ( this->template attribute(dh)==ah ) return; + + if ( this->template attribute(dh)!=null_handle ) + { + this->template dec_attribute_ref_counting(this->template attribute(dh)); + } + + Base::template basic_set_dart_attribute(dh, ah); + + if ( ah!=null_handle ) + { + this->template inc_attribute_ref_counting(ah); + } + } + // Set the handle on the i th attribute template void set_dart_attribute(Dart_handle dh, @@ -712,6 +749,8 @@ namespace CGAL { Helper::template Foreach_enabled_attributes >::run(*this, adart); + + internal::Init_id::run(mdarts, adart); } // Initialize a given dart: all alpha to this and all // attributes to null, marks are given. @@ -725,6 +764,8 @@ namespace CGAL { Helper::template Foreach_enabled_attributes >::run(*this, adart); + + internal::Init_id::run(mdarts, adart); } public: @@ -1168,7 +1209,7 @@ namespace CGAL { /** Test if the map is valid. * @return true iff the map is valid. */ - bool is_valid() const + bool is_valid(bool show_errors=true) const { bool valid = true; unsigned int i = 0, j = 0; @@ -1194,9 +1235,11 @@ namespace CGAL { for ( i = 0; i <= dimension; ++i) if (alpha(it, i, i)!=it) { - std::cerr << "Map not valid: alpha(" << i + if (show_errors) + { std::cerr << "Map not valid: alpha(" << i << ") is not an involution for dart " <template init_attribute_ref_counting(res); + internal::Init_id::type>::run + (this->template attributes(), res); return res; } @@ -1757,6 +1800,30 @@ namespace CGAL { else topo_unsew(adart); } + /// Keep the biggest connected component. + /// @return the size (in number of darts) of the biggest cc. + std::size_t keep_biggest_connected_component() + { + std::map ccs; + + size_type treated=get_new_mark(); + for (auto it=darts().begin(), itend=darts().end(); it!=itend; ++it) + { + if (!is_marked(it, treated)) + { ccs[mark_cell(it, treated)]=it; } + } + + if (ccs.size()>1) + { // Here all darts are marked + this->template unmark_cell(ccs.rbegin()->second, treated); // Unmark the biggest cc + erase_marked_darts(treated); + } + + free_mark(treated); + + return ccs.rbegin()->first; + } + /** Count the marked cells (at least one marked dart). * @param amark the mark to consider. * @param avector containing the dimensions of the cells to count. @@ -1890,6 +1957,7 @@ namespace CGAL { } public: + /// @return the positive turn between the two given darts. // @pre next(d1) and d2 must belong to the same vertex. std::size_t positive_turn(Dart_const_handle d1, Dart_const_handle d2) const @@ -2527,7 +2595,7 @@ namespace CGAL { if (!is_marked(current, m1)) { if (map2.is_marked(other, m2)) - match=false; + { match=false; } else { bijection[current] = other; @@ -3050,7 +3118,7 @@ namespace CGAL { * @param adart an intial dart * @return true iff the volume containing adart is a combinatorial tetrahedron. */ - bool is_volume_combinatorial_tetrahedron(Dart_const_handle d1) + bool is_volume_combinatorial_tetrahedron(Dart_const_handle d1) const { Dart_const_handle d2 = alpha(d1, 0, 2); Dart_const_handle d3 = alpha(d2, 1, 2); @@ -3127,7 +3195,7 @@ namespace CGAL { * @param adart an intial dart * @return true iff the volume containing adart is a combinatorial hexahedron. */ - bool is_volume_combinatorial_hexahedron(Dart_const_handle d1) + bool is_volume_combinatorial_hexahedron(Dart_const_handle d1) const { Dart_const_handle d2 = alpha(d1,1,0,1,2); Dart_const_handle d3 = alpha(d2,1,0,1,2); @@ -3612,7 +3680,7 @@ namespace CGAL { * @param afirst iterator on the beginning of the path. * @param alast iterator on the end of the path. * @return true iff a 2-cell can be inserted along the path. - * the path is a sequence of dartd, one per edge + * the path is a sequence of dart, one per edge * where the face will be inserted. */ template @@ -3919,6 +3987,68 @@ namespace CGAL { {} }; + namespace Index + { + template + class Generalized_map : + public Generalized_map_base, + Items_, Alloc_, Storage_ > + { + public: + typedef Generalized_map Self; + typedef Generalized_map_base Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Dart_const_handle Dart_const_handle; + typedef typename Base::Alloc Alloc; + typedef typename Base::Exception_no_more_available_mark + Exception_no_more_available_mark; + + Generalized_map() : Base() + {} + + Generalized_map(const Self & amap) : Base(amap) + {} + + Generalized_map(Self && amap) : Base(amap) + {} + + template + Generalized_map(const Generalized_map_base& amap) : + Base(amap) + {} + + template + Generalized_map(const Generalized_map_base& amap, + const Converters& converters) : + Base(amap, converters) + {} + + template + Generalized_map(const Generalized_map_base& amap, + const Converters& converters, + const DartInfoConverter& dartinfoconverter) : + Base(amap, converters, dartinfoconverter) + {} + + template + Generalized_map(const Generalized_map_base& amap, + const Converters& converters, + const DartInfoConverter& dartinfoconverter, + const PointConverter& pointconverter) : + Base(amap, converters, dartinfoconverter, pointconverter) + {} + }; + } // namespace Index + } // namespace CGAL #if defined(BOOST_GCC) diff --git a/Generalized_map/include/CGAL/Generalized_map_storages.h b/Generalized_map/include/CGAL/Generalized_map_storages.h index 837717fe68f..d28a050f42b 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages.h @@ -34,17 +34,13 @@ namespace CGAL { struct Container_type; } - /** @file Generalized_map_storages.h - * Definition of storages for dD Generalized map. - */ - // Storage of darts with compact container, alpha with handles template class Generalized_map_storage_1 { public: - typedef Generalized_map_storage_1 Self; - typedef CGAL::Tag_false Use_index; + using Self=Generalized_map_storage_1; + using Use_index=CGAL::Tag_false; typedef internal::Combinatorial_map_helper Helper; @@ -62,7 +58,6 @@ namespace CGAL { typedef typename internal::Container_type ::type Dart_container; - typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; typedef typename Dart_container::size_type size_type; @@ -72,7 +67,6 @@ namespace CGAL { typedef Items_ Items; typedef Alloc_ Alloc; - template struct Container_for_attributes : public internal::Container_type @@ -109,14 +103,33 @@ namespace CGAL { typedef Handle_hash_function Hash_function; + typedef Dart_container Dart_range; + typedef const Dart_container Dart_const_range; + /// @return a Dart_range (range through all the darts of the map). + Dart_range& darts() { return mdarts;} + Dart_const_range& darts() const { return mdarts; } + // Init void init_storage() { null_dart_handle=nullptr; } - /** Return if this dart is free for adimension. + void clear_storage() + {} + + /** Test if the map is empty. + * @return true iff the map is empty. + */ + bool is_empty() const + { return mdarts.empty(); } + + /// @return the number of darts. + size_type number_of_darts() const + { return mdarts.size(); } + + /** Return if this dart is free for adimension. * @param dh a dart handle * @param i the dimension. - * @return true iff dh is linked with nullptr for \em adimension. + * @return true iff dh is linked with itself for \em adimension. */ template bool is_free(Dart_const_handle dh) const diff --git a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h new file mode 100644 index 00000000000..e9ba38f36ed --- /dev/null +++ b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h @@ -0,0 +1,439 @@ +// Copyright (c) 2016 CNRS and LIRIS' Establishments (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Guillaume Damiand +// +#ifndef CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H +#define CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H 1 + +#include +#include +#include + +#include +#if defined(BOOST_GCC) +_Pragma("GCC diagnostic push") +_Pragma("GCC diagnostic ignored \"-Warray-bounds\"") +#endif + +namespace CGAL { + + namespace internal { + template + struct Combinatorial_map_helper; + + template + struct Container_type; + } + + // Storage of darts with compact container, alpha with indices + template + class Generalized_map_storage_2 + { + public: + using Self=Generalized_map_storage_2; + using Use_index=CGAL::Tag_true; + using Index_type=Index_type_; + + typedef internal::Combinatorial_map_helper Helper; + + typedef typename Items_::template Dart_wrapper Dart_wrapper; + + typedef typename internal::template Get_dart_info::type + Dart_info; + typedef CGAL::Index::Dart Dart; + + typedef std::allocator_traits Allocator_traits; + typedef typename Allocator_traits::template rebind_alloc Dart_allocator; + + typedef Compact_container_with_index_2, Index_type> + Dart_container; + + // typedef unsigned int Dart_index; + // typedef MyIndex Dart_index; + typedef typename Dart_container::Index Dart_index; + + // Definition of old types, for backward compatibility. + typedef Dart_index Dart_handle; + typedef Dart_index Dart_const_handle; + typedef typename Dart_container::size_type size_type; + + typedef Dart_index Null_handle_type; + static Null_handle_type null_handle; + + typedef Items_ Items; + typedef Alloc_ Alloc; + template + struct Container_for_attributes : public + Compact_container_with_index_2::other, + Multiply_by_two_policy_for_cc_with_size<64>, size_type > + {}; + /// Typedef for attributes + typedef typename internal::template Get_attributes_tuple::type + Attributes; + + template + struct Attribute_type: public Helper::template Attribute_type + {}; + template + struct Attribute_handle: public Helper::template Attribute_handle + {}; + template + struct Attribute_const_handle: + public Helper::template Attribute_const_handle + {}; + template + struct Attribute_range: public Helper::template Attribute_range + {}; + template + struct Attribute_const_range: + public Helper::template Attribute_const_range + {}; + + /// Number of marks + static const size_type NB_MARKS = 32; + + /// The dimension of the generalized map. + static const unsigned int dimension = d_; + + typedef internal::Index_hash_function Hash_function; + + typedef Dart_container Dart_range; + typedef const Dart_container Dart_const_range; + /// @return a Dart_range (range through all the darts of the map). + Dart_range& darts() { return mdarts;} + Dart_const_range& darts() const { return mdarts; } + + // Init + void init_storage() + { null_dart_handle=nullptr; } + + void clear_storage() + {} + + /** Test if the map is empty. + * @return true iff the map is empty. + */ + bool is_empty() const + { return mdarts.empty(); } + + /// @return the number of darts. + size_type number_of_darts() const + { return mdarts.size(); } + + /** Return if this dart is free for adimension. + * @param dh a dart handle + * @param i the dimension. + * @return true iff dh is linked with itself for \em adimension. + */ + template + bool is_free(Dart_const_handle dh) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mf[i]==dh; + } + bool is_free(Dart_const_handle dh, unsigned int i) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mf[i]==dh; + } + bool is_perforated(Dart_const_handle /*dh*/) const + { return false; } + + /// Set simultaneously all the marks of this dart to a given value. + void set_dart_marks(Dart_const_handle ADart, + const std::bitset& amarks) const + { + mdarts[ADart].set_marks(amarks); + } + /// Return all the marks of a dart. + std::bitset get_dart_marks(Dart_const_handle ADart) const + { + return mdarts[ADart].get_marks(); + } + /// Return the mark value of dart a given mark number. + bool get_dart_mark(Dart_const_handle ADart, size_type amark) const + { + return mdarts[ADart].get_mark(amark); + } + + /// Set the mark of a given mark number to a given value. + void set_dart_mark(Dart_const_handle ADart, size_type amark, bool avalue) const + { + mdarts[ADart].set_mark(amark, avalue); + } + + /// Flip the mark of a given mark number to a given value. + void flip_dart_mark(Dart_const_handle ADart, size_type amark) const + { + mdarts[ADart].flip_mark(amark); + } + + // Access to alpha maps + Dart_handle get_alpha(Dart_handle ADart, int B1) + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + Dart_const_handle get_alpha(Dart_const_handle ADart, int B1) const + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + template + Dart_handle get_alpha(Dart_handle ADart) + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + template + Dart_const_handle get_alpha(Dart_const_handle ADart) const + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + + // return a handle on the i-attribute + template + typename Attribute_handle::type attribute(Dart_handle ADart) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return std::get::value> + (mdarts[ADart].mattribute_handles); + } + template + typename Attribute_const_handle::type + attribute(Dart_const_handle ADart) const + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return std::get::value> + (mdarts[ADart].mattribute_handles); + } + + // Copy a given attribute + template + typename Attribute_handle::type copy_attribute + (typename Attribute_const_handle::type ah) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "copy_attribute called but i-attributes are disabled."); + typename Attribute_handle::type res= + std::get::value> + (mattribute_containers).emplace(get_attribute(ah)); + this->template init_attribute_ref_counting(res); + return res; + } + + // Test if a given attribute is valid + template + bool is_valid_attribute(typename Attribute_const_handle::type ah) const + { + return get_attribute(ah).is_valid(); + } + + // accessors and modifiers to the attribute ref counting given its handle + template + std::size_t get_attribute_ref_counting + (typename Attribute_const_handle::type ah) const + { + return get_attribute(ah).get_nb_refs(); + } + template + void init_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).mrefcounting=0; + } + template + void inc_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).inc_nb_refs(); + } + template + void dec_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).dec_nb_refs(); + } + + // get the attribute given its index + template + typename Attribute_type::type& + get_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return std::get::value> + (mattribute_containers)[ah]; + } + template + const typename Attribute_type::type& + get_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return std::get::value> + (mattribute_containers)[ah]; + } + + // Get the dart of the given attribute + template + Dart_handle dart_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).dart(); + } + template + Dart_const_handle + dart_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).dart(); + } + + // Set the dart of the given attribute + template + void set_dart_of_attribute(typename Attribute_handle::type ah, + Dart_handle adart) + { + CGAL_assertion( ah!=null_handle ); + get_attribute(ah).set_dart(adart); + } + + // Get the information associated with a given dart + Dart_info& info(Dart_handle adart) + { return mdarts[adart].info(); } + const Dart_info& info(Dart_const_handle adart) const + { return mdarts[adart].info(); } + + // Get the info of the given attribute + template + typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).info(); + } + template + const typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).info(); + } + + // Get the info of the i-cell attribute associated with the given dart + template + typename Attribute_type::type::Info & info(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( this->template attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + template + const typename Attribute_type::type::Info & + info(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + + // Get the dart of the i-cell attribute associated with the given dart + template + Dart_handle dart(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + template + Dart_const_handle dart(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + + // Debug function + void display_dart(Dart_const_handle ADart) const + { std::cout< + void display_attribute(typename Attribute_const_handle::type ah) const + { std::cout< + void basic_set_dart_attribute(Dart_handle dh, + typename Attribute_handle::type ah) + { + std::get::value> + (mdarts[dh].mattribute_handles) = ah; + } + + /** Link a dart with a given dart for a given dimension. + * @param adart the dart to link. + * @param adart2 the dart to link with. + * @param i the dimension. + */ + template + void dart_link_alpha(Dart_handle adart, Dart_handle adart2) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=nullptr && adart2!=nullptr); + mdarts[adart].mf[i] = adart2; + } + void dart_link_alpha(Dart_handle adart, Dart_handle adart2, unsigned int i) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=nullptr && adart2!=nullptr); + mdarts[adart].mf[i] = adart2; + } + + /** Unlink a dart for a given dimension. + * @param adart a dart. + * @param i the dimension. + */ + template + void dart_unlink_alpha(Dart_handle adart) + { + CGAL_assertion(adart!=nullptr && i <= dimension); + mdarts[adart].mf[i] = adart; + } + void dart_unlink_alpha(Dart_handle adart, unsigned int i) + { + CGAL_assertion(adart!=nullptr && i <= dimension); + mdarts[adart].mf[i] = adart; + } + + protected: + Dart_handle null_dart_handle; // To be compatible with combinatorial map + + /// Dart container. + Dart_container mdarts; + + /// Tuple of attributes containers + typename Helper::Attribute_containers mattribute_containers; + }; + + /// null_handle + template + typename Generalized_map_storage_2::Null_handle_type + Generalized_map_storage_2::null_handle((std::numeric_limits::max)()/2); + +} // namespace CGAL + +#if defined(BOOST_GCC) + _Pragma("GCC diagnostic pop") +#endif + +#endif // CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H // +// EOF // diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h index 08dc411ec19..38d000f9d06 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h @@ -34,9 +34,6 @@ namespace CGAL { struct Container_type; } - /** @file CMap_linear_cell_complex_storages.h - * Definition of storages for dD Linear cell complex for combinatorial maps. - */ // Storage of darts with compact container, beta with handles // Copy of Combinatorial_map_storage_1 and add new types related // to geometry (not possible to inherith because we use Self type @@ -47,9 +44,9 @@ namespace CGAL { class CMap_linear_cell_complex_storage_1 { public: - typedef CMap_linear_cell_complex_storage_1 Self; - typedef CGAL::Tag_false Use_index; + using Self=CMap_linear_cell_complex_storage_1; + using Use_index=CGAL::Tag_false; typedef typename Traits_::Point Point; typedef typename Traits_::Vector Vector; @@ -156,7 +153,7 @@ namespace CGAL { /** Return if this dart is free for adimension. * @param dh a dart handle * @param i the dimension. - * @return true iff dh is linked with nullptr for \em adimension. + * @return true iff dh is linked with null_dart_handle for \em adimension. */ template bool is_free(Dart_const_handle dh) const diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h index 7ca289c8686..403195a9d2f 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -33,16 +32,13 @@ namespace CGAL { struct Container_type; } - /** @file CMap_linear_cell_complex_storages_with_index.h - * Definition of storages for dD Linear cell complex for combinatorial maps index version. - */ - // Storage with combinatorial maps using index + // Storage of darts with compact container, alpha using index // Copy of Combinatorial_map_storage_2 and add new types related // to geometry (not possible to inherith because we use Self type // as template parameter of Dart_wrapper. If we inherit, Self is not - // the correct type.) - template + // the correct type). + template class CMap_linear_cell_complex_storage_2 { public: @@ -206,6 +202,8 @@ namespace CGAL { CGAL_assertion(i <= dimension); return mdarts[dh].mf[i]==null_dart_handle; } + bool is_perforated(Dart_const_handle /*dh*/) const + { return false; } /// Set simultaneously all the marks of this dart to a given value. void set_dart_marks(Dart_const_handle ADart, @@ -239,24 +237,24 @@ namespace CGAL { // Access to beta maps Dart_handle get_beta(Dart_handle ADart, int B1) { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } Dart_const_handle get_beta(Dart_const_handle ADart, int B1) const { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } template Dart_handle get_beta(Dart_handle ADart) { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } template Dart_const_handle get_beta(Dart_const_handle ADart) const { - CGAL_assertion(B1>=0 && B1<=dimension); + CGAL_assertion(B1>=0 && B1<=(int)dimension); return mdarts[ADart].mf[B1]; } @@ -445,11 +443,11 @@ namespace CGAL { protected: // Set the handle on the i th attribute template - void basic_set_dart_attribute(Dart_handle ADart, + void basic_set_dart_attribute(Dart_handle dh, typename Attribute_handle::type ah) { std::get::value> - (mdarts[ADart].mattribute_handles) = ah; + (mdarts[dh].mattribute_handles) = ah; } /** Link a dart with a given dart for a given dimension. @@ -496,6 +494,9 @@ namespace CGAL { Dart_container mdarts; Dart_range mdarts_range; + /// Container for the null_dart_handle: unused; to be compatible with handle version + Dart_container mnull_dart_container; + /// Tuple of attributes containers typename Helper::Attribute_containers mattribute_containers; }; @@ -508,11 +509,11 @@ namespace CGAL { null_dart_handle(0); /// null_handle - template - typename CMap_linear_cell_complex_storage_2:: + template + typename CMap_linear_cell_complex_storage_2:: Null_handle_type CMap_linear_cell_complex_storage_2:: + Items_, Alloc_, Index_type_>:: null_handle((std::numeric_limits::max)()/2); } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h index c1baa30409e..6368d7c9e30 100644 --- a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h +++ b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h @@ -13,6 +13,7 @@ #define CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_H 1 #include +#include #include #include #include @@ -33,10 +34,6 @@ namespace CGAL { struct Container_type; } - /** @file GMap_linear_cell_complex_storages.h - * Definition of storages for dD Linear cell complex for generalized map. - */ - // Storage of darts with compact container, alpha with handles // Copy of Generalized_map_storage_1 and add new types related // to geometry (not possible to inherith because we use Self type @@ -47,14 +44,14 @@ namespace CGAL { class GMap_linear_cell_complex_storage_1 { public: + using Self=GMap_linear_cell_complex_storage_1; + using Use_index=CGAL::Tag_false; + typedef typename Traits_::Point Point; typedef typename Traits_::Vector Vector; typedef typename Traits_::FT FT; - typedef GMap_linear_cell_complex_storage_1 Self; - typedef CGAL::Tag_false Use_index; - typedef internal::Combinatorial_map_helper Helper; typedef typename Items_::template Dart_wrapper Dart_wrapper; @@ -71,7 +68,6 @@ namespace CGAL { typedef typename internal::Container_type ::type Dart_container; - typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; typedef typename Dart_container::size_type size_type; @@ -81,7 +77,6 @@ namespace CGAL { typedef Items_ Items; typedef Alloc_ Alloc; - template struct Container_for_attributes : public internal::Container_type @@ -127,14 +122,33 @@ namespace CGAL { typedef Handle_hash_function Hash_function; + typedef Dart_container Dart_range; + typedef const Dart_container Dart_const_range; + /// @return a Dart_range (range through all the darts of the map). + Dart_range& darts() { return mdarts;} + Dart_const_range& darts() const { return mdarts; } + // Init void init_storage() { null_dart_handle=nullptr; } + void clear_storage() + {} + + /** Test if the map is empty. + * @return true iff the map is empty. + */ + bool is_empty() const + { return mdarts.empty(); } + + /// @return the number of darts. + size_type number_of_darts() const + { return mdarts.size(); } + /** Return if this dart is free for adimension. * @param dh a dart handle * @param i the dimension. - * @return true iff dh is linked with nullptr for \em adimension. + * @return true iff dh is linked with itself for \em adimension. */ template bool is_free(Dart_const_handle dh) const diff --git a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h new file mode 100644 index 00000000000..a90309c3fcd --- /dev/null +++ b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h @@ -0,0 +1,475 @@ +// Copyright (c) 2016 CNRS and LIRIS' Establishments (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Guillaume Damiand +// +#ifndef CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H +#define CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H 1 + +#include +#include +#include + +#include +#if defined(BOOST_GCC) +_Pragma("GCC diagnostic push") +_Pragma("GCC diagnostic ignored \"-Warray-bounds\"") +#endif + +namespace CGAL { + + namespace internal { + template + struct Combinatorial_map_helper; + + template + struct Container_type; + } + + // Storage of darts with compact container, alpha using index + // Copy of Generalized_map_storage_2 and add new types related + // to geometry (not possible to inherith because we use Self type + // as template parameter of Dart_wrapper. If we inherit, Self is not + // the correct type). + template + class GMap_linear_cell_complex_storage_2 + { + public: + using Self=GMap_linear_cell_complex_storage_2; + using Use_index=CGAL::Tag_true; + using Index_type=Index_type_; + + typedef typename Traits_::Point Point; + typedef typename Traits_::Vector Vector; + typedef typename Traits_::FT FT; + + typedef internal::Combinatorial_map_helper Helper; + + typedef typename Items_::template Dart_wrapper Dart_wrapper; + + typedef typename internal::template Get_dart_info::type + Dart_info; + typedef CGAL::Index::Dart Dart; + + typedef std::allocator_traits Allocator_traits; + typedef typename Allocator_traits::template rebind_alloc Dart_allocator; + + typedef Compact_container_with_index_2, Index_type> + Dart_container; + + // typedef unsigned int Dart_index; + // typedef MyIndex Dart_index; + typedef typename Dart_container::Index Dart_index; + + // Definition of old types, for backward compatibility. + typedef Dart_index Dart_handle; + typedef Dart_index Dart_const_handle; + typedef typename Dart_container::size_type size_type; + + typedef Dart_index Null_handle_type; + static Null_handle_type null_handle; + + typedef Items_ Items; + typedef Alloc_ Alloc; + template + struct Container_for_attributes : public + Compact_container_with_index_2::other, + Multiply_by_two_policy_for_cc_with_size<64>, size_type > + {}; + /// Typedef for attributes + typedef typename internal::template Get_attributes_tuple::type + Attributes; + + template + struct Attribute_type: public Helper::template Attribute_type + {}; + template + struct Attribute_handle: public Helper::template Attribute_handle + {}; + template + struct Attribute_const_handle: + public Helper::template Attribute_const_handle + {}; + template + struct Attribute_range: public Helper::template Attribute_range + {}; + template + struct Attribute_const_range: + public Helper::template Attribute_const_range + {}; + + typedef typename Attribute_type<0>::type Vertex_attribute; + typedef typename Attribute_handle<0>::type Vertex_attribute_handle; + typedef typename Attribute_const_handle<0>::type + Vertex_attribute_const_handle; + + typedef typename Attribute_range<0>::type Vertex_attribute_range; + typedef typename Attribute_const_range<0>::type + Vertex_attribute_const_range; + + /// Number of marks + static const size_type NB_MARKS = 32; + + /// The dimension of the generalized map. + static const unsigned int dimension = d_; + + typedef internal::Index_hash_function Hash_function; + + typedef Dart_container Dart_range; + typedef const Dart_container Dart_const_range; + /// @return a Dart_range (range through all the darts of the map). + Dart_range& darts() { return mdarts;} + Dart_const_range& darts() const { return mdarts; } + + // Init + void init_storage() + { null_dart_handle=nullptr; } + + void clear_storage() + {} + + /** Test if the map is empty. + * @return true iff the map is empty. + */ + bool is_empty() const + { return mdarts.empty(); } + + /// @return the number of darts. + size_type number_of_darts() const + { return mdarts.size(); } + + /** Return if this dart is free for adimension. + * @param dh a dart handle + * @param i the dimension. + * @return true iff dh is linked with itself for \em adimension. + */ + template + bool is_free(Dart_const_handle dh) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mf[i]==dh; + } + bool is_free(Dart_const_handle dh, unsigned int i) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mf[i]==dh; + } + bool is_perforated(Dart_const_handle /*dh*/) const + { return false; } + + /// Set simultaneously all the marks of this dart to a given value. + void set_dart_marks(Dart_const_handle ADart, + const std::bitset& amarks) const + { + mdarts[ADart].set_marks(amarks); + } + /// Return all the marks of a dart. + std::bitset get_dart_marks(Dart_const_handle ADart) const + { + return mdarts[ADart].get_marks(); + } + /// Return the mark value of dart a given mark number. + bool get_dart_mark(Dart_const_handle ADart, size_type amark) const + { + return mdarts[ADart].get_mark(amark); + } + + /// Set the mark of a given mark number to a given value. + void set_dart_mark(Dart_const_handle ADart, size_type amark, bool avalue) const + { + mdarts[ADart].set_mark(amark, avalue); + } + + /// Flip the mark of a given mark number to a given value. + void flip_dart_mark(Dart_const_handle ADart, size_type amark) const + { + mdarts[ADart].flip_mark(amark); + } + + // Access to alpha maps + Dart_handle get_alpha(Dart_handle ADart, int B1) + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + Dart_const_handle get_alpha(Dart_const_handle ADart, int B1) const + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + template + Dart_handle get_alpha(Dart_handle ADart) + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + template + Dart_const_handle get_alpha(Dart_const_handle ADart) const + { + CGAL_assertion(B1>=0 && B1<=(int)dimension); + return mdarts[ADart].mf[B1]; + } + + // return a handle on the i-attribute + template + typename Attribute_handle::type attribute(Dart_handle ADart) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return std::get::value> + (mdarts[ADart].mattribute_handles); + } + template + typename Attribute_const_handle::type + attribute(Dart_const_handle ADart) const + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return std::get::value> + (mdarts[ADart].mattribute_handles); + } + + // Copy a given attribute + template + typename Attribute_handle::type copy_attribute + (typename Attribute_const_handle::type ah) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "copy_attribute called but i-attributes are disabled."); + typename Attribute_handle::type res= + std::get::value> + (mattribute_containers).emplace(get_attribute(ah)); + this->template init_attribute_ref_counting(res); + return res; + } + + // Test if a given attribute is valid + template + bool is_valid_attribute(typename Attribute_const_handle::type ah) const + { + return get_attribute(ah).is_valid(); + } + + // accessors and modifiers to the attribute ref counting given its handle + template + std::size_t get_attribute_ref_counting + (typename Attribute_const_handle::type ah) const + { + return get_attribute(ah).get_nb_refs(); + } + template + void init_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).mrefcounting=0; + } + template + void inc_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).inc_nb_refs(); + } + template + void dec_attribute_ref_counting(typename Attribute_handle::type ah) + { + get_attribute(ah).dec_nb_refs(); + } + + // get the attribute given its index + template + typename Attribute_type::type& + get_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return std::get::value> + (mattribute_containers)[ah]; + } + template + const typename Attribute_type::type& + get_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return std::get::value> + (mattribute_containers)[ah]; + } + + // Get the dart of the given attribute + template + Dart_handle dart_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).dart(); + } + template + Dart_const_handle + dart_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).dart(); + } + + // Set the dart of the given attribute + template + void set_dart_of_attribute(typename Attribute_handle::type ah, + Dart_handle adart) + { + CGAL_assertion( ah!=null_handle ); + get_attribute(ah).set_dart(adart); + } + + // Get the information associated with a given dart + Dart_info& info(Dart_handle adart) + { return mdarts[adart].info(); } + const Dart_info& info(Dart_const_handle adart) const + { return mdarts[adart].info(); } + + // Get the info of the given attribute + template + typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).info(); + } + template + const typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return get_attribute(ah).info(); + } + + // Get the info of the i-cell attribute associated with the given dart + template + typename Attribute_type::type::Info & info(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( this->template attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + template + const typename Attribute_type::type::Info & + info(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + + // Get the dart of the i-cell attribute associated with the given dart + template + Dart_handle dart(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + template + Dart_const_handle dart(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + + // Get the dart of the given 0-attribute + Point & point_of_vertex_attribute(typename Attribute_handle<0>::type vh) + { + CGAL_assertion( vh!=null_handle ); + return get_attribute<0>(vh).point(); + } + + const Point & point_of_vertex_attribute + (typename Attribute_const_handle<0>::type vh) const + { + CGAL_assertion( vh!=null_handle ); + return get_attribute<0>(vh).point(); + } + + // Debug function + void display_dart(Dart_const_handle ADart) const + { std::cout< + void display_attribute(typename Attribute_const_handle::type ah) const + { std::cout< + void basic_set_dart_attribute(Dart_handle dh, + typename Attribute_handle::type ah) + { + std::get::value> + (mdarts[dh].mattribute_handles) = ah; + } + + /** Link a dart with a given dart for a given dimension. + * @param adart the dart to link. + * @param adart2 the dart to link with. + * @param i the dimension. + */ + template + void dart_link_alpha(Dart_handle adart, Dart_handle adart2) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=nullptr && adart2!=nullptr); + mdarts[adart].mf[i] = adart2; + } + void dart_link_alpha(Dart_handle adart, Dart_handle adart2, unsigned int i) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=nullptr && adart2!=nullptr); + mdarts[adart].mf[i] = adart2; + } + + /** Unlink a dart for a given dimension. + * @param adart a dart. + * @param i the dimension. + */ + template + void dart_unlink_alpha(Dart_handle adart) + { + CGAL_assertion(adart!=nullptr && i <= dimension); + mdarts[adart].mf[i] = adart; + } + void dart_unlink_alpha(Dart_handle adart, unsigned int i) + { + CGAL_assertion(adart!=nullptr && i <= dimension); + mdarts[adart].mf[i] = adart; + } + + protected: + Dart_handle null_dart_handle; // To be compatible with combinatorial map + + /// Dart container. + Dart_container mdarts; + + /// Tuple of attributes containers + typename Helper::Attribute_containers mattribute_containers; + }; + + /// null_handle + template + typename GMap_linear_cell_complex_storage_2:: + Null_handle_type GMap_linear_cell_complex_storage_2:: + null_handle((std::numeric_limits::max)()/2); + +} // namespace CGAL + +#if defined(BOOST_GCC) + _Pragma("GCC diagnostic pop") +#endif + +#endif // CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H // +// EOF // diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_combinatorial_map.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_combinatorial_map.h index fe5faf69cac..7f701c4a22e 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_combinatorial_map.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_combinatorial_map.h @@ -29,32 +29,26 @@ namespace CGAL { * points associated to all vertices. */ - // Linear_cell_complex_for_combinatorial_map class. - // No difference with class Linear_cell_complex_base except the default - // template parameters for Refs class which is a combinatorial map. + // Linear_cell_complex_for_combinatorial_map_base class. template < unsigned int d_, unsigned int ambient_dim, class Traits_, class Items_, class Alloc_, template class CMap, - class Storage_ > + class Refs_, class Storage_ > class Linear_cell_complex_for_combinatorial_map_base: public Linear_cell_complex_base, - Storage_> + Items_, Alloc_, CMap, Refs_, Storage_> { public: typedef Linear_cell_complex_for_combinatorial_map_base Self; + Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Self; typedef Linear_cell_complex_base Base; + Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Base; typedef Traits_ Traits; typedef Items_ Items; typedef Alloc_ Alloc; + typedef Refs_ Refs; static const unsigned int ambient_dimension = Base::ambient_dimension; static const unsigned int dimension = Base::dimension; @@ -104,29 +98,29 @@ namespace CGAL { template class CMap2, - class Storage2> + class Ref2, class Storage2> Linear_cell_complex_for_combinatorial_map_base (const Linear_cell_complex_for_combinatorial_map_base& alcc) : Base(alcc) + Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc) : Base(alcc) {} template class CMap2, - class Storage2, typename Converters> + class Ref2, class Storage2, typename Converters> Linear_cell_complex_for_combinatorial_map_base (const Linear_cell_complex_for_combinatorial_map_base& alcc, + Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc, const Converters& converters) : Base(alcc, converters) {} template class CMap2, - class Storage2, typename Converters, typename DartInfoConverter> + class Ref2, class Storage2, typename Converters, typename DartInfoConverter> Linear_cell_complex_for_combinatorial_map_base (const Linear_cell_complex_for_combinatorial_map_base& alcc, + Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc, const Converters& converters, const DartInfoConverter& dartinfoconverter) : Base(alcc, converters, dartinfoconverter) @@ -135,11 +129,11 @@ namespace CGAL { template class CMap2, - class Storage2, typename Converters, + class Ref2, class Storage2, typename Converters, typename DartInfoConverter, typename PointConverter> Linear_cell_complex_for_combinatorial_map_base (const Linear_cell_complex_for_combinatorial_map_base& alcc, + Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc, const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter) : Base(alcc, converters, dartinfoconverter, pointconverter) @@ -232,14 +226,16 @@ namespace CGAL { class Storage_ > class Linear_cell_complex_for_combinatorial_map: public Linear_cell_complex_for_combinatorial_map_base - + , Storage_> { public: typedef Linear_cell_complex_for_combinatorial_map Self; typedef Linear_cell_complex_for_combinatorial_map_base Base; + Traits_, Items_, Alloc_, CMap, Self, Storage_> Base; typedef Traits_ Traits; typedef Items_ Items; @@ -302,6 +298,14 @@ namespace CGAL { const PointConverter& pointconverter) : Base(alcc, converters, dartinfoconverter, pointconverter) {} + + Self & operator= (const Self & alcc) + { + Base::operator=(alcc); + return *this; + } + + void clear() { Base::clear(); } //need explicit definition for Has_member_clear in bgl helpers }; namespace Index @@ -317,14 +321,16 @@ template< unsigned int d_, unsigned int ambient_dim, class CMap, class Storage_> class Linear_cell_complex_for_combinatorial_map: public Linear_cell_complex_for_combinatorial_map_base - + , Storage_> { public: typedef Linear_cell_complex_for_combinatorial_map Self; typedef Linear_cell_complex_for_combinatorial_map_base Base; + Traits_, Items_, Alloc_, CMap, Self, Storage_> Base; typedef Traits_ Traits; typedef Items_ Items; @@ -387,6 +393,14 @@ public: const PointConverter& pointconverter) : Base(alcc, converters, dartinfoconverter, pointconverter) {} + + Self & operator= (const Self & alcc) + { + Base::operator=(alcc); + return *this; + } + + void clear() { Base::clear(); } //need explicit definition for Has_member_clear in bgl helpers }; } // namespace Index } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h index b432adb2965..1ae9cd4166a 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_generalized_map.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace CGAL { @@ -26,32 +27,26 @@ namespace CGAL { * points associated to all vertices. */ - // Linear_cell_complex_for_generalized_map class. - // No difference with class Linear_cell_complex_base except the default - // template parameters for Refs class which is a generalized map. + // Linear_cell_complex_for_generalized_map class_base. template < unsigned int d_, unsigned int ambient_dim, class Traits_, class Items_, class Alloc_, template class CMap, - class Storage_ > - class Linear_cell_complex_for_generalized_map: + class Refs_, class Storage_ > + class Linear_cell_complex_for_generalized_map_base: public Linear_cell_complex_base, - Storage_> + Items_, Alloc_, CMap, Refs_, Storage_> { public: - typedef Linear_cell_complex_for_generalized_map Self; + typedef Linear_cell_complex_for_generalized_map_base Self; typedef Linear_cell_complex_base Base; + Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Base; typedef Traits_ Traits; typedef Items_ Items; typedef Alloc_ Alloc; + typedef Refs_ Refs; static const unsigned int ambient_dimension = Base::ambient_dimension; static const unsigned int dimension = Base::dimension; @@ -84,6 +79,105 @@ namespace CGAL { typedef typename Base::Exception_no_more_available_mark Exception_no_more_available_mark; + Linear_cell_complex_for_generalized_map_base() : Base() + {} + + /** Copy the given linear cell complex into *this. + * Note that both LCC can have different dimensions and/or non void attributes. + * @param alcc the linear cell complex to copy. + * @post *this is valid. + */ + Linear_cell_complex_for_generalized_map_base(const Self & alcc) : Base(alcc) + {} + + Linear_cell_complex_for_generalized_map_base(Self && alcc) : Base(alcc) + {} + + template class CMap2, + class Ref2, class Storage2> + Linear_cell_complex_for_generalized_map_base + (const Linear_cell_complex_for_generalized_map_base& alcc) : Base(alcc) + {} + + template class CMap2, + class Ref2, class Storage2, typename Converters> + Linear_cell_complex_for_generalized_map_base + (const Linear_cell_complex_for_generalized_map_base& alcc, + const Converters& converters) : Base(alcc, converters) + {} + + template class CMap2, + class Ref2, class Storage2, typename Converters, typename DartInfoConverter> + Linear_cell_complex_for_generalized_map_base + (const Linear_cell_complex_for_generalized_map_base& alcc, + const Converters& converters, + const DartInfoConverter& dartinfoconverter) : + Base(alcc, converters, dartinfoconverter) + {} + + template class CMap2, + class Ref2, class Storage2, typename Converters, typename DartInfoConverter, + typename PointConverter> + Linear_cell_complex_for_generalized_map_base + (const Linear_cell_complex_for_generalized_map_base& alcc, + const Converters& converters, + const DartInfoConverter& dartinfoconverter, + const PointConverter& pointconverter) : + Base(alcc, converters, dartinfoconverter, pointconverter) + {} + + Self & operator= (const Self & alcc) + { + Base::operator=(alcc); + return *this; + } + + friend std::ostream& operator<< (std::ostream& os, const Self& amap) + { + save_generalized_map(amap, os); + return os; + } + + friend std::ifstream& operator>> (std::ifstream& is, Self& amap) + { + load_generalized_map(is, amap); + return is; + } + }; + + template < unsigned int d_, unsigned int ambient_dim, + class Traits_, class Items_, class Alloc_, + template class CMap, + class Storage_ > + class Linear_cell_complex_for_generalized_map: + public Linear_cell_complex_for_generalized_map_base + , Storage_> + { + public: + typedef Linear_cell_complex_for_generalized_map Self; + + typedef Linear_cell_complex_for_generalized_map_base Base; + + typedef Traits_ Traits; + typedef Items_ Items; + typedef Alloc_ Alloc; + Linear_cell_complex_for_generalized_map() : Base() {} @@ -92,10 +186,10 @@ namespace CGAL { * @param alcc the linear cell complex to copy. * @post *this is valid. */ - Linear_cell_complex_for_generalized_map(const Self & alcc) : Base(alcc) + Linear_cell_complex_for_generalized_map(const Self& alcc) : Base(alcc) {} - Linear_cell_complex_for_generalized_map(Self && alcc) : Base(alcc) + Linear_cell_complex_for_generalized_map(Self&& alcc) : Base(alcc) {} template class CMap2, - class Storage2, typename Converters, typename DartInfoConverter, - typename PointConverter> + class Storage2, typename Converters, + typename DartInfoConverter, typename PointConverter> Linear_cell_complex_for_generalized_map (const Linear_cell_complex_for_generalized_map& alcc, - const Converters& converters, - const DartInfoConverter& dartinfoconverter, + const Converters& converters, const DartInfoConverter& dartinfoconverter, const PointConverter& pointconverter) : Base(alcc, converters, dartinfoconverter, pointconverter) {} @@ -149,19 +242,104 @@ namespace CGAL { return *this; } - friend std::ostream& operator<< (std::ostream& os, const Self& amap) - { - save_generalized_map(amap, os); - return os; - } + void clear() { Base::clear(); } //need explicit definition for Has_member_clear in bgl helpers +}; - friend std::ifstream& operator>> (std::ifstream& is, Self& amap) - { - load_generalized_map(is, amap); - return is; - } - }; +namespace Index +{ +// New class Linear_cell_complex using compact container with index. +// No difference with class Linear_cell_complex_base except the default +// template parameters and the default parameter for Refs class. +// NOTE: If we want to inherit from this class, we need to add the Refs class +// template parameter. +template< unsigned int d_, unsigned int ambient_dim, + class Traits_, class Items_, class Alloc_, + template + class CMap, class Storage_> +class Linear_cell_complex_for_generalized_map: + public Linear_cell_complex_for_generalized_map_base + , Storage_> +{ +public: + typedef Linear_cell_complex_for_generalized_map Self; + typedef Linear_cell_complex_for_generalized_map_base Base; + + typedef Traits_ Traits; + typedef Items_ Items; + typedef Alloc_ Alloc; + + Linear_cell_complex_for_generalized_map() : Base() + {} + + /** Copy the given linear cell complex into *this. + * Note that both LCC can have different dimensions and/or non void attributes. + * @param alcc the linear cell complex to copy. + * @post *this is valid. + */ + Linear_cell_complex_for_generalized_map(const Self& alcc) : Base(alcc) + {} + + Linear_cell_complex_for_generalized_map(Self&& alcc) : Base(alcc) + {} + + template class CMap2, + class Storage2> + Linear_cell_complex_for_generalized_map + (const Linear_cell_complex_for_generalized_map& alcc) : Base(alcc) + {} + + template class CMap2, + class Storage2, typename Converters> + Linear_cell_complex_for_generalized_map + (const Linear_cell_complex_for_generalized_map& alcc, + const Converters& converters) : Base(alcc, converters) + {} + + template class CMap2, + class Storage2, typename Converters, typename DartInfoConverter> + Linear_cell_complex_for_generalized_map + (const Linear_cell_complex_for_generalized_map& alcc, + const Converters& converters, + const DartInfoConverter& dartinfoconverter) : + Base(alcc, converters, dartinfoconverter) + {} + + template class CMap2, + class Storage2, typename Converters, + typename DartInfoConverter, typename PointConverter> + Linear_cell_complex_for_generalized_map + (const Linear_cell_complex_for_generalized_map& alcc, + const Converters& converters, const DartInfoConverter& dartinfoconverter, + const PointConverter& pointconverter) : + Base(alcc, converters, dartinfoconverter, pointconverter) + {} + + Self & operator= (const Self & alcc) + { + Base::operator=(alcc); + return *this; + } + + void clear() { Base::clear(); } //need explicit definition for Has_member_clear in bgl helpers +}; +} // namespace Index } // namespace CGAL #endif // CGAL_LINEAR_CELL_COMPLEX_FOR_GENERALIZED_MAP_H // diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h index c207e24ff49..4dcc28da93e 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h @@ -89,17 +89,17 @@ template < unsigned int d_, unsigned int ambient_dim = d_, // TODO READD CGAL::Tag_false> > class Linear_cell_complex_for_combinatorial_map; -/* TODO GMap_linear_cell_complex_storage_2 - template < unsigned int d_, unsigned int ambient_dim = d_, - class Traits_ = Linear_cell_complex_traits, - class Items_ = Linear_cell_complex_min_items, - class Alloc_ = CGAL_ALLOCATOR(int), - template - class CMap = Generalized_map_base, - class Storage_ = GMap_linear_cell_complex_storage_2> +template < unsigned int d_, unsigned int ambient_dim = d_, + class Traits_ = Linear_cell_complex_traits, + class Items_ = Linear_cell_complex_min_items, + class Alloc_ = CGAL_ALLOCATOR(int), + template + class CMap = Generalized_map_base, + class Storage_ = GMap_linear_cell_complex_storage_2> // TODO READD CGAL::Tag_false> > - class Linear_cell_complex_for_generalized_map; */ +class Linear_cell_complex_for_generalized_map; } // namespace Index } // CGAL diff --git a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt index b41fc5211b7..1d2c55a8370 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt @@ -6,16 +6,28 @@ project(Linear_cell_complex_Tests) find_package(CGAL REQUIRED) -file( - GLOB hfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.h) +set(hfiles Linear_cell_complex_2_test.h + Linear_cell_complex_3_test.h Linear_cell_complex_3_test.h) # create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}" "${hfiles}") -endforeach() +create_single_source_cgal_program(Linear_cell_complex_2_test.cpp ${hfiles}) +create_single_source_cgal_program(Linear_cell_complex_3_test.cpp ${hfiles}) +create_single_source_cgal_program(Linear_cell_complex_4_test.cpp ${hfiles}) +create_single_source_cgal_program(Linear_cell_complex_copy_test.cpp ${hfiles}) + +# Same targets, defining USE_COMPACT_CONTAINER_WITH_INDEX to test index version +add_executable(Linear_cell_complex_2_test_index Linear_cell_complex_2_test.cpp ${hfiles}) +target_compile_definitions(Linear_cell_complex_2_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) +target_link_libraries(Linear_cell_complex_2_test_index PUBLIC CGAL) + +add_executable(Linear_cell_complex_3_test_index Linear_cell_complex_3_test.cpp ${hfiles}) +target_compile_definitions(Linear_cell_complex_3_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) +target_link_libraries(Linear_cell_complex_3_test_index PUBLIC CGAL) + +add_executable(Linear_cell_complex_4_test_index Linear_cell_complex_4_test.cpp ${hfiles}) +target_compile_definitions(Linear_cell_complex_4_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) +target_link_libraries(Linear_cell_complex_4_test_index PUBLIC CGAL) + +add_executable(Linear_cell_complex_copy_test_index Linear_cell_complex_copy_test.cpp ${hfiles}) +target_compile_definitions(Linear_cell_complex_copy_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) +target_link_libraries(Linear_cell_complex_copy_test_index PUBLIC CGAL) diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp index 6de16e83b88..5178e268110 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp @@ -23,10 +23,9 @@ template; -// TODO use CGAL::Index::Linear_cell_complex_for_generalized_map template -using My_lcc_gmap=CGAL::Linear_cell_complex_for_generalized_map +using My_lcc_gmap=CGAL::Index::Linear_cell_complex_for_generalized_map ; #else template @@ -56,7 +55,7 @@ struct Map_2_dart_items { typedef My_cell_attribute< Refs, int > Int_attrib; typedef My_cell_attribute< Refs, double > Double_attrib; - typedef My_cell_attribute< Refs, double > Double_attrib_wp; + typedef My_cell_attribute_with_point< Refs, double > Double_attrib_wp; typedef std::tuple Attributes; }; };