Point Cloud Library (PCL)  1.11.1-dev
polygon_mesh.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #pragma once
42 
43 #include <pcl/memory.h>
44 #include <pcl/pcl_macros.h>
45 #include <pcl/geometry/mesh_base.h>
46 
47 namespace pcl
48 {
49  namespace geometry
50  {
51  /** \brief Tag describing the type of the mesh. */
52  struct PolygonMeshTag {};
53 
54  /** \brief General half-edge mesh that can store any polygon with a minimum number of vertices of 3.
55  * \tparam MeshTraitsT Please have a look at pcl::geometry::DefaultMeshTraits.
56  * \author Martin Saelzle
57  * \ingroup geometry
58  */
59  template <class MeshTraitsT>
60  class PolygonMesh : public pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, PolygonMeshTag>
61  {
62  public:
63 
65 
67  using Ptr = shared_ptr<Self>;
68  using ConstPtr = shared_ptr<const Self>;
69 
70  using VertexData = typename Base::VertexData;
71  using HalfEdgeData = typename Base::HalfEdgeData;
72  using EdgeData = typename Base::EdgeData;
73  using FaceData = typename Base::FaceData;
74  using IsManifold = typename Base::IsManifold;
75  using MeshTag = typename Base::MeshTag;
76 
79  using HasEdgeData = typename Base::HasEdgeData;
80  using HasFaceData = typename Base::HasFaceData;
81 
86 
87  // Indices
88  using VertexIndex = typename Base::VertexIndex;
90  using EdgeIndex = typename Base::EdgeIndex;
91  using FaceIndex = typename Base::FaceIndex;
92 
95  using EdgeIndices = typename Base::EdgeIndices;
96  using FaceIndices = typename Base::FaceIndices;
97 
98  // Circulators
107 
108  /** \brief Constructor. */
110  : Base (),
111  add_triangle_ (3),
112  add_quad_ (4)
113  {
114  }
115 
116  /** \brief The base method of addFace is hidden because of the overloads in this class. */
117  using Base::addFace;
118 
119  /** \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.
120  * \param[in] idx_v_0 Index to the first vertex.
121  * \param[in] idx_v_1 Index to the second vertex.
122  * \param[in] idx_v_2 Index to the third vertex.
123  * \param[in] face_data Data that is set for the face.
124  * \param[in] half_edge_data Data that is set for all added half-edges.
125  * \param[in] edge_data Data that is set for all added edges.
126  * \return Index to the new face. Failure is signaled by returning an invalid face index.
127  * \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior!
128  */
129  inline FaceIndex
130  addFace (const VertexIndex& idx_v_0,
131  const VertexIndex& idx_v_1,
132  const VertexIndex& idx_v_2,
133  const FaceData& face_data = FaceData (),
134  const EdgeData& edge_data = EdgeData (),
135  const HalfEdgeData& half_edge_data = HalfEdgeData ())
136  {
137  add_triangle_ [0] = idx_v_0;
138  add_triangle_ [1] = idx_v_1;
139  add_triangle_ [2] = idx_v_2;
140 
141  return (this->addFaceImplBase (add_triangle_, face_data, edge_data, half_edge_data));
142  }
143 
144  /** \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.
145  * \param[in] idx_v_0 Index to the first vertex.
146  * \param[in] idx_v_1 Index to the second vertex.
147  * \param[in] idx_v_2 Index to the third vertex.
148  * \param[in] idx_v_3 Index to the fourth vertex.
149  * \param[in] face_data Data that is set for the face.
150  * \param[in] half_edge_data Data that is set for all added half-edges.
151  * \param[in] edge_data Data that is set for all added edges.
152  * \return Index to the new face. Failure is signaled by returning an invalid face index.
153  * \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior!
154  */
155  inline FaceIndex
156  addFace (const VertexIndex& idx_v_0,
157  const VertexIndex& idx_v_1,
158  const VertexIndex& idx_v_2,
159  const VertexIndex& idx_v_3,
160  const FaceData& face_data = FaceData (),
161  const EdgeData& edge_data = EdgeData (),
162  const HalfEdgeData& half_edge_data = HalfEdgeData ())
163  {
164  add_quad_ [0] = idx_v_0;
165  add_quad_ [1] = idx_v_1;
166  add_quad_ [2] = idx_v_2;
167  add_quad_ [3] = idx_v_3;
168 
169  return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data));
170  }
171 
172  private:
173 
174  // NOTE: Can't use the typedef of Base as a friend.
175  friend class pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::PolygonMeshTag>;
176 
177  /** \brief addFace for the polygon mesh. */
178  inline FaceIndex
179  addFaceImpl (const VertexIndices& vertices,
180  const FaceData& face_data,
181  const EdgeData& edge_data,
182  const HalfEdgeData& half_edge_data)
183  {
184  return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data));
185  }
186 
187  ////////////////////////////////////////////////////////////////////////
188  // Members
189  ////////////////////////////////////////////////////////////////////////
190 
191  /** \brief Storage for adding a triangle. */
192  VertexIndices add_triangle_;
193 
194  /** \brief Storage for adding a quad. */
195  VertexIndices add_quad_;
196 
197  public:
199  };
200  } // End namespace geom
201 } // End namespace pcl
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceIndex
pcl::geometry::FaceIndex FaceIndex
Definition: mesh_base.h:135
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::IncomingHalfEdgeAroundVertexCirculator
pcl::geometry::IncomingHalfEdgeAroundVertexCirculator< const Self > IncomingHalfEdgeAroundVertexCirculator
Definition: mesh_base.h:145
pcl
Definition: convolution.h:46
pcl::geometry::PolygonMesh::FaceDataCloud
typename Base::FaceDataCloud FaceDataCloud
Definition: polygon_mesh.h:85
pcl::geometry::PolygonMesh::HalfEdgeIndices
typename Base::HalfEdgeIndices HalfEdgeIndices
Definition: polygon_mesh.h:94
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexIndex
pcl::geometry::VertexIndex VertexIndex
Definition: mesh_base.h:132
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceAroundFaceCirculator
pcl::geometry::FaceAroundFaceCirculator< const Self > FaceAroundFaceCirculator
Definition: mesh_base.h:150
pcl::geometry::PolygonMesh::MeshTag
typename Base::MeshTag MeshTag
Definition: polygon_mesh.h:75
pcl::geometry::PolygonMesh::IsManifold
typename Base::IsManifold IsManifold
Definition: polygon_mesh.h:74
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeIndices
std::vector< EdgeIndex > EdgeIndices
Definition: mesh_base.h:139
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::OuterHalfEdgeAroundFaceCirculator
pcl::geometry::OuterHalfEdgeAroundFaceCirculator< const Self > OuterHalfEdgeAroundFaceCirculator
Definition: mesh_base.h:149
pcl::geometry::PolygonMesh::VertexAroundVertexCirculator
typename Base::VertexAroundVertexCirculator VertexAroundVertexCirculator
Definition: polygon_mesh.h:99
pcl::geometry::PolygonMesh::VertexIndex
typename Base::VertexIndex VertexIndex
Definition: polygon_mesh.h:88
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexDataCloud
pcl::PointCloud< VertexData > VertexDataCloud
Definition: mesh_base.h:126
pcl::geometry::PolygonMesh::HasHalfEdgeData
typename Base::HasHalfEdgeData HasHalfEdgeData
Definition: polygon_mesh.h:78
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexData
typename MeshTraitsT::VertexData VertexData
Definition: mesh_base.h:109
pcl::geometry::PolygonMesh::HalfEdgeIndex
typename Base::HalfEdgeIndex HalfEdgeIndex
Definition: polygon_mesh.h:89
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::IsManifold
typename MeshTraitsT::IsManifold IsManifold
Definition: mesh_base.h:113
pcl::geometry::PolygonMesh
General half-edge mesh that can store any polygon with a minimum number of vertices of 3.
Definition: polygon_mesh.h:60
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexAroundFaceCirculator
pcl::geometry::VertexAroundFaceCirculator< const Self > VertexAroundFaceCirculator
Definition: mesh_base.h:147
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::MeshTag
PolygonMeshTag MeshTag
Definition: mesh_base.h:118
pcl::geometry::PolygonMesh::HalfEdgeDataCloud
typename Base::HalfEdgeDataCloud HalfEdgeDataCloud
Definition: polygon_mesh.h:83
pcl::geometry::PolygonMesh::VertexAroundFaceCirculator
typename Base::VertexAroundFaceCirculator VertexAroundFaceCirculator
Definition: polygon_mesh.h:103
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceData
typename MeshTraitsT::FaceData FaceData
Definition: mesh_base.h:112
pcl::geometry::PolygonMesh::EdgeDataCloud
typename Base::EdgeDataCloud EdgeDataCloud
Definition: polygon_mesh.h:84
pcl::geometry::PolygonMesh::ConstPtr
shared_ptr< const Self > ConstPtr
Definition: polygon_mesh.h:68
pcl::geometry::PolygonMesh::IncomingHalfEdgeAroundVertexCirculator
typename Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator
Definition: polygon_mesh.h:101
pcl::geometry::PolygonMesh::HalfEdgeData
typename Base::HalfEdgeData HalfEdgeData
Definition: polygon_mesh.h:71
pcl::geometry::PolygonMesh::Ptr
shared_ptr< Self > Ptr
Definition: polygon_mesh.h:67
pcl::geometry::PolygonMesh::EdgeData
typename Base::EdgeData EdgeData
Definition: polygon_mesh.h:72
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeData
typename MeshTraitsT::HalfEdgeData HalfEdgeData
Definition: mesh_base.h:110
pcl::geometry::PolygonMesh::VertexData
typename Base::VertexData VertexData
Definition: polygon_mesh.h:70
pcl::geometry::PolygonMesh::EdgeIndex
typename Base::EdgeIndex EdgeIndex
Definition: polygon_mesh.h:90
pcl::geometry::PolygonMesh::OutgoingHalfEdgeAroundVertexCirculator
typename Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator
Definition: polygon_mesh.h:100
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeIndices
std::vector< HalfEdgeIndex > HalfEdgeIndices
Definition: mesh_base.h:138
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::addFaceImplBase
FaceIndex addFaceImplBase(const VertexIndices &vertices, const FaceData &face_data, const EdgeData &edge_data, const HalfEdgeData &half_edge_data)
General implementation of addFace.
Definition: mesh_base.h:1107
pcl::geometry::PolygonMesh::OuterHalfEdgeAroundFaceCirculator
typename Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator
Definition: polygon_mesh.h:105
pcl::geometry::PolygonMesh::FaceIndices
typename Base::FaceIndices FaceIndices
Definition: polygon_mesh.h:96
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeIndex
pcl::geometry::EdgeIndex EdgeIndex
Definition: mesh_base.h:134
pcl::geometry::PolygonMesh::PolygonMesh
PolygonMesh()
Constructor.
Definition: polygon_mesh.h:109
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexAroundVertexCirculator
pcl::geometry::VertexAroundVertexCirculator< const Self > VertexAroundVertexCirculator
Definition: mesh_base.h:143
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceDataCloud
pcl::PointCloud< FaceData > FaceDataCloud
Definition: mesh_base.h:129
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:63
pcl::geometry::PolygonMesh::HasEdgeData
typename Base::HasEdgeData HasEdgeData
Definition: polygon_mesh.h:79
pcl::geometry::PolygonMesh::FaceAroundVertexCirculator
typename Base::FaceAroundVertexCirculator FaceAroundVertexCirculator
Definition: polygon_mesh.h:102
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasFaceData
std::integral_constant< bool, !std::is_same< FaceData, pcl::geometry::NoData >::value > HasFaceData
Definition: mesh_base.h:124
pcl::geometry::PolygonMesh::VertexIndices
typename Base::VertexIndices VertexIndices
Definition: polygon_mesh.h:93
pcl::geometry::PolygonMesh::VertexDataCloud
typename Base::VertexDataCloud VertexDataCloud
Definition: polygon_mesh.h:82
pcl::geometry::PolygonMesh::HasVertexData
typename Base::HasVertexData HasVertexData
Definition: polygon_mesh.h:77
pcl::geometry::PolygonMesh::EdgeIndices
typename Base::EdgeIndices EdgeIndices
Definition: polygon_mesh.h:95
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceAroundVertexCirculator
pcl::geometry::FaceAroundVertexCirculator< const Self > FaceAroundVertexCirculator
Definition: mesh_base.h:146
pcl::geometry::PolygonMeshTag
Tag describing the type of the mesh.
Definition: polygon_mesh.h:52
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeDataCloud
pcl::PointCloud< HalfEdgeData > HalfEdgeDataCloud
Definition: mesh_base.h:127
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeData
typename MeshTraitsT::EdgeData EdgeData
Definition: mesh_base.h:111
pcl::geometry::PolygonMesh::FaceIndex
typename Base::FaceIndex FaceIndex
Definition: polygon_mesh.h:91
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasVertexData
std::integral_constant< bool, !std::is_same< VertexData, pcl::geometry::NoData >::value > HasVertexData
Definition: mesh_base.h:121
pcl::geometry::FaceIndex
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:478
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeDataCloud
pcl::PointCloud< EdgeData > EdgeDataCloud
Definition: mesh_base.h:128
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::OutgoingHalfEdgeAroundVertexCirculator
pcl::geometry::OutgoingHalfEdgeAroundVertexCirculator< const Self > OutgoingHalfEdgeAroundVertexCirculator
Definition: mesh_base.h:144
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasHalfEdgeData
std::integral_constant< bool, !std::is_same< HalfEdgeData, pcl::geometry::NoData >::value > HasHalfEdgeData
Definition: mesh_base.h:122
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceIndices
std::vector< FaceIndex > FaceIndices
Definition: mesh_base.h:140
pcl::geometry::PolygonMesh::addFace
FaceIndex addFace(const VertexIndex &idx_v_0, const VertexIndex &idx_v_1, const VertexIndex &idx_v_2, const VertexIndex &idx_v_3, const FaceData &face_data=FaceData(), const EdgeData &edge_data=EdgeData(), const HalfEdgeData &half_edge_data=HalfEdgeData())
Add a quad to the mesh.
Definition: polygon_mesh.h:156
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasEdgeData
std::integral_constant< bool, !std::is_same< EdgeData, pcl::geometry::NoData >::value > HasEdgeData
Definition: mesh_base.h:123
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::addFace
FaceIndex addFace(const VertexIndices &vertices, const FaceData &face_data=FaceData(), const EdgeData &edge_data=EdgeData(), const HalfEdgeData &half_edge_data=HalfEdgeData())
Add a face to the mesh.
Definition: mesh_base.h:186
pcl::geometry::PolygonMesh::InnerHalfEdgeAroundFaceCirculator
typename Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator
Definition: polygon_mesh.h:104
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeIndex
pcl::geometry::HalfEdgeIndex HalfEdgeIndex
Definition: mesh_base.h:133
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::InnerHalfEdgeAroundFaceCirculator
pcl::geometry::InnerHalfEdgeAroundFaceCirculator< const Self > InnerHalfEdgeAroundFaceCirculator
Definition: mesh_base.h:148
pcl::geometry::PolygonMesh::FaceData
typename Base::FaceData FaceData
Definition: polygon_mesh.h:73
pcl::geometry::PolygonMesh::FaceAroundFaceCirculator
typename Base::FaceAroundFaceCirculator FaceAroundFaceCirculator
Definition: polygon_mesh.h:106
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl::geometry::PolygonMesh::addFace
FaceIndex addFace(const VertexIndex &idx_v_0, const VertexIndex &idx_v_1, const VertexIndex &idx_v_2, const FaceData &face_data=FaceData(), const EdgeData &edge_data=EdgeData(), const HalfEdgeData &half_edge_data=HalfEdgeData())
Add a triangle to the mesh.
Definition: polygon_mesh.h:130
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexIndices
std::vector< VertexIndex > VertexIndices
Definition: mesh_base.h:137
pcl::geometry::PolygonMesh::HasFaceData
typename Base::HasFaceData HasFaceData
Definition: polygon_mesh.h:80
pcl::geometry::MeshBase
Base class for the half-edge mesh.
Definition: mesh_base.h:98