Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TriMeshT.hh
1 /* ========================================================================= *
2  * *
3  * OpenMesh *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openmesh.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenMesh. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  * ========================================================================= */
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Date$ *
46  * *
47 \*===========================================================================*/
48 
49 
50 //=============================================================================
51 //
52 // CLASS TriMeshT
53 //
54 //=============================================================================
55 
56 
57 #ifndef OPENMESH_TRIMESH_HH
58 #define OPENMESH_TRIMESH_HH
59 
60 
61 //== INCLUDES =================================================================
62 
63 
65 #include <OpenMesh/Core/Mesh/PolyMeshT.hh>
66 #include <vector>
67 
68 
69 //== NAMESPACES ===============================================================
70 
71 
72 namespace OpenMesh {
73 
74 
75 //== CLASS DEFINITION =========================================================
76 
77 
94 template <class Kernel>
95 class TriMeshT : public PolyMeshT<Kernel>
96 {
97 
98 public:
99 
100 
101  // self
102  typedef TriMeshT<Kernel> This;
103  typedef PolyMeshT<Kernel> PolyMesh;
104 
106  enum { IsPolyMesh = 0 };
108  enum { IsTriMesh = 1 };
109  static bool is_polymesh() { return false; }
110  static bool is_trimesh() { return true; }
112 
113  //--- items ---
114 
115  typedef typename PolyMesh::Scalar Scalar;
116  typedef typename PolyMesh::Point Point;
117  typedef typename PolyMesh::Normal Normal;
118  typedef typename PolyMesh::Color Color;
119  typedef typename PolyMesh::TexCoord1D TexCoord1D;
120  typedef typename PolyMesh::TexCoord2D TexCoord2D;
121  typedef typename PolyMesh::TexCoord3D TexCoord3D;
122  typedef typename PolyMesh::Vertex Vertex;
123  typedef typename PolyMesh::Halfedge Halfedge;
124  typedef typename PolyMesh::Edge Edge;
125  typedef typename PolyMesh::Face Face;
126 
127 
128  //--- handles ---
129 
130  typedef typename PolyMesh::VertexHandle VertexHandle;
131  typedef typename PolyMesh::HalfedgeHandle HalfedgeHandle;
132  typedef typename PolyMesh::EdgeHandle EdgeHandle;
133  typedef typename PolyMesh::FaceHandle FaceHandle;
134 
135 
136  //--- iterators ---
137 
138  typedef typename PolyMesh::VertexIter VertexIter;
139  typedef typename PolyMesh::ConstVertexIter ConstVertexIter;
140  typedef typename PolyMesh::EdgeIter EdgeIter;
141  typedef typename PolyMesh::ConstEdgeIter ConstEdgeIter;
142  typedef typename PolyMesh::FaceIter FaceIter;
143  typedef typename PolyMesh::ConstFaceIter ConstFaceIter;
144 
145 
146 
147  //--- circulators ---
148 
149  typedef typename PolyMesh::VertexVertexIter VertexVertexIter;
150  typedef typename PolyMesh::VertexOHalfedgeIter VertexOHalfedgeIter;
151  typedef typename PolyMesh::VertexIHalfedgeIter VertexIHalfedgeIter;
152  typedef typename PolyMesh::VertexEdgeIter VertexEdgeIter;
153  typedef typename PolyMesh::VertexFaceIter VertexFaceIter;
154  typedef typename PolyMesh::FaceVertexIter FaceVertexIter;
155  typedef typename PolyMesh::FaceHalfedgeIter FaceHalfedgeIter;
156  typedef typename PolyMesh::FaceEdgeIter FaceEdgeIter;
157  typedef typename PolyMesh::FaceFaceIter FaceFaceIter;
158  typedef typename PolyMesh::ConstVertexVertexIter ConstVertexVertexIter;
159  typedef typename PolyMesh::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter;
160  typedef typename PolyMesh::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter;
161  typedef typename PolyMesh::ConstVertexEdgeIter ConstVertexEdgeIter;
162  typedef typename PolyMesh::ConstVertexFaceIter ConstVertexFaceIter;
163  typedef typename PolyMesh::ConstFaceVertexIter ConstFaceVertexIter;
164  typedef typename PolyMesh::ConstFaceHalfedgeIter ConstFaceHalfedgeIter;
165  typedef typename PolyMesh::ConstFaceEdgeIter ConstFaceEdgeIter;
166  typedef typename PolyMesh::ConstFaceFaceIter ConstFaceFaceIter;
167 
168  // --- constructor/destructor
169 
171  TriMeshT() : PolyMesh() {}
173  virtual ~TriMeshT() {}
174 
175  //--- halfedge collapse / vertex split ---
176 
213  inline HalfedgeHandle vertex_split(Point _v0_point, VertexHandle _v1,
214  VertexHandle _vl, VertexHandle _vr)
215  { return PolyMesh::vertex_split(this->add_vertex(_v0_point), _v1, _vl, _vr); }
216 
253  inline HalfedgeHandle vertex_split(VertexHandle _v0, VertexHandle _v1,
254  VertexHandle _vl, VertexHandle _vr)
255  { return PolyMesh::vertex_split(_v0, _v1, _vl, _vr); }
256 
266  inline VertexHandle split(EdgeHandle _eh, const Point& _p)
267  {
268  //Do not call PolyMeshT function below as this does the wrong operation
269  const VertexHandle vh = this->add_vertex(_p); Kernel::split(_eh, vh); return vh;
270  }
271 
280  inline VertexHandle split_copy(EdgeHandle _eh, const Point& _p)
281  {
282  //Do not call PolyMeshT function below as this does the wrong operation
283  const VertexHandle vh = this->add_vertex(_p); Kernel::split_copy(_eh, vh); return vh;
284  }
285 
293  inline void split(EdgeHandle _eh, VertexHandle _vh)
294  {
295  //Do not call PolyMeshT function below as this does the wrong operation
296  Kernel::split(_eh, _vh);
297  }
298 
306  inline void split_copy(EdgeHandle _eh, VertexHandle _vh)
307  {
308  //Do not call PolyMeshT function below as this does the wrong operation
309  Kernel::split_copy(_eh, _vh);
310  }
311 
321  inline VertexHandle split(FaceHandle _fh, const Point& _p)
322  { const VertexHandle vh = this->add_vertex(_p); PolyMesh::split(_fh, vh); return vh; }
323 
333  inline VertexHandle split_copy(FaceHandle _fh, const Point& _p)
334  { const VertexHandle vh = this->add_vertex(_p); PolyMesh::split_copy(_fh, vh); return vh; }
335 
343  inline void split(FaceHandle _fh, VertexHandle _vh)
344  { PolyMesh::split(_fh, _vh); }
345 
353  inline void split_copy(FaceHandle _fh, VertexHandle _vh)
354  { PolyMesh::split_copy(_fh, _vh); }
355 
359 
361  Normal calc_face_normal(FaceHandle _fh) const;
362 
364 };
365 
366 
367 //=============================================================================
368 } // namespace OpenMesh
369 //=============================================================================
370 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_TRIMESH_C)
371 #define OPENMESH_TRIMESH_TEMPLATES
372 #include "TriMeshT.cc"
373 #endif
374 //=============================================================================
375 #endif // OPENMESH_TRIMESH_HH defined
376 //=============================================================================
TriMeshT()
Default constructor.
Definition: TriMeshT.hh:171
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:178
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
Definition: PolyMeshT.hh:180
Kernel::ConstVertexVertexIter ConstVertexVertexIter
Circulator.
Definition: PolyMeshT.hh:175
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:167
VertexHandle split_copy(EdgeHandle _eh, const Point &_p)
Edge split (= 2-to-4 split)
Definition: TriMeshT.hh:280
Kernel::Color Color
Color type.
Definition: PolyMeshT.hh:119
static bool is_trimesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Definition: TriMeshT.hh:110
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:176
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:182
Kernel::FaceEdgeIter FaceEdgeIter
Circulator.
Definition: PolyMeshT.hh:172
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Definition: PolyMeshT.hh:165
Kernel::Face Face
Face type.
Definition: PolyMeshT.hh:133
Kernel::Vertex Vertex
Vertex type.
Definition: PolyMeshT.hh:127
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
Handle for a halfedge entity.
Definition: Handles.hh:132
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Definition: PolyMeshT.hh:236
static bool is_polymesh()
Determine whether this is a PolyMeshT or TriMeshT ( This function does not check the per face vertex ...
Definition: TriMeshT.hh:109
void split_copy(EdgeHandle _eh, VertexHandle _vh)
Edge split (= 2-to-4 split)
Definition: TriMeshT.hh:306
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Definition: PolyMeshT.hh:123
VertexHandle split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-3 split, calls corresponding PolyMeshT function).
Definition: TriMeshT.hh:321
Kernel::FaceFaceIter FaceFaceIter
Circulator.
Definition: PolyMeshT.hh:173
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:181
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:177
HalfedgeHandle vertex_split(VertexHandle _v0, VertexHandle _v1, VertexHandle _vl, VertexHandle _vr)
Vertex Split: inverse operation to collapse().
Definition: TriMeshT.hh:253
Handle for a vertex entity.
Definition: Handles.hh:125
Kernel::VertexEdgeIter VertexEdgeIter
Circulator.
Definition: PolyMeshT.hh:168
void split(FaceHandle _fh, VertexHandle _vh)
Face split (= 1-to-3 split, calls corresponding PolyMeshT function).
Definition: TriMeshT.hh:343
Kernel::Edge Edge
Edge type.
Definition: PolyMeshT.hh:131
Handle for a edge entity.
Definition: Handles.hh:139
void split_copy(FaceHandle _fh, VertexHandle _vh)
Face split (= 1-to-3 split, calls corresponding PolyMeshT function).
Definition: TriMeshT.hh:353
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:166
Kernel::TexCoord3D TexCoord3D
TexCoord3D type.
Definition: PolyMeshT.hh:125
Handle for a face entity.
Definition: Handles.hh:146
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Definition: PolyMeshT.hh:179
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
VertexHandle split(EdgeHandle _eh, const Point &_p)
Edge split (= 2-to-4 split)
Definition: TriMeshT.hh:266
Kernel::TexCoord1D TexCoord1D
TexCoord1D type.
Definition: PolyMeshT.hh:121
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Definition: PolyMeshT.hh:170
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.
Definition: PolyMeshT.hh:183
Normal calc_face_normal(FaceHandle _fh) const
Definition: TriMeshT.cc:79
HalfedgeHandle vertex_split(Point _v0_point, VertexHandle _v1, VertexHandle _vl, VertexHandle _vr)
Vertex Split: inverse operation to collapse().
Definition: TriMeshT.hh:213
VertexHandle split_copy(FaceHandle _fh, const Point &_p)
Face split (= 1-to-3 split, calls corresponding PolyMeshT function).
Definition: TriMeshT.hh:333
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:171
void split(FaceHandle _fh, const Point &_p)
Face split (= 1-to-n split)
Definition: PolyMeshT.hh:545
Kernel::VertexFaceIter VertexFaceIter
Circulator.
Definition: PolyMeshT.hh:169
Kernel::Halfedge Halfedge
Halfedge type.
Definition: PolyMeshT.hh:129
virtual ~TriMeshT()
Destructor.
Definition: TriMeshT.hh:173
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117
void split(EdgeHandle _eh, VertexHandle _vh)
Edge split (= 2-to-4 split)
Definition: TriMeshT.hh:293