Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2009-2012, Willow Garage, Inc. 00006 * Copyright (c) 2012-, Open Perception, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * * Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * * Redistributions in binary form must reproduce the above 00017 * copyright notice, this list of conditions and the following 00018 * disclaimer in the documentation and/or other materials provided 00019 * with the distribution. 00020 * * Neither the name of the copyright holder(s) nor the names of its 00021 * contributors may be used to endorse or promote products derived 00022 * from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00027 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00028 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00030 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00034 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 * $Id$ 00038 * 00039 */ 00040 00041 #ifndef PCL_GEOMETRY_QUAD_MESH_H 00042 #define PCL_GEOMETRY_QUAD_MESH_H 00043 00044 #include <pcl/geometry/mesh_base.h> 00045 00046 namespace pcl 00047 { 00048 namespace geometry 00049 { 00050 /** \brief Tag describing the type of the mesh. */ 00051 struct QuadMeshTag {}; 00052 00053 /** \brief Half-edge mesh that can only store quads. 00054 * \tparam MeshTraitsT Please have a look at pcl::geometry::DefaultMeshTraits. 00055 * \author Martin Saelzle 00056 * \ingroup geometry 00057 */ 00058 template <class MeshTraitsT> 00059 class QuadMesh : public pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, QuadMeshTag> 00060 { 00061 public: 00062 00063 typedef pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, QuadMeshTag> Base; 00064 00065 typedef QuadMesh <MeshTraitsT> Self; 00066 typedef boost::shared_ptr <Self> Ptr; 00067 typedef boost::shared_ptr <const Self> ConstPtr; 00068 00069 typedef typename Base::VertexData VertexData; 00070 typedef typename Base::HalfEdgeData HalfEdgeData; 00071 typedef typename Base::EdgeData EdgeData; 00072 typedef typename Base::FaceData FaceData; 00073 typedef typename Base::IsManifold IsManifold; 00074 typedef typename Base::MeshTag MeshTag; 00075 00076 typedef typename Base::HasVertexData HasVertexData; 00077 typedef typename Base::HasHalfEdgeData HasHalfEdgeData; 00078 typedef typename Base::HasEdgeData HasEdgeData; 00079 typedef typename Base::HasFaceData HasFaceData; 00080 00081 typedef typename Base::VertexDataCloud VertexDataCloud; 00082 typedef typename Base::HalfEdgeDataCloud HalfEdgeDataCloud; 00083 typedef typename Base::EdgeDataCloud EdgeDataCloud; 00084 typedef typename Base::FaceDataCloud FaceDataCloud; 00085 00086 // Indices 00087 typedef typename Base::VertexIndex VertexIndex; 00088 typedef typename Base::HalfEdgeIndex HalfEdgeIndex; 00089 typedef typename Base::EdgeIndex EdgeIndex; 00090 typedef typename Base::FaceIndex FaceIndex; 00091 00092 typedef typename Base::VertexIndices VertexIndices; 00093 typedef typename Base::HalfEdgeIndices HalfEdgeIndices; 00094 typedef typename Base::EdgeIndices EdgeIndices; 00095 typedef typename Base::FaceIndices FaceIndices; 00096 00097 // Circulators 00098 typedef typename Base::VertexAroundVertexCirculator VertexAroundVertexCirculator; 00099 typedef typename Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator; 00100 typedef typename Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator; 00101 typedef typename Base::FaceAroundVertexCirculator FaceAroundVertexCirculator; 00102 typedef typename Base::VertexAroundFaceCirculator VertexAroundFaceCirculator; 00103 typedef typename Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator; 00104 typedef typename Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator; 00105 typedef typename Base::FaceAroundFaceCirculator FaceAroundFaceCirculator; 00106 00107 /** \brief Constructor. */ 00108 QuadMesh () 00109 : Base (), 00110 add_quad_ (4) 00111 { 00112 } 00113 00114 /** \brief The base method of addFace is hidden because of the overloads in this class. */ 00115 using Base::addFace; 00116 00117 /** \brief Add a quad to the mesh. Data is only added if it is associated with the elements. The last vertex is connected with the first one. 00118 * \param[in] idx_v_0 Index to the first vertex. 00119 * \param[in] idx_v_1 Index to the second vertex. 00120 * \param[in] idx_v_2 Index to the third vertex. 00121 * \param[in] idx_v_3 Index to the fourth vertex. 00122 * \param[in] face_data Data that is set for the face. 00123 * \param[in] half_edge_data Data that is set for all added half-edges. 00124 * \param[in] edge_data Data that is set for all added edges. 00125 * \return Index to the new face. Failure is signaled by returning an invalid face index. 00126 * \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior! 00127 */ 00128 inline FaceIndex 00129 addFace (const VertexIndex& idx_v_0, 00130 const VertexIndex& idx_v_1, 00131 const VertexIndex& idx_v_2, 00132 const VertexIndex& idx_v_3, 00133 const FaceData& face_data = FaceData (), 00134 const EdgeData& edge_data = EdgeData (), 00135 const HalfEdgeData& half_edge_data = HalfEdgeData ()) 00136 { 00137 add_quad_ [0] = idx_v_0; 00138 add_quad_ [1] = idx_v_1; 00139 add_quad_ [2] = idx_v_2; 00140 add_quad_ [3] = idx_v_3; 00141 00142 return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data)); 00143 } 00144 00145 private: 00146 00147 // NOTE: Can't use the typedef of Base as a friend. 00148 friend class pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::QuadMeshTag>; 00149 00150 /** \brief addFace for the quad mesh. */ 00151 inline FaceIndex 00152 addFaceImpl (const VertexIndices& vertices, 00153 const FaceData& face_data, 00154 const EdgeData& edge_data, 00155 const HalfEdgeData& half_edge_data) 00156 { 00157 if (vertices.size () == 4) 00158 return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data)); 00159 else 00160 return (FaceIndex ()); 00161 } 00162 00163 //////////////////////////////////////////////////////////////////////// 00164 // Members 00165 //////////////////////////////////////////////////////////////////////// 00166 00167 /** \brief Storage for adding a quad. */ 00168 VertexIndices add_quad_; 00169 00170 public: 00171 00172 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00173 }; 00174 } // End namespace geom 00175 } // End namespace pcl 00176 00177 #endif // PCL_GEOMETRY_QUAD_MESH_H