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