Class that can generate Mesh objects from Cube objects.
More...
#include <avogadro/qtgui/meshgenerator.h>
|
| 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 |
|
unsigned long | duplicate (const Vector3i &c, const Vector3f &pos) |
|
const Core::Cube * | cube () const |
|
void | calcTrimValues (int &xl, int &xr, int const &j, int const &k) const |
|
unsigned char | calcCubeCase (unsigned char const &ec0, unsigned char const &ec1, unsigned char const &ec2, unsigned char const &ec3) const |
|
Core::Mesh * | mesh () const |
|
void | clear () |
|
int | progressMinimum () |
|
int | progressMaximum () |
|
|
Methods to implement the "flying edges" method for isosurface mesh generation. Flying edges: A high-performance scalable isocontouring algorithm Schroeder; Maynard; Geveci; 2015 IEEE 5th Symposium on Large Data Analysis and Visualization (LDAV) 10.1109/LDAV.2015.7348069 Alternate (non-VTK) implementation at https://github.com/sandialabs/miniIsosurface/blob/master/flyingEdges/
|
void | FlyingEdgesAlgorithmPass1 () |
|
void | FlyingEdgesAlgorithmPass2 () |
|
void | FlyingEdgesAlgorithmPass3 () |
|
void | FlyingEdgesAlgorithmPass4 () |
|
|
bool | isCutEdge (int const &i, int const &j, int const &k) const |
|
std::array< float, 3 > | interpolateOnCube (std::array< std::array< float, 3 >, 8 > const &pts, std::array< float, 8 > const &isovals, unsigned char const &edge) const |
|
std::array< float, 3 > | interpolate (std::array< float, 3 > const &a, std::array< float, 3 > const &b, float const &weight) const |
|
unsigned char | calcCaseEdge (bool const &prevEdge, bool const &currEdge) const |
|
|
static const unsigned char | m_numTris [256] |
|
static const bool | m_isCut [256][12] |
|
static const signed char | m_caseTriangles [256][16] |
|
static const unsigned char | m_edgeVertices [12][2] |
|
- Author
- Marcus D. Hanwell
-
Perminder Singh
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.
◆ MeshGenerator() [1/2]
◆ MeshGenerator() [2/2]
Constructor. Can be used to initialize the MeshGenerator.
- Parameters
-
cube | The source Cube with the volumetric data. |
mesh | The Mesh that will hold the isosurface. |
iso | The iso value of the surface. |
passes | Number of smoothing passes to perform. |
- Returns
- True if the MeshGenerator was successfully initialized.
◆ ~MeshGenerator()
◆ 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
-
cube | The source Cube with the volumetric data. |
mesh | The Mesh that will hold the isosurface. |
iso | The iso value of the surface. |
passes | Number of smoothing passes to perform. |
◆ run()
Use this function to begin Mesh generation. Uses an asynchronous thread, and so avoids locking the user interface while the isosurface is found.
◆ duplicate()
unsigned long duplicate |
( |
const Vector3i & |
c, |
|
|
const Vector3f & |
pos |
|
) |
| |
Handles duplicate vertices (Not implemented). Placeholder for future functionality.
◆ FlyingEdgesAlgorithmPass1()
void FlyingEdgesAlgorithmPass1 |
( |
| ) |
|
Pass 1 for flying edges. Pass1 detects and records where the isosurface intersects each row of grid edges along the x-axis.
◆ FlyingEdgesAlgorithmPass2()
void FlyingEdgesAlgorithmPass2 |
( |
| ) |
|
Pass2 assigns case identifiers to each grid cell based on intersected edges and tallies the number of triangles needed for mesh construction.
◆ FlyingEdgesAlgorithmPass3()
void FlyingEdgesAlgorithmPass3 |
( |
| ) |
|
Pass3 computes cumulative offsets for triangles and vertices and allocates memory for the mesh structures.
◆ FlyingEdgesAlgorithmPass4()
void FlyingEdgesAlgorithmPass4 |
( |
| ) |
|
Calculates normals, triangles and vertices.
◆ cube()
- Returns
- The Cube being used by the class.
◆ calcTrimValues()
void calcTrimValues |
( |
int & |
xl, |
|
|
int & |
xr, |
|
|
int const & |
j, |
|
|
int const & |
k |
|
) |
| const |
Determines the x-range (xl to xr) where isosurface intersections occur, optimizing calculations within this range.
◆ calcCubeCase()
unsigned char calcCubeCase |
( |
unsigned char const & |
ec0, |
|
|
unsigned char const & |
ec1, |
|
|
unsigned char const & |
ec2, |
|
|
unsigned char const & |
ec3 |
|
) |
| const |
Indicates which edges intersects the isosurface.
◆ mesh()
- Returns
- The Mesh being generated by the class.
◆ clear()
◆ progressMinimum()
- Returns
- The minimum value of the progress value.
◆ progressMaximum()
- Returns
- The maximum value of the progress value.
◆ progressValueChanged
void progressValueChanged |
( |
int |
| ) |
|
|
signal |
The current value of the calculation's progress.
◆ isCutEdge()
bool isCutEdge |
( |
int const & |
i, |
|
|
int const & |
j, |
|
|
int const & |
k |
|
) |
| const |
|
protected |
isCutEdge checks whether the grid edge at position (i, j, k) is intersected by the isosurface based on edge case conditions.
- Returns
- Boolean if it's intersected or not.
◆ interpolateOnCube()
std::array< float, 3 > interpolateOnCube |
( |
std::array< std::array< float, 3 >, 8 > const & |
pts, |
|
|
std::array< float, 8 > const & |
isovals, |
|
|
unsigned char const & |
edge |
|
) |
| const |
|
protected |
It computes the 3D intersection point on a cube edge via interpolation.
◆ interpolate()
std::array< float, 3 > interpolate |
( |
std::array< float, 3 > const & |
a, |
|
|
std::array< float, 3 > const & |
b, |
|
|
float const & |
weight |
|
) |
| const |
|
protected |
It linearly interpolates between two 3D points, a and b, using the given weight to determine the intermediate position.
◆ calcCaseEdge()
unsigned char calcCaseEdge |
( |
bool const & |
prevEdge, |
|
|
bool const & |
currEdge |
|
) |
| const |
|
protected |
calcCaseEdge determines an edge case code (0–3) based on two boolean edge comparisons.
◆ m_passes
The value of the isosurface.
◆ m_reverseWinding
Number of smoothing passes to perform.
◆ m_cube
Whether the winding and normals are reversed.
◆ m_mesh
The cube that we are generating a Mesh from.
◆ m_stepSize
The mesh that is being generated.
◆ m_min
The step size vector for cube.
◆ m_dim
The minimum point in the cube.
◆ m_normals
The dimensions of the cube.
◆ m_numTris
const unsigned char m_numTris[256] |
|
staticprotected |
The documentation for this class was generated from the following file: