// Copyright (c) 2010-2011 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_CELL_ATTRIBUTE_H #define CGAL_CELL_ATTRIBUTE_H 1 #include #include #include #include namespace CGAL { template class Compact_container; template class Concurrent_compact_container; template class Compact_container_with_index; template class Combinatorial_map_storage_1; template class Combinatorial_map_storage_with_index; template class Generalized_map_storage_1; template class Generalized_map_storage_with_index; template class CMap_linear_cell_complex_storage_1; template class CMap_linear_cell_complex_storage_with_index; template class GMap_linear_cell_complex_storage_1; template class GMap_linear_cell_complex_storage_with_index; namespace internal { template struct Init_id; } // end namespace internal /** @file Cell_attribute.h * Definition of cell attribute, with or without info. */ /// 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: std::size_t m_id; ///< id of the cell }; /// If the tag WithId is false, we do not add id to cells. template <> class Add_id {}; /// Cell_attribute_without_info template class Cell_attribute_without_info; // Cell_attribute_without_info without dart support. template class Cell_attribute_without_info: public Add_id { template friend class Compact_container; template friend class Concurrent_compact_container; template friend class Compact_container_with_index; template friend class Combinatorial_map_storage_1; template friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template friend class GMap_linear_cell_complex_storage_with_index; template friend struct internal::Init_id; public: typedef Tag_false Supports_cell_dart; typedef typename Refs::Dart_descriptor Dart_descriptor; typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; typedef typename Refs::Alloc Alloc; typedef OnMerge On_merge; typedef OnSplit On_split; typedef WithID Has_id; using Type_for_compact_container=typename Refs::Type_for_compact_container; /// operator = Cell_attribute_without_info& operator=(const Cell_attribute_without_info& acell) { mrefcounting=acell.mrefcounting; m_for_cc=acell.m_for_cc; return *this; } /// Get the dart associated with the cell. Dart_descriptor dart() { return Refs::null_descriptor; } /// Get the dart associated with the cell. Dart_const_descriptor dart() const { return Refs::null_descriptor; } /// Set the dart associated with the cell. void set_dart(Dart_descriptor) {} /// Test if the cell is valid. /// For cell without dart, return always true. bool is_valid() const { return true; } bool operator==(const Cell_attribute_without_info&) const { return true; } bool operator!=(const Cell_attribute_without_info& other) const { return !operator==(other); } protected: /// Constructor without parameter. Cell_attribute_without_info(): mrefcounting(0), m_for_cc(Refs::null_descriptor) {} /// Copy constructor. Cell_attribute_without_info(const Cell_attribute_without_info& acell): mrefcounting(acell.mrefcounting) {} protected: /// Increment the reference counting. void inc_nb_refs() { ++mrefcounting; } /// Decrement the reference counting. void dec_nb_refs() { CGAL_assertion( mrefcounting>0 ); --mrefcounting; } public: /// Get the reference counting. std::size_t get_nb_refs() const { return mrefcounting; } Type_for_compact_container for_compact_container() const { return m_for_cc; } void for_compact_container(Type_for_compact_container p) { m_for_cc=p; } private: /// Reference counting: the number of darts linked to this cell. std::size_t mrefcounting; Type_for_compact_container m_for_cc; // TODO better: this is memory consuming // TODO: or keep like that and never use an attribute without info and without dart ! }; /** Definition of cell attribute. * Cell_attribute defines what is a a cell. This is an object allowing to * link to a dart of the cell (when T is true). * The refs class must provide the type of Combinatorial_map used. */ template class Cell_attribute_without_info: public Add_id { template friend class Compact_container; template friend class Concurrent_compact_container; template friend class Compact_container_with_index; template friend class Combinatorial_map_storage_1; template friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template friend class GMap_linear_cell_complex_storage_with_index; template friend struct internal::Init_id; public: typedef Tag_true Supports_cell_dart; typedef typename Refs::Dart_descriptor Dart_descriptor; typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; typedef typename Refs::Alloc Alloc; typedef OnMerge On_merge; typedef OnSplit On_split; typedef WithID Has_id; using Type_for_compact_container=typename Refs::Type_for_compact_container; /// operator = Cell_attribute_without_info& operator=(const Cell_attribute_without_info& acell) { mdart = acell.mdart; mrefcounting = acell.mrefcounting; return *this; } /// Get the dart associated with the cell. Dart_descriptor dart() { return mdart; } /// Get the dart associated with the cell. Dart_const_descriptor dart() const { return mdart; } /// Set the dart associated with the cell. void set_dart(Dart_descriptor adart) { mdart = adart; } /// Test if the cell is valid. /// A cell is valid if its dart is not null_descriptor. bool is_valid() const { return mdart!=Refs::null_descriptor; } bool operator==(const Cell_attribute_without_info&) const { return true; } bool operator!=(const Cell_attribute_without_info& other) const { return !operator==(other); } protected: /// Constructor without parameter. Cell_attribute_without_info() : mdart(Refs::null_descriptor), mrefcounting(0) {} /// Copy constructor. Cell_attribute_without_info(const Cell_attribute_without_info& acell): mdart(acell.mdart), mrefcounting(acell.mrefcounting) {} protected: /// Increment the reference counting. void inc_nb_refs() { ++mrefcounting; } /// Decrement the reference counting. void dec_nb_refs() { CGAL_assertion( mrefcounting>0 ); --mrefcounting; } public: /// Get the reference counting. std::size_t get_nb_refs() const { return mrefcounting; } Type_for_compact_container for_compact_container() const { return mdart.for_compact_container(); } void for_compact_container(Type_for_compact_container p) { mdart.for_compact_container(p); } private: /// The dart descriptor associated with the cell. Dart_descriptor 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 /// if Info==void. template class Cell_attribute; /// Specialization when Info==void. template class Cell_attribute : public Cell_attribute_without_info { template friend class Compact_container; template friend class Concurrent_compact_container; template friend class Compact_container_with_index; template friend class Combinatorial_map_storage_1; template friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template friend class GMap_linear_cell_complex_storage_with_index; public: typedef Tag_ Supports_cell_dart; typedef typename Refs::Dart_descriptor Dart_descriptor; typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; typedef typename Refs::Alloc Alloc; typedef OnMerge On_merge; typedef OnSplit On_split; typedef void Info; protected: /// Default constructor. Cell_attribute() {} }; /// Specialization when Info!=void. template class Cell_attribute : public Cell_attribute_without_info, public Info_for_cell_attribute { template friend class Compact_container; template friend class Concurrent_compact_container; template friend class Compact_container_with_index; template friend class Combinatorial_map_storage_1; template friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template friend class GMap_linear_cell_complex_storage_with_index; public: typedef Cell_attribute Self; typedef Tag_ Supports_cell_dart; typedef typename Refs::Dart_descriptor Dart_descriptor; typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; typedef typename Refs::Alloc Alloc; typedef OnMerge On_merge; typedef OnSplit On_split; typedef Info_ Info; bool operator==(const Self& other) const { return this->info()==other.info(); } bool operator!=(const Self& other) const { return !operator==(other); } protected: /// Default constructor. Cell_attribute() {} /// Constructor with an info in parameter. Cell_attribute(const Info_& ainfo) : Info_for_cell_attribute(ainfo) {} }; } // namespace CGAL #endif // CGAL_CELL_ATTRIBUTE_H // // EOF //