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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
|
// Copyright (c) 2007 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL: https://github.com/CGAL/cgal/blob/v5.2/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h $
// $Id: graph_traits_Surface_mesh.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Andreas Fabri, Philipp Moeller
#ifndef CGAL_BOOST_GRAPH_TRAITS_SURFACE_MESH_H
#define CGAL_BOOST_GRAPH_TRAITS_SURFACE_MESH_H
#ifndef DOXYGEN_RUNNING
#include <CGAL/license/Surface_mesh.h>
// include this to avoid a VC15 warning
#include <CGAL/boost/graph/Named_function_parameters.h>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <CGAL/boost/iterator/transform_iterator.hpp>
#include <CGAL/boost/graph/properties_Surface_mesh.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/assertions.h>
namespace boost {
template <class P>
struct graph_traits< CGAL::Surface_mesh<P> >
{
private:
typedef CGAL::Surface_mesh<P> SM;
struct SM_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
public virtual boost::vertex_list_graph_tag,
public virtual boost::edge_list_graph_tag
{};
public:
// Graph
typedef typename SM::Vertex_index vertex_descriptor;
typedef typename SM::Point vertex_property_type;
typedef typename SM::Edge_index edge_descriptor;
typedef boost::undirected_tag directed_category;
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
typedef SM_graph_traversal_category traversal_category;
// HalfedgeGraph
typedef typename SM::halfedge_index halfedge_descriptor;
// FaceGraph
typedef typename SM::face_index face_descriptor;
// VertexListGraph
typedef typename SM::Vertex_iterator vertex_iterator;
typedef typename SM::size_type vertices_size_type;
// EdgeListGraph
typedef typename SM::edge_iterator edge_iterator;
typedef typename SM::size_type edges_size_type;
// HalfEdgeListGraph
typedef typename SM::Halfedge_iterator halfedge_iterator;
typedef typename SM::size_type halfedges_size_type;
// FaceListGraph
typedef typename SM::Face_iterator face_iterator;
typedef typename SM::size_type faces_size_type;
// IncidenceGraph
typedef typename SM::size_type degree_size_type;
typedef CGAL::In_edge_iterator<SM> in_edge_iterator;
typedef CGAL::Out_edge_iterator<SM> out_edge_iterator;
// nulls
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
static face_descriptor null_face() { return face_descriptor(); }
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
};
template<typename P>
struct graph_traits< const CGAL::Surface_mesh<P> >
: public graph_traits< CGAL::Surface_mesh<P> >
{ };
} // namespace boost
namespace CGAL {
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertices_size_type
num_vertices(const CGAL::Surface_mesh<P>& sm)
{
return sm.num_vertices();
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::edges_size_type
num_edges(const CGAL::Surface_mesh<P>& sm)
{
return sm.num_edges();
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::degree_size_type
degree(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
return sm.degree(v);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::degree_size_type
degree(typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
const CGAL::Surface_mesh<P>& sm)
{
return sm.degree(f);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::degree_size_type
out_degree(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
return sm.degree(v);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::degree_size_type
in_degree(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
return sm.degree(v);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
source(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e,
const CGAL::Surface_mesh<P>& sm)
{
return sm.source(e.halfedge());
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
source(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.source(h);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
target(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e,
const CGAL::Surface_mesh<P>& sm)
{
return sm.target(e.halfedge());
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
target(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.target(h);
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_iterator>
vertices(const CGAL::Surface_mesh<P>& sm)
{
return sm.vertices();
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_iterator>
edges(const CGAL::Surface_mesh<P>& sm)
{
return sm.edges();
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::in_edge_iterator>
in_edges(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::in_edge_iterator Iter;
return make_range(Iter(halfedge(v,sm),sm), Iter(halfedge(v,sm),sm,1));
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::out_edge_iterator>
out_edges(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::out_edge_iterator Iter;
return make_range(Iter(halfedge(v,sm),sm), Iter(halfedge(v,sm),sm,1));
}
template<typename P>
std::pair<typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor,
bool>
edge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor u,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm) {
typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor
he(sm.halfedge(u, v));
return std::make_pair(he, he.is_valid());
}
//
// HalfedgeGraph
//
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
next(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.next(h);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
prev(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.prev(h);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
opposite(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.opposite(h);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor
edge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.edge(h);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e,
const CGAL::Surface_mesh<P>& sm)
{
return sm.halfedge(e);
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
return sm.halfedge(v);
}
template <typename P>
std::pair<
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor,
bool
>
halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor u,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h = sm.halfedge(u, v);
return std::make_pair(h, h.is_valid());
}
//
// HalfedgeListGraph
//
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_iterator>
halfedges(const CGAL::Surface_mesh<P>& sm)
{
return sm.halfedges();
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedges_size_type
num_halfedges(const CGAL::Surface_mesh<P>& sm)
{
return sm.num_halfedges();
}
//
// MutableHalfedgeGraph
//
template<typename P>
void
set_next(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h1,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h2,
CGAL::Surface_mesh<P>& sm)
{
sm.set_next(h1, h2);
}
template<typename P>
void
set_target(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
CGAL::Surface_mesh<P>& sm)
{
sm.set_target(h, v);
}
template<typename P>
void
set_halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
CGAL::Surface_mesh<P>& sm)
{
sm.set_halfedge(v, h);
}
template<typename P>
void
collect_garbage(CGAL::Surface_mesh<P>& sm)
{
sm.collect_garbage();
}
template<typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor
add_edge(CGAL::Surface_mesh<P>& sm)
{
return sm.edge(sm.add_edge());
}
//
// FaceGraph
//
template<typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor
halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
const CGAL::Surface_mesh<P>& sm)
{
return sm.halfedge(f);
}
template<typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor
face(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
const CGAL::Surface_mesh<P>& sm)
{
return sm.face(h);
}
//
// MutableFaceGraph
//
template<typename P>
void
set_face(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
CGAL::Surface_mesh<P>& sm)
{
sm.set_face(h, f);
}
template<typename P>
void
set_halfedge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
CGAL::Surface_mesh<P>& sm)
{
sm.set_halfedge(f, h);
}
//
// FaceListGraph
//
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::faces_size_type
num_faces(const CGAL::Surface_mesh<P>& sm)
{
return sm.num_faces();
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_iterator>
faces(const CGAL::Surface_mesh<P>& sm)
{
return sm.faces();
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
add_vertex(CGAL::Surface_mesh<P>& sm) {
return sm.add_vertex();
}
template <typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor
add_vertex(const typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_property_type& p, CGAL::Surface_mesh<P>& sm) {
return sm.add_vertex(p);
}
// MutableGraph
template<typename P>
void
reserve(CGAL::Surface_mesh<P>& sm,
typename boost::graph_traits< CGAL::Surface_mesh<P> >::vertices_size_type nv,
typename boost::graph_traits< CGAL::Surface_mesh<P> >::edges_size_type ne,
typename boost::graph_traits< CGAL::Surface_mesh<P> >::faces_size_type nf)
{
sm.reserve(nv, ne, nf);
}
template <typename P>
void
remove_vertex(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
CGAL::Surface_mesh<P>& sm) {
sm.remove_vertex(v);
}
template <typename P>
void
remove_edge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor u,
typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
CGAL::Surface_mesh<P>& sm)
{
typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e = edge(u, v, sm);
remove_edge(e,sm);
}
template <typename P>
void
remove_edge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e,
CGAL::Surface_mesh<P>& sm)
{
sm.remove_edge(e);
}
template <typename P>
void
remove_edge(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_iterator eiter,
CGAL::Surface_mesh<P>& sm)
{
remove_edge(*eiter, sm);
}
template<typename P>
void
remove_face(typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
CGAL::Surface_mesh<P>& sm)
{
sm.remove_face(f);
}
template<typename P>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor
add_face(CGAL::Surface_mesh<P>& sm)
{
return sm.add_face();
}
template<typename P, typename InputIterator>
typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor
add_face(InputIterator begin, InputIterator end, CGAL::Surface_mesh<P>& sm)
{
std::vector<typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor>
v(begin, end);
return sm.add_face(v);
}
template<typename P>
void normalize_border(const CGAL::Surface_mesh<P>&)
{}
} // namespace CGAL
#endif // DOXYGEN_RUNNING
#endif // CGAL_BOOST_GRAPH_TRAITS_SURFACE_MESH_H
|