RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
IndexedTriMeshN0< T, S > Class Template Reference

an Indexed Triangle mesh with zero normals More...

#include <IndexedTriMesh.hpp>

Inherits IndexedTriMesh< double >.

Public Types

typedef S index_type
 The type of indices.
 
typedef rw::geometry::IndexedTriangle< S > tri_type
 The type of the triangles of the mesh.
 
typedef std::vector< tri_typeTriangleArray
 The vector of triangles.
 
typedef IndexedTriMesh< T >::VertexArray VertexArray
 the vertex array type More...
 
typedef rw::core::Ptr< rw::geometry::IndexedTriMeshN0< T, S > > Ptr
 Smart pointer type of this class.
 
- Public Types inherited from IndexedTriMesh< double >
typedef double value_type
 the basic value type of this mesh (for instance double or float)
 
typedef std::vector< rw::math::Vector3D< double > > VertexArray
 the vertex array type
 
typedef rw::core::Ptr< rw::geometry::IndexedTriMesh< double > > Ptr
 the smart pointer type of this triangle mesh
 
- Public Types inherited from TriMesh
typedef rw::core::Ptr< TriMeshPtr
 smart pointer type to this class
 
- Public Types inherited from GeometryData
enum  GeometryType {
  PointCloud , LineMesh , PlainTriMesh , IdxTriMesh ,
  SpherePrim , BoxPrim , OBBPrim , AABBPrim ,
  LinePrim , PointPrim , PyramidPrim , ConePrim ,
  TrianglePrim , CylinderPrim , TubePrim , PlanePrim ,
  RayPrim , Implicit , Quadratic , UserType
}
 geometry data types
 
typedef rw::core::Ptr< GeometryDataPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const GeometryDataCPtr
 const smart pointer type to this class
 

Public Member Functions

 IndexedTriMeshN0 ()
 Constructor.
 
 IndexedTriMeshN0 (VertexArray *vertices)
 constructor - ownership of the vertice array is taken More...
 
 IndexedTriMeshN0 (rw::core::Ptr< VertexArray > vertices, rw::core::Ptr< VertexArray > normals)
 constructor - ownership of the vertice array is taken More...
 
 IndexedTriMeshN0 (rw::core::Ptr< VertexArray > vertices, rw::core::Ptr< VertexArray > normals, rw::core::Ptr< TriangleArray > triangles)
 constructor More...
 
 IndexedTriMeshN0 (rw::core::Ptr< VertexArray > vertices, rw::core::Ptr< TriangleArray > triangles)
 constructor More...
 
 IndexedTriMeshN0 (const rw::geometry::IndexedTriMeshN0< T, S > &mesh)
 Make deep copy of mesh. More...
 
virtual ~IndexedTriMeshN0 ()
 Destructor.
 
const rw::math::Vector3D< T > & getVertexNormal (size_t i, VertexIdx vidx) const
 Get normal of vertex vidx of triangle at index i. More...
 
rw::math::Vector3D< T > & getVertexNormal (size_t i, VertexIdx vidx)
 Get normal of vertex vidx of triangle at index i. More...
 
const rw::math::Vector3D< T > & getVertex (size_t i, VertexIdx vidx) const
 get vertex vidx of triangle at index i. More...
 
rw::math::Vector3D< T > & getVertex (size_t i, VertexIdx vidx)
 get vertex vidx of triangle at index i. More...
 
rw::geometry::IndexedTriangle< uint32_t > getIndexedTriangle (size_t i) const
 get the indexed triangle at index i More...
 
rw::geometry::Triangle< double > getTriangle (size_t i) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t i, rw::geometry::Triangle< double > &dst) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t i, rw::geometry::Triangle< float > &dst) const
 gets the triangle at index idx. More...
 
void add (const tri_type &triangle)
 Add indexed triangle to the triangle mesh. More...
 
const rw::math::Vector3D< T > & getTriVertex (size_t i, size_t triIdx) const
 get vertex i of triangle at index triIdx. More...
 
rw::math::Vector3D< T > & getTriVertex (size_t i, size_t triIdx)
 get vertex i of triangle at index triIdx. More...
 
TriangleArraygetTriangles ()
 get triangle list More...
 
const TriangleArraygetTriangles () const
 get triangle list More...
 
tri_typeoperator[] (int i)
 get indexed triangle at index i More...
 
const tri_typeoperator[] (int i) const
 get indexed triangle at index i More...
 
calcFaceArea (size_t triIdx)
 calculate area of triangle at index triIdx More...
 
rw::math::Vector3D< T > calcFaceCentroid (size_t triIdx)
 calculate centroid of triangle at index triIdx More...
 
rw::math::Vector3D< T > calcFaceNormal (size_t triIdx) const
 calculate face normal of triangle at index triIdx More...
 
void resize (size_t nsize)
 Set the number of triangles in the mesh. More...
 
int getNrTris () const
 The number of triangles in the mesh. More...
 
size_t getSize () const
 gets the number of triangles in the triangle array. More...
 
TriMesh::Ptr clone () const
 make a clone of this triangle mesh More...
 
- Public Member Functions inherited from IndexedTriMesh< double >
const std::vector< rw::math::Vector3D< double > > & getNormals () const
 Get vector of normals. More...
 
std::vector< rw::math::Vector3D< double > > & getNormals ()
 Get vector of normals. More...
 
const std::vector< rw::math::Vector3D< double > > & getVertices () const
 Get vector of vertices. More...
 
std::vector< rw::math::Vector3D< double > > & getVertices ()
 Get vector of vertices. More...
 
uint8_t getTriangleStride () const
 The stride of a triangle. More...
 
uint8_t getIndexSize () const
 The size of the index type used. More...
 
uint8_t * getIndexPtr ()
 Pointer to the start of the index array. More...
 
virtual size_t size () const
 gets the number of triangles in the triangle array. More...
 
rw::math::Vector3D< double > & getVertex (size_t i)
 Get vertex from vertex list. More...
 
const rw::math::Vector3D< double > & getVertex (size_t i) const
 Get vertex from vertex list. More...
 
bool hasVertexNormals () const
 Check if trimesh has vertex normals defined. More...
 
bool hasFaceNormals () const
 Check if trimesh has face normals defined. More...
 
GeometryData::GeometryType getType () const
 the type of this primitive More...
 
void * getIndices ()
 Get pointer to first element of index array. More...
 
void scale (double scale)
 Scale all vertices in the mesh. More...
 
- Public Member Functions inherited from TriMesh
virtual ~TriMesh ()
 destructor
 
rw::core::Ptr< TriMeshgetTriMesh (bool forceCopy=true)
 gets a trimesh representation of this geometry data. More...
 
rw::core::Ptr< const TriMeshgetTriMesh (bool forceCopy=true) const
 gets a trimesh representation of this geometry data. More...
 
virtual bool isConvex ()
 test if this geometry data is convex More...
 
void setConvexEnabled (bool isConvex)
 
double getVolume () const
 calculate a volume of this triangle mesh
 
- Public Member Functions inherited from GeometryData
virtual ~GeometryData ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from GeometryData
static std::string toString (GeometryType type)
 format GeometryType to string More...
 
- Protected Member Functions inherited from IndexedTriMesh< double >
 IndexedTriMesh (rw::core::Ptr< VertexArray > vertices, rw::core::Ptr< VertexArray > normals, uint8_t triStride, uint8_t idxsize)
 generic constructor More...
 
 ~IndexedTriMesh ()
 Destructor.
 
void setTriArray (uint8_t *triarray)
 Sets the indice array. More...
 
- Protected Attributes inherited from IndexedTriMesh< double >
VertexArray_vertices
 pointer to vertice array
 
rw::core::Ptr< VertexArray_vertPtr
 Smart pointer to maintain ownership of vertice array.
 
VertexArray_normals
 pointer to normal array
 
