Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TriMeshT.hh

00001 //=============================================================================
00002 //                                                                            
00003 //                               OpenMesh                                     
00004 //        Copyright (C) 2003 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.19 $
00027 //   $Date: 2003/10/03 16:24:44 $
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.h>
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 
00087 
00088   //--- items ---
00089 
00090   typedef typename PolyMesh::Scalar             Scalar;
00091   typedef typename PolyMesh::Point              Point;
00092   typedef typename PolyMesh::Normal             Normal;
00093   typedef typename PolyMesh::Color              Color;
00094   typedef typename PolyMesh::TexCoord           TexCoord;
00095   typedef typename PolyMesh::Vertex             Vertex;
00096   typedef typename PolyMesh::Halfedge           Halfedge;
00097   typedef typename PolyMesh::Edge               Edge;
00098   typedef typename PolyMesh::Face               Face;
00099   
00100 
00101   //--- handles ---
00102 
00103   typedef typename PolyMesh::VertexHandle       VertexHandle;
00104   typedef typename PolyMesh::HalfedgeHandle     HalfedgeHandle;
00105   typedef typename PolyMesh::EdgeHandle         EdgeHandle;
00106   typedef typename PolyMesh::FaceHandle         FaceHandle;
00107 
00108 
00109   //--- iterators ---
00110 
00111   typedef typename PolyMesh::VertexIter         VertexIter;
00112   typedef typename PolyMesh::ConstVertexIter    ConstVertexIter;
00113   typedef typename PolyMesh::EdgeIter           EdgeIter;
00114   typedef typename PolyMesh::ConstEdgeIter      ConstEdgeIter;
00115   typedef typename PolyMesh::FaceIter           FaceIter;
00116   typedef typename PolyMesh::ConstFaceIter      ConstFaceIter;
00117 
00118 
00119 
00120   //--- circulators ---
00121 
00122   typedef typename PolyMesh::VertexVertexIter         VertexVertexIter;
00123   typedef typename PolyMesh::VertexOHalfedgeIter      VertexOHalfedgeIter;
00124   typedef typename PolyMesh::VertexIHalfedgeIter      VertexIHalfedgeIter;
00125   typedef typename PolyMesh::VertexEdgeIter           VertexEdgeIter;
00126   typedef typename PolyMesh::VertexFaceIter           VertexFaceIter;
00127   typedef typename PolyMesh::FaceVertexIter           FaceVertexIter;
00128   typedef typename PolyMesh::FaceHalfedgeIter         FaceHalfedgeIter;
00129   typedef typename PolyMesh::FaceEdgeIter             FaceEdgeIter;
00130   typedef typename PolyMesh::FaceFaceIter             FaceFaceIter;
00131   typedef typename PolyMesh::ConstVertexVertexIter    ConstVertexVertexIter;
00132   typedef typename PolyMesh::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter;
00133   typedef typename PolyMesh::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter;
00134   typedef typename PolyMesh::ConstVertexEdgeIter      ConstVertexEdgeIter;
00135   typedef typename PolyMesh::ConstVertexFaceIter      ConstVertexFaceIter;
00136   typedef typename PolyMesh::ConstFaceVertexIter      ConstFaceVertexIter;
00137   typedef typename PolyMesh::ConstFaceHalfedgeIter    ConstFaceHalfedgeIter;
00138   typedef typename PolyMesh::ConstFaceEdgeIter        ConstFaceEdgeIter;
00139   typedef typename PolyMesh::ConstFaceFaceIter        ConstFaceFaceIter;
00140 
00141 
00142 
00143 
00144 
00145 
00146   // --- constructor/destructor
00147 
00149   TriMeshT() : PolyMesh() {}
00150 
00152   ~TriMeshT() {}
00153 
00155   TriMeshT& operator=(const TriMeshT& _rhs)
00156   { PolyMesh::operator=(_rhs); return *this; }
00157 
00158 
00159 
00160 
00161 
00162   // --- creation ---
00163 
00167 
00172   FaceHandle add_face(const std::vector<VertexHandle>& _vhandles);
00173 
00177   FaceHandle add_face(VertexHandle _v0, VertexHandle _v1, VertexHandle _v2) {
00178     static std::vector<VertexHandle> vhandles(3);
00179     vhandles[0] = _v0; vhandles[1] = _v1; vhandles[2] = _v2;
00180     return PolyMesh::add_face(vhandles);
00181   }
00182 
00186   template <class OtherMesh>
00187   TriMeshT& assign(const OtherMesh& _rhs)
00188   #if OM_OUT_OF_CLASS_TEMPLATE || defined(DOXYGEN)
00189      ;
00190   #else
00191   #  include "PolyMeshT_assign.hh"
00192   #endif
00193 
00195 
00196 
00201   VertexHandle opposite_vh(HalfedgeHandle _heh) const
00202   {
00203     if (is_boundary(_heh))
00204     {
00205       return InvalidVertexHandle;
00206     }
00207     return to_vertex_handle(next_halfedge_handle(_heh));
00208   }
00209 
00214   VertexHandle opposite_he_opposite_vh(HalfedgeHandle _heh) const
00215   {
00216     return opposite_vh(opposite_halfedge_handle(_heh));
00217   }
00218 
00219 
00220   //--- halfedge collapse / vertex split ---
00221 
00222 
00226 
00239   void collapse(HalfedgeHandle _heh);
00240 
00241 
00242 
00248   bool is_collapse_ok(HalfedgeHandle _heh);
00249 
00250 
00252   HalfedgeHandle vertex_split( Point        _v0_point,
00253                                VertexHandle _v1, 
00254                                VertexHandle _vl, 
00255                                VertexHandle _vr )
00256   { return vertex_split(add_vertex(_v0_point), _v1, _vl, _vr); }
00257 
00258 
00260   HalfedgeHandle vertex_split( VertexHandle v0,
00261                                VertexHandle v1, 
00262                                VertexHandle vl, 
00263                                VertexHandle vr );
00264 
00265 
00267   bool is_flip_ok(EdgeHandle _eh) const;
00268 
00271   void flip(EdgeHandle _eh);
00272 
00274   void split(EdgeHandle _eh, VertexHandle _vh);
00276   void split(EdgeHandle _eh, const Point& _p) { 
00277     split(_eh, add_vertex(_p)); 
00278   }
00279 
00281   void split(FaceHandle _fh, VertexHandle _vh) {
00282     PolyMeshT<Kernel>::split(_fh, _vh);
00283   }
00285   void split(FaceHandle _fh, const Point& _p) {
00286     PolyMeshT<Kernel>::split(_fh, _p);
00287   }
00288 
00290 
00291   
00292 private:
00293 
00295   void remove_edge(HalfedgeHandle _hh);
00296 
00298   void remove_loop(HalfedgeHandle _hh);
00299 
00301   HalfedgeHandle insert_loop(HalfedgeHandle _hh);
00302 
00304   HalfedgeHandle insert_edge(VertexHandle   _vh,
00305                              HalfedgeHandle _h0, 
00306                              HalfedgeHandle _h1);
00307 };
00308 
00309 
00310 //=============================================================================
00311 } // namespace OpenMesh
00312 //=============================================================================
00313 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_TRIMESH_C)
00314 #define OPENMESH_TRIMESH_TEMPLATES
00315 #include "TriMeshT.cc"
00316 #endif
00317 //=============================================================================
00318 #endif // OPENMESH_TRIMESH_HH defined
00319 //=============================================================================

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