- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# Core/Mesh/TriMeshT.hh

    00001 //=============================================================================
    00002 //
    00003 //                               OpenMesh
    00004 //      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen
    00005 //                           www.openmesh.org
    00006 //
    00007 //-----------------------------------------------------------------------------
    00008 //
    00009 //                                License
    00010 //
    00011 //   This library is free software; you can redistribute it and/or modify it
    00012 //   under the terms of the GNU Library General Public License as published
    00013 //   by the Free Software Foundation, version 2.
    00014 //
    00015 //   This library is distributed in the hope that it will be useful, but
    00016 //   WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 //   Library General Public License for more details.
    00019 //
    00020 //   You should have received a copy of the GNU Library General Public
    00021 //   License along with this library; if not, write to the Free Software
    00022 //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00023 //
    00024 //-----------------------------------------------------------------------------
    00025 //
    00026 //   $Revision: 1.5 $
    00027 //   $Date: 2005-12-21 13:51:50 $
    00028 //
    00029 //=============================================================================
    00030
    00031
    00032 //=============================================================================
    00033 //
    00034 //  CLASS TriMeshT
    00035 //
    00036 //=============================================================================
    00037
    00038
    00039 #ifndef OPENMESH_TRIMESH_HH
    00040 #define OPENMESH_TRIMESH_HH
    00041
    00042
    00043 //== INCLUDES =================================================================
    00044
    00045
    00046 #include <OpenMesh/Core/System/config.hh>
    00047 #include <OpenMesh/Core/Mesh/PolyMeshT.hh>
    00048 #include <vector>
    00049
    00050
    00051 //== NAMESPACES ===============================================================
    00052
    00053
    00054 namespace OpenMesh {
    00055
    00056
    00057 //== CLASS DEFINITION =========================================================
    00058
    00059
    00076 template <class Kernel>
    00077 class TriMeshT : public PolyMeshT<Kernel>
    00078 {
    00079
    00080 public:
    00081
    00082
    00083   // self
    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   //--- items ---
    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   //--- handles ---
    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   //--- iterators ---
    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   //--- circulators ---
    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   // --- constructor/destructor
    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   // --- creation ---
    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   //--- halfedge collapse / vertex split ---
    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 } // namespace OpenMesh
    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 //=============================================================================