rw::core::Ptr< VertexArray_normPtr
 Smart pointer to maintain ownership of normals array.
 
uint8_t * _triIdxArr
 pointer to indice array
 
const uint8_t _stride
 The stride.
 
const uint8_t _idxsize
 Size of index.
 

Detailed Description

template<class T = double, class S = uint16_t>
class rw::geometry::IndexedTriMeshN0< T, S >

an Indexed Triangle mesh with zero normals

Member Typedef Documentation

◆ VertexArray

the vertex array type

Constructor & Destructor Documentation

◆ IndexedTriMeshN0() [1/5]

IndexedTriMeshN0 ( VertexArray vertices)
inline

constructor - ownership of the vertice array is taken

Parameters
vertices[in] pointer to vector of vertices.

◆ IndexedTriMeshN0() [2/5]

IndexedTriMeshN0 ( rw::core::Ptr< VertexArray vertices,
rw::core::Ptr< VertexArray normals 
)
inline

constructor - ownership of the vertice array is taken

Parameters
vertices[in] pointer to vector of vertices.
normals[in] pointer to vector of normals.

◆ IndexedTriMeshN0() [3/5]

IndexedTriMeshN0 ( rw::core::Ptr< VertexArray vertices,
rw::core::Ptr< VertexArray normals,
rw::core::Ptr< TriangleArray triangles 
)
inline

constructor

Parameters
vertices[in] pointer to vector of vertices.
normals[in] pointer to vector of normals (expects same length as either vertices or triangles).
triangles[in] pointer to array of triangles.

◆ IndexedTriMeshN0() [4/5]

IndexedTriMeshN0 ( rw::core::Ptr< VertexArray vertices,
rw::core::Ptr< TriangleArray triangles 
)
inline

constructor

Parameters
vertices[in] pointer to vector of vertices.
triangles[in] pointer to array of triangles.

◆ IndexedTriMeshN0() [5/5]

IndexedTriMeshN0 ( const rw::geometry::IndexedTriMeshN0< T, S > &  mesh)
inline

Make deep copy of mesh.

Parameters
mesh[in] the mesh to copy.

Member Function Documentation

◆ add()

void add ( const tri_type triangle)
inline

Add indexed triangle to the triangle mesh.

Parameters
triangle[in] the indexed triangle to add.

◆ calcFaceArea()

T calcFaceArea ( size_t  triIdx)
inline

calculate area of triangle at index triIdx

Returns
the area.

◆ calcFaceCentroid()

rw::math::Vector3D<T> calcFaceCentroid ( size_t  triIdx)
inline

calculate centroid of triangle at index triIdx

Returns
the centroid.

◆ calcFaceNormal()

rw::math::Vector3D<T> calcFaceNormal ( size_t  triIdx) const
inline

calculate face normal of triangle at index triIdx

Returns
the face normal.

◆ clone()

TriMesh::Ptr clone ( ) const
inlinevirtual

make a clone of this triangle mesh

Returns
clone of this trimesh

Implements TriMesh.

◆ getIndexedTriangle()

rw::geometry::IndexedTriangle<uint32_t> getIndexedTriangle ( size_t  i) const
inlinevirtual

get the indexed triangle at index i

Parameters
i[in] the index of the triangle
Returns
an indexed triangle
Warning
Using the virtual function comes with a performance penalty. If possible, use functions implemented on subtypes directly.

Implements IndexedTriMesh< double >.

◆ getNrTris()

int getNrTris ( ) const
inlinevirtual

The number of triangles in the mesh.

Returns
nr of triangles

Implements IndexedTriMesh< double >.

◆ getSize()

size_t getSize ( ) const
inlinevirtual

gets the number of triangles in the triangle array.

Reimplemented from TriMesh.

◆ getTriangle() [1/3]

rw::geometry::Triangle<double> getTriangle ( size_t  i) const
inlinevirtual

gets the triangle at index idx.

Parameters
idx[in] the index of the triangle.
Returns
the triangle at index idx

Implements TriMesh.

◆ getTriangle() [2/3]

void getTriangle ( size_t  i,
rw::geometry::Triangle< double > &  dst 
) const
inlinevirtual

gets the triangle at index idx.

Parameters
idx[in] the index of the triangle.
Returns
the triangle at index idx

Implements TriMesh.

◆ getTriangle() [3/3]

void getTriangle ( size_t  i,
rw::geometry::Triangle< float > &  dst 
) const
inlinevirtual

gets the triangle at index idx.

Parameters
idx[in] the index of the triangle.
Returns
the triangle at index idx

Implements TriMesh.

◆ getTriangles() [1/2]

TriangleArray& getTriangles ( )
inline

get triangle list

Returns
vector of triangles

◆ getTriangles() [2/2]

const TriangleArray& getTriangles ( ) const
inline

get triangle list

Returns
vector of triangles

◆ getTriVertex() [1/2]

rw::math::Vector3D<T>& getTriVertex ( size_t  i,
size_t  triIdx 
)
inline

get vertex i of triangle at index triIdx.

Parameters
i[in] should be in interval [0;2]
triIdx[in] index of triangle in the triangle mesh
Returns
a reference to the given vertex.

◆ getTriVertex() [2/2]

const rw::math::Vector3D<T>& getTriVertex ( size_t  i,
size_t  triIdx 
) const
inline

get vertex i of triangle at index triIdx.

Parameters
i[in] should be in interval [0;2]
triIdx[in] index of triangle in the triangle mesh
Returns
a reference to the given vertex.

◆ getVertex() [1/2]

rw::math::Vector3D<T>& getVertex ( size_t  i,
VertexIdx  vidx 
)
inlinevirtual

get vertex vidx of triangle at index i.

Parameters
i[in] the index of the triangle
vidx[in] the index of the triangle vertex
Returns
reference to vertex.
Warning
Using the virtual function comes with a performance penalty. If possible, use functions implemented on subtypes directly (like IndexedTriMeshN0::getTriVertex).

Implements IndexedTriMesh< double >.

◆ getVertex() [2/2]

const rw::math::Vector3D<T>& getVertex ( size_t  i,
VertexIdx  vidx 
) const
inlinevirtual

get vertex vidx of triangle at index i.

Parameters
i[in] the index of the triangle
vidx[in] the index of the triangle vertex
Returns
reference to vertex.
Warning
Using the virtual function comes with a performance penalty. If possible, use functions implemented on subtypes directly (like IndexedTriMeshN0::getTriVertex).

Implements IndexedTriMesh< double >.

◆ getVertexNormal() [1/2]

rw::math::Vector3D<T>& getVertexNormal ( size_t  i,
VertexIdx  vidx 
)
inlinevirtual

Get normal of vertex vidx of triangle at index i.

Parameters
i[in] the index of the triangle.
vidx[in] the triangle vertex.
Returns
reference to normal vector.
Warning
Using the virtual function comes with a performance penalty. If possible, use functions implemented on subtypes directly.

Implements IndexedTriMesh< double >.

◆ getVertexNormal() [2/2]

const rw::math::Vector3D<T>& getVertexNormal ( size_t  i,
VertexIdx  vidx 
) const
inlinevirtual

Get normal of vertex vidx of triangle at index i.

Parameters
i[in] the index of the triangle.
vidx[in] the triangle vertex.
Returns
reference to normal vector.
Warning
Using the virtual function comes with a performance penalty. If possible, use functions implemented on subtypes directly.

Implements IndexedTriMesh< double >.

◆ operator[]() [1/2]

tri_type& operator[] ( int  i)
inline

get indexed triangle at index i

Returns
a reference to the triangle.

◆ operator[]() [2/2]

const tri_type& operator[] ( int  i) const
inline

get indexed triangle at index i

Returns
a reference to the triangle.

◆ resize()

void resize ( size_t  nsize)
inline

Set the number of triangles in the mesh.

Parameters
nsize[in] the new size of the mesh.

The documentation for this class was generated from the following file: