Point Cloud Library (PCL)  1.10.0-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/pcl_macros.h>
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 
68 
69  using VertexData = typename Base::VertexData;
70  using HalfEdgeData = typename Base::HalfEdgeData;
71  using EdgeData = typename Base::EdgeData;
72  using FaceData = typename Base::FaceData;
73  using IsManifold = typename Base::IsManifold;
74  using MeshTag = typename Base::MeshTag;
75 
78  using HasEdgeData = typename Base::HasEdgeData;
79  using HasFaceData = typename Base::HasFaceData;
80 
85 
86  // Indices
87  using VertexIndex = typename Base::VertexIndex;
89  using EdgeIndex = typename Base::EdgeIndex;
90  using FaceIndex = typename Base::FaceIndex;
91 
94  using EdgeIndices = typename Base::EdgeIndices;
95  using FaceIndices = typename Base::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  return (FaceIndex ());
160  }
161 
162  ////////////////////////////////////////////////////////////////////////
163  // Members
164  ////////////////////////////////////////////////////////////////////////
165 
166  /** \brief Storage for adding a quad. */
167  VertexIndices add_quad_;
168 
169  public:
171  };
172  } // End namespace geom
173 } // End namespace pcl
typename Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:99
typename Base::VertexIndex VertexIndex
Definition: quad_mesh.h:87
typename Base::HalfEdgeIndices HalfEdgeIndices
Definition: quad_mesh.h:93
QuadMesh()
Constructor.
Definition: quad_mesh.h:108
typename Base::IsManifold IsManifold
Definition: quad_mesh.h:73
typename Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:103
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
typename Base::MeshTag MeshTag
Definition: quad_mesh.h:74
typename Base::EdgeIndices EdgeIndices
Definition: quad_mesh.h:94
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:92
typename Base::HasVertexData HasVertexData
Definition: quad_mesh.h:76
typename Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator
Definition: quad_mesh.h:104
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: pcl_macros.h:371
typename Base::FaceAroundFaceCirculator FaceAroundFaceCirculator
Definition: quad_mesh.h:105
Tag describing the type of the mesh.
Definition: quad_mesh.h:51
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:129
typename Base::HalfEdgeIndex HalfEdgeIndex
Definition: quad_mesh.h:88
Half-edge mesh that can only store quads.
Definition: quad_mesh.h:59
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:67
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:61
typename Base::VertexDataCloud VertexDataCloud
Definition: quad_mesh.h:81
typename Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator
Definition: quad_mesh.h:100
typename Base::FaceAroundVertexCirculator FaceAroundVertexCirculator
Definition: quad_mesh.h:101
typename Base::FaceDataCloud FaceDataCloud
Definition: quad_mesh.h:84
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:98
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:72
std::integral_constant< bool, !std::is_same< FaceData, pcl::geometry::NoData >::value > HasFaceData
Definition: mesh_base.h:125
typename Base::HalfEdgeData HalfEdgeData
Definition: quad_mesh.h:70
std::integral_constant< bool, !std::is_same< VertexData, pcl::geometry::NoData >::value > HasVertexData
Definition: mesh_base.h:122
typename Base::VertexAroundFaceCirculator VertexAroundFaceCirculator
Definition: quad_mesh.h:102
typename Base::VertexData VertexData
Definition: quad_mesh.h:69
shared_ptr< Self > Ptr
Definition: quad_mesh.h:66
std::integral_constant< bool, !std::is_same< HalfEdgeData, pcl::geometry::NoData >::value > HasHalfEdgeData
Definition: mesh_base.h:123
typename Base::HasEdgeData HasEdgeData
Definition: quad_mesh.h:78
typename Base::EdgeData EdgeData
Definition: quad_mesh.h:71
std::integral_constant< bool, !std::is_same< EdgeData, pcl::geometry::NoData >::value > HasEdgeData
Definition: mesh_base.h:124
typename Base::HasFaceData HasFaceData
Definition: quad_mesh.h:79
typename Base::HalfEdgeDataCloud HalfEdgeDataCloud
Definition: quad_mesh.h:82
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:89
Base class for the half-edge mesh.
Definition: mesh_base.h:99
typename Base::HasHalfEdgeData HasHalfEdgeData
Definition: quad_mesh.h:77
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:90
std::vector< VertexIndex > VertexIndices
Definition: mesh_base.h:138
typename Base::FaceIndex FaceIndex
Definition: quad_mesh.h:90
typename Base::FaceIndices FaceIndices
Definition: quad_mesh.h:95
Defines all the PCL and non-PCL macros used.
typename Base::EdgeDataCloud EdgeDataCloud
Definition: quad_mesh.h:83