Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/geometry/include/pcl/geometry/mesh_elements.h
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Point Cloud Library (PCL) - www.pointclouds.org
00005  * Copyright (c) 2009-2012, Willow Garage, Inc.
00006  * Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  *
00014  *  * Redistributions of source code must retain the above copyright
00015  *    notice, this list of conditions and the following disclaimer.
00016  *  * Redistributions in binary form must reproduce the above
00017  *    copyright notice, this list of conditions and the following
00018  *    disclaimer in the documentation and/or other materials provided
00019  *    with the distribution.
00020  *  * Neither the name of the copyright holder(s) nor the names of its
00021  *    contributors may be used to endorse or promote products derived
00022  *    from this software without specific prior written permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  * POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  * $Id$
00038  *
00039  */
00040 
00041 #ifndef PCL_GEOMETRY_MESH_ELEMENTS_H
00042 #define PCL_GEOMETRY_MESH_ELEMENTS_H
00043 
00044 #include <pcl/geometry/mesh_indices.h>
00045 
00046 namespace pcl
00047 {
00048   namespace geometry
00049   {
00050     template <class DerivedT, class MeshTraitsT, class MeshTagT>
00051     class MeshBase;
00052 
00053     template <class MeshT>
00054     class MeshIO;
00055   } // End namespace geometry
00056 } // End namespace pcl
00057 
00058 ////////////////////////////////////////////////////////////////////////////////
00059 // Vertex
00060 ////////////////////////////////////////////////////////////////////////////////
00061 
00062 namespace pcl
00063 {
00064   namespace geometry
00065   {
00066     /** \brief A vertex is a node in the mesh.
00067       * \author Martin Saelzle
00068       * \ingroup geometry
00069       */
00070     class Vertex
00071     {
00072       private:
00073 
00074         typedef pcl::geometry::HalfEdgeIndex HalfEdgeIndex;
00075 
00076         /** \brief Constructor.
00077           * \param[in] idx_outgoing_half_edge Index to the outgoing half-edge. Defaults to an invalid index.
00078           */
00079         explicit Vertex (const HalfEdgeIndex& idx_outgoing_half_edge = HalfEdgeIndex ())
00080           : idx_outgoing_half_edge_ (idx_outgoing_half_edge)
00081         {}
00082 
00083         /** \brief Index to the outgoing half-edge. The vertex is considered to be deleted if it stores an invalid outgoing half-edge index. */
00084         HalfEdgeIndex idx_outgoing_half_edge_;
00085 
00086         template <class DerivedT, class MeshTraitsT, class MeshTagT>
00087         friend class pcl::geometry::MeshBase;
00088 
00089         template <class MeshT>
00090         friend class pcl::geometry::MeshIO;
00091     };
00092   } // End namespace geometry
00093 } // End namespace pcl
00094 
00095 ////////////////////////////////////////////////////////////////////////////////
00096 // HalfEdge
00097 ////////////////////////////////////////////////////////////////////////////////
00098 
00099 namespace pcl
00100 {
00101   namespace geometry
00102   {
00103     /** \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.
00104       * \author Martin Saelzle
00105       * \ingroup geometry
00106       */
00107     class HalfEdge
00108     {
00109       private:
00110 
00111         typedef pcl::geometry::VertexIndex   VertexIndex;
00112         typedef pcl::geometry::HalfEdgeIndex HalfEdgeIndex;
00113         typedef pcl::geometry::FaceIndex     FaceIndex;
00114 
00115         /** \brief Constructor.
00116           * \param[in] idx_terminating_vertex Index to the terminating vertex. Defaults to an invalid index.
00117           * \param[in] idx_next_half_edge     Index to the next half-edge. Defaults to an invalid index.
00118           * \param[in] idx_prev_half_edge     Index to the previous half-edge. Defaults to an invalid index.
00119           * \param[in] idx_face               Index to the face. Defaults to an invalid index.
00120           */
00121         explicit HalfEdge (const VertexIndex&   idx_terminating_vertex = VertexIndex   (),
00122                            const HalfEdgeIndex& idx_next_half_edge     = HalfEdgeIndex (),
00123                            const HalfEdgeIndex& idx_prev_half_edge     = HalfEdgeIndex (),
00124                            const FaceIndex&     idx_face               = FaceIndex     ())
00125           : idx_terminating_vertex_ (idx_terminating_vertex),
00126             idx_next_half_edge_     (idx_next_half_edge),
00127             idx_prev_half_edge_     (idx_prev_half_edge),
00128             idx_face_               (idx_face)
00129         {
00130         }
00131 
00132         /** \brief Index to the terminating vertex. The half-edge is considered to be deleted if it stores an invalid terminating vertex index. */
00133         VertexIndex idx_terminating_vertex_;
00134 
00135         /** \brief Index to the next half-edge. */
00136         HalfEdgeIndex idx_next_half_edge_;
00137 
00138         /** \brief Index to the previous half-edge. */
00139         HalfEdgeIndex idx_prev_half_edge_;
00140 
00141         /** \brief Index to the face. The half-edge is considered to be on the boundary if it stores an invalid face index. */
00142         FaceIndex idx_face_;
00143 
00144         template <class DerivedT, class MeshTraitsT, class MeshTagT>
00145         friend class pcl::geometry::MeshBase;
00146 
00147         template <class MeshT>
00148         friend class pcl::geometry::MeshIO;
00149     };
00150   } // End namespace geometry
00151 } // End namespace pcl
00152 
00153 ////////////////////////////////////////////////////////////////////////////////
00154 // Face
00155 ////////////////////////////////////////////////////////////////////////////////
00156 
00157 namespace pcl
00158 {
00159   namespace geometry
00160   {
00161     /** \brief A face is a closed loop of edges.
00162       * \author Martin Saelzle
00163       * \ingroup geometry
00164       */
00165     class Face
00166     {
00167       private:
00168 
00169         typedef pcl::geometry::HalfEdgeIndex HalfEdgeIndex;
00170 
00171         /** \brief Constructor.
00172           * \param[in] inner_half_edge_idx Index to the outgoing half-edge. Defaults to an invalid index
00173           */
00174         explicit Face (const HalfEdgeIndex& idx_inner_half_edge = HalfEdgeIndex ())
00175           : idx_inner_half_edge_ (idx_inner_half_edge)
00176         {}
00177 
00178         /** \brief Index to the inner half-edge. The face is considered to be deleted if it stores an invalid inner half-edge index. */
00179         HalfEdgeIndex idx_inner_half_edge_;
00180 
00181         template <class DerivedT, class MeshTraitsT, class MeshTagT>
00182         friend class pcl::geometry::MeshBase;
00183 
00184         template <class MeshT>
00185         friend class pcl::geometry::MeshIO;
00186     };
00187   } // End namespace geometry
00188 } // End namespace pcl
00189 
00190 #endif // PCL_GEOMETRY_MESH_ELEMENTS_H