Public Member Functions | Public Attributes | Static Public Attributes | List of all members
shapes::Mesh Class Reference

Definition of a triangle mesh By convention the "center" of the shape is at the origin. For a mesh this implies that the AABB of the mesh is centered at the origin. Some methods may not work with arbitrary meshes whose AABB is not centered at the origin. Padding is not applied to vertices plainly coordinate-wise, but instead the padding value is added to the length of the direction vector between centroid and each vertex. More...

#include <shapes.h>

Inheritance diagram for shapes::Mesh:
Inheritance graph
[legend]

Public Member Functions

Meshclone () const override
 Create a copy of this shape. More...
 
void computeTriangleNormals ()
 Compute the normals of each triangle from its vertices via cross product. More...
 
void computeVertexNormals ()
 Compute vertex normals by averaging from adjacent triangle normals. More...
 
void mergeVertices (double threshold)
 Merge vertices that are very close to each other, up to a threshold. More...
 
 Mesh ()
 
 Mesh (unsigned int v_count, unsigned int t_count)
 
void padd (double paddX, double paddY, double paddZ)
 Add non-uniform padding to this shape. More...
 
void print (std::ostream &out=std::cout) const override
 Print information about this shape. More...
 
void scale (double scaleX, double scaleY, double scaleZ)
 Scale this shape by a non-uniform factor. More...
 
void scaleAndPadd (double scaleX, double scaleY, double scaleZ, double paddX, double paddY, double paddZ)
 Scale this shape by a non-uniform factor and then add non-uniform padding. More...
 
void scaleAndPadd (double scale, double padd) override
 Uniformly scale and padd this shape. More...
 
 ~Mesh () override
 
- Public Member Functions inherited from shapes::Shape
virtual bool isFixed () const
 Return a flag indicating whether this shape can be scaled and/or padded. More...
 
void padd (double padding)
 Add uniform padding to this shape. More...
 
void scale (double scale)
 Uniformly scale this shape by a factor. More...
 
 Shape ()
 
virtual ~Shape ()
 

Public Attributes

unsigned int triangle_count
 The number of triangles formed with the vertices. More...
 
double * triangle_normals
 The normal to each triangle; unit vector represented as (x,y,z); If missing from the mesh, these vectors can be computed using computeTriangleNormals() More...
 
unsigned int * triangles
 The vertex indices for each triangle triangle k has vertices at index (3k, 3k+1, 3k+2) = (v1, v2, v3) More...
 
unsigned int vertex_count
 The number of available vertices. More...
 
double * vertex_normals
 The normal to each vertex; unit vector represented as (x,y,z); If missing from the mesh, these vectors can be computed using computeVertexNormals() More...
 
double * vertices
 The position for each vertex vertex k has values at index (3k, 3k+1, 3k+2) = (x,y,z) More...
 
- Public Attributes inherited from shapes::Shape
ShapeType type
 The type of the shape. More...
 

Static Public Attributes

static const std::string STRING_NAME = "mesh"
 The type of the shape, as a string. More...
 

Detailed Description

Definition of a triangle mesh By convention the "center" of the shape is at the origin. For a mesh this implies that the AABB of the mesh is centered at the origin. Some methods may not work with arbitrary meshes whose AABB is not centered at the origin. Padding is not applied to vertices plainly coordinate-wise, but instead the padding value is added to the length of the direction vector between centroid and each vertex.

Definition at line 281 of file shapes.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

shapes::Mesh::Mesh ( )

Definition at line 156 of file shapes.cpp.

◆ Mesh() [2/2]

shapes::Mesh::Mesh ( unsigned int  v_count,
unsigned int  t_count 
)

Definition at line 167 of file shapes.cpp.

◆ ~Mesh()

shapes::Mesh::~Mesh ( )
override

Definition at line 178 of file shapes.cpp.

Member Function Documentation

◆ clone()

Mesh * shapes::Mesh::clone ( ) const
overridevirtual

Create a copy of this shape.

Implements shapes::Shape.

Definition at line 235 of file shapes.cpp.

◆ computeTriangleNormals()

void shapes::Mesh::computeTriangleNormals ( )

Compute the normals of each triangle from its vertices via cross product.

Definition at line 503 of file shapes.cpp.

◆ computeVertexNormals()

void shapes::Mesh::computeVertexNormals ( )

Compute vertex normals by averaging from adjacent triangle normals.

Calls computeTriangleNormals() if needed.

Definition at line 526 of file shapes.cpp.

◆ mergeVertices()

void shapes::Mesh::mergeVertices ( double  threshold)

Merge vertices that are very close to each other, up to a threshold.

Definition at line 567 of file shapes.cpp.

◆ padd()

void shapes::Mesh::padd ( double  paddX,
double  paddY,
double  paddZ 
)

Add non-uniform padding to this shape.

Parameters
paddXPadding in x-dimension (in meters).
paddYPadding in y-dimension (in meters).
paddZPadding in z-dimension (in meters).
Note
Padding is not applied to vertices plainly coordinate-wise, but instead the padding value is added to the length of the direction vector between centroid and each vertex.

Definition at line 428 of file shapes.cpp.

◆ print()

void shapes::Mesh::print ( std::ostream &  out = std::cout) const
overridevirtual

Print information about this shape.

Reimplemented from shapes::Shape.

Definition at line 463 of file shapes.cpp.

◆ scale()

void shapes::Mesh::scale ( double  scaleX,
double  scaleY,
double  scaleZ 
)

Scale this shape by a non-uniform factor.

Parameters
scaleXScale in x-dimension.
scaleYScale in y-dimension.
scaleZScale in z-dimension.

Definition at line 423 of file shapes.cpp.

◆ scaleAndPadd() [1/2]

void shapes::Mesh::scaleAndPadd ( double  scaleX,
double  scaleY,
double  scaleZ,
double  paddX,
double  paddY,
double  paddZ 
)

Scale this shape by a non-uniform factor and then add non-uniform padding.

Parameters
scaleXScale in x-dimension.
scaleYScale in y-dimension.
scaleZScale in z-dimension.
paddXPadding in x-dimension (in meters).
paddYPadding in y-dimension (in meters).
paddZPadding in z-dimension (in meters).
Note
Padding is not applied to vertices plainly coordinate-wise, but instead the padding value is added to the length of the direction vector between centroid and each vertex.

Definition at line 378 of file shapes.cpp.

◆ scaleAndPadd() [2/2]

void shapes::Mesh::scaleAndPadd ( double  scale,
double  padd 
)
overridevirtual

Uniformly scale and padd this shape.

Implements shapes::Shape.

Definition at line 433 of file shapes.cpp.

Member Data Documentation

◆ STRING_NAME

const std::string shapes::Mesh::STRING_NAME = "mesh"
static

The type of the shape, as a string.

Definition at line 292 of file shapes.h.

◆ triangle_count

unsigned int shapes::Mesh::triangle_count

The number of triangles formed with the vertices.

Definition at line 350 of file shapes.h.

◆ triangle_normals

double* shapes::Mesh::triangle_normals

The normal to each triangle; unit vector represented as (x,y,z); If missing from the mesh, these vectors can be computed using computeTriangleNormals()

Definition at line 358 of file shapes.h.

◆ triangles

unsigned int* shapes::Mesh::triangles

The vertex indices for each triangle triangle k has vertices at index (3k, 3k+1, 3k+2) = (v1, v2, v3)

Definition at line 354 of file shapes.h.

◆ vertex_count

unsigned int shapes::Mesh::vertex_count

The number of available vertices.

Definition at line 343 of file shapes.h.

◆ vertex_normals

double* shapes::Mesh::vertex_normals

The normal to each vertex; unit vector represented as (x,y,z); If missing from the mesh, these vectors can be computed using computeVertexNormals()

Definition at line 362 of file shapes.h.

◆ vertices

double* shapes::Mesh::vertices

The position for each vertex vertex k has values at index (3k, 3k+1, 3k+2) = (x,y,z)

Definition at line 347 of file shapes.h.


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


geometric_shapes
Author(s): Ioan Sucan , Gil Jones
autogenerated on Fri Apr 14 2023 02:14:40