Point Cloud Library (PCL)  1.10.1-dev
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 #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 QuadMeshTag {};
53 
54  /** \brief Half-edge mesh that can only store quads.
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 QuadMesh : public pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, QuadMeshTag>
61  {
62  public:
63 
65 
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_quad_ (4)
112  {
113  }
114 
115  /** \brief The base method of addFace is hidden because of the overloads in this class. */
116  using Base::addFace;
117 
118  /** \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.
119  * \param[in] idx_v_0 Index to the first vertex.
120  * \param[in] idx_v_1 Index to the second vertex.
121  * \param[in] idx_v_2 Index to the third vertex.
122  * \param[in] idx_v_3 Index to the fourth 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 VertexIndex& idx_v_3,
134  const FaceData& face_data = FaceData (),
135  const EdgeData& edge_data = EdgeData (),
136  const HalfEdgeData& half_edge_data = HalfEdgeData ())
137  {
138  add_quad_ [0] = idx_v_0;
139  add_quad_ [1] = idx_v_1;
140  add_quad_ [2] = idx_v_2;
141  add_quad_ [3] = idx_v_3;
142 
143  return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data));
144  }
145 
146  private:
147 
148  // NOTE: Can't use the typedef of Base as a friend.
149  friend class pcl::geometry::MeshBase <QuadMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::QuadMeshTag>;
150 
151  /** \brief addFace for the quad mesh. */
152  inline FaceIndex
153  addFaceImpl (const VertexIndices& vertices,
154  const FaceData& face_data,
155  const EdgeData& edge_data,
156  const HalfEdgeData& half_edge_data)
157  {
158  if (vertices.size () == 4)
159  return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data));
160  return (FaceIndex ());
161  }
162 
163  ////////////////////////////////////////////////////////////////////////
164  // Members
165  ////////////////////////////////////////////////////////////////////////
166 
167  /** \brief Storage for adding a quad. */
168  VertexIndices add_quad_;
169 
170  public:
172  };
173  } // End namespace geom
174 } // End namespace pcl
typename Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:100
typename Base::VertexIndex VertexIndex
Definition: quad_mesh.h:88
typename Base::HalfEdgeIndices HalfEdgeIndices
Definition: quad_mesh.h:94
QuadMesh()
Constructor.
Definition: quad_mesh.h:109
Defines functions, macros and traits for allocating and using memory.
typename Base::IsManifold IsManifold
Definition: quad_mesh.h:74
typename Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:104
typename Base::MeshTag MeshTag
Definition: quad_mesh.h:75
typename Base::EdgeIndices EdgeIndices
Definition: quad_mesh.h:95
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...
typename Base::VertexIndices VertexIndices
Definition: quad_mesh.h:93
typename Base::HasVertexData HasVertexData
Definition: quad_mesh.h:77
typename Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:105
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:65
typename Base::FaceAroundFaceCirculator FaceAroundFaceCirculator
Definition: quad_mesh.h:106
Tag describing the type of the mesh.
Definition: quad_mesh.h:52
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:339
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:130
typename Base::HalfEdgeIndex HalfEdgeIndex
Definition: quad_mesh.h:89
Half-edge mesh that can only store quads.
Definition: quad_mesh.h:60
Circulates counter-clockwise around a vertex and returns an index to the terminating vertex of the ou...
shared_ptr< const Self > ConstPtr
Definition: quad_mesh.h:68
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:61
typename Base::VertexDataCloud VertexDataCloud
Definition: quad_mesh.h:82
typename Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:101
typename Base::FaceAroundVertexCirculator FaceAroundVertexCirculator
Definition: quad_mesh.h:102
typename Base::FaceDataCloud FaceDataCloud
Definition: quad_mesh.h:85
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:478
Circulates clockwise around a face and returns an index to the terminating vertex of the inner half-e...
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:200
typename Base::VertexAroundVertexCirculator VertexAroundVertexCirculator
Definition: quad_mesh.h:99
Circulates counter-clockwise around a vertex and returns an index to the outgoing half-edge (the targ...
typename Base::FaceData FaceData
Definition: quad_mesh.h:73
std::integral_constant< bool, !std::is_same< FaceData, pcl::geometry::NoData >::value > HasFaceData
Definition: mesh_base.h:126
typename Base::HalfEdgeData HalfEdgeData
Definition: quad_mesh.h:71
std::integral_constant< bool, !std::is_same< VertexData, pcl::geometry::NoData >::value > HasVertexData
Definition: mesh_base.h:123
typename Base::VertexAroundFaceCirculator VertexAroundFaceCirculator
Definition: quad_mesh.h:103
typename Base::VertexData VertexData
Definition: quad_mesh.h:70
shared_ptr< Self > Ptr
Definition: quad_mesh.h:67
std::integral_constant< bool, !std::is_same< HalfEdgeData, pcl::geometry::NoData >::value > HasHalfEdgeData
Definition: mesh_base.h:124
typename Base::HasEdgeData HasEdgeData
Definition: quad_mesh.h:79
typename Base::EdgeData EdgeData
Definition: quad_mesh.h:72
std::integral_constant< bool, !std::is_same< EdgeData, pcl::geometry::NoData >::value > HasEdgeData
Definition: mesh_base.h:125
typename Base::HasFaceData HasFaceData
Definition: quad_mesh.h:80
typename Base::HalfEdgeDataCloud HalfEdgeDataCloud
Definition: quad_mesh.h:83
Circulates clockwise around a face and returns an index to the inner half-edge (the target)...
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...
typename Base::EdgeIndex EdgeIndex
Definition: quad_mesh.h:90
Base class for the half-edge mesh.
Definition: mesh_base.h:100
typename Base::HasHalfEdgeData HasHalfEdgeData
Definition: quad_mesh.h:78
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: memory.h:81
std::vector< VertexIndex > VertexIndices
Definition: mesh_base.h:139
typename Base::FaceIndex FaceIndex
Definition: quad_mesh.h:91
typename Base::FaceIndices FaceIndices
Definition: quad_mesh.h:96
Defines all the PCL and non-PCL macros used.
typename Base::EdgeDataCloud EdgeDataCloud
Definition: quad_mesh.h:84