📄 attribkernelt.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. * * *\*===========================================================================*/#ifndef OPENMESH_ATTRIBKERNEL_HH#define OPENMESH_ATTRIBKERNEL_HH//== INCLUDES =================================================================#include <OpenMesh/Core/Attributes/Attributes.hh>#include <OpenMesh/Core/Mesh/Kernels/Common/BaseKernel.hh>#include <OpenMesh/Core/Utils/GenProg.hh>#include <OpenMesh/Core/Utils/vector_traits.hh>#include <vector>#include <algorithm>//== NAMESPACES ===============================================================namespace OpenMesh {//== CLASS DEFINITION =========================================================/// This class adds the standard properties to the mesh type.////// The attribute kernel adds all standard properties to the kernel. Therefore/// the functions/types defined here provide a subset of the kernel/// interface as described in Concepts::KernelT.////// \see Concepts::KernelTtemplate <class MeshItems>class AttribKernelT : public BaseKernel{public: //---------------------------------------------------------------- item types typedef typename MeshItems::Vertex Vertex; typedef typename MeshItems::Halfedge Halfedge; typedef typename MeshItems::Edge Edge; typedef typename MeshItems::Face Face; typedef typename MeshItems::Point Point; typedef typename MeshItems::Normal Normal; typedef typename MeshItems::Color Color; typedef typename MeshItems::TexCoord1D TexCoord1D; typedef typename MeshItems::TexCoord2D TexCoord2D; typedef typename MeshItems::TexCoord3D TexCoord3D; typedef typename MeshItems::Scalar Scalar; typedef Attributes::StatusInfo StatusInfo; typedef AttribKernelT<MeshItems> AttribKernel; enum Attribs { VAttribs = MeshItems::VAttribs, HAttribs = MeshItems::HAttribs, EAttribs = MeshItems::EAttribs, FAttribs = MeshItems::FAttribs, }; typedef GenProg::Bool2Type<(bool)(HAttribs & Attributes::PrevHalfedge)> HasPrevHalfedge;public: //-------------------------------------------------- constructor / destructor AttribKernelT() : refcount_vnormals_(0), refcount_vcolors_(0), refcount_vtexcoords1D_(0), refcount_vtexcoords2D_(0), refcount_vtexcoords3D_(0), refcount_vstatus_(0), refcount_hstatus_(0), refcount_estatus_(0), refcount_fnormals_(0), refcount_fcolors_(0), refcount_fstatus_(0) { add_property( points_, "v:points" ); if (VAttribs & Attributes::Normal) request_vertex_normals(); if (VAttribs & Attributes::Color) request_vertex_colors(); if (VAttribs & Attributes::TexCoord1D) request_vertex_texcoords1D(); if (VAttribs & Attributes::TexCoord2D) request_vertex_texcoords2D(); if (VAttribs & Attributes::TexCoord3D) request_vertex_texcoords3D(); if (VAttribs & Attributes::Status) request_vertex_status(); if (HAttribs & Attributes::Status) request_halfedge_status(); if (EAttribs & Attributes::Status) request_edge_status(); if (FAttribs & Attributes::Normal) request_face_normals(); if (FAttribs & Attributes::Color) request_face_colors(); if (FAttribs & Attributes::Status) request_face_status(); } ~AttribKernelT() { // should remove properties, but this will be done in // BaseKernel's destructor anyway... } // -------------------------------------------------------- copy & assignment AttribKernelT(const AttribKernelT& _rhs) : BaseKernel(_rhs) { operator=(_rhs); } AttribKernelT& operator=(const AttribKernelT& _rhs) { if (this!=&_rhs) { // remove old properties remove_property(points_); remove_property(vertex_normals_); remove_property(vertex_colors_); remove_property(vertex_texcoords1D_); remove_property(vertex_texcoords2D_); remove_property(vertex_texcoords3D_); remove_property(vertex_status_); remove_property(halfedge_status_); remove_property(edge_status_); remove_property(face_normals_); remove_property(face_colors_); remove_property(face_status_); // parent deep-copies properties BaseKernel::operator=(_rhs); // copy property handles points_ = _rhs.points_; vertex_normals_ = _rhs.vertex_normals_; vertex_colors_ = _rhs.vertex_colors_; vertex_texcoords1D_ = _rhs.vertex_texcoords1D_; vertex_texcoords2D_ = _rhs.vertex_texcoords2D_; vertex_texcoords3D_ = _rhs.vertex_texcoords3D_; vertex_status_ = _rhs.vertex_status_; halfedge_status_ = _rhs.halfedge_status_; edge_status_ = _rhs.edge_status_; face_normals_ = _rhs.face_normals_; face_colors_ = _rhs.face_colors_; face_status_ = _rhs.face_status_; // copy ref-counts refcount_vnormals_ = _rhs.refcount_vnormals_; refcount_vcolors_ = _rhs.refcount_vcolors_; refcount_vtexcoords1D_ = _rhs.refcount_vtexcoords1D_; refcount_vtexcoords2D_ = _rhs.refcount_vtexcoords2D_; refcount_vtexcoords3D_ = _rhs.refcount_vtexcoords3D_; refcount_vstatus_ = _rhs.refcount_vstatus_; refcount_hstatus_ = _rhs.refcount_hstatus_; refcount_estatus_ = _rhs.refcount_estatus_; refcount_fnormals_ = _rhs.refcount_fnormals_; refcount_fcolors_ = _rhs.refcount_fcolors_; refcount_fstatus_ = _rhs.refcount_fstatus_; } return *this; } //-------------------------------------------------------------------- points const Point* points() const { return property(points_).data(); } const Point& point(VertexHandle _vh) const { return property(points_, _vh); } Point& point(VertexHandle _vh) { return property(points_, _vh); } void set_point(VertexHandle _vh, const Point& _p) { property(points_, _vh) = _p; } //------------------------------------------------------------ vertex normals const Normal* vertex_normals() const { return property(vertex_normals_).data(); } const Normal& normal(VertexHandle _vh) const { return property(vertex_normals_, _vh); } void set_normal(VertexHandle _vh, const Normal& _n) { property(vertex_normals_, _vh) = _n; } //------------------------------------------------------------- vertex colors const Color* vertex_colors() const { return property(vertex_colors_).data(); } const Color& color(VertexHandle _vh) const { return property(vertex_colors_, _vh); } void set_color(VertexHandle _vh, const Color& _c) { property(vertex_colors_, _vh) = _c; } //------------------------------------------------------- vertex 1D texcoords const TexCoord1D* texcoords1D() const { return property(vertex_texcoords1D_).data(); } const TexCoord1D& texcoord1D(VertexHandle _vh) const { return property(vertex_texcoords1D_, _vh); } void set_texcoord1D(VertexHandle _vh, const TexCoord1D& _t) { property(vertex_texcoords1D_, _vh) = _t; } //------------------------------------------------------- vertex 2D texcoords const TexCoord2D* texcoords2D() const { return property(vertex_texcoords2D_).data(); } const TexCoord2D& texcoord2D(VertexHandle _vh) const { return property(vertex_texcoords2D_, _vh); } void set_texcoord2D(VertexHandle _vh, const TexCoord2D& _t) { property(vertex_texcoords2D_, _vh) = _t; } //------------------------------------------------------- vertex 3D texcoords const TexCoord3D* texcoords3D() const { return property(vertex_texcoords3D_).data(); } const TexCoord3D& texcoord3D(VertexHandle _vh) const { return property(vertex_texcoords3D_, _vh); } void set_texcoord3D(VertexHandle _vh, const TexCoord3D& _t) { property(vertex_texcoords3D_, _vh) = _t; } //------------------------------------------------------------ vertex status const StatusInfo& status(VertexHandle _vh) const { return property(vertex_status_, _vh); } StatusInfo& status(VertexHandle _vh) { return property(vertex_status_, _vh); } //----------------------------------------------------------- halfedge status
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -