OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PolyConnectivity.hh
1 /*===========================================================================*\
2  * *
3  * OpenMesh *
4  * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
5  * www.openmesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenMesh. *
9  * *
10  * OpenMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 570 $ *
38  * $Date: 2012-04-05 16:25:45 +0200 (Do, 05 Apr 2012) $ *
39  * *
40 \*===========================================================================*/
41 
42 #ifndef OPENMESH_POLYCONNECTIVITY_HH
43 #define OPENMESH_POLYCONNECTIVITY_HH
44 
45 #include <OpenMesh/Core/Mesh/ArrayKernel.hh>
46 #include <OpenMesh/Core/Mesh/IteratorsT.hh>
47 #include <OpenMesh/Core/Mesh/CirculatorsT.hh>
48 
49 namespace OpenMesh
50 {
51 
55 {
56 public:
58 
59 
68 
69  typedef PolyConnectivity This;
70 
71  //--- iterators ---
72 
78 
83 
89 
90  //--- circulators ---
91 
97 
107 
118 
119  // --- shortcuts
120 
125 
130 
131  typedef VertexIter VIter;
133  typedef EdgeIter EIter;
134  typedef FaceIter FIter;
135 
140 
150 
161 
162 public:
163 
164  PolyConnectivity() {}
165  virtual ~PolyConnectivity() {}
166 
167  inline static bool is_triangles()
168  { return false; }
169 
172  inline void assign_connectivity(const PolyConnectivity& _other)
174 
178 
181  { return new_vertex(); }
182 
190  FaceHandle add_face(const std::vector<VertexHandle>& _vhandles)
191  { return add_face(&_vhandles.front(), _vhandles.size()); }
192 
193 
204  {
205  VertexHandle vhs[3] = { _vh0, _vh1, _vh2 };
206  return add_face(vhs, 3);
207  }
208 
220  {
221  VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 };
222  return add_face(vhs, 4);
223  }
224 
233  FaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size);
235 
237 
238 
243  bool is_collapse_ok(HalfedgeHandle _he);
244 
245 
251  void delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices = true);
252 
261  void delete_edge(EdgeHandle _eh, bool _delete_isolated_vertices=true);
262 
273  void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true);
274 
276 
280 
283  { return VertexIter(*this, VertexHandle(0)); }
286  { return ConstVertexIter(*this, VertexHandle(0)); }
289  { return VertexIter(*this, VertexHandle(n_vertices())); }
292  { return ConstVertexIter(*this, VertexHandle(n_vertices())); }
293 
296  { return HalfedgeIter(*this, HalfedgeHandle(0)); }
299  { return ConstHalfedgeIter(*this, HalfedgeHandle(0)); }
302  { return HalfedgeIter(*this, HalfedgeHandle(n_halfedges())); }
305  { return ConstHalfedgeIter(*this, HalfedgeHandle(n_halfedges())); }
306 
309  { return EdgeIter(*this, EdgeHandle(0)); }
312  { return ConstEdgeIter(*this, EdgeHandle(0)); }
315  { return EdgeIter(*this, EdgeHandle(n_edges())); }
318  { return ConstEdgeIter(*this, EdgeHandle(n_edges())); }
319 
322  { return FaceIter(*this, FaceHandle(0)); }
325  { return ConstFaceIter(*this, FaceHandle(0)); }
328  { return FaceIter(*this, FaceHandle(n_faces())); }
331  { return ConstFaceIter(*this, FaceHandle(n_faces())); }
332 
334 
335 
336 
340 
343  { return VertexIter(*this, VertexHandle(0), true); }
346  { return ConstVertexIter(*this, VertexHandle(0), true); }
347 
350  { return HalfedgeIter(*this, HalfedgeHandle(0), true); }
353  { return ConstHalfedgeIter(*this, HalfedgeHandle(0), true); }
354 
357  { return EdgeIter(*this, EdgeHandle(0), true); }
360  { return ConstEdgeIter(*this, EdgeHandle(0), true); }
361 
364  { return FaceIter(*this, FaceHandle(0), true); }
367  { return ConstFaceIter(*this, FaceHandle(0), true); }
368 
370 
371  //--- circulators ---
372 
376 
379  { return VertexVertexIter(*this, _vh); }
382  { return VertexIHalfedgeIter(*this, _vh); }
385  { return VertexOHalfedgeIter(*this, _vh); }
388  { return VertexEdgeIter(*this, _vh); }
391  { return VertexFaceIter(*this, _vh); }
392 
395  { return ConstVertexVertexIter(*this, _vh); }
398  { return ConstVertexIHalfedgeIter(*this, _vh); }
401  { return ConstVertexOHalfedgeIter(*this, _vh); }
404  { return ConstVertexEdgeIter(*this, _vh); }
407  { return ConstVertexFaceIter(*this, _vh); }
408 
411  { return FaceVertexIter(*this, _fh); }
414  { return FaceHalfedgeIter(*this, _fh); }
417  { return FaceEdgeIter(*this, _fh); }
420  { return FaceFaceIter(*this, _fh); }
421 
424  { return ConstFaceVertexIter(*this, _fh); }
427  { return ConstFaceHalfedgeIter(*this, _fh); }
430  { return ConstFaceEdgeIter(*this, _fh); }
433  { return ConstFaceFaceIter(*this, _fh); }
434 
435  // 'begin' circulators
436 
439  { return VertexVertexIter(*this, _vh); }
442  { return VertexIHalfedgeIter(*this, _vh); }
445  { return VertexOHalfedgeIter(*this, _vh); }
448  { return VertexEdgeIter(*this, _vh); }
451  { return VertexFaceIter(*this, _vh); }
452 
455  { return ConstVertexVertexIter(*this, _vh); }
458  { return ConstVertexIHalfedgeIter(*this, _vh); }
461  { return ConstVertexOHalfedgeIter(*this, _vh); }
464  { return ConstVertexEdgeIter(*this, _vh); }
467  { return ConstVertexFaceIter(*this, _vh); }
468 
471  { return FaceVertexIter(*this, _fh); }
474  { return FaceHalfedgeIter(*this, _fh); }
477  { return FaceEdgeIter(*this, _fh); }
480  { return FaceFaceIter(*this, _fh); }
481 
484  { return ConstFaceVertexIter(*this, _fh); }
487  { return ConstFaceHalfedgeIter(*this, _fh); }
490  { return ConstFaceEdgeIter(*this, _fh); }
493  { return ConstFaceFaceIter(*this, _fh); }
494 
495  // 'end' circulators
496 
499  { return VertexVertexIter(*this, _vh, true); }
502  { return VertexIHalfedgeIter(*this, _vh, true); }
505  { return VertexOHalfedgeIter(*this, _vh, true); }
508  { return VertexEdgeIter(*this, _vh, true); }
511  { return VertexFaceIter(*this, _vh, true); }
512 
515  { return ConstVertexVertexIter(*this, _vh, true); }
518  { return ConstVertexIHalfedgeIter(*this, _vh, true); }
521  { return ConstVertexOHalfedgeIter(*this, _vh, true); }
524  { return ConstVertexEdgeIter(*this, _vh, true); }
527  { return ConstVertexFaceIter(*this, _vh, true); }
528 
531  { return FaceVertexIter(*this, _fh, true); }
534  { return FaceHalfedgeIter(*this, _fh, true); }
537  { return FaceEdgeIter(*this, _fh, true); }
540  { return FaceFaceIter(*this, _fh, true); }
541 
544  { return ConstFaceVertexIter(*this, _fh, true); }
547  { return ConstFaceHalfedgeIter(*this, _fh, true); }
550  { return ConstFaceEdgeIter(*this, _fh, true); }
553  { return ConstFaceFaceIter(*this, _fh, true); }
555 
559  bool is_boundary(HalfedgeHandle _heh) const
560  { return ArrayKernel::is_boundary(_heh); }
561 
564  bool is_boundary(EdgeHandle _eh) const
565  {
566  return (is_boundary(halfedge_handle(_eh, 0)) ||
567  is_boundary(halfedge_handle(_eh, 1)));
568  }
570  bool is_boundary(VertexHandle _vh) const
571  {
572  HalfedgeHandle heh(halfedge_handle(_vh));
573  return (!(heh.is_valid() && face_handle(heh).is_valid()));
574  }
575 
582  bool is_boundary(FaceHandle _fh, bool _check_vertex=false) const;
584  bool is_manifold(VertexHandle _vh) const;
586 
587  // --- shortcuts ---
588 
591  { return face_handle(opposite_halfedge_handle(_heh)); }
592 
593  // --- misc ---
594 
600  HalfedgeHandle find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh) const;
602  uint valence(VertexHandle _vh) const;
604  uint valence(FaceHandle _fh) const;
605 
606  // --- connectivity operattions
607 
622  void collapse(HalfedgeHandle _heh);
627  bool is_simple_link(EdgeHandle _eh) const;
632  bool is_simply_connected(FaceHandle _fh) const;
649  void reinsert_edge(EdgeHandle _eh);
660 
662  void split(FaceHandle _fh, VertexHandle _vh);
663 
677  void triangulate(FaceHandle _fh);
678 
681  void triangulate();
682 
684  void split_edge(EdgeHandle _eh, VertexHandle _vh);
685 
686 
692 
693  const Vertex& deref(VertexHandle _h) const { return vertex(_h); }
694  Vertex& deref(VertexHandle _h) { return vertex(_h); }
695  const Halfedge& deref(HalfedgeHandle _h) const { return halfedge(_h); }
696  Halfedge& deref(HalfedgeHandle _h) { return halfedge(_h); }
697  const Edge& deref(EdgeHandle _h) const { return edge(_h); }
698  Edge& deref(EdgeHandle _h) { return edge(_h); }
699  const Face& deref(FaceHandle _h) const { return face(_h); }
700  Face& deref(FaceHandle _h) { return face(_h); }
702 
703 protected:
705  void collapse_edge(HalfedgeHandle _hh);
707  void collapse_loop(HalfedgeHandle _hh);
708 
709 
710 
711 private: // Working storage for add_face()
712  struct AddFaceEdgeInfo
713  {
714  HalfedgeHandle halfedge_handle;
715  bool is_new;
716  bool needs_adjust;
717  };
718  std::vector<AddFaceEdgeInfo> edgeData_; //
719  std::vector<std::pair<HalfedgeHandle, HalfedgeHandle> > next_cache_; // cache for set_next_halfedge and vertex' set_halfedge
720  uint next_cache_count_;
721 
722 };
723 
724 }//namespace OpenMesh
725 
726 #endif//OPENMESH_POLYCONNECTIVITY_HH

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .