Point Cloud Library (PCL)  1.10.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 {
47  namespace geometry
48  {
49  template <class DerivedT, class MeshTraitsT, class MeshTagT>
50  class MeshBase;
51 
52  template <class MeshT>
53  class MeshIO;
54  } // End namespace geometry
55 } // End namespace pcl
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 // Vertex
59 ////////////////////////////////////////////////////////////////////////////////
60 
61 namespace pcl
62 {
63  namespace geometry
64  {
65  /** \brief A vertex is a node in the mesh.
66  * \author Martin Saelzle
67  * \ingroup geometry
68  */
69  class Vertex
70  {
71  private:
72 
74 
75  /** \brief Constructor.
76  * \param[in] idx_outgoing_half_edge Index to the outgoing half-edge. Defaults to an invalid index.
77  */
78  explicit Vertex (const HalfEdgeIndex& idx_outgoing_half_edge = HalfEdgeIndex ())
79  : idx_outgoing_half_edge_ (idx_outgoing_half_edge)
80  {}
81 
82  /** \brief Index to the outgoing half-edge. The vertex is considered to be deleted if it stores an invalid outgoing half-edge index. */
83  HalfEdgeIndex idx_outgoing_half_edge_;
84 
85  template <class DerivedT, class MeshTraitsT, class MeshTagT>
87 
88  template <class MeshT>
89  friend class pcl::geometry::MeshIO;
90  };
91  } // End namespace geometry
92 } // End namespace pcl
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 // HalfEdge
96 ////////////////////////////////////////////////////////////////////////////////
97 
98 namespace pcl
99 {
100  namespace geometry
101  {
102  /** \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.
103  * \author Martin Saelzle
104  * \ingroup geometry
105  */
106  class HalfEdge
107  {
108  private:
109 
113 
114  /** \brief Constructor.
115  * \param[in] idx_terminating_vertex Index to the terminating vertex. Defaults to an invalid index.
116  * \param[in] idx_next_half_edge Index to the next half-edge. Defaults to an invalid index.
117  * \param[in] idx_prev_half_edge Index to the previous half-edge. Defaults to an invalid index.
118  * \param[in] idx_face Index to the face. Defaults to an invalid index.
119  */
120  explicit HalfEdge (const VertexIndex& idx_terminating_vertex = VertexIndex (),
121  const HalfEdgeIndex& idx_next_half_edge = HalfEdgeIndex (),
122  const HalfEdgeIndex& idx_prev_half_edge = HalfEdgeIndex (),
123  const FaceIndex& idx_face = FaceIndex ())
124  : idx_terminating_vertex_ (idx_terminating_vertex),
125  idx_next_half_edge_ (idx_next_half_edge),
126  idx_prev_half_edge_ (idx_prev_half_edge),
127  idx_face_ (idx_face)
128  {
129  }
130 
131  /** \brief Index to the terminating vertex. The half-edge is considered to be deleted if it stores an invalid terminating vertex index. */
132  VertexIndex idx_terminating_vertex_;
133 
134  /** \brief Index to the next half-edge. */
135  HalfEdgeIndex idx_next_half_edge_;
136 
137  /** \brief Index to the previous half-edge. */
138  HalfEdgeIndex idx_prev_half_edge_;
139 
140  /** \brief Index to the face. The half-edge is considered to be on the boundary if it 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 {
158  namespace geometry
159  {
160  /** \brief A face is a closed loop of edges.
161  * \author Martin Saelzle
162  * \ingroup geometry
163  */
164  class Face
165  {
166  private:
167 
169 
170  /** \brief Constructor.
171  * \param[in] inner_half_edge_idx Index to the outgoing half-edge. Defaults to an invalid index
172  */
173  explicit Face (const HalfEdgeIndex& idx_inner_half_edge = HalfEdgeIndex ())
174  : idx_inner_half_edge_ (idx_inner_half_edge)
175  {}
176 
177  /** \brief Index to the inner half-edge. The face is considered to be deleted if it stores an invalid inner half-edge index. */
178  HalfEdgeIndex idx_inner_half_edge_;
179 
180  template <class DerivedT, class MeshTraitsT, class MeshTagT>
182 
183  template <class MeshT>
184  friend class pcl::geometry::MeshIO;
185  };
186  } // End namespace geometry
187 } // End namespace pcl
A vertex is a node in the mesh.
Definition: mesh_elements.h:69
An edge is a connection between two vertices.
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:61
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:478
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:200
Read / write the half-edge mesh from / to a file.
Definition: mesh_base.h:79
A face is a closed loop of edges.
Base class for the half-edge mesh.
Definition: mesh_base.h:100