Avogadro::Core::Mesh#

class Mesh#

Encapsulation of a triangular mesh that makes up a surface.

The Mesh class is a data container that provides a Mesh object. All meshes should be owned by a Molecule. It should also be removed by the Molecule that owns it. Meshes encapsulate triangular meshes that can also have colors associated with each vertex.

Author

Marcus D. Hanwell

Public Functions

Mesh()#

Constructor.

Mesh(const Mesh &other)#

Copy constructor

~Mesh()#

Destructor.

bool reserve(unsigned int size, bool colors = false)#

Reserve the expected space for the mesh. This causes all member array storage to call the reserve function with the number specified.

Parameters:
  • size – Expected size of the mesh.

  • colors – Should the colors array reserve this space too? Defaults to false.

Returns:

True on success.

void setStable(bool stable)#

This function allows long running calculations to mark the mesh as in progress.

Parameters:

stable – Indicate that the Mesh is currently being modified.

bool stable()#

Indicate whether the Mesh is complete or currently being modified. In general using Mesh values from an unstable Mesh is not advisable.

Returns:

True if the Mesh is complete, false if it is being modified.

inline void setIsoValue(float value)#

Set the iso value that was used to generate the Mesh.

inline float isoValue() const#
Returns:

The iso value used to generate the Mesh.

inline void setOtherMesh(unsigned int other)#

Set the unique id of the other Mesh if this Mesh is part of a pair.

inline unsigned int otherMesh() const#
Returns:

The unique id of the other Mesh if this is part of a pair.

inline void setCube(unsigned int cube_)#

Set the unique id of the Cube the Mesh was generated from.

inline unsigned int cube() const#
Returns:

The unique id of the Cube the Mesh was generated from.

const Core::Array<Vector3f> &vertices() const#
Returns:

Array containing all of the vertices in a one dimensional array.

inline unsigned int numVertices() const#
Returns:

The number of vertices.

const Vector3f *vertex(int n) const#
Returns:

Pointer to the first vertex of the specified triangle.

bool setVertices(const Core::Array<Vector3f> &values)#

Clear the vertices vector and assign new values.

bool addVertices(const Core::Array<Vector3f> &values)#

Add one or more vertices, i.e., the array is expected to be of length 3 x n where n is an integer.

const Core::Array<Vector3f> &normals() const#
Returns:

Array containing all of the normals in a one-dimensional array.

inline unsigned int numNormals() const#
Returns:

The number of normals.

const Vector3f *normal(int n) const#
Returns:

Pointer to the first normal of the specified triangle.

bool setNormals(const Core::Array<Vector3f> &values)#

Clear the normals array and assign new values.

bool addNormals(const Core::Array<Vector3f> &values)#

Add one or more normals, i.e., the array is expected to be of length 3 x n where n is an integer.

const Core::Array<Color3f> &colors() const#
Returns:

Array containing all of the colors in a one-dimensional array.

const Color3f *color(int n) const#
Returns:

Pointer to the first color of the specified triangle.

bool setColors(const Core::Array<Color3f> &values)#

Clear the colors array and assign new values.

bool addColors(const Core::Array<Color3f> &values)#

Add one or more normals, i.e., the array is expected to be of length 3 x n where n is an integer.

bool valid() const#

Sanity checking function - is the mesh sane?

Returns:

True if the Mesh object is sane and composed of the right number of elements.

bool clear()#

Clear all mesh data.

Returns:

True on success.

Mesh &operator=(const Mesh &other)#

Overloaded operator.

inline void setName(const std::string &name_)#

Set the name of the Mesh.

inline std::string name() const#
Returns:

The name of the Mesh.

inline Mutex *lock() const#

Provides locking.

void smooth(int iterationCount = 6)#

Applies Laplacian smoothing.

Parameters:

iterationCount – number of smoothing passes to make.

Friends

friend class Molecule