1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
|
// Copyright (c) 2011 CNRS and LIRIS' Establishments (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Linear_cell_complex/include/CGAL/Linear_cell_complex_for_combinatorial_map.h $
// $Id: include/CGAL/Linear_cell_complex_for_combinatorial_map.h b26b07a1242 $
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
//
#ifndef CGAL_LINEAR_CELL_COMPLEX_FOR_COMBINATORIAL_MAP_H
#define CGAL_LINEAR_CELL_COMPLEX_FOR_COMBINATORIAL_MAP_H 1
#include <CGAL/Linear_cell_complex_fwd.h>
#include <CGAL/Linear_cell_complex_base.h>
#include <CGAL/Linear_cell_complex_traits.h>
#include <CGAL/Linear_cell_complex_min_items.h>
#include <CGAL/Combinatorial_map.h>
#include <CGAL/CMap_linear_cell_complex_storages.h>
#include <CGAL/CMap_linear_cell_complex_storages_with_index.h>
#include <CGAL/boost/graph/properties.h>
#include <unordered_map>
namespace CGAL {
/** @file Linear_cell_complex_for_combinatorial_map.h
* Definition of a linear cell complex based on combinatorial map, having
* points associated to all vertices.
*/
// 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 Refs_, class Storage_ >
class Linear_cell_complex_for_combinatorial_map_base:
public Linear_cell_complex_base<d_, ambient_dim, Traits_,
Items_, Alloc_, CMap, Refs_, Storage_>
{
public:
typedef Linear_cell_complex_for_combinatorial_map_base<d_, ambient_dim,
Traits_, Items_, Alloc_, CMap, Refs_, Storage_> Self;
typedef Linear_cell_complex_base<d_, ambient_dim,
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;
typedef typename Base::Dart_descriptor Dart_descriptor;
typedef typename Base::Dart_const_descriptor Dart_const_descriptor;
typedef typename Base::Helper Helper;
typedef typename Base::Point Point;
typedef typename Base::Vector Vector;
typedef typename Base::FT FT;
typedef typename Base::Dart_range Dart_range;
typedef typename Base::template Attribute_type<0>::type Vertex_attribute;
typedef typename Base::template Attribute_descriptor<0>::type
Vertex_attribute_descriptor;
typedef typename Base::template Attribute_const_descriptor<0>::type
Vertex_attribute_const_descriptor;
typedef typename Base::template Attribute_range<0>::type
Vertex_attribute_range;
typedef typename Base::template Attribute_const_range<0>::type
Vertex_attribute_const_range;
typedef typename Base::size_type size_type;
typedef typename Base::Use_index Use_index;
typedef typename Base::Storage Storage;
typedef typename Base::Exception_no_more_available_mark
Exception_no_more_available_mark;
Linear_cell_complex_for_combinatorial_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_combinatorial_map_base(const Self& alcc) : Base(alcc)
{}
Linear_cell_complex_for_combinatorial_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_combinatorial_map_base
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map_base
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map_base
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map_base
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map(amap, os);
return os;
}
friend std::ifstream& operator>> (std::ifstream& is, Self& amap)
{
load_combinatorial_map(is, amap);
return is;
}
/** Import the given hds which should be a model of an halfedge graph. */
template<class HEG, class PointConverter>
void import_from_halfedge_graph(const HEG& heg ,
const PointConverter& pointconverter,
std::unordered_map
<typename boost::graph_traits<HEG>::halfedge_descriptor,
Dart_descriptor>* origin_to_copy=NULL,
std::unordered_map
<Dart_descriptor,
typename boost::graph_traits<HEG>::halfedge_descriptor>*
copy_to_origin=NULL)
{
std::unordered_map
<typename boost::graph_traits<HEG>::halfedge_descriptor,
Dart_descriptor> local_dartmap;
if (origin_to_copy==NULL) // Used local_dartmap if user does not provides its own unordered_map
{ origin_to_copy=&local_dartmap; }
Base::import_from_halfedge_graph(heg, origin_to_copy, copy_to_origin);
typedef typename boost::property_map<HEG,vertex_point_t>::const_type
Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, heg);
typename std::unordered_map
<typename boost::graph_traits<HEG>::halfedge_descriptor,
Dart_descriptor>::iterator dartmap_iter, dartmap_iter_end=origin_to_copy->end();
for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end;
++dartmap_iter)
{
if (this->vertex_attribute(dartmap_iter->second)==NULL)
{
this->set_vertex_attribute(dartmap_iter->second,
this->create_vertex_attribute());
pointconverter.run(ppmap[source(dartmap_iter->first, heg)],
this->point(dartmap_iter->second));
}
}
}
/** Import the given hds which should be a model of an halfedge graph. */
template<class HEG>
void import_from_halfedge_graph(const HEG& heg,
std::unordered_map
<typename boost::graph_traits<HEG>::halfedge_descriptor,
Dart_descriptor>* origin_to_copy=NULL,
std::unordered_map
<Dart_descriptor,
typename boost::graph_traits<HEG>::halfedge_descriptor>*
copy_to_origin=NULL)
{
typedef typename boost::property_traits<typename boost::property_map
<HEG, vertex_point_t>::type>::value_type HEG_point;
CGAL::internal::Set_point_if_possible_cmap<HEG_point, Point> default_point_converter;
import_from_halfedge_graph(heg, default_point_converter,
origin_to_copy, copy_to_origin);
}
void clear() { Base::clear(); } //need explicit definition for Has_member_clear in bgl helpers
};
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_combinatorial_map:
public Linear_cell_complex_for_combinatorial_map_base
<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, Self, Storage_> Base;
typedef Traits_ Traits;
typedef Items_ Items;
typedef Alloc_ Alloc;
Linear_cell_complex_for_combinatorial_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_combinatorial_map(const Self& alcc) : Base(alcc)
{}
Linear_cell_complex_for_combinatorial_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_combinatorial_map
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map
(const Linear_cell_complex_for_combinatorial_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_combinatorial_map
(const Linear_cell_complex_for_combinatorial_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 CGAL
#endif // CGAL_LINEAR_CELL_COMPLEX_FOR_COMBINATORIAL_MAP_H //
// EOF //
|