Point Cloud Library (PCL)  1.7.0
quad_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 #ifndef PCL_GEOMETRY_QUAD_MESH_H
42 #define PCL_GEOMETRY_QUAD_MESH_H
43 
44 #include <pcl/geometry/mesh_base.h>
45 
46 namespace pcl
47 {
48  namespace geometry
49  {
50  /** \brief Tag describing the type of the mesh. */
51  struct QuadMeshTag {};
52 
53  /** \brief Half-edge mesh that can only store quads.
54  * \tparam MeshTraitsT Please have a look at pcl::geometry::DefaultMeshTraits.
55  * \author Martin Saelzle
56  * \ingroup geometry
57  */
58  template <class MeshTraitsT>
59  class QuadMesh : public pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, QuadMeshTag>
60  {
61  public:
62 
64 
66  typedef boost::shared_ptr <Self> Ptr;
67  typedef boost::shared_ptr <const Self> ConstPtr;
68 
69  typedef typename Base::VertexData VertexData;
70  typedef typename Base::HalfEdgeData HalfEdgeData;
71  typedef typename Base::EdgeData EdgeData;
72  typedef typename Base::FaceData FaceData;
73  typedef typename Base::IsManifold IsManifold;
74  typedef typename Base::MeshTag MeshTag;
75 
78  typedef typename Base::HasEdgeData HasEdgeData;
79  typedef typename Base::HasFaceData HasFaceData;
80 
85 
86  // Indices
87  typedef typename Base::VertexIndex VertexIndex;
89  typedef typename Base::EdgeIndex EdgeIndex;
90  typedef typename Base::FaceIndex FaceIndex;
91 
94  typedef typename Base::EdgeIndices EdgeIndices;
95  typedef typename Base::FaceIndices FaceIndices;
96 
97  // Circulators
106 
107  /** \brief Constructor. */
109  : Base (),
110  add_quad_ (4)
111  {
112  }
113 
114  /** \brief The base method of addFace is hidden because of the overloads in this class. */
115  using Base::addFace;
116 
117  /** \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.
118  * \param[in] idx_v_0 Index to the first vertex.
119  * \param[in] idx_v_1 Index to the second vertex.
120  * \param[in] idx_v_2 Index to the third vertex.
121  * \param[in] idx_v_3 Index to the fourth vertex.
122  * \param[in] face_data Data that is set for the face.
123  * \param[in] half_edge_data Data that is set for all added half-edges.
124  * \param[in] edge_data Data that is set for all added edges.
125  * \return Index to the new face. Failure is signaled by returning an invalid face index.
126  * \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior!
127  */
128  inline FaceIndex
129  addFace (const VertexIndex& idx_v_0,
130  const VertexIndex& idx_v_1,
131  const VertexIndex& idx_v_2,
132  const VertexIndex& idx_v_3,
133  const FaceData& face_data = FaceData (),
134  const EdgeData& edge_data = EdgeData (),
135  const HalfEdgeData& half_edge_data = HalfEdgeData ())
136  {
137  add_quad_ [0] = idx_v_0;
138  add_quad_ [1] = idx_v_1;
139  add_quad_ [2] = idx_v_2;
140  add_quad_ [3] = idx_v_3;
141 
142  return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data));
143  }
144 
145  private:
146 
147  // NOTE: Can't use the typedef of Base as a friend.
148  friend class pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::QuadMeshTag>;
149 
150  /** \brief addFace for the quad mesh. */
151  inline FaceIndex
152  addFaceImpl (const VertexIndices& vertices,
153  const FaceData& face_data,
154  const EdgeData& edge_data,
155  const HalfEdgeData& half_edge_data)
156  {
157  if (vertices.size () == 4)
158  return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data));
159  else
160  return (FaceIndex ());
161  }
162 
163  ////////////////////////////////////////////////////////////////////////
164  // Members
165  ////////////////////////////////////////////////////////////////////////
166 
167  /** \brief Storage for adding a quad. */
168  VertexIndices add_quad_;
169 
170  public:
171 
172  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
173  };
174  } // End namespace geom
175 } // End namespace pcl
176 
177 #endif // PCL_GEOMETRY_QUAD_MESH_H
boost::shared_ptr< Self > Ptr
Definition: quad_mesh.h:66
QuadMesh< MeshTraitsT > Self
Definition: quad_mesh.h:65
QuadMesh()
Constructor.
Definition: quad_mesh.h:108
Base::FaceIndex FaceIndex
Definition: quad_mesh.h:90
Base::FaceAroundFaceCirculator FaceAroundFaceCirculator
Definition: quad_mesh.h:105
Base::HasEdgeData HasEdgeData
Definition: quad_mesh.h:78
Base::VertexIndex VertexIndex
Definition: quad_mesh.h:87
boost::integral_constant< bool,!boost::is_same< VertexData, pcl::geometry::NoData >::value > HasVertexData
Definition: mesh_base.h:121
Base::HasFaceData HasFaceData
Definition: quad_mesh.h:79
Base::VertexIndices VertexIndices
Definition: quad_mesh.h:92
Circulates clockwise around a face and returns an index to the face of the outer half-edge (the targe...
Circulates counter-clockwise around a vertex and returns an index to the incoming half-edge (the targ...
Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:99
Base::IsManifold IsManifold
Definition: quad_mesh.h:73
boost::integral_constant< bool,!boost::is_same< HalfEdgeData, pcl::geometry::NoData >::value > HasHalfEdgeData
Definition: mesh_base.h:122
Base::HasVertexData HasVertexData
Definition: quad_mesh.h:76
pcl::geometry::MeshBase< QuadMesh< MeshTraitsT >, MeshTraitsT, QuadMeshTag > Base
Definition: quad_mesh.h:63
Base::EdgeDataCloud EdgeDataCloud
Definition: quad_mesh.h:83
Tag describing the type of the mesh.
Definition: quad_mesh.h:51
Base::HasHalfEdgeData HasHalfEdgeData
Definition: quad_mesh.h:77
Base::VertexData VertexData
Definition: quad_mesh.h:69
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:340
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: quad_mesh.h:129
Half-edge mesh that can only store quads.
Definition: quad_mesh.h:59
Base::MeshTag MeshTag
Definition: quad_mesh.h:74
Base::VertexAroundFaceCirculator VertexAroundFaceCirculator
Definition: quad_mesh.h:102
Circulates counter-clockwise around a vertex and returns an index to the terminating vertex of the ou...
boost::shared_ptr< const Self > ConstPtr
Definition: quad_mesh.h:67
Base::HalfEdgeDataCloud HalfEdgeDataCloud
Definition: quad_mesh.h:82
Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:100
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:62
Base::EdgeIndices EdgeIndices
Definition: quad_mesh.h:94
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:479
Circulates clockwise around a face and returns an index to the terminating vertex of the inner half-e...
Base::HalfEdgeIndex HalfEdgeIndex
Definition: quad_mesh.h:88
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:201
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:1144
Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:104
Circulates counter-clockwise around a vertex and returns an index to the outgoing half-edge (the targ...
boost::integral_constant< bool,!boost::is_same< FaceData, pcl::geometry::NoData >::value > HasFaceData
Definition: mesh_base.h:124
Base::FaceData FaceData
Definition: quad_mesh.h:72
Base::EdgeData EdgeData
Definition: quad_mesh.h:71
boost::integral_constant< bool,!boost::is_same< EdgeData, pcl::geometry::NoData >::value > HasEdgeData
Definition: mesh_base.h:123
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:196
Circulates clockwise around a face and returns an index to the inner half-edge (the target)...
Base::VertexAroundVertexCirculator VertexAroundVertexCirculator
Definition: quad_mesh.h:98
Circulates clockwise around a face and returns an index to the outer half-edge (the target)...
Circulates counter-clockwise around a vertex and returns an index to the face of the outgoing half-ed...
Base class for the half-edge mesh.
Definition: mesh_base.h:98
Base::FaceDataCloud FaceDataCloud
Definition: quad_mesh.h:84
Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:103
Base::EdgeIndex EdgeIndex
Definition: quad_mesh.h:89
Base::VertexDataCloud VertexDataCloud
Definition: quad_mesh.h:81
Base::HalfEdgeIndices HalfEdgeIndices
Definition: quad_mesh.h:93
Base::FaceIndices FaceIndices
Definition: quad_mesh.h:95
Base::HalfEdgeData HalfEdgeData
Definition: quad_mesh.h:70
std::vector< VertexIndex > VertexIndices
Definition: mesh_base.h:137
Base::FaceAroundVertexCirculator FaceAroundVertexCirculator
Definition: quad_mesh.h:101