Storage with index for gmap.

This commit is contained in:
Guillaume Damiand 2022-04-12 15:22:01 +02:00
parent 2e076fa6f3
commit 3d874e8e1e
19 changed files with 1588 additions and 225 deletions

View File

@ -85,22 +85,22 @@ namespace CGAL {
public Add_id<WithID>
{
template<unsigned int, class, class, class>
friend class Combinatorial_map_storage_1;
friend class CGAL::Combinatorial_map_storage_1;
template<unsigned int, class, class, class>
friend class Generalized_map_storage_1;
friend class CGAL::Generalized_map_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
friend class CGAL::CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;
friend class CGAL::GMap_linear_cell_complex_storage_1;
template <class, class, class, class>
friend class Compact_container;
friend class CGAL::Compact_container;
template <class, class>
friend class Concurrent_compact_container;
friend class CGAL::Concurrent_compact_container;
template<class, class>
friend struct internal::Init_id;
@ -195,22 +195,22 @@ namespace CGAL {
OnMerge, OnSplit, WithID>: public Add_id<WithID>
{
template<unsigned int, class, class, class>
friend class Combinatorial_map_storage_1;
friend class CGAL::Combinatorial_map_storage_1;
template<unsigned int, class, class, class>
friend class Generalized_map_storage_1;
friend class CGAL::Generalized_map_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
friend class CGAL::CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;
friend class CGAL::GMap_linear_cell_complex_storage_1;
template <class, class, class, class>
friend class Compact_container;
friend class CGAL::Compact_container;
template <class, class>
friend class Concurrent_compact_container;
friend class CGAL::Concurrent_compact_container;
template<class, class>
friend struct internal::Init_id;
@ -311,22 +311,22 @@ namespace CGAL {
public Cell_attribute_without_info<Refs, Tag_, OnMerge, OnSplit, WithID>
{
template<unsigned int, class, class, class>
friend class Combinatorial_map_storage_1;
friend class CGAL::Combinatorial_map_storage_1;
template<unsigned int, class, class, class>
friend class Generalized_map_storage_1;
friend class CGAL::Generalized_map_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
friend class CGAL::CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;
friend class CGAL::GMap_linear_cell_complex_storage_1;
template <class, class, class, class>
friend class Compact_container;
friend class CGAL::Compact_container;
template <class, class>
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<Info_>
{
template<unsigned int, class, class, class>
friend class Combinatorial_map_storage_1;
friend class CGAL::Combinatorial_map_storage_1;
template<unsigned int, class, class, class>
friend class Generalized_map_storage_1;
friend class CGAL::Generalized_map_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
friend class CGAL::CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;
friend class CGAL::GMap_linear_cell_complex_storage_1;
template <class, class, class, class>
friend class Compact_container;
friend class CGAL::Compact_container;
template <class, class>
friend class Concurrent_compact_container;
friend class CGAL::Concurrent_compact_container;
public:
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit, WithID> Self;

View File

@ -25,6 +25,15 @@ namespace CGAL {
template<unsigned int, class, class, class>
class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
class CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
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<Refs, Tag_false,
OnMerge, OnSplit>
{
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
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<Refs, Tag_true,
OnMerge, OnSplit>
{
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index;
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
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<Refs, Tag_,
OnSplit, OnMerge>
{
template < unsigned int, class, class, class, class >
friend class CGAL::Combinatorial_map_base;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
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<Info_>
{
template < unsigned int, class, class, class, class >
friend class CGAL::Combinatorial_map_base;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::GMap_linear_cell_complex_storage_2;
public:
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit> Self;

View File

@ -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<unsigned int d_, class Items_, class Alloc_, class Concurrent_tag >
class Combinatorial_map_storage_1

View File

@ -14,7 +14,6 @@
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <CGAL/Handle_hash_function.h>
#include <bitset>
#include <boost/config.hpp>
@ -31,14 +30,6 @@ namespace CGAL {
template<typename Concurrent_tag, class T, class Alloc_>
struct Container_type;
struct Index_hash_function {
typedef std::size_t result_type;
template <class H>
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<int B1>
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<int B1>
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<unsigned int i>
void basic_set_dart_attribute(Dart_handle ADart,
void basic_set_dart_attribute(Dart_handle dh,
typename Attribute_handle<i>::type ah)
{
std::get<Helper::template Dimension_index<i>::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;

View File

@ -71,6 +71,17 @@
namespace CGAL {
namespace internal
{
struct Index_hash_function {
typedef std::size_t result_type;
template <class H>
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<size_type>(cit); }
size_type index(Index idx) const
{ return static_cast<size_type>(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

View File

@ -36,6 +36,9 @@ namespace CGAL {
template<unsigned int, unsigned int, class, class, class, class>
class CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
class CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
class GMap_linear_cell_complex_storage_1;
@ -70,6 +73,9 @@ namespace CGAL {
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;
@ -217,6 +223,9 @@ namespace CGAL {
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_1;
template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class GMap_linear_cell_complex_storage_1;

View File

@ -20,19 +20,40 @@
namespace CGAL {
namespace Index
template <class, class, class, class>
class Compact_container_with_index_2;
template<unsigned int, class, class, class>
class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
class CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
class GMap_linear_cell_complex_storage_2;
namespace Index
{
template <unsigned int d, typename Refs>
struct Dart_without_info
{
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
// TODO template<unsigned int, unsigned int, class, class, class, class>
// friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::GMap_linear_cell_complex_storage_2;
typedef Dart_without_info<d,Refs> Self;
typedef typename Refs::Dart_handle Dart_handle;
@ -159,14 +180,20 @@ namespace CGAL {
struct Dart : public Dart_without_info<d, Refs>
{
public:
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, class, class, class>
friend class CGAL::Combinatorial_map_storage_2;
/* TODO template<unsigned int, unsigned int, class, class, class, class>
friend class CMap_linear_cell_complex_storage_2; */
template<unsigned int, class, class, class>
friend class CGAL::Generalized_map_storage_2;
template <class, class, class, class>
friend class CGAL::Compact_container_with_index_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::CMap_linear_cell_complex_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
friend class CGAL::GMap_linear_cell_complex_storage_2;
typedef Dart<d, Refs, Info_> Self;
typedef Info_ Info;

View File

@ -21,6 +21,7 @@
#include <CGAL/Generalized_map/internal/Generalized_map_sewable.h>
#include <CGAL/Generalized_map_storages.h>
#include <CGAL/Generalized_map_storages_with_index.h>
#include <CGAL/Combinatorial_map_functors.h>
#include <CGAL/Combinatorial_map_basic_operations.h>
#include <CGAL/Generalized_map_operations.h>
@ -38,8 +39,6 @@
#include <boost/type_traits/is_same.hpp>
#include <CGAL/config.h>
#include <unordered_map>
#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<int i>
@ -262,7 +262,7 @@ namespace CGAL {
internal::Copy_dart_info_functor
<typename GMap2::Refs, Refs, DartInfoConverter>::run
(static_cast<const typename GMap2::Refs&>(amap), static_cast<Refs&>(*this),
(static_cast<typename GMap2::Refs&>(amap), static_cast<Refs&>(*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
<internal::Restricted_decrease_attribute_functor<Self> >::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<unsigned int i>
void restricted_set_dart_attribute(Dart_handle dh,
typename Attribute_handle<i>::type ah)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"set_dart_attribute<i> called but i-attributes are disabled.");
if ( this->template attribute<i>(dh)==ah ) return;
if ( this->template attribute<i>(dh)!=null_handle )
{
this->template dec_attribute_ref_counting<i>(this->template attribute<i>(dh));
}
Base::template basic_set_dart_attribute<i>(dh, ah);
if ( ah!=null_handle )
{
this->template inc_attribute_ref_counting<i>(ah);
}
}
// Set the handle on the i th attribute
template<unsigned int i>
void set_dart_attribute(Dart_handle dh,
@ -712,6 +749,8 @@ namespace CGAL {
Helper::template Foreach_enabled_attributes
<internal::Init_attribute_functor<Self> >::run(*this, adart);
internal::Init_id<Dart_container>::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
<internal::Init_attribute_functor<Self> >::run(*this, adart);
internal::Init_id<Dart_container>::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 "
<<darts().index(it)<< std::endl;
}
valid = false;
}
@ -1206,10 +1249,12 @@ namespace CGAL {
for ( j = i + 2; j <= dimension; ++j)
if (alpha(it, i, j)!=alpha(it, j, i))
{
std::cerr <<"Map not valid: alpha(" << i
<<") o alpha(" << j
<<") is not an involution for dart "
<<darts().index(it)<< std::endl;
if (show_errors)
{ std::cerr <<"Map not valid: alpha(" << i
<<") o alpha(" << j
<<") is not an involution for dart "
<<darts().index(it)<< std::endl;
}
valid = false;
}
}
@ -1259,10 +1304,6 @@ namespace CGAL {
run(*this);
}
/// @return the number of darts.
size_type number_of_darts() const
{ return mdarts.size(); }
/// @return an estimation of the bytes used by the generalized map.
size_type bytes() const
{
@ -1375,6 +1416,8 @@ namespace CGAL {
// Reinitialize the ref counting of the new attribute. This is normally
// not required except if create_attribute is used as "copy contructor".
this->template init_attribute_ref_counting<i>(res);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
@ -1757,6 +1800,30 @@ namespace CGAL {
else topo_unsew<i>(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<std::size_t, Dart_handle> 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<dimension+1>(it, treated)]=it; }
}
if (ccs.size()>1)
{ // Here all darts are marked
this->template unmark_cell<dimension+1>(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 <class InputIterator>
@ -3919,6 +3987,68 @@ namespace CGAL {
{}
};
namespace Index
{
template<unsigned int d_, class Items_, class Alloc_,class Storage_>
class Generalized_map :
public Generalized_map_base<d_,
Generalized_map<d_,Items_,Alloc_, Storage_>,
Items_, Alloc_, Storage_ >
{
public:
typedef Generalized_map<d_, Items_,Alloc_, Storage_> Self;
typedef Generalized_map_base<d_, Self, Items_, Alloc_, Storage_> 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 <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap) :
Base(amap)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2, typename Converters>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters) :
Base(amap, converters)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2,
typename Converters, typename DartInfoConverter>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters,
const DartInfoConverter& dartinfoconverter) :
Base(amap, converters, dartinfoconverter)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2,
typename Converters, typename DartInfoConverter,
typename PointConverter >
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters,
const DartInfoConverter& dartinfoconverter,
const PointConverter& pointconverter) :
Base(amap, converters, dartinfoconverter, pointconverter)
{}
};
} // namespace Index
} // namespace CGAL
#if defined(BOOST_GCC)

View File

@ -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<unsigned int d_, class Items_, class Alloc_, class Concurrent_tag >
class Generalized_map_storage_1
{
public:
typedef Generalized_map_storage_1<d_, Items_, Alloc_, Concurrent_tag> Self;
typedef CGAL::Tag_false Use_index;
using Self=Generalized_map_storage_1<d_, Items_, Alloc_, Concurrent_tag>;
using Use_index=CGAL::Tag_false;
typedef internal::Combinatorial_map_helper<Self> Helper;
@ -62,7 +58,6 @@ namespace CGAL {
typedef typename internal::Container_type
<Concurrent_tag, Dart, Dart_allocator>::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 <typename T>
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<unsigned int i>
bool is_free(Dart_const_handle dh) const

View File

@ -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 <guillaume.damiand@liris.cnrs.fr>
//
#ifndef CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H
#define CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H 1
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <bitset>
#include <boost/config.hpp>
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
#endif
namespace CGAL {
namespace internal {
template <typename M>
struct Combinatorial_map_helper;
template<typename Concurrent_tag, class T, class Alloc_>
struct Container_type;
}
// Storage of darts with compact container, alpha with indices
template<unsigned int d_, class Items_, class Alloc_, class Index_type_ >
class Generalized_map_storage_2
{
public:
using Self=Generalized_map_storage_2<d_, Items_, Alloc_, Index_type_>;
using Use_index=CGAL::Tag_true;
using Index_type=Index_type_;
typedef internal::Combinatorial_map_helper<Self> Helper;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Index::Dart<d_, Self, Dart_info> Dart;
typedef std::allocator_traits<Alloc_> Allocator_traits;
typedef typename Allocator_traits::template rebind_alloc<Dart> Dart_allocator;
typedef Compact_container_with_index_2<Dart,Dart_allocator,
Multiply_by_two_policy_for_cc_with_size<64>, Index_type>
Dart_container;
// typedef unsigned int Dart_index;
// typedef MyIndex<unsigned int> 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 <typename T>
struct Container_for_attributes : public
Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other,
Multiply_by_two_policy_for_cc_with_size<64>, size_type >
{};
/// Typedef for attributes
typedef typename internal::template Get_attributes_tuple<Dart_wrapper>::type
Attributes;
template<int i>
struct Attribute_type: public Helper::template Attribute_type<i>
{};
template<int i>
struct Attribute_handle: public Helper::template Attribute_handle<i>
{};
template<int i>
struct Attribute_const_handle:
public Helper::template Attribute_const_handle<i>
{};
template<int i>
struct Attribute_range: public Helper::template Attribute_range<i>
{};
template<int i>
struct Attribute_const_range:
public Helper::template Attribute_const_range<i>
{};
/// 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<unsigned int i>
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<NB_MARKS>& amarks) const
{
mdarts[ADart].set_marks(amarks);
}
/// Return all the marks of a dart.
std::bitset<NB_MARKS> 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<int B1>
Dart_handle get_alpha(Dart_handle ADart)
{
CGAL_assertion(B1>=0 && B1<=(int)dimension);
return mdarts[ADart].mf[B1];
}
template<int B1>
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<unsigned int i>
typename Attribute_handle<i>::type attribute(Dart_handle ADart)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return std::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_const_handle<i>::type
attribute(Dart_const_handle ADart) const
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return std::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
// Copy a given attribute
template<unsigned int i>
typename Attribute_handle<i>::type copy_attribute
(typename Attribute_const_handle<i>::type ah)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"copy_attribute<i> called but i-attributes are disabled.");
typename Attribute_handle<i>::type res=
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(get_attribute<i>(ah));
this->template init_attribute_ref_counting<i>(res);
return res;
}
// Test if a given attribute is valid
template<unsigned int i>
bool is_valid_attribute(typename Attribute_const_handle<i>::type ah) const
{
return get_attribute<i>(ah).is_valid();
}
// accessors and modifiers to the attribute ref counting given its handle
template<unsigned int i>
std::size_t get_attribute_ref_counting
(typename Attribute_const_handle<i>::type ah) const
{
return get_attribute<i>(ah).get_nb_refs();
}
template<unsigned int i>
void init_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).mrefcounting=0;
}
template<unsigned int i>
void inc_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).inc_nb_refs();
}
template<unsigned int i>
void dec_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).dec_nb_refs();
}
// get the attribute given its index
template<unsigned int i>
typename Attribute_type<i>::type&
get_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
// Get the dart of the given attribute
template<unsigned int i>
Dart_handle dart_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).dart();
}
template<unsigned int i>
Dart_const_handle
dart_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).dart();
}
// Set the dart of the given attribute
template<unsigned int i>
void set_dart_of_attribute(typename Attribute_handle<i>::type ah,
Dart_handle adart)
{
CGAL_assertion( ah!=null_handle );
get_attribute<i>(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<unsigned int i>
typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).info();
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).info();
}
// Get the info of the i-cell attribute associated with the given dart
template<unsigned int i>
typename Attribute_type<i>::type::Info & info(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( this->template attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
Dart_const_handle dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
// Debug function
void display_dart(Dart_const_handle ADart) const
{ std::cout<<ADart; }
template<unsigned int i>
void display_attribute(typename Attribute_const_handle<i>::type ah) const
{ std::cout<<ah; }
protected:
// Set the handle on the i th attribute
template<unsigned int i>
void basic_set_dart_attribute(Dart_handle dh,
typename Attribute_handle<i>::type ah)
{
std::get<Helper::template Dimension_index<i>::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<unsigned int i>
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<unsigned int i>
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<unsigned int d_, class Items_, class Alloc_, class Size_type>
typename Generalized_map_storage_2<d_, Items_, Alloc_, Size_type>::Null_handle_type
Generalized_map_storage_2<d_, Items_, Alloc_, Size_type>::null_handle((std::numeric_limits<size_type>::max)()/2);
} // namespace CGAL
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic pop")
#endif
#endif // CGAL_GENERALIZED_MAP_STORAGES_WITH_INDEX_H //
// EOF //

View File

@ -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<d_, ambient_dim, Traits_,
Items_, Alloc_, Concurrent_tag> Self;
typedef CGAL::Tag_false Use_index;
using Self=CMap_linear_cell_complex_storage_1<d_, ambient_dim, Traits_,
Items_, Alloc_, Concurrent_tag>;
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<unsigned int i>
bool is_free(Dart_const_handle dh) const

View File

@ -14,7 +14,6 @@
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <CGAL/Combinatorial_map_storages_with_index.h>
#include <bitset>
#include <boost/config.hpp>
@ -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<unsigned int d_, unsigned int ambient_dim,
class Traits_, class Items_, class Alloc_, class Index_type_ >
// the correct type).
template<unsigned int d_, unsigned int ambient_dim, class Traits_,
class Items_, class Alloc_, class Index_type_ >
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<int B1>
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<int B1>
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<unsigned int i>
void basic_set_dart_attribute(Dart_handle ADart,
void basic_set_dart_attribute(Dart_handle dh,
typename Attribute_handle<i>::type ah)
{
std::get<Helper::template Dimension_index<i>::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<unsigned int d_, unsigned int ambient_dim,
class Traits_, class Items_, class Alloc_, class Index_type_>
typename CMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_, Items_, Alloc_, Index_type_>::
template<unsigned int d_, unsigned int ambient_dim, class Traits_,
class Items_, class Alloc_, class Index_type_>
typename CMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_, Items_, Alloc_, Index_type_>::
Null_handle_type CMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_,
Items_, Alloc_, Index_type_>::
Items_, Alloc_, Index_type_>::
null_handle((std::numeric_limits<Index_type_>::max)()/2);
} // namespace CGAL

View File

@ -13,6 +13,7 @@
#define CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_H 1
#include <CGAL/Compact_container.h>
#include <CGAL/Concurrent_compact_container.h>
#include <CGAL/Dart.h>
#include <CGAL/Handle_hash_function.h>
#include <bitset>
@ -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<d_, ambient_dim, Traits_,
Items_, Alloc_, Concurrent_tag>;
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<d_, ambient_dim, Traits_,
Items_, Alloc_, Concurrent_tag> Self;
typedef CGAL::Tag_false Use_index;
typedef internal::Combinatorial_map_helper<Self> Helper;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
@ -71,7 +68,6 @@ namespace CGAL {
typedef typename internal::Container_type
<Concurrent_tag, Dart, Dart_allocator>::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 <typename T>
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<unsigned int i>
bool is_free(Dart_const_handle dh) const

View File

@ -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 <guillaume.damiand@liris.cnrs.fr>
//
#ifndef CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H
#define CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H 1
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <bitset>
#include <boost/config.hpp>
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
#endif
namespace CGAL {
namespace internal {
template <typename M>
struct Combinatorial_map_helper;
template<typename Concurrent_tag, class T, class Alloc_>
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<unsigned int d_, unsigned int ambient_dim, class Traits_,
class Items_, class Alloc_, class Index_type_ >
class GMap_linear_cell_complex_storage_2
{
public:
using Self=GMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_,
Items_, Alloc_, Index_type_>;
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<Self> Helper;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Index::Dart<d_, Self, Dart_info> Dart;
typedef std::allocator_traits<Alloc_> Allocator_traits;
typedef typename Allocator_traits::template rebind_alloc<Dart> Dart_allocator;
typedef Compact_container_with_index_2<Dart,Dart_allocator,
Multiply_by_two_policy_for_cc_with_size<64>, Index_type>
Dart_container;
// typedef unsigned int Dart_index;
// typedef MyIndex<unsigned int> 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 <typename T>
struct Container_for_attributes : public
Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other,
Multiply_by_two_policy_for_cc_with_size<64>, size_type >
{};
/// Typedef for attributes
typedef typename internal::template Get_attributes_tuple<Dart_wrapper>::type
Attributes;
template<int i>
struct Attribute_type: public Helper::template Attribute_type<i>
{};
template<int i>
struct Attribute_handle: public Helper::template Attribute_handle<i>
{};
template<int i>
struct Attribute_const_handle:
public Helper::template Attribute_const_handle<i>
{};
template<int i>
struct Attribute_range: public Helper::template Attribute_range<i>
{};
template<int i>
struct Attribute_const_range:
public Helper::template Attribute_const_range<i>
{};
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<unsigned int i>
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<NB_MARKS>& amarks) const
{
mdarts[ADart].set_marks(amarks);
}
/// Return all the marks of a dart.
std::bitset<NB_MARKS> 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<int B1>
Dart_handle get_alpha(Dart_handle ADart)
{
CGAL_assertion(B1>=0 && B1<=(int)dimension);
return mdarts[ADart].mf[B1];
}
template<int B1>
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<unsigned int i>
typename Attribute_handle<i>::type attribute(Dart_handle ADart)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return std::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_const_handle<i>::type
attribute(Dart_const_handle ADart) const
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return std::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
// Copy a given attribute
template<unsigned int i>
typename Attribute_handle<i>::type copy_attribute
(typename Attribute_const_handle<i>::type ah)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"copy_attribute<i> called but i-attributes are disabled.");
typename Attribute_handle<i>::type res=
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(get_attribute<i>(ah));
this->template init_attribute_ref_counting<i>(res);
return res;
}
// Test if a given attribute is valid
template<unsigned int i>
bool is_valid_attribute(typename Attribute_const_handle<i>::type ah) const
{
return get_attribute<i>(ah).is_valid();
}
// accessors and modifiers to the attribute ref counting given its handle
template<unsigned int i>
std::size_t get_attribute_ref_counting
(typename Attribute_const_handle<i>::type ah) const
{
return get_attribute<i>(ah).get_nb_refs();
}
template<unsigned int i>
void init_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).mrefcounting=0;
}
template<unsigned int i>
void inc_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).inc_nb_refs();
}
template<unsigned int i>
void dec_attribute_ref_counting(typename Attribute_handle<i>::type ah)
{
get_attribute<i>(ah).dec_nb_refs();
}
// get the attribute given its index
template<unsigned int i>
typename Attribute_type<i>::type&
get_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
// Get the dart of the given attribute
template<unsigned int i>
Dart_handle dart_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).dart();
}
template<unsigned int i>
Dart_const_handle
dart_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).dart();
}
// Set the dart of the given attribute
template<unsigned int i>
void set_dart_of_attribute(typename Attribute_handle<i>::type ah,
Dart_handle adart)
{
CGAL_assertion( ah!=null_handle );
get_attribute<i>(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<unsigned int i>
typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).info();
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return get_attribute<i>(ah).info();
}
// Get the info of the i-cell attribute associated with the given dart
template<unsigned int i>
typename Attribute_type<i>::type::Info & info(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( this->template attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
Dart_const_handle dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(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<<ADart; }
template<unsigned int i>
void display_attribute(typename Attribute_const_handle<i>::type ah) const
{ std::cout<<ah; }
protected:
// Set the handle on the i th attribute
template<unsigned int i>
void basic_set_dart_attribute(Dart_handle dh,
typename Attribute_handle<i>::type ah)
{
std::get<Helper::template Dimension_index<i>::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<unsigned int i>
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<unsigned int i>
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<unsigned int d_, unsigned int ambient_dim, class Traits_,
class Items_, class Alloc_, class Index_type_>
typename GMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_, Items_, Alloc_, Index_type_>::
Null_handle_type GMap_linear_cell_complex_storage_2<d_, ambient_dim, Traits_,
Items_, Alloc_, Index_type_>::
null_handle((std::numeric_limits<Index_type_>::max)()/2);
} // namespace CGAL
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic pop")
#endif
#endif // CGAL_GMAP_LINEAR_CELL_COMPLEX_STORAGES_WITH_INDEX_H //
// EOF //

View File

@ -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<unsigned int,class,class,class,class> class CMap,
class Storage_ >
class Refs_, class Storage_ >
class Linear_cell_complex_for_combinatorial_map_base:
public Linear_cell_complex_base<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap,
Linear_cell_complex_for_combinatorial_map
<d_, ambient_dim,
Traits_, Items_,
Alloc_, CMap, Storage_>,
Storage_>
Items_, Alloc_, CMap, Refs_, Storage_>
{
public:
typedef Linear_cell_complex_for_combinatorial_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Self;
typedef Linear_cell_complex_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Self, Storage_> 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 <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Storage2>
class Ref2, class Storage2>
Linear_cell_complex_for_combinatorial_map_base
(const Linear_cell_complex_for_combinatorial_map_base<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& alcc) : Base(alcc)
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc) : Base(alcc)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& alcc,
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc,
const Converters& converters) : Base(alcc, converters)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& 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 <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& 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
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap, Storage_>
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap,
Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap, Storage_>, Storage_>
{
public:
typedef Linear_cell_complex_for_combinatorial_map<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
typedef Linear_cell_complex_for_combinatorial_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> 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
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap, Storage_>
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap,
Linear_cell_complex_for_combinatorial_map<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap, Storage_>, Storage_>
{
public:
typedef Linear_cell_complex_for_combinatorial_map<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
typedef Linear_cell_complex_for_combinatorial_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> 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

View File

@ -18,6 +18,7 @@
#include <CGAL/Linear_cell_complex_min_items.h>
#include <CGAL/Generalized_map.h>
#include <CGAL/GMap_linear_cell_complex_storages.h>
#include <CGAL/GMap_linear_cell_complex_storages_with_index.h>
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<unsigned int,class,class,class,class> 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<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap,
Linear_cell_complex_for_generalized_map
<d_, ambient_dim,
Traits_, Items_,
Alloc_, CMap, Storage_>,
Storage_>
Items_, Alloc_, CMap, Refs_, Storage_>
{
public:
typedef Linear_cell_complex_for_generalized_map<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
typedef Linear_cell_complex_for_generalized_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Self;
typedef Linear_cell_complex_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Self, Storage_> 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 <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Ref2, class Storage2>
Linear_cell_complex_for_generalized_map_base
(const Linear_cell_complex_for_generalized_map_base<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc) : Base(alcc)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Ref2, class Storage2, typename Converters>
Linear_cell_complex_for_generalized_map_base
(const Linear_cell_complex_for_generalized_map_base<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc,
const Converters& converters) : Base(alcc, converters)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& alcc,
const Converters& converters,
const DartInfoConverter& dartinfoconverter) :
Base(alcc, converters, dartinfoconverter)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Ref2, Storage2>& 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<unsigned int,class,class,class,class> class CMap,
class Storage_ >
class Linear_cell_complex_for_generalized_map:
public Linear_cell_complex_for_generalized_map_base
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap,
Linear_cell_complex_for_generalized_map<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap, Storage_>, Storage_>
{
public:
typedef Linear_cell_complex_for_generalized_map<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
typedef Linear_cell_complex_for_generalized_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Self, Storage_> 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 <unsigned int d2, unsigned int ambient_dim2, class Traits2,
@ -132,13 +226,12 @@ namespace CGAL {
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> 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<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& 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<unsigned int,class,class,class,class>
class CMap, class Storage_>
class Linear_cell_complex_for_generalized_map:
public Linear_cell_complex_for_generalized_map_base
<d_, ambient_dim, Traits_, Items_, Alloc_, CMap,
Linear_cell_complex_for_generalized_map<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap, Storage_>, Storage_>
{
public:
typedef Linear_cell_complex_for_generalized_map<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Storage_> Self;
typedef Linear_cell_complex_for_generalized_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Self, Storage_> 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 <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Storage2>
Linear_cell_complex_for_generalized_map
(const Linear_cell_complex_for_generalized_map<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& alcc) : Base(alcc)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Storage2, typename Converters>
Linear_cell_complex_for_generalized_map
(const Linear_cell_complex_for_generalized_map<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& alcc,
const Converters& converters) : Base(alcc, converters)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Storage2, typename Converters, typename DartInfoConverter>
Linear_cell_complex_for_generalized_map
(const Linear_cell_complex_for_generalized_map<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& alcc,
const Converters& converters,
const DartInfoConverter& dartinfoconverter) :
Base(alcc, converters, dartinfoconverter)
{}
template <unsigned int d2, unsigned int ambient_dim2, class Traits2,
class Items2, class Alloc2,
template<unsigned int,class,class,class,class> class CMap2,
class Storage2, typename Converters,
typename DartInfoConverter, typename PointConverter>
Linear_cell_complex_for_generalized_map
(const Linear_cell_complex_for_generalized_map<d2, ambient_dim2,
Traits2, Items2, Alloc2, CMap2, Storage2>& 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 //

View File

@ -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<ambient_dim>,
class Items_ = Linear_cell_complex_min_items,
class Alloc_ = CGAL_ALLOCATOR(int),
template<unsigned int,class,class,class,class>
class CMap = Generalized_map_base,
class Storage_ = GMap_linear_cell_complex_storage_2<d_, ambient_dim,
Traits_, Items_, unsigned int>>
template < unsigned int d_, unsigned int ambient_dim = d_,
class Traits_ = Linear_cell_complex_traits<ambient_dim>,
class Items_ = Linear_cell_complex_min_items,
class Alloc_ = CGAL_ALLOCATOR(int),
template<unsigned int,class,class,class,class>
class CMap = Generalized_map_base,
class Storage_ = GMap_linear_cell_complex_storage_2<d_, ambient_dim,
Traits_, Items_,
Alloc_, unsigned int>>
// TODO READD CGAL::Tag_false> >
class Linear_cell_complex_for_generalized_map; */
class Linear_cell_complex_for_generalized_map;
} // namespace Index
} // CGAL

View File

@ -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)

View File

@ -23,10 +23,9 @@ template<unsigned int d, unsigned int ambient_dim,
using My_lcc_cmap=CGAL::Index::Linear_cell_complex_for_combinatorial_map
<d, ambient_dim, Traits, Items>;
// TODO use CGAL::Index::Linear_cell_complex_for_generalized_map
template<unsigned int d, unsigned int ambient_dim,
class Traits, class Items>
using My_lcc_gmap=CGAL::Linear_cell_complex_for_generalized_map
using My_lcc_gmap=CGAL::Index::Linear_cell_complex_for_generalized_map
<d, ambient_dim, Traits, Items>;
#else
template<class Refs, class Info>
@ -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<Double_attrib_wp, void, Double_attrib> Attributes;
};
};