RobWorkProject  23.9.11-
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::core::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::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

 PlainTriMesh (std::size_t 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 rw::geometry::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...
 
rw::geometry::Triangle< double > getTriangle (size_t idx) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t idx, rw::geometry::Triangle< double > &dst) const
 gets the triangle at index idx. More...
 
void getTriangle (size_t idx, rw::geometry::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...
 
rw::geometry::GeometryData::GeometryType getType () const
 the type of this primitive More...
 
rw::core::Ptr< rw::geometry::TriMeshclone () const
 make a clone of this triangle 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...
 

Detailed Description

template<class TRI = rw::geometry::Triangle<double>>
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 rw::geometry::PlainTriMesh< TRI >::Ptr  triangles)
inline

Add all triangles in the mesh triangles to this.

Parameters
[in]trianglesTriangle mesh for which to add triangles

◆ clone()

rw::core::Ptr<rw::geometry::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.

Reimplemented from TriMesh.

◆ getTriangle() [1/3]

rw::geometry::Triangle<double> getTriangle ( size_t  idx) 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  idx,
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  idx,
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()

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

the vector of triangles

Returns
a reference to the triangle vector

◆ getType()

rw::geometry::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: