PolyConnectivity.hh 64.4 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
/* ========================================================================= *
Jan Möbius's avatar
Jan Möbius committed
2 3
 *                                                                           *
 *                               OpenMesh                                    *
Jan Möbius's avatar
Jan Möbius committed
4
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
Jan Möbius's avatar
Typo  
Jan Möbius committed
5
 *           Department of Computer Graphics and Multimedia                  *
Jan Möbius's avatar
Jan Möbius committed
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
 *                          All rights reserved.                             *
 *                            www.openmesh.org                               *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenMesh.                                            *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39 40
 *                                                                           *
 * ========================================================================= */
41

42

Jan Möbius's avatar
Jan Möbius committed
43 44 45 46 47 48 49 50 51 52 53

#ifndef OPENMESH_POLYCONNECTIVITY_HH
#define OPENMESH_POLYCONNECTIVITY_HH

#include <OpenMesh/Core/Mesh/ArrayKernel.hh>
#include <OpenMesh/Core/Mesh/IteratorsT.hh>
#include <OpenMesh/Core/Mesh/CirculatorsT.hh>

namespace OpenMesh
{

Jan Möbius's avatar
Jan Möbius committed
54
/** \brief Connectivity Class for polygonal meshes
55
*/
56
class OPENMESHDLLEXPORT PolyConnectivity : public ArrayKernel
Jan Möbius's avatar
Jan Möbius committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
{
public:
  /// \name Mesh Handles
  //@{
  /// Invalid handle
  static const VertexHandle                           InvalidVertexHandle;
  /// Invalid handle
  static const HalfedgeHandle                         InvalidHalfedgeHandle;
  /// Invalid handle
  static const EdgeHandle                             InvalidEdgeHandle;
  /// Invalid handle
  static const FaceHandle                             InvalidFaceHandle;
  //@}

  typedef PolyConnectivity                            This;

  //--- iterators ---

  /** \name Mesh Iterators
      Refer to OpenMesh::Mesh::Iterators or \ref mesh_iterators for
      documentation.
  */
  //@{
  /// Linear iterator
Jan Möbius's avatar
Jan Möbius committed
81 82 83 84
  typedef Iterators::GenericIteratorT<This, This::VertexHandle, ArrayKernel , &ArrayKernel::has_vertex_status, &ArrayKernel::n_vertices> VertexIter;
  typedef Iterators::GenericIteratorT<This, This::HalfedgeHandle, ArrayKernel , &ArrayKernel::has_halfedge_status, &ArrayKernel::n_halfedges> HalfedgeIter;
  typedef Iterators::GenericIteratorT<This, This::EdgeHandle, ArrayKernel , &ArrayKernel::has_edge_status, &ArrayKernel::n_edges> EdgeIter;
  typedef Iterators::GenericIteratorT<This, This::FaceHandle, ArrayKernel , &ArrayKernel::has_face_status, &ArrayKernel::n_faces> FaceIter;
Jan Möbius's avatar
Jan Möbius committed
85

86 87 88 89
  typedef VertexIter ConstVertexIter;
  typedef HalfedgeIter ConstHalfedgeIter;
  typedef EdgeIter ConstEdgeIter;
  typedef FaceIter ConstFaceIter;
Jan Möbius's avatar
Jan Möbius committed
90 91 92 93 94 95 96 97 98
  //@}

  //--- circulators ---

  /** \name Mesh Circulators
      Refer to OpenMesh::Mesh::Iterators or \ref mesh_iterators
      for documentation.
  */
  //@{
99 100 101 102

  /*
   * Vertex-centered circulators
   */
103 104 105 106

  /**
   * Enumerates 1-ring vertices in a clockwise fashion.
   */
107
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::VertexHandle,  This::VertexHandle,
108 109
          &Iterators::GenericCirculatorBaseT<This>::toVertexHandle>
  VertexVertexIter;
110 111
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::VertexHandle,
            &Iterators::GenericCirculatorBaseT<This>::toVertexHandle> VertexVertexCWIter;
112 113 114 115 116 117 118

  /**
   * Enumerates 1-ring vertices in a counter clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::VertexHandle,
          &Iterators::GenericCirculatorBaseT<This>::toVertexHandle, false>
  VertexVertexCCWIter;
119

120 121 122
  /**
   * Enumerates outgoing half edges in a clockwise fashion.
   */
123
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::VertexHandle,  This::HalfedgeHandle,
124 125
          &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
  VertexOHalfedgeIter;
126 127
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::HalfedgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> VertexOHalfedgeCWIter;
128 129 130 131 132 133 134

  /**
   * Enumerates outgoing half edges in a counter clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::HalfedgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle, false>
  VertexOHalfedgeCCWIter;
135

136 137 138
  /**
   * Enumerates incoming half edges in a clockwise fashion.
   */
139
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::VertexHandle,  This::HalfedgeHandle,
140 141
          &Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle>
  VertexIHalfedgeIter;
142 143
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::HalfedgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle> VertexIHalfedgeCWIter;
144 145 146 147 148 149 150

  /**
   * Enumerates incoming half edges in a counter clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::HalfedgeHandle,
          &Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle, false>
  VertexIHalfedgeCCWIter;
151

152 153 154
  /**
   * Enumerates incident faces in a clockwise fashion.
   */
155
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::VertexHandle,  This::FaceHandle,
156 157
          &Iterators::GenericCirculatorBaseT<This>::toFaceHandle>
  VertexFaceIter;
158 159
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::FaceHandle,
      &Iterators::GenericCirculatorBaseT<This>::toFaceHandle> VertexFaceCWIter;
160 161 162 163 164 165 166

  /**
   * Enumerates incident faces in a counter clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::FaceHandle,
          &Iterators::GenericCirculatorBaseT<This>::toFaceHandle, false>
  VertexFaceCCWIter;
167

168 169 170
  /**
   * Enumerates incident edges in a clockwise fashion.
   */
171
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::VertexHandle,  This::EdgeHandle,
172 173
          &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle>
  VertexEdgeIter;
174 175
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::EdgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle> VertexEdgeCWIter;
176 177 178 179 180 181
  /**
   * Enumerates incident edges in a counter clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::VertexHandle,  This::EdgeHandle,
          &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle, false>
  VertexEdgeCCWIter;
182

183 184 185
  /**
   * Identical to #FaceHalfedgeIter. God knows why this typedef exists.
   */
186
  typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::FaceHandle, This::HalfedgeHandle,
187 188
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
  HalfedgeLoopIter;
189
  typedef Iterators::GenericCirculatorT<This, This::FaceHandle, This::HalfedgeHandle,
190
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle, false> HalfedgeLoopCWIter;
191 192 193 194
  /**
   * Identical to #FaceHalfedgeIter. God knows why this typedef exists.
   */
  typedef Iterators::GenericCirculatorT<This, This::FaceHandle, This::HalfedgeHandle,
195
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
  HalfedgeLoopCCWIter;

  typedef VertexVertexIter        ConstVertexVertexIter;
  typedef VertexVertexCWIter      ConstVertexVertexCWIter;
  typedef VertexVertexCCWIter     ConstVertexVertexCCWIter;
  typedef VertexOHalfedgeIter     ConstVertexOHalfedgeIter;
  typedef VertexOHalfedgeCWIter   ConstVertexOHalfedgeCWIter;
  typedef VertexOHalfedgeCCWIter  ConstVertexOHalfedgeCCWIter;
  typedef VertexIHalfedgeIter     ConstVertexIHalfedgeIter;
  typedef VertexIHalfedgeCWIter   ConstVertexIHalfedgeCWIter;
  typedef VertexIHalfedgeCCWIter  ConstVertexIHalfedgeCCWIter;
  typedef VertexFaceIter          ConstVertexFaceIter;
  typedef VertexFaceCWIter        ConstVertexFaceCWIter;
  typedef VertexFaceCCWIter       ConstVertexFaceCCWIter;
  typedef VertexEdgeIter          ConstVertexEdgeIter;
  typedef VertexEdgeCWIter        ConstVertexEdgeCWIter;
  typedef VertexEdgeCCWIter       ConstVertexEdgeCCWIter;
213

214 215 216
  /*
   * Face-centered circulators
   */
217 218 219 220

  /**
   * Enumerate incident vertices in a counter clockwise fashion.
   */
221
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::FaceHandle,  This::VertexHandle,
222 223
          &Iterators::GenericCirculatorBaseT<This>::toVertexHandle>
  FaceVertexIter;
224 225
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::VertexHandle,
      &Iterators::GenericCirculatorBaseT<This>::toVertexHandle> FaceVertexCCWIter;
226 227 228 229 230 231 232

  /**
   * Enumerate incident vertices in a clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::VertexHandle,
      &Iterators::GenericCirculatorBaseT<This>::toVertexHandle, false>
  FaceVertexCWIter;
233

234 235 236
  /**
   * Enumerate incident half edges in a counter clockwise fashion.
   */
237
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::FaceHandle,  This::HalfedgeHandle,
238 239
          &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
  FaceHalfedgeIter;
240 241
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::HalfedgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> FaceHalfedgeCCWIter;
242 243 244 245 246 247 248

  /**
   * Enumerate incident half edges in a clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::HalfedgeHandle,
          &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle, false>
  FaceHalfedgeCWIter;
249

250 251 252
  /**
   * Enumerate incident edges in a counter clockwise fashion.
   */
253
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::FaceHandle,  This::EdgeHandle,
254 255
          &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle>
  FaceEdgeIter;
256 257
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::EdgeHandle,
      &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle> FaceEdgeCCWIter;
258 259 260 261 262 263 264

  /**
   * Enumerate incident edges in a clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::EdgeHandle,
          &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle, false>
  FaceEdgeCWIter;
265

266 267 268
  /**
   * Enumerate adjacent faces in a counter clockwise fashion.
   */
269
  typedef Iterators::GenericCirculatorT_DEPRECATED<This,  This::FaceHandle,  This::FaceHandle,
270 271
          &Iterators::GenericCirculatorBaseT<This>::toOppositeFaceHandle>
  FaceFaceIter;
272 273
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::FaceHandle,
      &Iterators::GenericCirculatorBaseT<This>::toOppositeFaceHandle> FaceFaceCCWIter;
Jan Möbius's avatar
Jan Möbius committed
274

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
  /**
   * Enumerate adjacent faces in a clockwise fashion.
   */
  typedef Iterators::GenericCirculatorT<This,  This::FaceHandle,  This::FaceHandle,
          &Iterators::GenericCirculatorBaseT<This>::toOppositeFaceHandle, false>
  FaceFaceCWIter;

  typedef FaceVertexIter        ConstFaceVertexIter;
  typedef FaceVertexCWIter      ConstFaceVertexCWIter;
  typedef FaceVertexCCWIter     ConstFaceVertexCCWIter;
  typedef FaceHalfedgeIter      ConstFaceHalfedgeIter;
  typedef FaceHalfedgeCWIter    ConstFaceHalfedgeCWIter;
  typedef FaceHalfedgeCCWIter   ConstFaceHalfedgeCCWIter;
  typedef FaceEdgeIter          ConstFaceEdgeIter;
  typedef FaceEdgeCWIter        ConstFaceEdgeCWIter;
  typedef FaceEdgeCCWIter       ConstFaceEdgeCCWIter;
  typedef FaceFaceIter          ConstFaceFaceIter;
  typedef FaceFaceCWIter        ConstFaceFaceCWIter;
  typedef FaceFaceCCWIter       ConstFaceFaceCCWIter;
294 295 296 297

  /*
   * Halfedge circulator
   */
298 299 300
  typedef HalfedgeLoopIter      ConstHalfedgeLoopIter;
  typedef HalfedgeLoopCWIter    ConstHalfedgeLoopCWIter;
  typedef HalfedgeLoopCCWIter   ConstHalfedgeLoopCCWIter;
301

Jan Möbius's avatar
Jan Möbius committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
  //@}

  // --- shortcuts

  /** \name Typedef Shortcuts
      Provided for convenience only
  */
  //@{
  /// Alias typedef
  typedef VertexHandle    VHandle;
  typedef HalfedgeHandle  HHandle;
  typedef EdgeHandle      EHandle;
  typedef FaceHandle      FHandle;

  typedef VertexIter    VIter;
  typedef HalfedgeIter  HIter;
  typedef EdgeIter      EIter;
  typedef FaceIter      FIter;

  typedef ConstVertexIter    CVIter;
  typedef ConstHalfedgeIter  CHIter;
  typedef ConstEdgeIter      CEIter;
  typedef ConstFaceIter      CFIter;

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
  typedef VertexVertexIter        VVIter;
  typedef VertexVertexCWIter      VVCWIter;
  typedef VertexVertexCCWIter     VVCCWIter;
  typedef VertexOHalfedgeIter     VOHIter;
  typedef VertexOHalfedgeCWIter   VOHCWIter;
  typedef VertexOHalfedgeCCWIter  VOHCCWIter;
  typedef VertexIHalfedgeIter     VIHIter;
  typedef VertexIHalfedgeCWIter   VIHICWter;
  typedef VertexIHalfedgeCCWIter  VIHICCWter;
  typedef VertexEdgeIter          VEIter;
  typedef VertexEdgeCWIter        VECWIter;
  typedef VertexEdgeCCWIter       VECCWIter;
  typedef VertexFaceIter          VFIter;
  typedef VertexFaceCWIter        VFCWIter;
  typedef VertexFaceCCWIter       VFCCWIter;
  typedef FaceVertexIter          FVIter;
  typedef FaceVertexCWIter        FVCWIter;
  typedef FaceVertexCCWIter       FVCCWIter;
  typedef FaceHalfedgeIter        FHIter;
  typedef FaceHalfedgeCWIter      FHCWIter;
  typedef FaceHalfedgeCCWIter     FHCWWIter;
  typedef FaceEdgeIter            FEIter;
  typedef FaceEdgeCWIter          FECWIter;
  typedef FaceEdgeCCWIter         FECWWIter;
  typedef FaceFaceIter            FFIter;

  typedef ConstVertexVertexIter         CVVIter;
  typedef ConstVertexVertexCWIter       CVVCWIter;
  typedef ConstVertexVertexCCWIter      CVVCCWIter;
  typedef ConstVertexOHalfedgeIter      CVOHIter;
  typedef ConstVertexOHalfedgeCWIter    CVOHCWIter;
  typedef ConstVertexOHalfedgeCCWIter   CVOHCCWIter;
  typedef ConstVertexIHalfedgeIter      CVIHIter;
  typedef ConstVertexIHalfedgeCWIter    CVIHCWIter;
  typedef ConstVertexIHalfedgeCCWIter   CVIHCCWIter;
  typedef ConstVertexEdgeIter           CVEIter;
  typedef ConstVertexEdgeCWIter         CVECWIter;
  typedef ConstVertexEdgeCCWIter        CVECCWIter;
  typedef ConstVertexFaceIter           CVFIter;
  typedef ConstVertexFaceCWIter         CVFCWIter;
  typedef ConstVertexFaceCCWIter        CVFCCWIter;
  typedef ConstFaceVertexIter           CFVIter;
  typedef ConstFaceVertexCWIter         CFVCWIter;
  typedef ConstFaceVertexCCWIter        CFVCCWIter;
  typedef ConstFaceHalfedgeIter         CFHIter;
  typedef ConstFaceHalfedgeCWIter       CFHCWIter;
  typedef ConstFaceHalfedgeCCWIter      CFHCCWIter;
  typedef ConstFaceEdgeIter             CFEIter;
  typedef ConstFaceEdgeCWIter           CFECWIter;
  typedef ConstFaceEdgeCCWIter          CFECCWIter;
  typedef ConstFaceFaceIter             CFFIter;
  typedef ConstFaceFaceCWIter           CFFCWIter;
  typedef ConstFaceFaceCCWIter          CFFCCWIter;
Jan Möbius's avatar
Jan Möbius committed
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
  //@}

public:

  PolyConnectivity()  {}
  virtual ~PolyConnectivity() {}

  inline static bool is_triangles()
  { return false; }

  /** assign_connectivity() method. See ArrayKernel::assign_connectivity()
      for more details. */
  inline void assign_connectivity(const PolyConnectivity& _other)
  { ArrayKernel::assign_connectivity(_other); }
  
  /** \name Adding items to a mesh
  */
  //@{
397

Jan Möbius's avatar
Jan Möbius committed
398 399 400 401
  /// Add a new vertex 
  inline VertexHandle add_vertex()
  { return new_vertex(); }

402 403 404 405 406 407 408
  /** \brief Add and connect a new face
  *
  * Create a new face consisting of the vertices provided by the vertex handle vector.
  * (The vertices have to be already added to the mesh by add_vertex)
  *
  * @param _vhandles sorted list of vertex handles (also defines order in which the vertices are added to the face)
  */
409
  FaceHandle add_face(const std::vector<VertexHandle>& _vhandles);
410 411 412 413 414 415 416
 
   
  /** \brief Add and connect a new face
  *
  * Create a new face consisting of three vertices provided by the handles.
  * (The vertices have to be already added to the mesh by add_vertex)
  *
Jan Möbius's avatar
Jan Möbius committed
417 418 419
  * @param _vh0 First  vertex handle
  * @param _vh1 Second vertex handle
  * @param _vh2 Third  vertex handle
420
  */
421
  FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2);
422 423 424 425 426 427

  /** \brief Add and connect a new face
  *
  * Create a new face consisting of four vertices provided by the handles.
  * (The vertices have to be already added to the mesh by add_vertex)
  *
Jan Möbius's avatar
Jan Möbius committed
428 429 430 431
  * @param _vh0 First  vertex handle
  * @param _vh1 Second vertex handle
  * @param _vh2 Third  vertex handle
  * @param _vh3 Fourth vertex handle
432
  */
433
  FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3);
434 435 436 437 438 439 440 441 442
 
  /** \brief Add and connect a new face
  *
  * Create a new face consisting of vertices provided by a handle array.
  * (The vertices have to be already added to the mesh by add_vertex)
  *
  * @param _vhandles pointer to a sorted list of vertex handles (also defines order in which the vertices are added to the face)
  * @param _vhs_size number of vertex handles in the array
  */
Jan Möbius's avatar
Jan Möbius committed
443
  FaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size);
444

Jan Möbius's avatar
Jan Möbius committed
445 446 447 448 449
  //@}

  /// \name Deleting mesh items and other connectivity/topology modifications
  //@{

450 451 452 453 454 455 456
  /** Returns whether collapsing halfedge _heh is ok or would lead to
      topological inconsistencies.
      \attention This method need the Attributes::Status attribute and
      changes the \em tagged bit.  */
  bool is_collapse_ok(HalfedgeHandle _he);
    
    
Jan Möbius's avatar
Jan Möbius committed
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
  /** Mark vertex and all incident edges and faces deleted.
      Items marked deleted will be removed by garbageCollection().
      \attention Needs the Attributes::Status attribute for vertices,
      edges and faces.
  */
  void delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices = true);

  /** Mark edge (two opposite halfedges) and incident faces deleted.
      Resulting isolated vertices are marked deleted if
      _delete_isolated_vertices is true. Items marked deleted will be
      removed by garbageCollection().

      \attention Needs the Attributes::Status attribute for vertices,
      edges and faces.
  */
  void delete_edge(EdgeHandle _eh, bool _delete_isolated_vertices=true);

  /** Delete face _fh and resulting degenerated empty halfedges as
475
      well.  Resulting isolated vertices will be deleted if
Jan Möbius's avatar
Jan Möbius committed
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
      _delete_isolated_vertices is true.

      \attention All item will only be marked to be deleted. They will
      actually be removed by calling garbage_collection().

      \attention Needs the Attributes::Status attribute for vertices,
      edges and faces.
  */
  void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true);

  //@}
  
  /** \name Begin and end iterators
  */
  //@{

  /// Begin iterator for vertices
493
  VertexIter vertices_begin();
Jan Möbius's avatar
Jan Möbius committed
494
  /// Const begin iterator for vertices
495
  ConstVertexIter vertices_begin() const;
Jan Möbius's avatar
Jan Möbius committed
496
  /// End iterator for vertices
497
  VertexIter vertices_end();
Jan Möbius's avatar
Jan Möbius committed
498
  /// Const end iterator for vertices
499
  ConstVertexIter vertices_end() const;
Jan Möbius's avatar
Jan Möbius committed
500 501

  /// Begin iterator for halfedges
502
  HalfedgeIter halfedges_begin();
Jan Möbius's avatar
Jan Möbius committed
503
  /// Const begin iterator for halfedges
504
  ConstHalfedgeIter halfedges_begin() const;
Jan Möbius's avatar
Jan Möbius committed
505
  /// End iterator for halfedges
506
  HalfedgeIter halfedges_end();
Jan Möbius's avatar
Jan Möbius committed
507
  /// Const end iterator for halfedges
508
  ConstHalfedgeIter halfedges_end() const;
Jan Möbius's avatar
Jan Möbius committed
509 510

  /// Begin iterator for edges
511
  EdgeIter edges_begin();
Jan Möbius's avatar
Jan Möbius committed
512
  /// Const begin iterator for edges
513
  ConstEdgeIter edges_begin() const;
Jan Möbius's avatar
Jan Möbius committed
514
  /// End iterator for edges
515
  EdgeIter edges_end();
Jan Möbius's avatar
Jan Möbius committed
516
  /// Const end iterator for edges
517
  ConstEdgeIter edges_end() const;
Jan Möbius's avatar
Jan Möbius committed
518 519

  /// Begin iterator for faces
520
  FaceIter faces_begin();
Jan Möbius's avatar
Jan Möbius committed
521
  /// Const begin iterator for faces
522
  ConstFaceIter faces_begin() const;
Jan Möbius's avatar
Jan Möbius committed
523
  /// End iterator for faces
524
  FaceIter faces_end();
Jan Möbius's avatar
Jan Möbius committed
525
  /// Const end iterator for faces
526
  ConstFaceIter faces_end() const;
Jan Möbius's avatar
Jan Möbius committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
  //@}


  /** \name Begin for skipping iterators
  */
  //@{

  /// Begin iterator for vertices
  VertexIter vertices_sbegin()
  { return VertexIter(*this, VertexHandle(0), true); }
  /// Const begin iterator for vertices
  ConstVertexIter vertices_sbegin() const
  { return ConstVertexIter(*this, VertexHandle(0), true); }

  /// Begin iterator for halfedges
  HalfedgeIter halfedges_sbegin()
  { return HalfedgeIter(*this, HalfedgeHandle(0), true); }
  /// Const begin iterator for halfedges
  ConstHalfedgeIter halfedges_sbegin() const
  { return ConstHalfedgeIter(*this, HalfedgeHandle(0), true); }

  /// Begin iterator for edges
  EdgeIter edges_sbegin()
  { return EdgeIter(*this, EdgeHandle(0), true); }
  /// Const begin iterator for edges
  ConstEdgeIter edges_sbegin() const
  { return ConstEdgeIter(*this, EdgeHandle(0), true); }

  /// Begin iterator for faces
  FaceIter faces_sbegin()
  { return FaceIter(*this, FaceHandle(0), true); }
  /// Const begin iterator for faces
  ConstFaceIter faces_sbegin() const
  { return ConstFaceIter(*this, FaceHandle(0), true); }

  //@}

  //--- circulators ---

  /** \name Vertex and Face circulators
  */
  //@{

  /// vertex - vertex circulator
571 572
  VertexVertexIter vv_iter(VertexHandle _vh)
  { return VertexVertexIter(*this, _vh); }
573 574 575 576 577 578
  /// vertex - vertex circulator cw
  VertexVertexCWIter vv_cwiter(VertexHandle _vh)
  { return VertexVertexCWIter(*this, _vh); }
  /// vertex - vertex circulator ccw
  VertexVertexCCWIter vv_ccwiter(VertexHandle _vh)
  { return VertexVertexCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
579 580 581
  /// vertex - incoming halfedge circulator
  VertexIHalfedgeIter vih_iter(VertexHandle _vh)
  { return VertexIHalfedgeIter(*this, _vh); }
582 583 584 585 586 587
  /// vertex - incoming halfedge circulator cw
  VertexIHalfedgeCWIter vih_cwiter(VertexHandle _vh)
  { return VertexIHalfedgeCWIter(*this, _vh); }
  /// vertex - incoming halfedge circulator ccw
  VertexIHalfedgeCCWIter vih_ccwiter(VertexHandle _vh)
  { return VertexIHalfedgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
588 589 590
  /// vertex - outgoing halfedge circulator
  VertexOHalfedgeIter voh_iter(VertexHandle _vh)
  { return VertexOHalfedgeIter(*this, _vh); }
591 592 593 594 595 596
  /// vertex - outgoing halfedge circulator cw
  VertexOHalfedgeCWIter voh_cwiter(VertexHandle _vh)
  { return VertexOHalfedgeCWIter(*this, _vh); }
  /// vertex - outgoing halfedge circulator ccw
  VertexOHalfedgeCCWIter voh_ccwiter(VertexHandle _vh)
  { return VertexOHalfedgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
597 598 599
  /// vertex - edge circulator
  VertexEdgeIter ve_iter(VertexHandle _vh)
  { return VertexEdgeIter(*this, _vh); }
600 601 602 603 604 605
  /// vertex - edge circulator cw
  VertexEdgeCWIter ve_cwiter(VertexHandle _vh)
  { return VertexEdgeCWIter(*this, _vh); }
  /// vertex - edge circulator ccw
  VertexEdgeCCWIter ve_ccwiter(VertexHandle _vh)
  { return VertexEdgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
606 607 608
  /// vertex - face circulator
  VertexFaceIter vf_iter(VertexHandle _vh)
  { return VertexFaceIter(*this, _vh); }
609 610 611 612 613 614
  /// vertex - face circulator cw
  VertexFaceCWIter vf_cwiter(VertexHandle _vh)
  { return VertexFaceCWIter(*this, _vh); }
  /// vertex - face circulator ccw
  VertexFaceCCWIter vf_ccwiter(VertexHandle _vh)
  { return VertexFaceCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
615 616 617 618

  /// const vertex circulator
  ConstVertexVertexIter cvv_iter(VertexHandle _vh) const
  { return ConstVertexVertexIter(*this, _vh); }
619 620 621 622 623 624
  /// const vertex circulator cw
  ConstVertexVertexCWIter cvv_cwiter(VertexHandle _vh) const
  { return ConstVertexVertexCWIter(*this, _vh); }
  /// const vertex circulator ccw
  ConstVertexVertexCCWIter cvv_ccwiter(VertexHandle _vh) const
  { return ConstVertexVertexCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
625 626 627
  /// const vertex - incoming halfedge circulator
  ConstVertexIHalfedgeIter cvih_iter(VertexHandle _vh) const
  { return ConstVertexIHalfedgeIter(*this, _vh); }
628 629 630 631 632 633
  /// const vertex - incoming halfedge circulator cw
  ConstVertexIHalfedgeCWIter cvih_cwiter(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCWIter(*this, _vh); }
  /// const vertex - incoming halfedge circulator ccw
  ConstVertexIHalfedgeCCWIter cvih_ccwiter(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
634 635 636
  /// const vertex - outgoing halfedge circulator
  ConstVertexOHalfedgeIter cvoh_iter(VertexHandle _vh) const
  { return ConstVertexOHalfedgeIter(*this, _vh); }
637 638 639 640 641 642
  /// const vertex - outgoing halfedge circulator cw
  ConstVertexOHalfedgeCWIter cvoh_cwiter(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCWIter(*this, _vh); }
  /// const vertex - outgoing halfedge circulator ccw
  ConstVertexOHalfedgeCCWIter cvoh_ccwiter(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
643 644 645
  /// const vertex - edge circulator
  ConstVertexEdgeIter cve_iter(VertexHandle _vh) const
  { return ConstVertexEdgeIter(*this, _vh); }
646 647 648 649 650 651
  /// const vertex - edge circulator cw
  ConstVertexEdgeCWIter cve_cwiter(VertexHandle _vh) const
  { return ConstVertexEdgeCWIter(*this, _vh); }
  /// const vertex - edge circulator ccw
  ConstVertexEdgeCCWIter cve_ccwiter(VertexHandle _vh) const
  { return ConstVertexEdgeCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
652 653 654
  /// const vertex - face circulator
  ConstVertexFaceIter cvf_iter(VertexHandle _vh) const
  { return ConstVertexFaceIter(*this, _vh); }
655 656 657 658 659 660
  /// const vertex - face circulator cw
  ConstVertexFaceCWIter cvf_cwiter(VertexHandle _vh) const
  { return ConstVertexFaceCWIter(*this, _vh); }
  /// const vertex - face circulator ccw
  ConstVertexFaceCCWIter cvf_ccwiter(VertexHandle _vh) const
  { return ConstVertexFaceCCWIter(*this, _vh); }
Jan Möbius's avatar
Jan Möbius committed
661 662 663 664

  /// face - vertex circulator
  FaceVertexIter fv_iter(FaceHandle _fh)
  { return FaceVertexIter(*this, _fh); }
665 666 667 668 669 670
  /// face - vertex circulator cw
  FaceVertexCWIter fv_cwiter(FaceHandle _fh)
  { return FaceVertexCWIter(*this, _fh); }
  /// face - vertex circulator ccw
  FaceVertexCCWIter fv_ccwiter(FaceHandle _fh)
  { return FaceVertexCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
671 672 673
  /// face - halfedge circulator
  FaceHalfedgeIter fh_iter(FaceHandle _fh)
  { return FaceHalfedgeIter(*this, _fh); }
674 675 676 677 678 679
  /// face - halfedge circulator cw
  FaceHalfedgeCWIter fh_cwiter(FaceHandle _fh)
  { return FaceHalfedgeCWIter(*this, _fh); }
  /// face - halfedge circulator ccw
  FaceHalfedgeCCWIter fh_ccwiter(FaceHandle _fh)
  { return FaceHalfedgeCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
680 681 682
  /// face - edge circulator
  FaceEdgeIter fe_iter(FaceHandle _fh)
  { return FaceEdgeIter(*this, _fh); }
683 684 685 686 687 688
  /// face - edge circulator cw
  FaceEdgeCWIter fe_cwiter(FaceHandle _fh)
  { return FaceEdgeCWIter(*this, _fh); }
  /// face - edge circulator ccw
  FaceEdgeCCWIter fe_ccwiter(FaceHandle _fh)
  { return FaceEdgeCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
689 690 691
  /// face - face circulator
  FaceFaceIter ff_iter(FaceHandle _fh)
  { return FaceFaceIter(*this, _fh); }
692 693 694 695 696 697
  /// face - face circulator cw
  FaceFaceCWIter ff_cwiter(FaceHandle _fh)
  { return FaceFaceCWIter(*this, _fh); }
  /// face - face circulator ccw
  FaceFaceCCWIter ff_ccwiter(FaceHandle _fh)
  { return FaceFaceCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
698 699 700 701

  /// const face - vertex circulator
  ConstFaceVertexIter cfv_iter(FaceHandle _fh) const
  { return ConstFaceVertexIter(*this, _fh); }
702 703 704 705 706 707
  /// const face - vertex circulator cw
  ConstFaceVertexCWIter cfv_cwiter(FaceHandle _fh) const
  { return ConstFaceVertexCWIter(*this, _fh); }
  /// const face - vertex circulator ccw
  ConstFaceVertexCCWIter cfv_ccwiter(FaceHandle _fh) const
  { return ConstFaceVertexCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
708 709 710
  /// const face - halfedge circulator
  ConstFaceHalfedgeIter cfh_iter(FaceHandle _fh) const
  { return ConstFaceHalfedgeIter(*this, _fh); }
711 712 713 714 715 716
  /// const face - halfedge circulator cw
  ConstFaceHalfedgeCWIter cfh_cwiter(FaceHandle _fh) const
  { return ConstFaceHalfedgeCWIter(*this, _fh); }
  /// const face - halfedge circulator ccw
  ConstFaceHalfedgeCCWIter cfh_ccwiter(FaceHandle _fh) const
  { return ConstFaceHalfedgeCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
717 718 719
  /// const face - edge circulator
  ConstFaceEdgeIter cfe_iter(FaceHandle _fh) const
  { return ConstFaceEdgeIter(*this, _fh); }
720 721 722 723 724 725
  /// const face - edge circulator cw
  ConstFaceEdgeCWIter cfe_cwiter(FaceHandle _fh) const
  { return ConstFaceEdgeCWIter(*this, _fh); }
  /// const face - edge circulator ccw
  ConstFaceEdgeCCWIter cfe_ccwiter(FaceHandle _fh) const
  { return ConstFaceEdgeCCWIter(*this, _fh); }
Jan Möbius's avatar
Jan Möbius committed
726 727 728
  /// const face - face circulator
  ConstFaceFaceIter cff_iter(FaceHandle _fh) const
  { return ConstFaceFaceIter(*this, _fh); }
729 730 731 732 733 734
  /// const face - face circulator cw
  ConstFaceFaceCWIter cff_cwiter(FaceHandle _fh) const
  { return ConstFaceFaceCWIter(*this, _fh); }
  /// const face - face circulator
  ConstFaceFaceCCWIter cff_ccwiter(FaceHandle _fh) const
  { return ConstFaceFaceCCWIter(*this, _fh); }
735 736 737 738 739 740
  
  // 'begin' circulators
  
  /// vertex - vertex circulator
  VertexVertexIter vv_begin(VertexHandle _vh)
  { return VertexVertexIter(*this, _vh); }
741 742 743 744 745 746
  /// vertex - vertex circulator cw
  VertexVertexCWIter vv_cwbegin(VertexHandle _vh)
  { return VertexVertexCWIter(*this, _vh); }
  /// vertex - vertex circulator ccw
  VertexVertexCCWIter vv_ccwbegin(VertexHandle _vh)
  { return VertexVertexCCWIter(*this, _vh); }
747 748 749
  /// vertex - incoming halfedge circulator
  VertexIHalfedgeIter vih_begin(VertexHandle _vh)
  { return VertexIHalfedgeIter(*this, _vh); }
750 751 752 753 754 755
  /// vertex - incoming halfedge circulator cw
  VertexIHalfedgeCWIter vih_cwbegin(VertexHandle _vh)
  { return VertexIHalfedgeCWIter(*this, _vh); }
  /// vertex - incoming halfedge circulator ccw
  VertexIHalfedgeCCWIter vih_ccwbegin(VertexHandle _vh)
  { return VertexIHalfedgeCCWIter(*this, _vh); }
756 757 758
  /// vertex - outgoing halfedge circulator
  VertexOHalfedgeIter voh_begin(VertexHandle _vh)
  { return VertexOHalfedgeIter(*this, _vh); }
759 760 761 762 763 764
  /// vertex - outgoing halfedge circulator cw
  VertexOHalfedgeCWIter voh_cwbegin(VertexHandle _vh)
  { return VertexOHalfedgeCWIter(*this, _vh); }
  /// vertex - outgoing halfedge circulator ccw
  VertexOHalfedgeCCWIter voh_ccwbegin(VertexHandle _vh)
  { return VertexOHalfedgeCCWIter(*this, _vh); }
765 766 767
  /// vertex - edge circulator
  VertexEdgeIter ve_begin(VertexHandle _vh)
  { return VertexEdgeIter(*this, _vh); }
768 769 770 771 772 773
  /// vertex - edge circulator cw
  VertexEdgeCWIter ve_cwbegin(VertexHandle _vh)
  { return VertexEdgeCWIter(*this, _vh); }
  /// vertex - edge circulator ccw
  VertexEdgeCCWIter ve_ccwbegin(VertexHandle _vh)
  { return VertexEdgeCCWIter(*this, _vh); }
774 775 776
  /// vertex - face circulator
  VertexFaceIter vf_begin(VertexHandle _vh)
  { return VertexFaceIter(*this, _vh); }
777 778 779 780 781 782 783
  /// vertex - face circulator cw
  VertexFaceCWIter vf_cwbegin(VertexHandle _vh)
  { return VertexFaceCWIter(*this, _vh); }
  /// vertex - face circulator ccw
  VertexFaceCCWIter vf_ccwbegin(VertexHandle _vh)
  { return VertexFaceCCWIter(*this, _vh); }

784 785 786 787

  /// const vertex circulator
  ConstVertexVertexIter cvv_begin(VertexHandle _vh) const
  { return ConstVertexVertexIter(*this, _vh); }
788 789 790 791 792 793
  /// const vertex circulator cw
  ConstVertexVertexCWIter cvv_cwbegin(VertexHandle _vh) const
  { return ConstVertexVertexCWIter(*this, _vh); }
  /// const vertex circulator ccw
  ConstVertexVertexCCWIter cvv_ccwbegin(VertexHandle _vh) const
  { return ConstVertexVertexCCWIter(*this, _vh); }
794 795 796
  /// const vertex - incoming halfedge circulator
  ConstVertexIHalfedgeIter cvih_begin(VertexHandle _vh) const
  { return ConstVertexIHalfedgeIter(*this, _vh); }
797 798 799 800 801 802
  /// const vertex - incoming halfedge circulator cw
  ConstVertexIHalfedgeCWIter cvih_cwbegin(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCWIter(*this, _vh); }
  /// const vertex - incoming halfedge circulator ccw
  ConstVertexIHalfedgeCCWIter cvih_ccwbegin(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCCWIter(*this, _vh); }
803 804 805
  /// const vertex - outgoing halfedge circulator
  ConstVertexOHalfedgeIter cvoh_begin(VertexHandle _vh) const
  { return ConstVertexOHalfedgeIter(*this, _vh); }
806 807 808 809 810 811
  /// const vertex - outgoing halfedge circulator cw
  ConstVertexOHalfedgeCWIter cvoh_cwbegin(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCWIter(*this, _vh); }
  /// const vertex - outgoing halfedge circulator ccw
  ConstVertexOHalfedgeCCWIter cvoh_ccwbegin(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCCWIter(*this, _vh); }
812 813 814
  /// const vertex - edge circulator
  ConstVertexEdgeIter cve_begin(VertexHandle _vh) const
  { return ConstVertexEdgeIter(*this, _vh); }
815 816 817 818 819 820
  /// const vertex - edge circulator cw
  ConstVertexEdgeCWIter cve_cwbegin(VertexHandle _vh) const
  { return ConstVertexEdgeCWIter(*this, _vh); }
  /// const vertex - edge circulator ccw
  ConstVertexEdgeCCWIter cve_ccwbegin(VertexHandle _vh) const
  { return ConstVertexEdgeCCWIter(*this, _vh); }
821 822 823
  /// const vertex - face circulator
  ConstVertexFaceIter cvf_begin(VertexHandle _vh) const
  { return ConstVertexFaceIter(*this, _vh); }
824 825 826 827 828 829
  /// const vertex - face circulator cw
  ConstVertexFaceCWIter cvf_cwbegin(VertexHandle _vh) const
  { return ConstVertexFaceCWIter(*this, _vh); }
  /// const vertex - face circulator ccw
  ConstVertexFaceCCWIter cvf_ccwbegin(VertexHandle _vh) const
  { return ConstVertexFaceCCWIter(*this, _vh); }
830 831 832 833

  /// face - vertex circulator
  FaceVertexIter fv_begin(FaceHandle _fh)
  { return FaceVertexIter(*this, _fh); }
834 835 836 837 838 839
  /// face - vertex circulator cw
  FaceVertexCWIter fv_cwbegin(FaceHandle _fh)
  { return FaceVertexCWIter(*this, _fh); }
  /// face - vertex circulator ccw
  FaceVertexCCWIter fv_ccwbegin(FaceHandle _fh)
  { return FaceVertexCCWIter(*this, _fh); }
840 841 842
  /// face - halfedge circulator
  FaceHalfedgeIter fh_begin(FaceHandle _fh)
  { return FaceHalfedgeIter(*this, _fh); }
843 844 845 846 847 848
  /// face - halfedge circulator cw
  FaceHalfedgeCWIter fh_cwbegin(FaceHandle _fh)
  { return FaceHalfedgeCWIter(*this, _fh); }
  /// face - halfedge circulator ccw
  FaceHalfedgeCCWIter fh_ccwbegin(FaceHandle _fh)
  { return FaceHalfedgeCCWIter(*this, _fh); }
849 850 851
  /// face - edge circulator
  FaceEdgeIter fe_begin(FaceHandle _fh)
  { return FaceEdgeIter(*this, _fh); }
852 853 854 855 856 857
  /// face - edge circulator cw
  FaceEdgeCWIter fe_cwbegin(FaceHandle _fh)
  { return FaceEdgeCWIter(*this, _fh); }
  /// face - edge circulator ccw
  FaceEdgeCCWIter fe_ccwbegin(FaceHandle _fh)
  { return FaceEdgeCCWIter(*this, _fh); }
858 859 860
  /// face - face circulator
  FaceFaceIter ff_begin(FaceHandle _fh)
  { return FaceFaceIter(*this, _fh); }
861 862 863 864 865 866
  /// face - face circulator cw
  FaceFaceCWIter ff_cwbegin(FaceHandle _fh)
  { return FaceFaceCWIter(*this, _fh); }
  /// face - face circulator ccw
  FaceFaceCCWIter ff_ccwbegin(FaceHandle _fh)
  { return FaceFaceCCWIter(*this, _fh); }
867 868 869
  /// halfedge circulator
  HalfedgeLoopIter hl_begin(HalfedgeHandle _heh)
  { return HalfedgeLoopIter(*this, _heh); }
870 871 872 873 874 875
  /// halfedge circulator
  HalfedgeLoopCWIter hl_cwbegin(HalfedgeHandle _heh)
  { return HalfedgeLoopCWIter(*this, _heh); }
  /// halfedge circulator ccw
  HalfedgeLoopCCWIter hl_ccwbegin(HalfedgeHandle _heh)
  { return HalfedgeLoopCCWIter(*this, _heh); }
876 877 878 879

  /// const face - vertex circulator
  ConstFaceVertexIter cfv_begin(FaceHandle _fh) const
  { return ConstFaceVertexIter(*this, _fh); }
880 881 882 883 884 885
  /// const face - vertex circulator cw
  ConstFaceVertexCWIter cfv_cwbegin(FaceHandle _fh) const
  { return ConstFaceVertexCWIter(*this, _fh); }
  /// const face - vertex circulator ccw
  ConstFaceVertexCCWIter cfv_ccwbegin(FaceHandle _fh) const
  { return ConstFaceVertexCCWIter(*this, _fh); }
886 887 888
  /// const face - halfedge circulator
  ConstFaceHalfedgeIter cfh_begin(FaceHandle _fh) const
  { return ConstFaceHalfedgeIter(*this, _fh); }
889 890 891 892 893 894
  /// const face - halfedge circulator cw
  ConstFaceHalfedgeCWIter cfh_cwbegin(FaceHandle _fh) const
  { return ConstFaceHalfedgeCWIter(*this, _fh); }
  /// const face - halfedge circulator ccw
  ConstFaceHalfedgeCCWIter cfh_ccwbegin(FaceHandle _fh) const
  { return ConstFaceHalfedgeCCWIter(*this, _fh); }
895 896 897
  /// const face - edge circulator
  ConstFaceEdgeIter cfe_begin(FaceHandle _fh) const
  { return ConstFaceEdgeIter(*this, _fh); }
898 899 900 901 902 903
  /// const face - edge circulator cw
  ConstFaceEdgeCWIter cfe_cwbegin(FaceHandle _fh) const
  { return ConstFaceEdgeCWIter(*this, _fh); }
  /// const face - edge circulator ccw
  ConstFaceEdgeCCWIter cfe_ccwbegin(FaceHandle _fh) const
  { return ConstFaceEdgeCCWIter(*this, _fh); }
904 905 906
  /// const face - face circulator
  ConstFaceFaceIter cff_begin(FaceHandle _fh) const
  { return ConstFaceFaceIter(*this, _fh); }
907 908 909 910 911 912
  /// const face - face circulator cw
  ConstFaceFaceCWIter cff_cwbegin(FaceHandle _fh) const
  { return ConstFaceFaceCWIter(*this, _fh); }
  /// const face - face circulator ccw
  ConstFaceFaceCCWIter cff_ccwbegin(FaceHandle _fh) const
  { return ConstFaceFaceCCWIter(*this, _fh); }
913 914 915
  /// const halfedge circulator
  ConstHalfedgeLoopIter chl_begin(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopIter(*this, _heh); }
916 917 918 919 920 921
  /// const halfedge circulator cw
  ConstHalfedgeLoopCWIter chl_cwbegin(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopCWIter(*this, _heh); }
  /// const halfedge circulator ccw
  ConstHalfedgeLoopCCWIter chl_ccwbegin(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopCCWIter(*this, _heh); }
922 923 924 925 926 927
  
  // 'end' circulators
  
  /// vertex - vertex circulator
  VertexVertexIter vv_end(VertexHandle _vh)
  { return VertexVertexIter(*this, _vh, true); }
928 929 930 931 932 933
  /// vertex - vertex circulator cw
  VertexVertexCWIter vv_cwend(VertexHandle _vh)
  { return VertexVertexCWIter(*this, _vh, true); }
  /// vertex - vertex circulator ccw
  VertexVertexCCWIter vv_ccwend(VertexHandle _vh)
  { return VertexVertexCCWIter(*this, _vh, true); }
934 935 936
  /// vertex - incoming halfedge circulator
  VertexIHalfedgeIter vih_end(VertexHandle _vh)
  { return VertexIHalfedgeIter(*this, _vh, true); }
937 938 939 940 941 942
  /// vertex - incoming halfedge circulator cw
  VertexIHalfedgeCWIter vih_cwend(VertexHandle _vh)
  { return VertexIHalfedgeCWIter(*this, _vh, true); }
  /// vertex - incoming halfedge circulator ccw
  VertexIHalfedgeCCWIter vih_ccwend(VertexHandle _vh)
  { return VertexIHalfedgeCCWIter(*this, _vh, true); }
943 944 945
  /// vertex - outgoing halfedge circulator
  VertexOHalfedgeIter voh_end(VertexHandle _vh)
  { return VertexOHalfedgeIter(*this, _vh, true); }
946 947 948 949 950 951
  /// vertex - outgoing halfedge circulator cw
  VertexOHalfedgeCWIter voh_cwend(VertexHandle _vh)
  { return VertexOHalfedgeCWIter(*this, _vh, true); }
  /// vertex - outgoing halfedge circulator ccw
  VertexOHalfedgeCCWIter voh_ccwend(VertexHandle _vh)
  { return VertexOHalfedgeCCWIter(*this, _vh, true); }
952 953 954
  /// vertex - edge circulator
  VertexEdgeIter ve_end(VertexHandle _vh)
  { return VertexEdgeIter(*this, _vh, true); }
955 956 957 958 959 960
  /// vertex - edge circulator cw
  VertexEdgeCWIter ve_cwend(VertexHandle _vh)
  { return VertexEdgeCWIter(*this, _vh, true); }
  /// vertex - edge circulator ccw
  VertexEdgeCCWIter ve_ccwend(VertexHandle _vh)
  { return VertexEdgeCCWIter(*this, _vh, true); }
961 962 963
  /// vertex - face circulator
  VertexFaceIter vf_end(VertexHandle _vh)
  { return VertexFaceIter(*this, _vh, true); }
964 965 966 967 968 969
  /// vertex - face circulator cw
  VertexFaceCWIter vf_cwend(VertexHandle _vh)
  { return VertexFaceCWIter(*this, _vh, true); }
  /// vertex - face circulator ccw
  VertexFaceCCWIter vf_ccwend(VertexHandle _vh)
  { return VertexFaceCCWIter(*this, _vh, true); }
970 971 972 973

  /// const vertex circulator
  ConstVertexVertexIter cvv_end(VertexHandle _vh) const
  { return ConstVertexVertexIter(*this, _vh, true); }
974 975 976 977 978 979
  /// const vertex circulator cw
  ConstVertexVertexCWIter cvv_cwend(VertexHandle _vh) const
  { return ConstVertexVertexCWIter(*this, _vh, true); }
  /// const vertex circulator ccw
  ConstVertexVertexCCWIter cvv_ccwend(VertexHandle _vh) const
  { return ConstVertexVertexCCWIter(*this, _vh, true); }
980 981 982
  /// const vertex - incoming halfedge circulator
  ConstVertexIHalfedgeIter cvih_end(VertexHandle _vh) const
  { return ConstVertexIHalfedgeIter(*this, _vh, true); }
983 984 985 986 987 988
  /// const vertex - incoming halfedge circulator cw
  ConstVertexIHalfedgeCWIter cvih_cwend(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCWIter(*this, _vh, true); }
  /// const vertex - incoming halfedge circulator ccw
  ConstVertexIHalfedgeCCWIter cvih_ccwend(VertexHandle _vh) const
  { return ConstVertexIHalfedgeCCWIter(*this, _vh, true); }
989 990 991
  /// const vertex - outgoing halfedge circulator
  ConstVertexOHalfedgeIter cvoh_end(VertexHandle _vh) const
  { return ConstVertexOHalfedgeIter(*this, _vh, true); }
992 993 994 995 996 997
  /// const vertex - outgoing halfedge circulator cw
  ConstVertexOHalfedgeCWIter cvoh_cwend(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCWIter(*this, _vh, true); }
  /// const vertex - outgoing halfedge circulator ccw
  ConstVertexOHalfedgeCCWIter cvoh_ccwend(VertexHandle _vh) const
  { return ConstVertexOHalfedgeCCWIter(*this, _vh, true); }
998 999 1000
  /// const vertex - edge circulator
  ConstVertexEdgeIter cve_end(VertexHandle _vh) const
  { return ConstVertexEdgeIter(*this, _vh, true); }
1001 1002 1003 1004 1005 1006
  /// const vertex - edge circulator cw
  ConstVertexEdgeCWIter cve_cwend(VertexHandle _vh) const
  { return ConstVertexEdgeCWIter(*this, _vh, true); }
  /// const vertex - edge circulator ccw
  ConstVertexEdgeCCWIter cve_ccwend(VertexHandle _vh) const
  { return ConstVertexEdgeCCWIter(*this, _vh, true); }
1007 1008 1009
  /// const vertex - face circulator
  ConstVertexFaceIter cvf_end(VertexHandle _vh) const
  { return ConstVertexFaceIter(*this, _vh, true); }
1010 1011 1012 1013 1014 1015
  /// const vertex - face circulator cw
  ConstVertexFaceCWIter cvf_cwend(VertexHandle _vh) const
  { return ConstVertexFaceCWIter(*this, _vh, true); }
  /// const vertex - face circulator ccw
  ConstVertexFaceCCWIter cvf_ccwend(VertexHandle _vh) const
  { return ConstVertexFaceCCWIter(*this, _vh, true); }
1016 1017 1018 1019

  /// face - vertex circulator
  FaceVertexIter fv_end(FaceHandle _fh)
  { return FaceVertexIter(*this, _fh, true); }
1020 1021 1022 1023 1024 1025
  /// face - vertex circulator cw
  FaceVertexCWIter fv_cwend(FaceHandle _fh)
  { return FaceVertexCWIter(*this, _fh, true); }
  /// face - vertex circulator ccw
  FaceVertexCCWIter fv_ccwend(FaceHandle _fh)
  { return FaceVertexCCWIter(*this, _fh, true); }
1026 1027 1028
  /// face - halfedge circulator
  FaceHalfedgeIter fh_end(FaceHandle _fh)
  { return FaceHalfedgeIter(*this, _fh, true); }
1029 1030 1031 1032 1033 1034
  /// face - halfedge circulator cw
  FaceHalfedgeCWIter fh_cwend(FaceHandle _fh)
  { return FaceHalfedgeCWIter(*this, _fh, true); }
  /// face - halfedge circulator ccw
  FaceHalfedgeCCWIter fh_ccwend(FaceHandle _fh)
  { return FaceHalfedgeCCWIter(*this, _fh, true); }
1035 1036 1037
  /// face - edge circulator
  FaceEdgeIter fe_end(FaceHandle _fh)
  { return FaceEdgeIter(*this, _fh, true); }
1038 1039 1040 1041 1042 1043
  /// face - edge circulator cw
  FaceEdgeCWIter fe_cwend(FaceHandle _fh)
  { return FaceEdgeCWIter(*this, _fh, true); }
  /// face - edge circulator ccw
  FaceEdgeCCWIter fe_ccwend(FaceHandle _fh)
  { return FaceEdgeCCWIter(*this, _fh, true); }
1044 1045 1046
  /// face - face circulator
  FaceFaceIter ff_end(FaceHandle _fh)
  { return FaceFaceIter(*this, _fh, true); }
1047 1048 1049 1050 1051 1052
  /// face - face circulator cw
  FaceFaceCWIter ff_cwend(FaceHandle _fh)
  { return FaceFaceCWIter(*this, _fh, true); }
  /// face - face circulator ccw
  FaceFaceCCWIter ff_ccwend(FaceHandle _fh)
  { return FaceFaceCCWIter(*this, _fh, true); }
1053 1054 1055
  /// face - face circulator
  HalfedgeLoopIter hl_end(HalfedgeHandle _heh)
  { return HalfedgeLoopIter(*this, _heh, true); }
1056 1057 1058 1059 1060 1061
  /// face - face circulator cw
  HalfedgeLoopCWIter hl_cwend(HalfedgeHandle _heh)
  { return HalfedgeLoopCWIter(*this, _heh, true); }
  /// face - face circulator ccw
  HalfedgeLoopCCWIter hl_ccwend(HalfedgeHandle _heh)
  { return HalfedgeLoopCCWIter(*this, _heh, true); }
1062 1063 1064 1065

  /// const face - vertex circulator
  ConstFaceVertexIter cfv_end(FaceHandle _fh) const
  { return ConstFaceVertexIter(*this, _fh, true); }
1066 1067 1068 1069 1070 1071
  /// const face - vertex circulator cw
  ConstFaceVertexCWIter cfv_cwend(FaceHandle _fh) const
  { return ConstFaceVertexCWIter(*this, _fh, true); }
  /// const face - vertex circulator ccw
  ConstFaceVertexCCWIter cfv_ccwend(FaceHandle _fh) const
  { return ConstFaceVertexCCWIter(*this, _fh, true); }
1072 1073 1074
  /// const face - halfedge circulator
  ConstFaceHalfedgeIter cfh_end(FaceHandle _fh) const
  { return ConstFaceHalfedgeIter(*this, _fh, true); }
1075 1076 1077 1078 1079 1080
  /// const face - halfedge circulator cw
  ConstFaceHalfedgeCWIter cfh_cwend(FaceHandle _fh) const
  { return ConstFaceHalfedgeCWIter(*this, _fh, true); }
  /// const face - halfedge circulator ccw
  ConstFaceHalfedgeCCWIter cfh_ccwend(FaceHandle _fh) const
  { return ConstFaceHalfedgeCCWIter(*this, _fh, true); }
1081 1082 1083
  /// const face - edge circulator
  ConstFaceEdgeIter cfe_end(FaceHandle _fh) const
  { return ConstFaceEdgeIter(*this, _fh, true); }
1084 1085 1086 1087 1088 1089
  /// const face - edge circulator cw
  ConstFaceEdgeCWIter cfe_cwend(FaceHandle _fh) const
  { return ConstFaceEdgeCWIter(*this, _fh, true); }
  /// const face - edge circulator ccw
  ConstFaceEdgeCCWIter cfe_ccwend(FaceHandle _fh) const
  { return ConstFaceEdgeCCWIter(*this, _fh, true); }
1090 1091 1092
  /// const face - face circulator
  ConstFaceFaceIter cff_end(FaceHandle _fh) const
  { return ConstFaceFaceIter(*this, _fh, true); }
1093
  /// const face - face circulator
1094 1095 1096 1097 1098 1099
  ConstFaceFaceCWIter cff_cwend(FaceHandle _fh) const
  { return ConstFaceFaceCWIter(*this, _fh, true); }
  /// const face - face circulator
  ConstFaceFaceCCWIter cff_ccwend(FaceHandle _fh) const
  { return ConstFaceFaceCCWIter(*this, _fh, true); }
  /// const face - face circulator
1100 1101
  ConstHalfedgeLoopIter chl_end(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopIter(*this, _heh, true); }
1102 1103 1104 1105 1106 1107
  /// const face - face circulator cw
  ConstHalfedgeLoopCWIter chl_cwend(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopCWIter(*this, _heh, true); }
  /// const face - face circulator ccw
  ConstHalfedgeLoopCCWIter chl_ccwend(HalfedgeHandle _heh) const
  { return ConstHalfedgeLoopCCWIter(*this, _heh, true); }
Jan Möbius's avatar
Jan Möbius committed
1108 1109
  //@}

1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
  /** @name Range based iterators and circulators */
  //@{

  /// Generic class for vertex/halfedge/edge/face ranges.
  template<
      typename CONTAINER_TYPE,
      typename ITER_TYPE,
      ITER_TYPE (CONTAINER_TYPE::*begin_fn)() const,
      ITER_TYPE (CONTAINER_TYPE::*end_fn)() const>
  class EntityRange {
      public:
1121 1122 1123
          typedef ITER_TYPE iterator;
          typedef ITER_TYPE const_iterator;

Jan Möbius's avatar
Jan Möbius committed
1124
          explicit EntityRange(CONTAINER_TYPE &container) : container_(container) {}
1125 1126
          ITER_TYPE begin() const { return (container_.*begin_fn)(); }
          ITER_TYPE end() const { return (container_.*end_fn)(); }
1127 1128 1129 1130 1131 1132 1133 1134 1135

      private:
          CONTAINER_TYPE &container_;
  };
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstVertexIter,
          &PolyConnectivity::vertices_begin,
          &PolyConnectivity::vertices_end> ConstVertexRange;
1136 1137 1138 1139 1140
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstVertexIter,
          &PolyConnectivity::vertices_sbegin,
          &PolyConnectivity::vertices_end> ConstVertexRangeSkipping;
1141 1142 1143 1144 1145
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstHalfedgeIter,
          &PolyConnectivity::halfedges_begin,
          &PolyConnectivity::halfedges_end> ConstHalfedgeRange;
1146 1147 1148 1149 1150
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstHalfedgeIter,
          &PolyConnectivity::halfedges_sbegin,
          &PolyConnectivity::halfedges_end> ConstHalfedgeRangeSkipping;
1151 1152 1153 1154 1155
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstEdgeIter,
          &PolyConnectivity::edges_begin,
          &PolyConnectivity::edges_end> ConstEdgeRange;
1156 1157 1158 1159 1160
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstEdgeIter,
          &PolyConnectivity::edges_sbegin,
          &PolyConnectivity::edges_end> ConstEdgeRangeSkipping;
1161 1162 1163 1164 1165
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstFaceIter,
          &PolyConnectivity::faces_begin,
          &PolyConnectivity::faces_end> ConstFaceRange;
1166 1167 1168 1169 1170
  typedef EntityRange<
          const PolyConnectivity,
          PolyConnectivity::ConstFaceIter,
          &PolyConnectivity::faces_sbegin,
          &PolyConnectivity::faces_end> ConstFaceRangeSkipping;
1171 1172 1173

  /**
   * @return The vertices as a range object suitable
1174
   * for C++11 range based for loops. Will skip deleted vertices.
1175
   */
1176 1177 1178 1179 1180 1181 1182
  ConstVertexRangeSkipping vertices() const { return ConstVertexRangeSkipping(*this); }

  /**
   * @return The vertices as a range object suitable
   * for C++11 range based for loops. Will include deleted vertices.
   */
  ConstVertexRange all_vertices() const { return ConstVertexRange(*this); }
1183 1184 1185

  /**
   * @return The halfedges as a range object suitable
1186
   * for C++11 range based for loops. Will skip deleted halfedges.
1187
   */
1188
  ConstHalfedgeRangeSkipping halfedges() const { return ConstHalfedgeRangeSkipping(*this); }
1189 1190

  /**
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
   * @return The halfedges as a range object suitable
   * for C++11 range based for loops. Will include deleted halfedges.
   */
  ConstHalfedgeRange all_halfedges() const { return ConstHalfedgeRange(*this); }

  /**
   * @return The edges as a range object suitable
   * for C++11 range based for loops. Will skip deleted edges.
   */
  ConstEdgeRangeSkipping edges() const { return ConstEdgeRangeSkipping(*this); }

  /**
   * @return The edges as a range object suitable
   * for C++11 range based for loops. Will include deleted edges.
   */
  ConstEdgeRange all_edges() const { return ConstEdgeRange(*this); }

  /**
   * @return The faces as a range object suitable
   * for C++11 range based for loops. Will skip deleted faces.
1211
   */
1212
  ConstFaceRangeSkipping faces() const { return ConstFaceRangeSkipping(*this); }
1213 1214 1215

  /**
   * @return The faces as a range object suitable
1216
   * for C++11 range based for loops. Will include deleted faces.
1217
   */
1218
  ConstFaceRange all_faces() const { return ConstFaceRange(*this); }
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228

  /// Generic class for iterator ranges.
  template<
      typename CONTAINER_TYPE,
      typename ITER_TYPE,
      typename CENTER_ENTITY_TYPE,
      ITER_TYPE (CONTAINER_TYPE::*begin_fn)(CENTER_ENTITY_TYPE) const,
      ITER_TYPE (CONTAINER_TYPE::*end_fn)(CENTER_ENTITY_TYPE) const>
  class CirculatorRange {
      public:
1229 1230 1231
          typedef ITER_TYPE iterator;
          typedef ITER_TYPE const_iterator;

1232
          CirculatorRange(
1233
                  const CONTAINER_TYPE &container,
1234 1235
                  CENTER_ENTITY_TYPE center) :
              container_(container), center_(center) {}
1236 1237
          ITER_TYPE begin() const { return (container_.*begin_fn)(center_); }
          ITER_TYPE end() const { return (container_.*end_fn)(center_); }
1238 1239

      private:
1240
          const CONTAINER_TYPE &container_;
1241 1242 1243 1244
          CENTER_ENTITY_TYPE center_;
  };

  typedef CirculatorRange<
1245
          PolyConnectivity,
1246
          ConstVertexVertexCWIter,
1247
          VertexHandle,
1248 1249
          &PolyConnectivity::cvv_cwbegin,
          &PolyConnectivity::cvv_cwend> ConstVertexVertexRange;
1250
  typedef CirculatorRange<
1251
          PolyConnectivity,
1252 1253 1254 1255 1256
          ConstVertexIHalfedgeIter,
          VertexHandle,
          &PolyConnectivity::cvih_begin,
          &PolyConnectivity::cvih_end> ConstVertexIHalfedgeRange;
  typedef CirculatorRange<
1257
          PolyConnectivity,
1258 1259 1260 1261
          ConstVertexOHalfedgeIter, VertexHandle,
          &PolyConnectivity::cvoh_begin,
          &PolyConnectivity::cvoh_end> ConstVertexOHalfedgeRange;
  typedef CirculatorRange<
1262
          PolyConnectivity,
1263 1264 1265 1266 1267
          ConstVertexEdgeIter,
          VertexHandle,
          &PolyConnectivity::cve_begin,
          &PolyConnectivity::cve_end> ConstVertexEdgeRange;
  typedef CirculatorRange<
1268
          PolyConnectivity,
1269 1270 1271 1272 1273
          ConstVertexFaceIter,
          VertexHandle,
          &PolyConnectivity::cvf_begin,
          &PolyConnectivity::cvf_end> ConstVertexFaceRange;
  typedef CirculatorRange<
1274
          PolyConnectivity,
1275 1276 1277 1278 1279
          ConstFaceVertexIter,
          FaceHandle,
          &PolyConnectivity::cfv_begin,
          &PolyConnectivity::cfv_end> ConstFaceVertexRange;
  typedef CirculatorRange<
1280
          PolyConnectivity,
1281 1282 1283 1284 1285
          ConstFaceHalfedgeIter,
          FaceHandle,
          &PolyConnectivity::cfh_begin,
          &PolyConnectivity::cfh_end> ConstFaceHalfedgeRange;
  typedef CirculatorRange<
1286
          PolyConnectivity,
1287 1288 1289 1290 1291
          ConstFaceEdgeIter,
          FaceHandle,
          &PolyConnectivity::cfe_begin,
          &PolyConnectivity::cfe_end> ConstFaceEdgeRange;
  typedef CirculatorRange<
1292
          PolyConnectivity,
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
          ConstFaceFaceIter,
          FaceHandle,
          &PolyConnectivity::cff_begin,
          &PolyConnectivity::cff_end> ConstFaceFaceRange;

  /**
   * @return The vertices adjacent to the specified vertex
   * as a range object suitable for C++11 range based for loops.
   */
  ConstVertexVertexRange vv_range(VertexHandle _vh) const {
      return ConstVertexVertexRange(*this, _vh);
  }

  /**
   * @return The incoming halfedges incident to the specified vertex
   * as a range object suitable for C++11 range based for loops.
   */
  ConstVertexIHalfedgeRange vih_range(VertexHandle _vh) const {
      return ConstVertexIHalfedgeRange(*this, _vh);
  }

  /**
   * @return The outgoing halfedges incident to the specified vertex
   * as a range object suitable for C++11 range based for loops.
   */
  ConstVertexOHalfedgeRange voh_range(VertexHandle _vh) const {
      return ConstVertexOHalfedgeRange(*this, _vh);
  }

  /**
   * @return The edges incident to the specified vertex
   * as a range object suitable for C++11 range based for loops.
   */
  ConstVertexEdgeRange ve_range(VertexHandle _vh) const {
      return ConstVertexEdgeRange(*this, _vh);
  }

  /**
   * @return The faces incident to the specified vertex
   * as a range object suitable for C++11 range based for loops.
   */
Jan Möbius's avatar
Jan Möbius committed
1334
  ConstVertexFaceRange vf_range(VertexHandle _vh) const {
1335
      return ConstVertexFaceRange(*this, _vh);
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
  }

  /**
   * @return The vertices incident to the specified face
   * as a range object suitable for C++11 range based for loops.
   */
  ConstFaceVertexRange fv_range(FaceHandle _fh) const {
      return ConstFaceVertexRange(*this, _fh);
  }

  /**
   * @return The halfedges incident to the specified face
   * as a range object suitable for C++11 range based for loops.
   */
  ConstFaceHalfedgeRange fh_range(FaceHandle _fh) const {
      return ConstFaceHalfedgeRange(*this, _fh);
  }

  /**
   * @return The edges incident to the specified face
   * as a range object suitable for C++11 range based for loops.
   */
  ConstFaceEdgeRange fe_range(FaceHandle _fh) const {
      return ConstFaceEdgeRange(*this, _fh);
  }

  /**
   * @return The faces adjacent to the specified face
   * as a range object suitable for C++11 range based for loops.
   */
Jan Möbius's avatar
Jan Möbius committed
1366
  ConstFaceFaceRange ff_range(FaceHandle _fh) const {
1367
      return ConstFaceFaceRange(*this, _fh);
1368 1369 1370
  }

  //@}
Jan Möbius's avatar
Jan Möbius committed
1371 1372 1373 1374 1375

  //===========================================================================
  /** @name Boundary and manifold tests
   * @{ */
  //===========================================================================
1376 1377 1378 1379 1380 1381 1382 1383

  /** \brief Check if the halfedge is at the boundary
   *
   * The halfedge is at the boundary, if no face is incident to it.
   *
   * @param _heh HalfedgeHandle to test
   * @return boundary?
   */
Jan Möbius's avatar
Jan Möbius committed
1384 1385 1386
  bool is_boundary(HalfedgeHandle _heh) const
  { return ArrayKernel::is_boundary(_heh); }

1387 1388 1389
  /** \brief Is the edge a boundary edge?
   *
   * Checks it the edge _eh is a boundary edge, i.e. is one of its halfedges
Jan Möbius's avatar
Jan Möbius committed
1390
   * a boundary halfedge.
1391 1392 1393 1394
   *
   * @param _eh Edge handle to test
   * @return boundary?
   */
Jan Möbius's avatar
Jan Möbius committed
1395 1396 1397 1398 1399
  bool is_boundary(EdgeHandle _eh) const
  {
    return (is_boundary(halfedge_handle(_eh, 0)) ||
            is_boundary(halfedge_handle(_eh, 1)));
  }
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411

  /** \brief Is vertex _vh a boundary vertex ?
   *
   * Checks if the associated halfedge (which would on a boundary be the outside
   * halfedge), is connected to a face. Which is equivalent, if the vertex is
   * at the boundary of the mesh, as OpenMesh will make sure, that if there is a
   * boundary halfedge at the vertex, the halfedge will be the one which is associated
   * to the vertex.
   *
   * @param _vh VertexHandle to test
   * @return boundary?
   */
Jan Möbius's avatar
Jan Möbius committed
1412 1413 1414 1415 1416 1417
  bool is_boundary(VertexHandle _vh) const
  {
    HalfedgeHandle heh(halfedge_handle(_vh));
    return (!(heh.is_valid() && face_handle(heh).is_valid()));
  }

1418 1419 1420 1421 1422 1423 1424 1425
  /** \brief Check if face is at the boundary
   *
   * Is face _fh at boundary, i.e. is one of its edges (or vertices)
   * a boundary edge?
   *
   * @param _fh Check this face
   * @param _check_vertex If \c true, check the corner vertices of the face, too.
   * @return boundary?
Jan Möbius's avatar
Jan Möbius committed
1426 1427
   */
  bool is_boundary(FaceHandle _fh, bool _check_vertex=false) const;
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438

  /** \brief Is (the mesh at) vertex _vh  two-manifold ?
   *
   * The vertex is non-manifold if more than one gap exists, i.e.
   * more than one outgoing boundary halfedge. If (at least) one
   * boundary halfedge exists, the vertex' halfedge must be a
   * boundary halfedge.
   *
   * @param _vh VertexHandle to test
   * @return manifold?
   */
Jan Möbius's avatar
Jan Möbius committed
1439
  bool is_manifold(VertexHandle _vh) const;
1440

Jan Möbius's avatar
Jan Möbius committed
1441
  /** @} */
Jan Möbius's avatar
Jan Möbius committed
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454

  // --- shortcuts ---
  
  /// returns the face handle of the opposite halfedge 
  inline FaceHandle opposite_face_handle(HalfedgeHandle _heh) const
  { return face_handle(opposite_halfedge_handle(_heh)); }
    
  // --- misc ---

  /** Adjust outgoing halfedge handle for vertices, so that it is a
      boundary halfedge whenever possible. 
  */
  void adjust_outgoing_halfedge(VertexHandle _vh);
1455

Jan Möbius's avatar
Jan Möbius committed
1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470
  /// Find halfedge from _vh0 to _vh1. Returns invalid handle if not found.
  HalfedgeHandle find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh) const;
  /// Vertex valence
  uint valence(VertexHandle _vh) const;
  /// Face valence
  uint valence(FaceHandle _fh) const;
  
  // --- connectivity operattions 
    
  /** Halfedge collapse: collapse the from-vertex of halfedge _heh
      into its to-vertex.

      \attention Needs vertex/edge/face status attribute in order to
      delete the items that degenerate.

Jan Möbius's avatar
Jan Möbius committed
1471 1472
      \note The from vertex is marked as deleted while the to vertex will still exist.

Jan Möbius's avatar
Jan Möbius committed
1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
      \note This function does not perform a garbage collection. It
      only marks degenerate items as deleted.

      \attention A halfedge collapse may lead to topological inconsistencies.
      Therefore you should check this using is_collapse_ok().  
  */
  void collapse(HalfedgeHandle _heh);
  /** return true if the this the only link between the faces adjacent to _eh.
      _eh is allowed to be boundary, in which case true is returned iff _eh is 
      the only boundary edge of its ajdacent face.
  */
  bool is_simple_link(EdgeHandle _eh) const;
  /** return true if _fh shares only one edge with all of its adjacent faces.
      Boundary is treated as one face, i.e., the function false if _fh has more
      than one boundary edge.
  */
  bool is_simply_connected(FaceHandle _fh) const;
  /** Removes the edge _eh. Its adjacent faces are merged. _eh and one of the 
      adjacent faces are set deleted. The handle of the remaining face is 
      returned (InvalidFaceHandle is returned if _eh is a boundary edge).
      
1494
      \pre is_simple_link(_eh). This ensures that there are no hole faces
Jan Möbius's avatar
Jan Möbius committed
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
      or isolated vertices appearing in result of the operation.
      
      \attention Needs the Attributes::Status attribute for edges and faces.
      
      \note This function does not perform a garbage collection. It
      only marks items as deleted.
  */
  FaceHandle remove_edge(EdgeHandle _eh);
  /** Inverse of remove_edge. _eh should be the handle of the edge and the
      vertex and halfedge handles pointed by edge(_eh) should be valid. 
  */
  void reinsert_edge(EdgeHandle _eh);
  /** Inserts an edge between to_vh(_prev_heh) and from_vh(_next_heh).
      A new face is created started at heh0 of the inserted edge and
      its halfedges loop includes both _prev_heh and _next_heh. If an 
      old face existed which includes the argument halfedges, it is 
      split at the new edge. heh0 is returned. 
      
      \note assumes _prev_heh and _next_heh are either boundary or pointed
      to the same face
  */
  HalfedgeHandle insert_edge(HalfedgeHandle _prev_heh, HalfedgeHandle _next_heh);