📄 polymesht.hh
字号:
//=============================================================================//// OpenMesh// Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen// www.openmesh.org////-----------------------------------------------------------------------------//// License//// This library is free software; you can redistribute it and/or modify it// under the terms of the GNU Library General Public License as published// by the Free Software Foundation, version 2.//// This library is distributed in the hope that it will be useful, but// WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Library General Public License for more details.//// You should have received a copy of the GNU Library General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.////-----------------------------------------------------------------------------//// $Revision: 1.4 $// $Date: 2005-12-21 13:51:49 $////=============================================================================//=============================================================================//// CLASS PolyMeshT////=============================================================================#ifndef OPENMESH_POLYMESHT_HH#define OPENMESH_POLYMESHT_HH//== INCLUDES =================================================================#include <OpenMesh/Core/System/config.hh>#include <OpenMesh/Core/Mesh/BaseMesh.hh>#include <OpenMesh/Core/Mesh/Iterators/IteratorsT.hh>#include <OpenMesh/Core/Mesh/Iterators/CirculatorsT.hh>#include <OpenMesh/Core/Attributes/Attributes.hh>#include <OpenMesh/Core/Math/MathDefs.hh>#include <vector>//== NAMESPACES ===============================================================namespace OpenMesh {//== CLASS DEFINITION =========================================================/** \class PolyMeshT PolyMeshT.hh <OpenMesh/Mesh/PolyMeshT.hh> Base type for a polygonal mesh. This is the base class for a polygonal mesh. It is parameterized by a mesh kernel that is given as a template argument. This class inherits all methods from its mesh kernel. \param Kernel: template argument for the mesh kernel \note You should use the predefined mesh-kernel combinations in \ref mesh_types_group \see \ref mesh_type*/template <class Kernel>class PolyMeshT : public Kernel, public BaseMesh{public: /// Self type. Used to specify iterators/circulators. typedef PolyMeshT<Kernel> This; //@{ /// Determine whether this is a PolyMeshT or TriMeshT enum { IsPolyMesh = 1 }; enum { IsTriMesh = 0 }; static bool is_polymesh() { return true; } static bool is_trimesh() { return false; } //@} //--- item types --- /// \name Mesh Items //@{ /// Scalar type typedef typename Kernel::Scalar Scalar; /// Coordinate type typedef typename Kernel::Point Point; /// Normal type typedef typename Kernel::Normal Normal; /// Color type typedef typename Kernel::Color Color; /// TexCoord1D type typedef typename Kernel::TexCoord1D TexCoord1D; /// TexCoord2D type typedef typename Kernel::TexCoord2D TexCoord2D; /// TexCoord3D type typedef typename Kernel::TexCoord3D TexCoord3D; /// Vertex type typedef typename Kernel::Vertex Vertex; /// Halfedge type typedef typename Kernel::Halfedge Halfedge; /// Edge type typedef typename Kernel::Edge Edge; /// Face type typedef typename Kernel::Face Face; //@} //--- handle types --- /// \name Mesh Handles //@{ /// Handle for referencing the corresponding item typedef typename Kernel::VertexHandle VertexHandle; typedef typename Kernel::HalfedgeHandle HalfedgeHandle; typedef typename Kernel::EdgeHandle EdgeHandle; typedef typename Kernel::FaceHandle FaceHandle; /// Invalid handle static const VertexHandle InvalidVertexHandle; /// Invalid handle static const HalfedgeHandle InvalidHalfedgeHandle; /// Invalid handle static const EdgeHandle InvalidEdgeHandle; /// Invalid handle static const FaceHandle InvalidFaceHandle; //@} //--- iterators --- /** \name Mesh Iterators Refer to OpenMesh::Mesh::Iterators or \ref mesh_iterators for documentation. */ //@{ /// Linear iterator typedef Iterators::VertexIterT<This> VertexIter; typedef Iterators::HalfedgeIterT<This> HalfedgeIter; typedef Iterators::EdgeIterT<This> EdgeIter; typedef Iterators::FaceIterT<This> FaceIter; typedef Iterators::ConstVertexIterT<This> ConstVertexIter; typedef Iterators::ConstHalfedgeIterT<This> ConstHalfedgeIter; typedef Iterators::ConstEdgeIterT<This> ConstEdgeIter; typedef Iterators::ConstFaceIterT<This> ConstFaceIter; //@} //--- circulators --- /** \name Mesh Circulators Refer to OpenMesh::Mesh::Iterators or \ref mesh_iterators for documentation. */ //@{ /// Circulator typedef Iterators::VertexVertexIterT<This> VertexVertexIter; typedef Iterators::VertexOHalfedgeIterT<This> VertexOHalfedgeIter; typedef Iterators::VertexIHalfedgeIterT<This> VertexIHalfedgeIter; typedef Iterators::VertexEdgeIterT<This> VertexEdgeIter; typedef Iterators::VertexFaceIterT<This> VertexFaceIter; typedef Iterators::FaceVertexIterT<This> FaceVertexIter; typedef Iterators::FaceHalfedgeIterT<This> FaceHalfedgeIter; typedef Iterators::FaceEdgeIterT<This> FaceEdgeIter; typedef Iterators::FaceFaceIterT<This> FaceFaceIter; typedef Iterators::ConstVertexVertexIterT<This> ConstVertexVertexIter; typedef Iterators::ConstVertexOHalfedgeIterT<This> ConstVertexOHalfedgeIter; typedef Iterators::ConstVertexIHalfedgeIterT<This> ConstVertexIHalfedgeIter; typedef Iterators::ConstVertexEdgeIterT<This> ConstVertexEdgeIter; typedef Iterators::ConstVertexFaceIterT<This> ConstVertexFaceIter; typedef Iterators::ConstFaceVertexIterT<This> ConstFaceVertexIter; typedef Iterators::ConstFaceHalfedgeIterT<This> ConstFaceHalfedgeIter; typedef Iterators::ConstFaceEdgeIterT<This> ConstFaceEdgeIter; typedef Iterators::ConstFaceFaceIterT<This> ConstFaceFaceIter; //@} // --- shortcuts /** \name Typedef Shortcuts Provided for convenience only */ //@{ /// Alias typedef typedef VertexHandle VHandle; typedef HalfedgeHandle HHandle; typedef EdgeHandle EHandle; typedef FaceHandle FHandle; typedef VertexIter VIter; typedef HalfedgeIter HIter; typedef EdgeIter EIter; typedef FaceIter FIter; typedef ConstVertexIter CVIter; typedef ConstHalfedgeIter CHIter; typedef ConstEdgeIter CEIter; typedef ConstFaceIter CFIter; typedef VertexVertexIter VVIter; typedef VertexOHalfedgeIter VOHIter; typedef VertexIHalfedgeIter VIHIter; typedef VertexEdgeIter VEIter; typedef VertexFaceIter VFIter; typedef FaceVertexIter FVIter; typedef FaceHalfedgeIter FHIter; typedef FaceEdgeIter FEIter; typedef FaceFaceIter FFIter; typedef ConstVertexVertexIter CVVIter; typedef ConstVertexOHalfedgeIter CVOHIter; typedef ConstVertexIHalfedgeIter CVIHIter; typedef ConstVertexEdgeIter CVEIter; typedef ConstVertexFaceIter CVFIter; typedef ConstFaceVertexIter CFVIter; typedef ConstFaceHalfedgeIter CFHIter; typedef ConstFaceEdgeIter CFEIter; typedef ConstFaceFaceIter CFFIter; //@} // --- constructor/destructor /// Default constructor PolyMeshT() {} /// Destructor ~PolyMeshT() {} /** Assignment operator. This function call is passed on to the correspoding mesh kernel. Use this function to assign two meshes of \b equal type. If the mesh types vary, use PolyMeshT::assign() instead. */ PolyMeshT& operator=(const PolyMeshT& _rhs) { if (this!=&_rhs) Kernel::operator=(_rhs); return *this; } // --- creation --- /** \name Adding items to a mesh */ //@{ /// Add a new vertex with coordinate \c _p VertexHandle add_vertex(const Point& _p) { return new_vertex(_p); } /// Add and connect a new face FaceHandle add_face(const std::vector<VertexHandle>& _vhandles); /** Assignment from another mesh of \em another type. This method will use \c add_vertex() and \c add_face() in order to copy _rhs to itself. This will not be very efficient, but because different mesh types can have different item types it's the only solution. \note All that's copied is connectivity and vertex positions. All other information (like e.g. attributes or additional elements from traits classes) is not copied. \note If the two mesh types are equal (PolyMeshT<Kernel>==OtherMesh) you should use PolyMeshT::operator=() instead, because its more efficient and \em all information is copied. */ template <class OtherMesh> PolyMeshT& assign(const OtherMesh& _rhs)#if OM_OUT_OF_CLASS_TEMPLATE || defined(DOXYGEN) ;#else# include "PolyMeshT_assign.hh"#endif //@} // --- deletion --- /// \name Deleting mesh items //@{ /** Mark vertex and all incident edges and faces deleted. Items marked deleted will be removed by garbageCollection(). \attention Needs the Attributes::Status attribute for vertices, edges and faces. */ void delete_vertex(VertexHandle _vh, bool _delete_isolated_vertices = true); /** Mark edge (two opposite halfedges) and incident faces deleted. Resulting isolated vertices are marked deleted if _delete_isolated_vertices is true. Items marked deleted will be removed by garbageCollection(). \attention Needs the Attributes::Status attribute for vertices, edges and faces. */ void delete_edge(EdgeHandle _eh, bool _delete_isolated_vertices=true); /** Delete face _fh and resulting degenerated empty halfedges as well. Resultling isolated vertices will be deleted if _delete_isolated_vertices is true. \attention All item will only be marked to be deleted. They will actually be removed by calling garbage_collection(). \attention Needs the Attributes::Status attribute for vertices, edges and faces. */ void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true); //@} // --- iterators begin() and end() --- /** \name Begin and end iterators */ //@{ /// Begin iterator for vertices VertexIter vertices_begin() { return VertexIter(*this, VertexHandle(0)); } /// Const begin iterator for vertices ConstVertexIter vertices_begin() const { return ConstVertexIter(*this, VertexHandle(0)); } /// End iterator for vertices VertexIter vertices_end() { return VertexIter(*this, VertexHandle(This::n_vertices())); } /// Const end iterator for vertices ConstVertexIter vertices_end() const { return ConstVertexIter(*this, VertexHandle(This::n_vertices())); } /// Begin iterator for halfedges HalfedgeIter halfedges_begin() { return HalfedgeIter(*this, HalfedgeHandle(0)); } /// Const begin iterator for halfedges ConstHalfedgeIter halfedges_begin() const { return ConstHalfedgeIter(*this, HalfedgeHandle(0)); } /// End iterator for halfedges HalfedgeIter halfedges_end() { return HalfedgeIter(*this, HalfedgeHandle(This::n_halfedges())); } /// Const end iterator for halfedges ConstHalfedgeIter halfedges_end() const { return ConstHalfedgeIter(*this, HalfedgeHandle(This::n_halfedges())); } /// Begin iterator for edges EdgeIter edges_begin() { return EdgeIter(*this, EdgeHandle(0)); } /// Const begin iterator for edges ConstEdgeIter edges_begin() const { return ConstEdgeIter(*this, EdgeHandle(0)); } /// End iterator for edges EdgeIter edges_end() { return EdgeIter(*this, EdgeHandle(This::n_edges())); } /// Const end iterator for edges ConstEdgeIter edges_end() const { return ConstEdgeIter(*this, EdgeHandle(This::n_edges())); } /// Begin iterator for faces FaceIter faces_begin() { return FaceIter(*this, FaceHandle(0)); } /// Const begin iterator for faces ConstFaceIter faces_begin() const { return ConstFaceIter(*this, FaceHandle(0)); } /// End iterator for faces FaceIter faces_end() { return FaceIter(*this, FaceHandle(This::n_faces())); } /// Const end iterator for faces ConstFaceIter faces_end() const { return ConstFaceIter(*this, FaceHandle(This::n_faces())); } //@} /** \name Begin for skipping iterators */ //@{ /// Begin iterator for vertices VertexIter vertices_sbegin() { return VertexIter(*this, VertexHandle(0), true); } /// Const begin iterator for vertices ConstVertexIter vertices_sbegin() const { return ConstVertexIter(*this, VertexHandle(0), true); } /// Begin iterator for halfedges HalfedgeIter halfedges_sbegin() { return HalfedgeIter(*this, HalfedgeHandle(0), true); } /// Const begin iterator for halfedges ConstHalfedgeIter halfedges_sbegin() const { return ConstHalfedgeIter(*this, HalfedgeHandle(0), true); } /// Begin iterator for edges EdgeIter edges_sbegin()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -