Gazebo Common

API Reference

4.7.0

A 3D mesh. More...

#include <ignition/common/Mesh.hh>

Public Member Functions

 Mesh ()
 Constructor. More...
 
virtual ~Mesh ()
 Destructor. More...
 
void AABB (ignition::math::Vector3d &_center, ignition::math::Vector3d &_minXYZ, ignition::math::Vector3d &_maxXYZ) const
 Get axis-aligned bounding box in the mesh frame. More...
 
int AddMaterial (const MaterialPtr &_mat)
 Add a material to the mesh. More...
 
std::weak_ptr< SubMeshAddSubMesh (const SubMesh &_child)
 Add a submesh mesh. This can be an expensive since _child is copied into this mesh. More...
 
std::weak_ptr< SubMeshAddSubMesh (std::unique_ptr< SubMesh > _child)
 Add a submesh mesh. This transfers ownership of _child to this mesh. The value of _child after this call is nullptr. More...
 
void Center (const ignition::math::Vector3d &_center=ignition::math::Vector3d::Zero)
 Move the center of the mesh to the given coordinate in the mesh frame. This will move all the vertices in all submeshes. More...
 
void FillArrays (double **_vertArr, int **_indArr) const
 Put all the data into flat arrays. More...
 
void GenSphericalTexCoord (const ignition::math::Vector3d &_center)
 Generate texture coordinates using spherical projection from center. More...
 
bool HasSkeleton () const
 Check if mesh is attached to a skeleton. More...
 
unsigned int IndexCount () const
 Get the number of indices. More...
 
int IndexOfMaterial (const Material *_mat) const
 Get the index of material. More...
 
MaterialPtr MaterialByIndex (const unsigned int _index) const
 Get a material by index. More...
 
unsigned int MaterialCount () const
 Get the number of materials. More...
 
ignition::math::Vector3d Max () const
 Get the maximun X, Y, Z values. More...
 
SkeletonPtr MeshSkeleton () const
 Get the skeleton to which this mesh is attached. More...
 
ignition::math::Vector3d Min () const
 Get the minimum X, Y, Z values. More...
 
std::string Name () const
 Get the name of this mesh. More...
 
unsigned int NormalCount () const
 Get the number of normals. More...
 
std::string Path () const
 Get the path which contains the mesh resource. More...
 
void RecalculateNormals ()
 Recalculate all the normals of each face defined by three indices. More...
 
void Scale (const ignition::math::Vector3d &_factor)
 Scale all vertices by _factor. More...
 
void SetName (const std::string &_name)
 Set the name of this mesh. More...
 
void SetPath (const std::string &_path)
 Set the path which contains the mesh resource. More...
 
void SetScale (const ignition::math::Vector3d &_factor)
 Set the scale all vertices. More...
 
void SetSkeleton (const SkeletonPtr &_skel)
 Set the mesh skeleton. More...
 
std::weak_ptr< SubMeshSubMeshByIndex (const unsigned int _index) const
 Get a child submesh by index. More...
 
std::weak_ptr< SubMeshSubMeshByName (const std::string &_name) const
 Get a child submesh by name. More...
 
unsigned int SubMeshCount () const
 Get the number of child submeshes. More...
 
unsigned int TexCoordCount () const
 Get the number of texture coordinates. More...
 
void Translate (const ignition::math::Vector3d &_vec)
 Move all vertices in all submeshes by _vec. More...
 
unsigned int VertexCount () const
 Get the number of vertices. More...
 
double Volume () const
 Compute the volume of this mesh. The primitive type must be TRIANGLES. More...
 

Detailed Description

A 3D mesh.

Constructor & Destructor Documentation

◆ Mesh()

Mesh ( )

Constructor.

◆ ~Mesh()

virtual ~Mesh ( )
virtual

Destructor.

Member Function Documentation

◆ AABB()

void AABB ( ignition::math::Vector3d _center,
ignition::math::Vector3d _minXYZ,
ignition::math::Vector3d _maxXYZ 
) const

Get axis-aligned bounding box in the mesh frame.

Parameters
[out]_centerCenter of the bounding box
[out]_minXYZBounding box minimum values
[out]_maxXYZBounding box maximum values

◆ AddMaterial()

int AddMaterial ( const MaterialPtr _mat)

Add a material to the mesh.

Parameters
[in]_matThe material to add.
Returns
Index of this material

◆ AddSubMesh() [1/2]

std::weak_ptr<SubMesh> AddSubMesh ( const SubMesh _child)

Add a submesh mesh. This can be an expensive since _child is copied into this mesh.

See also
AddSubMesh(std::unique_ptr<SubMesh> _child);
Parameters
[in]_childthe submesh
Returns
Weak pointer to the added submesh

◆ AddSubMesh() [2/2]

std::weak_ptr<SubMesh> AddSubMesh ( std::unique_ptr< SubMesh _child)

Add a submesh mesh. This transfers ownership of _child to this mesh. The value of _child after this call is nullptr.

Parameters
[in]_childthe submesh
Returns
Weak pointer to the added submesh

◆ Center()

void Center ( const ignition::math::Vector3d _center = ignition::math::Vector3d::Zero)

Move the center of the mesh to the given coordinate in the mesh frame. This will move all the vertices in all submeshes.

Parameters
[in]_centerLocation of the mesh center.

◆ FillArrays()

void FillArrays ( double **  _vertArr,
int **  _indArr 
) const

Put all the data into flat arrays.

Parameters
[out]_vertArrthe vertex array
[out]_indArrthe index array

◆ GenSphericalTexCoord()

void GenSphericalTexCoord ( const ignition::math::Vector3d _center)

Generate texture coordinates using spherical projection from center.

Parameters
[in]_centerCenter of the projection

◆ HasSkeleton()

bool HasSkeleton ( ) const

Check if mesh is attached to a skeleton.

Returns
True if mesh is attached to a skeleton.

◆ IndexCount()

unsigned int IndexCount ( ) const

Get the number of indices.

Returns
The number of indices

◆ IndexOfMaterial()

int IndexOfMaterial ( const Material _mat) const

Get the index of material.

Parameters
[in]_matThe material
Returns
The index of the material or -1 if not found, or _mat is null.

◆ MaterialByIndex()

MaterialPtr MaterialByIndex ( const unsigned int  _index) const

Get a material by index.

Parameters
[in]_indexThe index of the material.
Returns
The material or NULL if the index is out of bounds

◆ MaterialCount()

unsigned int MaterialCount ( ) const

Get the number of materials.

Returns
The number of materials

◆ Max()

ignition::math::Vector3d Max ( ) const

Get the maximun X, Y, Z values.

Returns
The upper bounds of the bounding box

◆ MeshSkeleton()

SkeletonPtr MeshSkeleton ( ) const

Get the skeleton to which this mesh is attached.

Returns
Pointer to skeleton or nullptr if none is present.

◆ Min()

ignition::math::Vector3d Min ( ) const

Get the minimum X, Y, Z values.

Returns
The lower bounds of the bounding box

◆ Name()

std::string Name ( ) const

Get the name of this mesh.

Returns
Name of the mesh.

◆ NormalCount()

unsigned int NormalCount ( ) const

Get the number of normals.

Returns
The number of normals

◆ Path()

std::string Path ( ) const

Get the path which contains the mesh resource.

Returns
The path to the mesh resource

◆ RecalculateNormals()

void RecalculateNormals ( )

Recalculate all the normals of each face defined by three indices.

◆ Scale()

void Scale ( const ignition::math::Vector3d _factor)

Scale all vertices by _factor.

Parameters
_factorScaling factor

◆ SetName()

void SetName ( const std::string _name)

Set the name of this mesh.

Parameters
[in]_nameThe name to set

◆ SetPath()

void SetPath ( const std::string _path)

Set the path which contains the mesh resource.

Parameters
[in]_pathThe file path

◆ SetScale()

void SetScale ( const ignition::math::Vector3d _factor)

Set the scale all vertices.

Parameters
[in]_factorScaling vector

◆ SetSkeleton()

void SetSkeleton ( const SkeletonPtr _skel)

Set the mesh skeleton.

Parameters
[in]_skelSkeleton to attach to the mesh.

◆ SubMeshByIndex()

std::weak_ptr<SubMesh> SubMeshByIndex ( const unsigned int  _index) const

Get a child submesh by index.

Parameters
[in]_indexIndex of the submesh
Returns
The submesh or nullptr if the index is out of bounds.

◆ SubMeshByName()

std::weak_ptr<SubMesh> SubMeshByName ( const std::string _name) const

Get a child submesh by name.

Parameters
[in]_nameName of the submesh.
Returns
The submesh or nullptr if the _name is not found.

◆ SubMeshCount()

unsigned int SubMeshCount ( ) const

Get the number of child submeshes.

Returns
The number of submeshes.

◆ TexCoordCount()

unsigned int TexCoordCount ( ) const

Get the number of texture coordinates.

Returns
The number of texture coordinates

◆ Translate()

void Translate ( const ignition::math::Vector3d _vec)

Move all vertices in all submeshes by _vec.

Parameters
[in]_vecAmount to translate vertices.

◆ VertexCount()

unsigned int VertexCount ( ) const

Get the number of vertices.

Returns
The number of vertices

◆ Volume()

double Volume ( ) const

Compute the volume of this mesh. The primitive type must be TRIANGLES.

This function utilizes the mesh volume formula from "Efficient feature extraction for 2d/3d objects in mesh representation" by Cha Zhang and Tsuhan Chen. Link: http://chenlab.ece.cornell.edu/Publication/Cha/icip01_Cha.pdf. The formula does not check for a closed (water tight) mesh.

Returns
The mesh's volume. The volume can be zero if the primitive type of the submeshes is not TRIANGLES, or there are no submeshes.

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