RobWorkProject
Public Types | Public Member Functions | List of all members
PlainTriMesh< TRI > Class Template Reference

a triangle mesh representation that maintains a list of simple triangles. More...

#include <PlainTriMesh.hpp>

Inherits TriMesh.

Public Types

typedef rw::common::Ptr< PlainTriMesh< TRI > > Ptr
 smart pointer type of this class
 
typedef TRI::value_type value_type
 the triangle type
 
- Public Types inherited from TriMesh
typedef rw::common::Ptr< TriMeshPtr
 smart pointer type to this class
 
typedef rw::common::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, Quadratic, UserType
}
 geometry data types
 
typedef rw::common::Ptr< GeometryDataPtr
 smart pointer type to this class
 

Public Member Functions

 PlainTriMesh (int initSize=0)
 constructor
 
 PlainTriMesh (const std::vector< TRI > &tris)
 constructor
 
void scale (double scale)
 Scale all vertices in the mesh. More...
 
void add (const TRI &triangle)
 add a triangle to the triangle mesh. More...
 
void add (typename PlainTriMesh< TRI >::Ptr triangles)
 Add all triangles in the mesh triangles to this. More...
 
void clear ()
 Clears the list of triangles.
 
std::vector< TRI > & getTriangles ()
 the vector of triangles More...
 
const TRI & operator[] (size_t i) const
 returns triangle at index i
 
TRI & operator[] (size_t i)
 returns triangle at index i
 
void resize (size_t i)
 resize the triangle mesh More...
 
Triangle< double > getTriangle (size_t idx) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t idx, Triangle< double > &dst) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t idx, Triangle< float > &dst) const
 gets the triangle at index idx. More...
 
size_t getSize () const
 gets the number of triangles in the triangle array. More...
 
size_t size () const
 gets the number of triangles in the triangle array. More...
 
GeometryData::GeometryType getType () const
 the type of this primitive More...
 
rw::common::Ptr< TriMeshclone () const
 make a clone of this triangle mesh More...
 
- Public Member Functions inherited from TriMesh
virtual ~TriMesh ()
 destructor
 
rw::common::Ptr< TriMeshgetTriMesh (bool forceCopy=true)
 gets a trimesh representation of this geometry data. More...
 
rw::common::Ptr< const TriMeshgetTriMesh (bool forceCopy=true) const
 gets a trimesh representation of this geometry data. More...
 
virtual ~TriMesh ()
 destructor
 
rw::common::Ptr< TriMeshgetTriMesh (bool forceCopy=true)
 gets a trimesh representation of this geometry data. More...
 
rw::common::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...
 

Detailed Description

template<class TRI = Triangle<>>
class rw::geometry::PlainTriMesh< TRI >

a triangle mesh representation that maintains a list of simple triangles.

This class is templated and can be setup with different types of triangle storage. Mainly this concerns single or double precision but also number of normals in each Triangle. Check out Triangle.hpp to get an idea of the different types.

The PlainTriMesh can be used as follows

// create trimesh
PlainTriMesh<TriangleN1<float> > mesh;
// add data
mesh.add( TriangleN1<float>(v1,v2,v3) );
mesh.add( TriangleN1<float>(v1,v2,v3) );
mesh.add( TriangleN1<float>(v1,v2,v3) );
// and access the mesh
TriangleN1<float> tri_index1 = mesh[1];
Vector3D<float> normal = mesh[2].getFaceNormal();

To convert the plain trimesh to a more efficient mesh representation take a look at TriangleUtil::toIndexedTriMesh().

Member Function Documentation

◆ add() [1/2]

void add ( const TRI &  triangle)
inline

add a triangle to the triangle mesh.

Parameters
triangle[in] Triangle to add. The triangle is copied.

◆ add() [2/2]

void add ( typename PlainTriMesh< TRI >::Ptr  triangles)
inline

Add all triangles in the mesh triangles to this.

Parameters
[in]Trianglemesh for which to add triangles

◆ clone()

rw::common::Ptr<TriMesh> clone ( ) const
inlinevirtual

make a clone of this triangle mesh

Returns
clone of this trimesh

Implements TriMesh.

◆ getSize()

size_t getSize ( ) const
inlinevirtual

gets the number of triangles in the triangle array.

Implements TriMesh.

◆ getTriangle() [1/3]

Triangle<double> getTriangle ( size_t  idx) const
inlinevirtual

gets the triangle at index idx.

Implements TriMesh.

◆ getTriangle() [2/3]

void getTriangle ( size_t  idx,
Triangle< double > &  dst 
) const
inlinevirtual

gets the triangle at index idx.

Implements TriMesh.

◆ getTriangle() [3/3]

void getTriangle ( size_t  idx,
Triangle< float > &  dst 
) const
inlinevirtual

gets the triangle at index idx.

Implements TriMesh.

◆ getTriangles()

std::vector<TRI>& getTriangles ( )
inline

the vector of triangles

Returns
a reference to the triangle vector

◆ getType()

GeometryData::GeometryType getType ( ) const
inlinevirtual

the type of this primitive

Implements GeometryData.

◆ resize()

void resize ( size_t  i)
inline

resize the triangle mesh

Parameters
i[in] new size of mesh.

◆ scale()

void scale ( double  scale)
inlinevirtual

Scale all vertices in the mesh.

Implements TriMesh.

◆ size()

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: