RobWorkProject  24.5.15-
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
IndexedTriMesh< T > Class Template Referenceabstract

Interface for indexed triangle meshes. More...

#include <IndexedTriMesh.hpp>

Inherits TriMesh.

Public Types

typedef T value_type
 the basic value type of this mesh (for instance double or float)
 
typedef std::vector< rw::math::Vector3D< T > > VertexArray
 the vertex array type
 
typedef rw::core::Ptr< rw::geometry::IndexedTriMesh< T > > 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

const std::vector< rw::math::Vector3D< T > > & getNormals () const
 Get vector of normals. More...
 
std::vector< rw::math::Vector3D< T > > & getNormals ()
 Get vector of normals. More...
 
const std::vector< rw::math::Vector3D< T > > & getVertices () const
 Get vector of vertices. More...
 
std::vector< rw::math::Vector3D< T > > & 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< T > & getVertex (size_t i)
 Get vertex from vertex list. More...
 
const rw::math::Vector3D< T > & 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...
 
virtual const rw::math::Vector3D< T > & getVertexNormal (size_t i, VertexIdx vidx) const =0
 Get normal of vertex vidx of triangle at index i. More...
 
virtual rw::math::Vector3D< T > & getVertexNormal (size_t i, VertexIdx vidx)=0
 Get normal of vertex vidx of triangle at index i. More...
 
virtual const rw::math::Vector3D< T > & getVertex (size_t i, VertexIdx vidx) const =0
 get vertex vidx of triangle at index i. More...
 
virtual rw::math::Vector3D< T > & getVertex (size_t i, VertexIdx vidx)=0
 get vertex vidx of triangle at index i. More...
 
virtual rw::geometry::IndexedTriangle< uint32_t > getIndexedTriangle (size_t i) const =0
 get the indexed triangle at index i More...
 
virtual int getNrTris () const =0
 The number of triangles in the mesh. 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
 
virtual rw::geometry::Triangle< double > getTriangle (size_t idx) const =0
 gets the triangle at index idx. More...
 
virtual void getTriangle (size_t idx, rw::geometry::Triangle< double > &dst) const =0
 gets the triangle at index idx. More...
 
virtual void getTriangle (size_t idx, rw::geometry::Triangle< float > &dst) const =0
 gets the triangle at index idx. Using Floating point presicion More...
 
virtual size_t getSize () const
 gets the number of triangles in the triangle array.
 
virtual rw::core::Ptr< TriMeshclone () const =0
 make a clone of this triangle mesh More...
 
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.
 

Protected Member Functions

 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

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.
 

Additional Inherited Members

- Static Public Member Functions inherited from GeometryData
static std::string toString (GeometryType type)
 format GeometryType to string More...
 

Detailed Description

template<class T = double>
class rw::geometry::IndexedTriMesh< T >

Interface for indexed triangle meshes.

An indexed triangle mesh has a list of vertices and a list of indicies. The indicies is used as reference into the vertex list. Indicies are grouped into threes such that one triangle is defined by three following indicies.

In the IndexedTriMesh classes the indice list is hidden under a list of IndexedTriangle.

Constructor & Destructor Documentation

◆ IndexedTriMesh()

IndexedTriMesh ( rw::core::Ptr< VertexArray vertices,
rw::core::Ptr< VertexArray normals,
uint8_t  triStride,
uint8_t  idxsize 
)
inlineprotected

generic constructor

Parameters
vertices[in] pointer to vertice array (ownership taken)
normals[in] pointer to normal array (NULL if not used) (ownership taken)
triStride[in] the stride of the indice array (set using setTriArray).
idxsize[in] the size in bytes of an indice in the indice array

Member Function Documentation

◆ getIndexedTriangle()

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

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.

Implemented in IndexedTriMeshN0< T, S >.

◆ getIndexPtr()

uint8_t* getIndexPtr ( )
inline

Pointer to the start of the index array.

Returns
pointer to byte array.

◆ getIndexSize()

uint8_t getIndexSize ( ) const
inline

The size of the index type used.

Returns
Typically 2 (uint16_t) or 4 (uint32_t).

◆ getIndices()

void* getIndices ( )
inline

Get pointer to first element of index array.

Returns
pointer to first element.

◆ getNormals() [1/2]

std::vector<rw::math::Vector3D<T> >& getNormals ( )
inline

Get vector of normals.

Returns
reference to vector.

◆ getNormals() [2/2]

const std::vector<rw::math::Vector3D<T> >& getNormals ( ) const
inline

Get vector of normals.

Returns
reference to vector.

◆ getNrTris()

virtual int getNrTris ( ) const
pure virtual

The number of triangles in the mesh.

Returns
nr of triangles

Implemented in IndexedTriMeshN0< T, S >.

◆ getTriangleStride()

uint8_t getTriangleStride ( ) const
inline

The stride of a triangle.

Returns
the stride.

◆ getType()

GeometryData::GeometryType getType ( ) const
inlinevirtual

the type of this primitive

Implements GeometryData.

◆ getVertex() [1/4]

rw::math::Vector3D<T>& getVertex ( size_t  i)
inline

Get vertex from vertex list.

Parameters
i[in] the vertex id (NOT the triangle id).
Returns
a reference to the vertex.

◆ getVertex() [2/4]

const rw::math::Vector3D<T>& getVertex ( size_t  i) const
inline

Get vertex from vertex list.

Parameters
i[in] the vertex id (NOT the triangle id).
Returns
a reference to the vertex.

◆ getVertex() [3/4]

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

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).

Implemented in IndexedTriMeshN0< T, S >.

◆ getVertex() [4/4]

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

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).

Implemented in IndexedTriMeshN0< T, S >.

◆ getVertexNormal() [1/2]

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

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.

Implemented in IndexedTriMeshN0< T, S >.

◆ getVertexNormal() [2/2]

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

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.

Implemented in IndexedTriMeshN0< T, S >.

◆ getVertices() [1/2]

std::vector<rw::math::Vector3D<T> >& getVertices ( )
inline

Get vector of vertices.

Returns
reference to vector.

◆ getVertices() [2/2]

const std::vector<rw::math::Vector3D<T> >& getVertices ( ) const
inline

Get vector of vertices.

Returns
reference to vector.

◆ hasFaceNormals()

bool hasFaceNormals ( ) const
inline

Check if trimesh has face normals defined.

Returns
true if face normals are defined.

◆ hasVertexNormals()

bool hasVertexNormals ( ) const
inline

Check if trimesh has vertex normals defined.

Returns
true if vertex normals are defined.

◆ scale()

void scale ( double  scale)
inlinevirtual

Scale all vertices in the mesh.

Implements TriMesh.

◆ setTriArray()

void setTriArray ( uint8_t *  triarray)
inlineprotected

Sets the indice array.

Parameters
triarray[in] the array.

◆ size()

virtual size_t size ( ) const
inlinevirtual

gets the number of triangles in the triangle array.

Implements TriMesh.


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