diff --git a/BGL/test/BGL/graph_concept_Linear_cell_complex.cpp b/BGL/test/BGL/graph_concept_Linear_cell_complex.cpp index 7d9a1382755..65a2cd0dd58 100644 --- a/BGL/test/BGL/graph_concept_Linear_cell_complex.cpp +++ b/BGL/test/BGL/graph_concept_Linear_cell_complex.cpp @@ -12,9 +12,9 @@ struct Myitem template struct Dart_wrapper { - typedef CGAL::Dart<2, Refs > Dart; - typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute; - typedef CGAL::Cell_attribute< Refs > Face_attribute; + typedef CGAL::Tag_true Darts_with_id; + typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute; + typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute; typedef CGAL::cpp11::tuple Attributes; }; }; diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index 705a04316f2..fb938fd157d 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -46,9 +46,9 @@ struct Myitem template struct Dart_wrapper { - typedef CGAL::Dart<2, Refs > Dart; - typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute; - typedef CGAL::Cell_attribute< Refs > Face_attribute; + typedef CGAL::Tag_true Darts_with_id; + typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute; + typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute; typedef CGAL::cpp11::tuple Attributes; }; }; diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index fb557dec046..74af7d41eb0 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -42,7 +42,7 @@ namespace CGAL { namespace internal { - template + template struct Init_id; } // end namespace internal @@ -77,15 +77,41 @@ namespace CGAL { Info minfo; }; + /// Id associated with a cell attribute + template + class Add_id + { + public: + // Required to have "internal" property maps. + std::size_t& id() + { return m_id; } + const std::size_t& id() const + { return m_id; } + + protected: + void set_id(std::size_t id) + { m_id=id; } + + protected: + /// id of the cell + std::size_t m_id; + }; + + /// If the tag WithId is false, we do not add id to cells. + template <> + class Add_id + {}; + /// Cell_attribute_without_info template + class OnSplit=Null_functor, class WithID=Tag_false> class Cell_attribute_without_info; // Cell_attribute_without_info without dart support. - template + template class Cell_attribute_without_info + OnMerge, OnSplit, WithID>: + public Add_id { template friend class Combinatorial_map_storage_1; @@ -105,7 +131,7 @@ namespace CGAL { template friend class Concurrent_compact_container; - template + template friend struct internal::Init_id; public: @@ -117,6 +143,7 @@ namespace CGAL { typedef OnMerge On_merge; typedef OnSplit On_split; + typedef WithID Has_id; /// operator = Cell_attribute_without_info& @@ -146,14 +173,6 @@ namespace CGAL { bool operator!=(const Cell_attribute_without_info& other) const { return !operator==(other); } - // Required to have "internal" property maps. - // TODO better (use id only when we want to use bgl ?) - // (or have an id directly in compact container ?) - std::size_t& id() - { return m_id; } - const std::size_t& id() const - { return m_id; } - protected: /// Contructor without parameter. Cell_attribute_without_info(): mrefcounting(0) @@ -176,9 +195,6 @@ namespace CGAL { mrefcounting-=4; // 4 because the two lowest bits are reserved for cc } - void set_id(std::size_t id) - { m_id=id; } - public: /// Get the reference counting. std::size_t get_nb_refs() const @@ -196,9 +212,6 @@ namespace CGAL { std::size_t mrefcounting; void *vp; }; - - /// id of the dart // TODO better - std::size_t m_id; }; /** Definition of cell attribute. @@ -206,9 +219,9 @@ namespace CGAL { * link to a dart of the cell (when T is true). * The refs class must provide the type of Combinatorial_map used. */ - template + template class Cell_attribute_without_info + OnMerge, OnSplit, WithID>: public Add_id { template friend class Combinatorial_map_storage_1; @@ -240,6 +253,7 @@ namespace CGAL { typedef OnMerge On_merge; typedef OnSplit On_split; + typedef WithID Has_id; /// operator = Cell_attribute_without_info& @@ -270,14 +284,6 @@ namespace CGAL { bool operator!=(const Cell_attribute_without_info& other) const { return !operator==(other); } - // Required to have "internal" property maps. - // TODO better (use id only when we want to use bgl ?) - // (or have an id directly in compact container ?) - std::size_t& id() - { return m_id; } - const std::size_t& id() const - { return m_id; } - protected: /// Contructor without parameter. Cell_attribute_without_info() : mdart(Refs::null_handle), @@ -302,9 +308,6 @@ namespace CGAL { --mrefcounting; } - void set_id(std::size_t id) - { m_id=id; } - public: /// Get the reference counting. std::size_t get_nb_refs() const @@ -321,23 +324,20 @@ namespace CGAL { /// Reference counting: the number of darts linked to this cell. std::size_t mrefcounting; - - /// id of the dart // TODO better - std::size_t m_id; }; /// Cell associated with an attribute, with or without info depending /// if Info==void. template + class OnSplit=Null_functor, + class WithID=Tag_false> class Cell_attribute; /// Specialization when Info==void. - template - class Cell_attribute : - public Cell_attribute_without_info + template + class Cell_attribute : + public Cell_attribute_without_info { template friend class Combinatorial_map_storage_1; @@ -374,9 +374,9 @@ namespace CGAL { /// Specialization when Info!=void. template + class OnMerge, class OnSplit, class WithID> class Cell_attribute : - public Cell_attribute_without_info, + public Cell_attribute_without_info, public Info_for_cell_attribute { template @@ -398,7 +398,7 @@ namespace CGAL { friend class Concurrent_compact_container; public: - typedef Cell_attribute Self; + typedef Cell_attribute Self; typedef Tag_ Supports_cell_dart; typedef typename Refs::Dart_handle Dart_handle; @@ -425,6 +425,47 @@ namespace CGAL { {} }; + // A cell attribute with an id, when Info_!=void + template + class Cell_attribute_with_id: public Cell_attribute + + { + template + friend class Compact_container; + + template + friend class Concurrent_compact_container; + + protected: + /// Default contructor. + Cell_attribute_with_id() + {} + + /// Contructor with an info in parameter. + Cell_attribute_with_id(const Info_& ainfo) : + Cell_attribute(ainfo) + {} + }; + + /// Specialization when Info==void. + template + class Cell_attribute_with_id: + public Cell_attribute + { + template + friend class Compact_container; + + template + friend class Concurrent_compact_container; + + protected: + /// Default contructor. + Cell_attribute_with_id() + {} + }; + } // namespace CGAL #endif // CGAL_CELL_ATTRIBUTE_H // diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index ca1d4d6fda3..0edc5dec58b 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -57,16 +57,18 @@ namespace CGAL { typedef typename Dart_wrapper::Dart Dart; #else typedef typename internal::template Get_dart_info::type - Dart_info; - typedef CGAL::Dart Dart; + Dart_info; + typedef typename internal::template Get_darts_with_id::type + Darts_with_id; + typedef CGAL::Dart Dart; #endif - typedef typename Alloc_::template rebind::other Dart_allocator; + typedef typename Alloc_::template rebind::other Dart_allocator; - typedef Compact_container Dart_container; + typedef Compact_container 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; + typedef typename Dart_container::iterator Dart_handle; + typedef typename Dart_container::const_iterator Dart_const_handle; + typedef typename Dart_container::size_type size_type; typedef CGAL::Void* Null_handle_type; static const Null_handle_type null_handle; diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index c9acbe3e623..f7d269ddaf4 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -46,7 +46,7 @@ namespace CGAL { namespace internal { - template + template struct Init_id; } // end namespace internal @@ -62,8 +62,8 @@ namespace CGAL { * n is the dimension of the space (2 for 2D, 3 for 3D...) * Refs the ref class */ - template - struct Dart_without_info + template + struct Dart_without_info: public Add_id { public: template @@ -87,11 +87,12 @@ namespace CGAL { template friend struct internal::Init_id; - typedef Dart_without_info Self; - typedef typename Refs::Dart_handle Dart_handle; - typedef typename Refs::size_type size_type; - typedef typename Refs::Dart_const_handle Dart_const_handle; - typedef typename Refs::Helper Helper; + typedef Dart_without_info Self; + typedef typename Refs::Dart_handle Dart_handle; + typedef typename Refs::size_type size_type; + typedef typename Refs::Dart_const_handle Dart_const_handle; + typedef typename Refs::Helper Helper; + typedef WithId Has_id; /// Typedef for attributes template @@ -119,14 +120,6 @@ namespace CGAL { return mf[i]; } - // Required to have "internal" property maps. - // TODO better (use id only when we want to use bgl ?) - // (or have an id directly in compact container ?) - std::size_t& id() - { return m_id; } - const std::size_t& id() const - { return m_id; } - protected: /** Default constructor: no real initialisation, * because this is done in the combinatorial map class. @@ -202,9 +195,6 @@ namespace CGAL { (mattribute_handles); } - void set_id(std::size_t id) - { m_id=id; } - protected: /// Neighboors for each dimension +1 (from 0 to dimension). Dart_handle mf[dimension+1]; @@ -214,9 +204,6 @@ namespace CGAL { /// Attributes enabled typename Helper::Attribute_handles mattribute_handles; - - /// id of the dart // TODO better - std::size_t m_id; }; #if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE) @@ -324,8 +311,9 @@ namespace CGAL { #else // CGAL_CMAP_DART_DEPRECATED // Dart definition with an info; // (there is a specialization below when Info_==void) - template - struct Dart : public Dart_without_info + template + struct Dart : public Dart_without_info { public: template @@ -346,8 +334,8 @@ namespace CGAL { template friend class Concurrent_compact_container; - typedef Dart Self; - typedef Info_ Info; + typedef Dart Self; + typedef Info_ Info; protected: /** Default constructor: no real initialisation, @@ -369,8 +357,8 @@ namespace CGAL { }; // Specialization of Dart class when info==void - template - struct Dart : public Dart_without_info + template + struct Dart : public Dart_without_info { public: typedef CGAL::Void Info; diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h index a2a3036156e..b41369d4216 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h @@ -1037,7 +1037,8 @@ struct Beta_functor_static }; #endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES // **************************************************************************** -template +template struct Init_id { static void run(Container& c, typename Container::iterator e) @@ -1045,6 +1046,12 @@ struct Init_id e->set_id(c.index(e)); } }; +template +struct Init_id +{ + static void run(Container&, typename Container::iterator) + {} +}; // **************************************************************************** } // namespace internal } // namespace CGAL diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h index d9ff3fa3cf9..beb83990d73 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h @@ -60,6 +60,16 @@ namespace CGAL struct Get_dart_info { typedef typename Convert_void::type type; }; + // Get the type Darts_with_id as inner type of T. + // If T::Darts_with_id is not defined or if T::Darts_widh_id is Tag_false + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_darts_with_id,Darts_with_id,false) + template::value > + struct Get_darts_with_id + { typedef CGAL::Tag_false type; }; + template + struct Get_darts_with_id + { typedef CGAL::Tag_true type; }; + // Get the type Attributes defined as inner type of T. // If T::Attributes is not defined, defined CGAL::cpp11::tuple<> as type. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_attributes_tuple,Attributes,false) diff --git a/Generalized_map/include/CGAL/Generalized_map_storages.h b/Generalized_map/include/CGAL/Generalized_map_storages.h index 9498cde9ef2..4e682e2df74 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages.h @@ -56,7 +56,9 @@ namespace CGAL { typedef typename internal::template Get_dart_info::type Dart_info; - typedef CGAL::Dart Dart; + typedef typename internal::template Get_darts_with_id::type + Darts_with_id; + typedef CGAL::Dart Dart; typedef typename Alloc_::template rebind::other Dart_allocator; 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 a55a8582fbe..4b5e9109783 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 @@ -68,16 +68,18 @@ namespace CGAL { typedef typename Dart_wrapper::Dart Dart; #else typedef typename internal::template Get_dart_info::type - Dart_info; - typedef CGAL::Dart Dart; + Dart_info; + typedef typename internal::template Get_darts_with_id::type + Darts_with_id; + typedef CGAL::Dart Dart; #endif - typedef typename Alloc_::template rebind::other Dart_allocator; + typedef typename Alloc_::template rebind::other Dart_allocator; - typedef Compact_container Dart_container; + typedef Compact_container 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; + typedef typename Dart_container::iterator Dart_handle; + typedef typename Dart_container::const_iterator Dart_const_handle; + typedef typename Dart_container::size_type size_type; typedef CGAL::Void* Null_handle_type; static const Null_handle_type null_handle; diff --git a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h index 3331133c662..2bbeb363bff 100644 --- a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h +++ b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h @@ -57,10 +57,11 @@ namespace CGAL { /// Attribute associated with a point and an info. template < class LCC, class Info_=void, class Tag=Tag_true, class Functor_on_merge_=Null_functor, - class Functor_on_split_=Null_functor > + class Functor_on_split_=Null_functor, + class WithID=Tag_false > class Cell_attribute_with_point : public Cell_attribute, + Functor_on_merge_, Functor_on_split_, WithID>, public Point_for_cell { template @@ -112,10 +113,13 @@ namespace CGAL { /// Attribute associated with a point and without info. template < class LCC, class Tag, class Functor_on_merge_, - class Functor_on_split_ > + class Functor_on_split_, + class WithID> class Cell_attribute_with_point : - public Cell_attribute, + Functor_on_merge_, Functor_on_split_, + WithID>: + public Cell_attribute, public Point_for_cell { template @@ -126,7 +130,7 @@ namespace CGAL { public: typedef Cell_attribute Base1; + Functor_on_merge_, Functor_on_split_, WithID> Base1; typedef Point_for_cell Base2; typedef void Info; @@ -156,6 +160,63 @@ namespace CGAL { Cell_attribute_with_point(const Point& apoint) : Base2(apoint) {} }; + + // A cell attribute with point and id, when Info_!=void + template + class Cell_attribute_with_point_and_id: public + Cell_attribute_with_point + { + typedef Cell_attribute_with_point + Base; + typedef typename Refs::Point Point; + + template + friend class Compact_container; + + template + friend class Concurrent_compact_container; + + protected: + /// Default contructor. + Cell_attribute_with_point_and_id() + {} + + /// Contructor with an info in parameter. + Cell_attribute_with_point_and_id(const Point& apoint) : Base(apoint) + {} + + /// Contructor with a point and an attribute in parameters. + Cell_attribute_with_point_and_id(const Point& apoint, const Info_& ainfo) : + Base(apoint, ainfo) + {} + }; + + /// Specialization when Info==void. + template + class Cell_attribute_with_point_and_id: + public Cell_attribute_with_point + { + typedef Cell_attribute_with_point + Base; + typedef typename Refs::Point Point; + + template + friend class Compact_container; + + template + friend class Concurrent_compact_container; + + protected: + /// Default contructor. + Cell_attribute_with_point_and_id() + {} + + /// Contructor with a point in parameter. + Cell_attribute_with_point_and_id(const Point& apoint) : Base(apoint) + {} + }; } // namespace CGAL #endif // CGAL_CELL_ATTRIBUTE_WITH_POINT_H // 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 ec99f027d67..54cafb2ce2f 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 @@ -65,16 +65,18 @@ namespace CGAL { typedef typename Items_::template Dart_wrapper Dart_wrapper; typedef typename internal::template Get_dart_info::type - Dart_info; - typedef CGAL::Dart Dart; + Dart_info; + typedef typename internal::template Get_darts_with_id::type + Darts_with_id; + typedef CGAL::Dart Dart; - typedef typename Alloc_::template rebind::other Dart_allocator; + typedef typename Alloc_::template rebind::other Dart_allocator; - typedef Compact_container Dart_container; + typedef Compact_container 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; + typedef typename Dart_container::iterator Dart_handle; + typedef typename Dart_container::const_iterator Dart_const_handle; + typedef typename Dart_container::size_type size_type; typedef CGAL::Void* Null_handle_type; static const Null_handle_type null_handle; diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp index b938c43f33f..91cc3d076c9 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp @@ -19,9 +19,9 @@ struct Myitem template struct Dart_wrapper { - typedef CGAL::Dart<2, Refs > Dart; - typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute; - typedef CGAL::Cell_attribute< Refs > Face_attribute; + typedef CGAL::Tag_true Darts_with_id; + typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute; + typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute; typedef CGAL::cpp11::tuple Attributes; }; };