00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OPENMESH_TRIMESH_HH
00040 #define OPENMESH_TRIMESH_HH
00041
00042
00043
00044
00045
00046 #include <OpenMesh/Core/System/config.hh>
00047 #include <OpenMesh/Core/Mesh/PolyMeshT.hh>
00048 #include <vector>
00049
00050
00051
00052
00053
00054 namespace OpenMesh {
00055
00056
00057
00058
00059
00076 template <class Kernel>
00077 class TriMeshT : public PolyMeshT<Kernel>
00078 {
00079
00080 public:
00081
00082
00083
00084 typedef TriMeshT<Kernel> This;
00085 typedef PolyMeshT<Kernel> PolyMesh;
00086
00088
00089 enum { IsPolyMesh = 0 };
00090 enum { IsTriMesh = 1 };
00091 static bool is_polymesh() { return false; }
00092 static bool is_trimesh() { return true; }
00094
00095
00096
00097
00098 typedef typename PolyMesh::Scalar Scalar;
00099 typedef typename PolyMesh::Point Point;
00100 typedef typename PolyMesh::Normal Normal;
00101 typedef typename PolyMesh::Color Color;
00102 typedef typename PolyMesh::TexCoord1D TexCoord1D;
00103 typedef typename PolyMesh::TexCoord2D TexCoord2D;
00104 typedef typename PolyMesh::TexCoord3D TexCoord3D;
00105 typedef typename PolyMesh::Vertex Vertex;
00106 typedef typename PolyMesh::Halfedge Halfedge;
00107 typedef typename PolyMesh::Edge Edge;
00108 typedef typename PolyMesh::Face Face;
00109
00110
00111
00112
00113 typedef typename PolyMesh::VertexHandle VertexHandle;
00114 typedef typename PolyMesh::HalfedgeHandle HalfedgeHandle;
00115 typedef typename PolyMesh::EdgeHandle EdgeHandle;
00116 typedef typename PolyMesh::FaceHandle FaceHandle;
00117
00118
00119
00120
00121 typedef typename PolyMesh::VertexIter VertexIter;
00122 typedef typename PolyMesh::ConstVertexIter ConstVertexIter;
00123 typedef typename PolyMesh::EdgeIter EdgeIter;
00124 typedef typename PolyMesh::ConstEdgeIter ConstEdgeIter;
00125 typedef typename PolyMesh::FaceIter FaceIter;
00126 typedef typename PolyMesh::ConstFaceIter ConstFaceIter;
00127
00128
00129
00130
00131
00132 typedef typename PolyMesh::VertexVertexIter VertexVertexIter;
00133 typedef typename PolyMesh::VertexOHalfedgeIter VertexOHalfedgeIter;
00134 typedef typename PolyMesh::VertexIHalfedgeIter VertexIHalfedgeIter;
00135 typedef typename PolyMesh::VertexEdgeIter VertexEdgeIter;
00136 typedef typename PolyMesh::VertexFaceIter VertexFaceIter;
00137 typedef typename PolyMesh::FaceVertexIter FaceVertexIter;
00138 typedef typename PolyMesh::FaceHalfedgeIter FaceHalfedgeIter;
00139 typedef typename PolyMesh::FaceEdgeIter FaceEdgeIter;
00140 typedef typename PolyMesh::FaceFaceIter FaceFaceIter;
00141 typedef typename PolyMesh::ConstVertexVertexIter ConstVertexVertexIter;
00142 typedef typename PolyMesh::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter;
00143 typedef typename PolyMesh::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter;
00144 typedef typename PolyMesh::ConstVertexEdgeIter ConstVertexEdgeIter;
00145 typedef typename PolyMesh::ConstVertexFaceIter ConstVertexFaceIter;
00146 typedef typename PolyMesh::ConstFaceVertexIter ConstFaceVertexIter;
00147 typedef typename PolyMesh::ConstFaceHalfedgeIter ConstFaceHalfedgeIter;
00148 typedef typename PolyMesh::ConstFaceEdgeIter ConstFaceEdgeIter;
00149 typedef typename PolyMesh::ConstFaceFaceIter ConstFaceFaceIter;
00150
00151
00152
00153
00154
00155
00156
00157
00159 TriMeshT() : PolyMesh() {}
00160
00162 ~TriMeshT() {}
00163
00167 TriMeshT& operator=(const TriMeshT& _rhs)
00168 { if (this!=&_rhs) PolyMesh::operator=(_rhs); return *this; }
00169
00170
00171
00172
00173
00174
00175
00179
00184 FaceHandle add_face(const std::vector<VertexHandle>& _vhandles);
00185
00189 FaceHandle add_face(VertexHandle _v0, VertexHandle _v1, VertexHandle _v2) {
00190 static std::vector<VertexHandle> vhandles(3);
00191 vhandles[0] = _v0; vhandles[1] = _v1; vhandles[2] = _v2;
00192 return PolyMesh::add_face(vhandles);
00193 }
00194
00198 template <class OtherMesh>
00199 TriMeshT& assign(const OtherMesh& _rhs)
00200 #if OM_OUT_OF_CLASS_TEMPLATE || defined(DOXYGEN)
00201 ;
00202 #else
00203 # include "PolyMeshT_assign.hh"
00204 #endif
00205
00207
00208
00213 VertexHandle opposite_vh(HalfedgeHandle _heh) const
00214 {
00215 if (is_boundary(_heh))
00216 {
00217 return This::InvalidVertexHandle;
00218 }
00219 return to_vertex_handle(next_halfedge_handle(_heh));
00220 }
00221
00226 VertexHandle opposite_he_opposite_vh(HalfedgeHandle _heh) const
00227 {
00228 return opposite_vh(opposite_halfedge_handle(_heh));
00229 }
00230
00231
00232
00233
00234
00238
00251 void collapse(HalfedgeHandle _heh);
00252
00253
00254
00260 bool is_collapse_ok(HalfedgeHandle _heh);
00261
00262
00264 HalfedgeHandle vertex_split( Point _v0_point,
00265 VertexHandle _v1,
00266 VertexHandle _vl,
00267 VertexHandle _vr )
00268 { return vertex_split(add_vertex(_v0_point), _v1, _vl, _vr); }
00269
00270
00272 HalfedgeHandle vertex_split( VertexHandle v0,
00273 VertexHandle v1,
00274 VertexHandle vl,
00275 VertexHandle vr );
00276
00277
00279 bool is_flip_ok(EdgeHandle _eh) const;
00280
00283 void flip(EdgeHandle _eh);
00284
00286 void split(EdgeHandle _eh, VertexHandle _vh);
00288 void split(EdgeHandle _eh, const Point& _p) {
00289 split(_eh, add_vertex(_p));
00290 }
00291
00293 void split(FaceHandle _fh, VertexHandle _vh) {
00294 PolyMeshT<Kernel>::split(_fh, _vh);
00295 }
00297 void split(FaceHandle _fh, const Point& _p) {
00298 PolyMeshT<Kernel>::split(_fh, _p);
00299 }
00300
00302
00303
00305 void remove_edge(HalfedgeHandle _hh);
00306
00308 void remove_loop(HalfedgeHandle _hh);
00309
00311 HalfedgeHandle insert_loop(HalfedgeHandle _hh);
00312
00314 HalfedgeHandle insert_edge(VertexHandle _vh,
00315 HalfedgeHandle _h0,
00316 HalfedgeHandle _h1);
00317 };
00318
00319
00320
00321 }
00322
00323 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_TRIMESH_C)
00324 #define OPENMESH_TRIMESH_TEMPLATES
00325 #include "TriMeshT.cc"
00326 #endif
00327
00328 #endif // OPENMESH_TRIMESH_HH defined
00329