Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | List of all members
CDPL::Vis::TriangleMesh3D Class Reference

Data structure for the storage of 3D triangle mesh vertices, vertex normals and faces. More...

#include <TriangleMesh3D.hpp>

+ Inheritance diagram for CDPL::Vis::TriangleMesh3D:

Public Types

typedef std::shared_ptr< TriangleMesh3DSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated TriangleMesh3D instances. More...
 
- Public Types inherited from CDPL::Vis::Shape3D
typedef std::shared_ptr< Shape3DSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated Shape3D instances. More...
 

Public Member Functions

Shape3D::SharedPointer clone () const
 Creates a dynamically allocated copy of the triangle mesh. More...
 
void accept (Shape3DVisitor &visitor) const
 Accepts the Vis::Shape3DVisitor instance visitor by dispatching to its visitTriangleMesh() method [VPTN]. More...
 
Math::Vector3DArraygetVertices ()
 Returns a non-const reference to the array storing the mesh vertices. More...
 
const Math::Vector3DArraygetVertices () const
 Returns a const reference to the array storing the mesh vertices. More...
 
void addVertex (double x, double y, double z)
 Appends a new vertex at the position (x, y, z). More...
 
std::size_t getNumVertices () const
 Returns the number of stored vertices. More...
 
Math::Vector3DArraygetVertexNormals ()
 Returns a non-const reference to the array storing the per-vertex normals. More...
 
const Math::Vector3DArraygetVertexNormals () const
 Returns a const reference to the array storing the per-vertex normals. More...
 
void addVertexNormal (double x, double y, double z)
 Appends a new vertex normal with the components (x, y, z). More...
 
std::size_t getNumVertexNormals () const
 Returns the number of stored vertex normals. More...
 
Math::Vector3ULArraygetFaces ()
 Returns a non-const reference to the array storing the triangle faces. More...
 
const Math::Vector3ULArraygetFaces () const
 Returns a const reference to the array storing the triangle faces. More...
 
void addFace (unsigned long v1_idx, unsigned long v2_idx, unsigned long v3_idx)
 Appends a new triangle face defined by the three vertex indices v1_idx, v2_idx and v3_idx. More...
 
std::size_t getNumFaces () const
 Returns the number of stored triangle faces. More...
 
bool isClosed () const
 Tells whether the mesh has been flagged as a closed surface. More...
 
void setClosed (bool closed=true)
 Sets the flag that marks the mesh as a closed surface. More...
 
void clear ()
 Removes all vertices, vertex normals and faces and resets the closed-surface flag. More...
 
void swap (TriangleMesh3D &mesh)
 Swaps the vertices, vertex normals and faces of this mesh with those of mesh. More...
 
TriangleMesh3Doperator+= (const TriangleMesh3D &mesh)
 Appends the vertices, vertex normals and (vertex index corrected) faces of mesh to this mesh. More...
 
- Public Member Functions inherited from CDPL::Vis::Shape3D
virtual ~Shape3D ()
 Virtual destructor. More...
 

Detailed Description

Data structure for the storage of 3D triangle mesh vertices, vertex normals and faces.

Since
1.3

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated TriangleMesh3D instances.

Member Function Documentation

◆ clone()

Shape3D::SharedPointer CDPL::Vis::TriangleMesh3D::clone ( ) const
virtual

Creates a dynamically allocated copy of the triangle mesh.

Returns
A smart pointer to the copy.

Implements CDPL::Vis::Shape3D.

◆ accept()

void CDPL::Vis::TriangleMesh3D::accept ( Shape3DVisitor visitor) const
virtual

Accepts the Vis::Shape3DVisitor instance visitor by dispatching to its visitTriangleMesh() method [VPTN].

Parameters
visitorThe Vis::Shape3DVisitor instance to accept.

Implements CDPL::Vis::Shape3D.

◆ getVertices() [1/2]

Math::Vector3DArray& CDPL::Vis::TriangleMesh3D::getVertices ( )

Returns a non-const reference to the array storing the mesh vertices.

Returns
A non-const reference to the vertex array.

◆ getVertices() [2/2]

const Math::Vector3DArray& CDPL::Vis::TriangleMesh3D::getVertices ( ) const

Returns a const reference to the array storing the mesh vertices.

Returns
A const reference to the vertex array.

◆ addVertex()

void CDPL::Vis::TriangleMesh3D::addVertex ( double  x,
double  y,
double  z 
)

Appends a new vertex at the position (x, y, z).

Parameters
xThe x-coordinate of the vertex.
yThe y-coordinate of the vertex.
zThe z-coordinate of the vertex.

◆ getNumVertices()

std::size_t CDPL::Vis::TriangleMesh3D::getNumVertices ( ) const

Returns the number of stored vertices.

Returns
The vertex count.

◆ getVertexNormals() [1/2]

Math::Vector3DArray& CDPL::Vis::TriangleMesh3D::getVertexNormals ( )

Returns a non-const reference to the array storing the per-vertex normals.

Returns
A non-const reference to the vertex-normal array.

◆ getVertexNormals() [2/2]

const Math::Vector3DArray& CDPL::Vis::TriangleMesh3D::getVertexNormals ( ) const

Returns a const reference to the array storing the per-vertex normals.

Returns
A const reference to the vertex-normal array.

◆ addVertexNormal()

void CDPL::Vis::TriangleMesh3D::addVertexNormal ( double  x,
double  y,
double  z 
)

Appends a new vertex normal with the components (x, y, z).

Parameters
xThe x-component of the normal vector.
yThe y-component of the normal vector.
zThe z-component of the normal vector.

◆ getNumVertexNormals()

std::size_t CDPL::Vis::TriangleMesh3D::getNumVertexNormals ( ) const

Returns the number of stored vertex normals.

Returns
The vertex normal count.

◆ getFaces() [1/2]

Math::Vector3ULArray& CDPL::Vis::TriangleMesh3D::getFaces ( )

Returns a non-const reference to the array storing the triangle faces.

Returns
A non-const reference to the face array.

◆ getFaces() [2/2]

const Math::Vector3ULArray& CDPL::Vis::TriangleMesh3D::getFaces ( ) const

Returns a const reference to the array storing the triangle faces.

Returns
A const reference to the face array.

◆ addFace()

void CDPL::Vis::TriangleMesh3D::addFace ( unsigned long  v1_idx,
unsigned long  v2_idx,
unsigned long  v3_idx 
)

Appends a new triangle face defined by the three vertex indices v1_idx, v2_idx and v3_idx.

Parameters
v1_idxThe zero-based index of the first vertex.
v2_idxThe zero-based index of the second vertex.
v3_idxThe zero-based index of the third vertex.

◆ getNumFaces()

std::size_t CDPL::Vis::TriangleMesh3D::getNumFaces ( ) const

Returns the number of stored triangle faces.

Returns
The face count.

◆ isClosed()

bool CDPL::Vis::TriangleMesh3D::isClosed ( ) const

Tells whether the mesh has been flagged as a closed surface.

Returns
true if the mesh is flagged as closed, and false otherwise.

◆ setClosed()

void CDPL::Vis::TriangleMesh3D::setClosed ( bool  closed = true)

Sets the flag that marks the mesh as a closed surface.

Parameters
closedtrue to flag the mesh as closed, and false otherwise.

◆ clear()

void CDPL::Vis::TriangleMesh3D::clear ( )

Removes all vertices, vertex normals and faces and resets the closed-surface flag.

◆ swap()

void CDPL::Vis::TriangleMesh3D::swap ( TriangleMesh3D mesh)

Swaps the vertices, vertex normals and faces of this mesh with those of mesh.

Parameters
meshThe mesh to swap with.

◆ operator+=()

TriangleMesh3D& CDPL::Vis::TriangleMesh3D::operator+= ( const TriangleMesh3D mesh)

Appends the vertices, vertex normals and (vertex index corrected) faces of mesh to this mesh.

Parameters
meshThe mesh to append.
Returns
A reference to itself.

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