Class Mesh

Inheritance Relationships

Base Type

Class Documentation

class Mesh : public shapes::Shape

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.

Public Functions

Mesh()
Mesh(unsigned int v_count, unsigned int t_count)
~Mesh() override
void scale(double scaleX, double scaleY, double scaleZ)

Scale this shape by a non-uniform factor.

Parameters:
  • scaleX – Scale in x-dimension.

  • scaleY – Scale in y-dimension.

  • scaleZ – Scale in z-dimension.

void padd(double paddX, double paddY, double paddZ)

Add non-uniform padding to this shape.

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.

Parameters:
  • paddX – Padding in x-dimension (in meters).

  • paddY – Padding in y-dimension (in meters).

  • paddZ – Padding in z-dimension (in meters).

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.

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.

Parameters:
  • scaleX – Scale in x-dimension.

  • scaleY – Scale in y-dimension.

  • scaleZ – Scale in z-dimension.

  • paddX – Padding in x-dimension (in meters).

  • paddY – Padding in y-dimension (in meters).

  • paddZ – Padding in z-dimension (in meters).

virtual void scaleAndPadd(double scale, double padd) override

Uniformly scale and padd this shape.

virtual Mesh *clone() const override

Create a copy of this shape.

virtual void print(std::ostream &out = std::cout) const override

Print information about this shape.

void computeTriangleNormals()

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

void computeVertexNormals()

Compute vertex normals by averaging from adjacent triangle normals, weighted using magnitude of angles formed by adjacent triangles at the vertex.

Calls computeTriangleNormals() if needed.

void mergeVertices(double threshold)

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

void padd(double padding)

Add uniform padding to this shape.

void scale(double scale)

Uniformly scale this shape by a factor.

Public Members

unsigned int vertex_count

The number of available vertices.

double *vertices

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

unsigned int triangle_count

The number of triangles formed with the vertices.

unsigned int *triangles

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

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

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

Public Static Attributes

static const std::string STRING_NAME

The type of the shape, as a string.