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_POLYGON_MESH_H 00042 #define PCL_GEOMETRY_POLYGON_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 PolygonMeshTag {}; 00052 00053 /** \brief General half-edge mesh that can store any polygon with a minimum number of vertices of 3. 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 PolygonMesh : public pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, PolygonMeshTag> 00060 { 00061 public: 00062 00063 typedef pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, PolygonMeshTag> Base; 00064 00065 typedef PolygonMesh <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 PolygonMesh () 00109 : Base (), 00110 add_triangle_ (3), 00111 add_quad_ (4) 00112 { 00113 } 00114 00115 /** \brief The base method of addFace is hidden because of the overloads in this class. */ 00116 using Base::addFace; 00117 00118 /** \brief Add a triangle to the mesh. Data is only added if it is associated with the elements. The last vertex is connected with the first one. 00119 * \param[in] idx_v_0 Index to the first vertex. 00120 * \param[in] idx_v_1 Index to the second vertex. 00121 * \param[in] idx_v_2 Index to the third 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 FaceData& face_data = FaceData (), 00133 const EdgeData& edge_data = EdgeData (), 00134 const HalfEdgeData& half_edge_data = HalfEdgeData ()) 00135 { 00136 add_triangle_ [0] = idx_v_0; 00137 add_triangle_ [1] = idx_v_1; 00138 add_triangle_ [2] = idx_v_2; 00139 00140 return (this->addFaceImplBase (add_triangle_, face_data, edge_data, half_edge_data)); 00141 } 00142 00143 /** \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. 00144 * \param[in] idx_v_0 Index to the first vertex. 00145 * \param[in] idx_v_1 Index to the second vertex. 00146 * \param[in] idx_v_2 Index to the third vertex. 00147 * \param[in] idx_v_3 Index to the fourth vertex. 00148 * \param[in] face_data Data that is set for the face. 00149 * \param[in] half_edge_data Data that is set for all added half-edges. 00150 * \param[in] edge_data Data that is set for all added edges. 00151 * \return Index to the new face. Failure is signaled by returning an invalid face index. 00152 * \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior! 00153 */ 00154 inline FaceIndex 00155 addFace (const VertexIndex& idx_v_0, 00156 const VertexIndex& idx_v_1, 00157 const VertexIndex& idx_v_2, 00158 const VertexIndex& idx_v_3, 00159 const FaceData& face_data = FaceData (), 00160 const EdgeData& edge_data = EdgeData (), 00161 const HalfEdgeData& half_edge_data = HalfEdgeData ()) 00162 { 00163 add_quad_ [0] = idx_v_0; 00164 add_quad_ [1] = idx_v_1; 00165 add_quad_ [2] = idx_v_2; 00166 add_quad_ [3] = idx_v_3; 00167 00168 return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data)); 00169 } 00170 00171 private: 00172 00173 // NOTE: Can't use the typedef of Base as a friend. 00174 friend class pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::PolygonMeshTag>; 00175 00176 /** \brief addFace for the polygon mesh. */ 00177 inline FaceIndex 00178 addFaceImpl (const VertexIndices& vertices, 00179 const FaceData& face_data, 00180 const EdgeData& edge_data, 00181 const HalfEdgeData& half_edge_data) 00182 { 00183 return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data)); 00184 } 00185 00186 //////////////////////////////////////////////////////////////////////// 00187 // Members 00188 //////////////////////////////////////////////////////////////////////// 00189 00190 /** \brief Storage for adding a triangle. */ 00191 VertexIndices add_triangle_; 00192 00193 /** \brief Storage for adding a quad. */ 00194 VertexIndices add_quad_; 00195 00196 public: 00197 00198 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00199 }; 00200 } // End namespace geom 00201 } // End namespace pcl 00202 00203 #endif // PCL_GEOMETRY_POLYGON_MESH_H