AvogadroLibs 1.97.0
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MeshGenerator Class Reference

Class that can generate Mesh objects from Cube objects. More...

#include <avogadro/qtgui/meshgenerator.h>

Inheritance diagram for MeshGenerator:

Signals

void progressValueChanged (int)
 

Public Member Functions

 MeshGenerator (QObject *parent=nullptr)
 
 MeshGenerator (const Core::Cube *cube, Core::Mesh *mesh, float iso, int passes=6, bool reverse=false, QObject *parent=nullptr)
 
 ~MeshGenerator () override
 
bool initialize (const Core::Cube *cube, Core::Mesh *mesh, float iso, int passes=6, bool reverse=false)
 
void run () override
 
const Core::Cubecube () const
 
Core::Meshmesh () const
 
void clear ()
 
int progressMinimum ()
 
int progressMaximum ()
 

Protected Member Functions

Vector3f normal (const Vector3f &pos)
 
float offset (float val1, float val2)
 
unsigned long duplicate (const Vector3i &c, const Vector3f &pos)
 
bool marchingCube (const Vector3i &pos)
 

Protected Attributes

float m_iso
 
int m_passes
 
bool m_reverseWinding
 
const Core::Cubem_cube
 
Core::Meshm_mesh
 
Vector3f m_stepSize
 
Vector3f m_min
 
Vector3i m_dim
 
Core::Array< Vector3f > m_vertices
 
Core::Array< Vector3f > m_normals
 
Core::Array< unsigned int > m_indices
 
int m_progmin
 
int m_progmax
 

Static Protected Attributes

static const float a2fVertexOffset [8][3]
 
static const int a2iVertexOffset [8][3]
 
static const int a2iEdgeConnection [12][2]
 
static const float a2fEdgeDirection [12][3]
 
static const int a2iTetrahedronEdgeConnection [6][2]
 
static const int a2iTetrahedronsInACube [6][4]
 
static const long aiTetrahedronEdgeFlags [16]
 
static const int a2iTetrahedronTriangles [16][7]
 
static const long aiCubeEdgeFlags [256]
 
static const int a2iTriangleConnectionTable [256][16]
 

Detailed Description

Author
Marcus D. Hanwell

This class implements a method of generating an isosurface Mesh from volumetric data using the marching cubes algorithm. In the case of the MeshGenerator class it expects a Cube as an input and an isosurface value. The tables and the basic code is taken from the public domain code written by Cory Bloyd (marchingsource.cpp) and available at, http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/

You must first initialize the class and then call run() to actually polygonize the isosurface. Connect to the classes finished() signal to do something once the polygonization is complete.

Constructor & Destructor Documentation

◆ MeshGenerator() [1/2]

MeshGenerator ( QObject *  parent = nullptr)
explicit

Constructor.

◆ MeshGenerator() [2/2]

MeshGenerator ( const Core::Cube cube,
Core::Mesh mesh,
float  iso,
int  passes = 6,
bool  reverse = false,
QObject *  parent = nullptr 
)

Constructor. Can be used to initialize the MeshGenerator.

Parameters
cubeThe source Cube with the volumetric data.
meshThe Mesh that will hold the isosurface.
isoThe iso value of the surface.
passesNumber of smoothing passes to perform.
Returns
True if the MeshGenerator was successfully initialized.

◆ ~MeshGenerator()

~MeshGenerator ( )
override

Destructor.

Member Function Documentation

◆ initialize()

bool initialize ( const Core::Cube cube,
Core::Mesh mesh,
float  iso,
int  passes = 6,
bool  reverse = false 
)

Initialization function, set up the MeshGenerator ready to find an isosurface of the supplied Cube.

Parameters
cubeThe source Cube with the volumetric data.
meshThe Mesh that will hold the isosurface.
isoThe iso value of the surface.
passesNumber of smoothing passes to perform.

◆ run()

void run ( )
override

Use this function to begin Mesh generation. Uses an asynchronous thread, and so avoids locking the user interface while the isosurface is found.

◆ cube()

const Core::Cube * cube ( ) const
Returns
The Cube being used by the class.

◆ mesh()

Core::Mesh * mesh ( ) const
Returns
The Mesh being generated by the class.

◆ clear()

void clear ( )

Clears the contents of the MeshGenerator.

◆ progressMinimum()

int progressMinimum ( )
Returns
The minimum value of the progress value.

◆ progressMaximum()

int progressMaximum ( )
Returns
The maximum value of the progress value.

◆ progressValueChanged

void progressValueChanged ( int  )
signal

The current value of the calculation's progress.

◆ normal()

Vector3f normal ( const Vector3f &  pos)
protected

Get the normal to the supplied point. This operation is quite expensive and so should be avoided wherever possible.

Parameters
posThe position of the vertex whose normal is needed.
Returns
The normal vector for the supplied point.

◆ offset()

float offset ( float  val1,
float  val2 
)
protected

Get the offset, i.e. the approximate point of intersection of the surface between two points.

Parameters
val1The position of the vertex whose normal is needed.
Returns
The normal vector for the supplied point.

◆ marchingCube()

bool marchingCube ( const Vector3i &  pos)
protected

Perform a marching cubes step on a single cube.

Member Data Documentation

◆ m_passes

int m_passes
protected

The value of the isosurface.

◆ m_reverseWinding

bool m_reverseWinding
protected

Number of smoothing passes to perform.

◆ m_cube

const Core::Cube* m_cube
protected

Whether the winding and normals are reversed.

◆ m_mesh

Core::Mesh* m_mesh
protected

The cube that we are generating a Mesh from.

◆ m_stepSize

Vector3f m_stepSize
protected

The mesh that is being generated.

◆ m_min

Vector3f m_min
protected

The step size vector for cube.

◆ m_dim

Vector3i m_dim
protected

The minimum point in the cube.

◆ m_vertices

Core::Array<Vector3f> m_vertices
protected

The dimensions of the cube.

◆ a2fVertexOffset

const float a2fVertexOffset[8][3]
staticprotected

These are the tables of constants for the marching cubes and tetrahedra algorithms. They are taken from the public domain source at http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/


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