Point Cloud Library (PCL)  1.7.1
mesh_elements.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_MESH_ELEMENTS_H
42 #define PCL_GEOMETRY_MESH_ELEMENTS_H
43 
44 #include <pcl/geometry/mesh_indices.h>
45 
46 namespace pcl
47 {
48  namespace geometry
49  {
50  template <class DerivedT, class MeshTraitsT, class MeshTagT>
51  class MeshBase;
52 
53  template <class MeshT>
54  class MeshIO;
55  } // End namespace geometry
56 } // End namespace pcl
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 // Vertex
60 ////////////////////////////////////////////////////////////////////////////////
61 
62 namespace pcl
63 {
64  namespace geometry
65  {
66  /** \brief A vertex is a node in the mesh.
67  * \author Martin Saelzle
68  * \ingroup geometry
69  */
70  class Vertex
71  {
72  private:
73 
75 
76  /** \brief Constructor.
77  * \param[in] idx_outgoing_half_edge Index to the outgoing half-edge. Defaults to an invalid index.
78  */
79  explicit Vertex (const HalfEdgeIndex& idx_outgoing_half_edge = HalfEdgeIndex ())
80  : idx_outgoing_half_edge_ (idx_outgoing_half_edge)
81  {}
82 
83  /** \brief Index to the outgoing half-edge. The vertex is considered to be deleted if it stores an invalid outgoing half-edge index. */
84  HalfEdgeIndex idx_outgoing_half_edge_;
85 
86  template <class DerivedT, class MeshTraitsT, class MeshTagT>
88 
89  template <class MeshT>
90  friend class pcl::geometry::MeshIO;
91  };
92  } // End namespace geometry
93 } // End namespace pcl
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 // HalfEdge
97 ////////////////////////////////////////////////////////////////////////////////
98 
99 namespace pcl
100 {
101  namespace geometry
102  {
103  /** \brief An edge is a connection between two vertices. In a half-edge mesh the edge is split into two half-edges with opposite orientation. Each half-edge stores the index to the terminating vertex, the next half-edge, the previous half-edge and the face it belongs to. The opposite half-edge is accessed implicitly.
104  * \author Martin Saelzle
105  * \ingroup geometry
106  */
107  class HalfEdge
108  {
109  private:
110 
114 
115  /** \brief Constructor.
116  * \param[in] idx_terminating_vertex Index to the terminating vertex. Defaults to an invalid index.
117  * \param[in] idx_next_half_edge Index to the next half-edge. Defaults to an invalid index.
118  * \param[in] idx_prev_half_edge Index to the previous half-edge. Defaults to an invalid index.
119  * \param[in] idx_face Index to the face. Defaults to an invalid index.
120  */
121  explicit HalfEdge (const VertexIndex& idx_terminating_vertex = VertexIndex (),
122  const HalfEdgeIndex& idx_next_half_edge = HalfEdgeIndex (),
123  const HalfEdgeIndex& idx_prev_half_edge = HalfEdgeIndex (),
124  const FaceIndex& idx_face = FaceIndex ())
125  : idx_terminating_vertex_ (idx_terminating_vertex),
126  idx_next_half_edge_ (idx_next_half_edge),
127  idx_prev_half_edge_ (idx_prev_half_edge),
128  idx_face_ (idx_face)
129  {
130  }
131 
132  /** \brief Index to the terminating vertex. The half-edge is considered to be deleted if it stores an invalid terminating vertex index. */
133  VertexIndex idx_terminating_vertex_;
134 
135  /** \brief Index to the next half-edge. */
136  HalfEdgeIndex idx_next_half_edge_;
137 
138  /** \brief Index to the previous half-edge. */
139  HalfEdgeIndex idx_prev_half_edge_;
140 
141  /** \brief Index to the face. The half-edge is considered to be on the boundary if it stores an invalid face index. */
142  FaceIndex idx_face_;
143 
144  template <class DerivedT, class MeshTraitsT, class MeshTagT>
146 
147  template <class MeshT>
148  friend class pcl::geometry::MeshIO;
149  };
150  } // End namespace geometry
151 } // End namespace pcl
152 
153 ////////////////////////////////////////////////////////////////////////////////
154 // Face
155 ////////////////////////////////////////////////////////////////////////////////
156 
157 namespace pcl
158 {
159  namespace geometry
160  {
161  /** \brief A face is a closed loop of edges.
162  * \author Martin Saelzle
163  * \ingroup geometry
164  */
165  class Face
166  {
167  private:
168 
170 
171  /** \brief Constructor.
172  * \param[in] inner_half_edge_idx Index to the outgoing half-edge. Defaults to an invalid index
173  */
174  explicit Face (const HalfEdgeIndex& idx_inner_half_edge = HalfEdgeIndex ())
175  : idx_inner_half_edge_ (idx_inner_half_edge)
176  {}
177 
178  /** \brief Index to the inner half-edge. The face is considered to be deleted if it stores an invalid inner half-edge index. */
179  HalfEdgeIndex idx_inner_half_edge_;
180 
181  template <class DerivedT, class MeshTraitsT, class MeshTagT>
183 
184  template <class MeshT>
185  friend class pcl::geometry::MeshIO;
186  };
187  } // End namespace geometry
188 } // End namespace pcl
189 
190 #endif // PCL_GEOMETRY_MESH_ELEMENTS_H