polygon_mesh.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2012, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_GEOMETRY_POLYGON_MESH_H
#define PCL_GEOMETRY_POLYGON_MESH_H
#include <pcl/geometry/mesh_base.h>
namespace pcl
{
namespace geometry
{
/** \brief Tag describing the type of the mesh. */
struct PolygonMeshTag {};
/** \brief General half-edge mesh that can store any polygon with a minimum number of vertices of 3.
* \tparam MeshTraitsT Please have a look at pcl::geometry::DefaultMeshTraits.
* \author Martin Saelzle
* \ingroup geometry
*/
template <class MeshTraitsT>
class PolygonMesh : public pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, PolygonMeshTag>
{
public:
typedef pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, PolygonMeshTag> Base;
typedef PolygonMesh <MeshTraitsT> Self;
typedef boost::shared_ptr <Self> Ptr;
typedef boost::shared_ptr <const Self> ConstPtr;
typedef typename Base::VertexData VertexData;
typedef typename Base::HalfEdgeData HalfEdgeData;
typedef typename Base::EdgeData EdgeData;
typedef typename Base::FaceData FaceData;
typedef typename Base::IsManifold IsManifold;
typedef typename Base::MeshTag MeshTag;
typedef typename Base::HasVertexData HasVertexData;
typedef typename Base::HasHalfEdgeData HasHalfEdgeData;
typedef typename Base::HasEdgeData HasEdgeData;
typedef typename Base::HasFaceData HasFaceData;
typedef typename Base::VertexDataCloud VertexDataCloud;
typedef typename Base::HalfEdgeDataCloud HalfEdgeDataCloud;
typedef typename Base::EdgeDataCloud EdgeDataCloud;
typedef typename Base::FaceDataCloud FaceDataCloud;
// Indices
typedef typename Base::VertexIndex VertexIndex;
typedef typename Base::HalfEdgeIndex HalfEdgeIndex;
typedef typename Base::EdgeIndex EdgeIndex;
typedef typename Base::FaceIndex FaceIndex;
typedef typename Base::VertexIndices VertexIndices;
typedef typename Base::HalfEdgeIndices HalfEdgeIndices;
typedef typename Base::EdgeIndices EdgeIndices;
typedef typename Base::FaceIndices FaceIndices;
// Circulators
typedef typename Base::VertexAroundVertexCirculator VertexAroundVertexCirculator;
typedef typename Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator;
typedef typename Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator;
typedef typename Base::FaceAroundVertexCirculator FaceAroundVertexCirculator;
typedef typename Base::VertexAroundFaceCirculator VertexAroundFaceCirculator;
typedef typename Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator;
typedef typename Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator;
typedef typename Base::FaceAroundFaceCirculator FaceAroundFaceCirculator;
/** \brief Constructor. */
PolygonMesh ()
: Base (),
add_triangle_ (3),
add_quad_ (4)
{
}
/** \brief The base method of addFace is hidden because of the overloads in this class. */
using Base::addFace;
/** \brief Add a triangle to the mesh. Data is only added if it is associated with the elements. The last vertex is connected with the first one.
* \param[in] idx_v_0 Index to the first vertex.
* \param[in] idx_v_1 Index to the second vertex.
* \param[in] idx_v_2 Index to the third vertex.
* \param[in] face_data Data that is set for the face.
* \param[in] half_edge_data Data that is set for all added half-edges.
* \param[in] edge_data Data that is set for all added edges.
* \return Index to the new face. Failure is signaled by returning an invalid face index.
* \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior!
*/
inline FaceIndex
addFace (const VertexIndex& idx_v_0,
const VertexIndex& idx_v_1,
const VertexIndex& idx_v_2,
const FaceData& face_data = FaceData (),
const EdgeData& edge_data = EdgeData (),
const HalfEdgeData& half_edge_data = HalfEdgeData ())
{
add_triangle_ [0] = idx_v_0;
add_triangle_ [1] = idx_v_1;
add_triangle_ [2] = idx_v_2;
return (this->addFaceImplBase (add_triangle_, face_data, edge_data, half_edge_data));
}
/** \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.
* \param[in] idx_v_0 Index to the first vertex.
* \param[in] idx_v_1 Index to the second vertex.
* \param[in] idx_v_2 Index to the third vertex.
* \param[in] idx_v_3 Index to the fourth vertex.
* \param[in] face_data Data that is set for the face.
* \param[in] half_edge_data Data that is set for all added half-edges.
* \param[in] edge_data Data that is set for all added edges.
* \return Index to the new face. Failure is signaled by returning an invalid face index.
* \warning The vertices must be valid and unique (each vertex may be contained only once). Not complying with this requirement results in undefined behavior!
*/
inline 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_quad_ [0] = idx_v_0;
add_quad_ [1] = idx_v_1;
add_quad_ [2] = idx_v_2;
add_quad_ [3] = idx_v_3;
return (this->addFaceImplBase (add_quad_, face_data, edge_data, half_edge_data));
}
private:
// NOTE: Can't use the typedef of Base as a friend.
friend class pcl::geometry::MeshBase <PolygonMesh <MeshTraitsT>, MeshTraitsT, pcl::geometry::PolygonMeshTag>;
/** \brief addFace for the polygon mesh. */
inline FaceIndex
addFaceImpl (const VertexIndices& vertices,
const FaceData& face_data,
const EdgeData& edge_data,
const HalfEdgeData& half_edge_data)
{
return (this->addFaceImplBase (vertices, face_data, edge_data, half_edge_data));
}
////////////////////////////////////////////////////////////////////////
// Members
////////////////////////////////////////////////////////////////////////
/** \brief Storage for adding a triangle. */
VertexIndices add_triangle_;
/** \brief Storage for adding a quad. */
VertexIndices add_quad_;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
} // End namespace geom
} // End namespace pcl
#endif // PCL_GEOMETRY_POLYGON_MESH_H
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceIndices
std::vector< FaceIndex > FaceIndices
Definition: mesh_base.h:140
pcl::geometry::PolygonMesh::HalfEdgeDataCloud
Base::HalfEdgeDataCloud HalfEdgeDataCloud
Definition: polygon_mesh.h:82
pcl::geometry::PolygonMesh::ConstPtr
boost::shared_ptr< const Self > ConstPtr
Definition: polygon_mesh.h:67
pcl::geometry::PolygonMesh::Base
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag > Base
Definition: polygon_mesh.h:63
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeData
MeshTraitsT::HalfEdgeData HalfEdgeData
Definition: mesh_base.h:110
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasVertexData
boost::integral_constant< bool,!boost::is_same< VertexData, pcl::geometry::NoData >::value > HasVertexData
Definition: mesh_base.h:121
pcl::geometry::PolygonMesh::VertexIndex
Base::VertexIndex VertexIndex
Definition: polygon_mesh.h:87
pcl::geometry::PolygonMesh::HasEdgeData
Base::HasEdgeData HasEdgeData
Definition: polygon_mesh.h:78
pcl
Definition: cloud_iterator.h:46
pcl::geometry::FaceAroundFaceCirculator
Circulates clockwise around a face and returns an index to the face of the outer half-edge (the targe...
Definition: mesh_circulators.h:822
pcl::geometry::IncomingHalfEdgeAroundVertexCirculator
Circulates counter-clockwise around a vertex and returns an index to the incoming half-edge (the targ...
Definition: mesh_circulators.h:280
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasHalfEdgeData
boost::integral_constant< bool,!boost::is_same< HalfEdgeData, pcl::geometry::NoData >::value > HasHalfEdgeData
Definition: mesh_base.h:122
pcl::geometry::PolygonMesh::HasFaceData
Base::HasFaceData HasFaceData
Definition: polygon_mesh.h:79
pcl::geometry::PolygonMesh::FaceData
Base::FaceData FaceData
Definition: polygon_mesh.h:72
pcl::geometry::PolygonMesh::HalfEdgeIndices
Base::HalfEdgeIndices HalfEdgeIndices
Definition: polygon_mesh.h:93
pcl::geometry::PolygonMesh::IsManifold
Base::IsManifold IsManifold
Definition: polygon_mesh.h:73
pcl::geometry::PolygonMesh::addFace
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: polygon_mesh.h:155
pcl::geometry::EdgeIndex
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:340
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HalfEdgeIndices
std::vector< HalfEdgeIndex > HalfEdgeIndices
Definition: mesh_base.h:138
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::IsManifold
MeshTraitsT::IsManifold IsManifold
Definition: mesh_base.h:113
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeData
MeshTraitsT::EdgeData EdgeData
Definition: mesh_base.h:111
pcl::geometry::PolygonMesh::HalfEdgeData
Base::HalfEdgeData HalfEdgeData
Definition: polygon_mesh.h:70
pcl::geometry::PolygonMesh::Ptr
boost::shared_ptr< Self > Ptr
Definition: polygon_mesh.h:66
pcl::geometry::PolygonMesh::IncomingHalfEdgeAroundVertexCirculator
Base::IncomingHalfEdgeAroundVertexCirculator IncomingHalfEdgeAroundVertexCirculator
Definition: polygon_mesh.h:100
pcl::geometry::PolygonMesh::OuterHalfEdgeAroundFaceCirculator
Base::OuterHalfEdgeAroundFaceCirculator OuterHalfEdgeAroundFaceCirculator
Definition: polygon_mesh.h:104
pcl::geometry::VertexAroundVertexCirculator
Circulates counter-clockwise around a vertex and returns an index to the terminating vertex of the ou...
Definition: mesh_circulators.h:64
pcl::geometry::PolygonMesh::OutgoingHalfEdgeAroundVertexCirculator
Base::OutgoingHalfEdgeAroundVertexCirculator OutgoingHalfEdgeAroundVertexCirculator
Definition: polygon_mesh.h:99
pcl::geometry::VertexIndex
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:62
pcl::geometry::FaceIndex
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:479
pcl::geometry::VertexAroundFaceCirculator
Circulates clockwise around a face and returns an index to the terminating vertex of the inner half-e...
Definition: mesh_circulators.h:497
pcl::geometry::PolygonMesh::VertexDataCloud
Base::VertexDataCloud VertexDataCloud
Definition: polygon_mesh.h:81
pcl::geometry::PolygonMesh::VertexAroundVertexCirculator
Base::VertexAroundVertexCirculator VertexAroundVertexCirculator
Definition: polygon_mesh.h:98
pcl::geometry::HalfEdgeIndex
Index used to access elements in the half-edge mesh.
Definition: mesh_indices.h:201
pcl::geometry::PolygonMesh::EdgeData
Base::EdgeData EdgeData
Definition: polygon_mesh.h:71
pcl::geometry::OutgoingHalfEdgeAroundVertexCirculator
Circulates counter-clockwise around a vertex and returns an index to the outgoing half-edge (the targ...
Definition: mesh_circulators.h:172
pcl::geometry::PolygonMesh::Self
PolygonMesh< MeshTraitsT > Self
Definition: polygon_mesh.h:65
pcl::geometry::PolygonMesh::FaceIndex
Base::FaceIndex FaceIndex
Definition: polygon_mesh.h:90
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::FaceData
MeshTraitsT::FaceData FaceData
Definition: mesh_base.h:112
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasFaceData
boost::integral_constant< bool,!boost::is_same< FaceData, pcl::geometry::NoData >::value > HasFaceData
Definition: mesh_base.h:124
pcl::geometry::PolygonMesh::FaceDataCloud
Base::FaceDataCloud FaceDataCloud
Definition: polygon_mesh.h:84
pcl::PointCloud< VertexData >
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::EdgeIndices
std::vector< EdgeIndex > EdgeIndices
Definition: mesh_base.h:139
pcl::geometry::PolygonMesh::EdgeIndex
Base::EdgeIndex EdgeIndex
Definition: polygon_mesh.h:89
pcl::geometry::PolygonMesh::FaceAroundVertexCirculator
Base::FaceAroundVertexCirculator FaceAroundVertexCirculator
Definition: polygon_mesh.h:101
pcl::geometry::PolygonMesh::VertexData
Base::VertexData VertexData
Definition: polygon_mesh.h:69
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::VertexData
MeshTraitsT::VertexData VertexData
Definition: mesh_base.h:109
pcl::geometry::PolygonMeshTag
Tag describing the type of the mesh.
Definition: polygon_mesh.h:51
pcl::geometry::MeshBase< PolygonMesh< MeshTraitsT >, MeshTraitsT, PolygonMeshTag >::HasEdgeData
boost::integral_constant< bool,!boost::is_same< EdgeData, pcl::geometry::NoData >::value > HasEdgeData
Definition: mesh_base.h:123
pcl::geometry::PolygonMesh::MeshTag
Base::MeshTag MeshTag
Definition: polygon_mesh.h:74
pcl::geometry::PolygonMesh::VertexIndices
Base::VertexIndices VertexIndices
Definition: polygon_mesh.h:92
pcl::geometry::InnerHalfEdgeAroundFaceCirculator
Circulates clockwise around a face and returns an index to the inner half-edge (the target)...
Definition: mesh_circulators.h:606
pcl::geometry::PolygonMesh::HasHalfEdgeData
Base::HasHalfEdgeData HasHalfEdgeData
Definition: polygon_mesh.h:77
pcl::geometry::PolygonMesh::EdgeIndices
Base::EdgeIndices EdgeIndices
Definition: polygon_mesh.h:94
pcl::geometry::PolygonMesh::VertexAroundFaceCirculator
Base::VertexAroundFaceCirculator VertexAroundFaceCirculator
Definition: polygon_mesh.h:102
pcl::geometry::PolygonMesh::HasVertexData
Base::HasVertexData HasVertexData
Definition: polygon_mesh.h:76
pcl::geometry::OuterHalfEdgeAroundFaceCirculator
Circulates clockwise around a face and returns an index to the outer half-edge (the target)...
Definition: mesh_circulators.h:714
pcl::geometry::FaceAroundVertexCirculator
Circulates counter-clockwise around a vertex and returns an index to the face of the outgoing half-ed...
Definition: mesh_circulators.h:388
pcl::geometry::MeshBase
Base class for the half-edge mesh.
Definition: mesh_base.h:98
pcl::geometry::PolygonMesh::HalfEdgeIndex
Base::HalfEdgeIndex HalfEdgeIndex
Definition: polygon_mesh.h:88
pcl::geometry::PolygonMesh
General half-edge mesh that can store any polygon with a minimum number of vertices of 3...
Definition: polygon_mesh.h:59
pcl::geometry::PolygonMesh::FaceIndices
Base::FaceIndices FaceIndices
Definition: polygon_mesh.h:95
pcl::geometry::PolygonMesh::InnerHalfEdgeAroundFaceCirculator
Base::InnerHalfEdgeAroundFaceCirculator InnerHalfEdgeAroundFaceCirculator
Definition: polygon_mesh.h:103
pcl::geometry::MeshBase::VertexIndices
std::vector< VertexIndex > VertexIndices
Definition: mesh_base.h:137
pcl::geometry::PolygonMesh::PolygonMesh
PolygonMesh()
Constructor.
Definition: polygon_mesh.h:108
pcl::geometry::PolygonMesh::FaceAroundFaceCirculator
Base::FaceAroundFaceCirculator FaceAroundFaceCirculator
Definition: polygon_mesh.h:105
pcl::geometry::PolygonMesh::EdgeDataCloud
Base::EdgeDataCloud EdgeDataCloud
Definition: polygon_mesh.h:83
pcl::geometry::PolygonMesh::addFace
FaceIndex addFace(const VertexIndex &idx_v_0, const VertexIndex &idx_v_1, const VertexIndex &idx_v_2, const FaceData &face_data=FaceData(), const EdgeData &edge_data=EdgeData(), const HalfEdgeData &half_edge_data=HalfEdgeData())
Add a triangle to the mesh.
Definition: polygon_mesh.h:129