Avogadro::QtGui::MeshGenerator#
-
class MeshGenerator : public QThread#
Class that can generate Mesh objects from Cube objects.
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/
- Author
Marcus D. Hanwell
- Author
Perminder Singh
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.
Flying Edges
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 sandialabs/miniIsosurface
-
void FlyingEdgesAlgorithmPass1()#
Pass 1 for flying edges. Pass1 detects and records where the isosurface intersects each row of grid edges along the x-axis.
-
void FlyingEdgesAlgorithmPass2()#
Pass2 assigns case identifiers to each grid cell based on intersected edges and tallies the number of triangles needed for mesh construction.
-
void FlyingEdgesAlgorithmPass3()#
Pass3 computes cumulative offsets for triangles and vertices and allocates memory for the mesh structures.
-
void FlyingEdgesAlgorithmPass4()#
Calculates normals, triangles and vertices.
Public Functions
-
explicit MeshGenerator(QObject *parent = nullptr)#
Constructor.
-
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:
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() override#
Destructor.
-
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.
-
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.
-
unsigned long duplicate(const Vector3i &c, const Vector3f &pos)#
Handles duplicate vertices (Not implemented). Placeholder for future functionality.
-
inline 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.
-
inline 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.
-
void clear()#
Clears the contents of the MeshGenerator.
-
inline int progressMinimum()#
- Returns:
The minimum value of the progress value.
-
inline int progressMaximum()#
- Returns:
The maximum value of the progress value.
Signals
-
void progressValueChanged(int)#
The current value of the calculation’s progress.
Protected Functions
-
bool isCutEdge(int const &i, int const &j, int const &k) const#
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.
-
inline 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#
It computes the 3D intersection point on a cube edge via interpolation.
-
inline std::array<float, 3> interpolate(std::array<float, 3> const &a, std::array<float, 3> const &b, float const &weight) const#
It linearly interpolates between two 3D points, a and b, using the given weight to determine the intermediate position.
-
inline unsigned char calcCaseEdge(bool const &prevEdge, bool const &currEdge) const#
calcCaseEdge determines an edge case code (0–3) based on two boolean edge comparisons.
Protected Attributes
-
float m_iso#
-
int m_passes#
The value of the isosurface.
-
bool m_reverseWinding#
Number of smoothing passes to perform.
-
Vector3f m_stepSize#
The mesh that is being generated.
-
Vector3f m_min#
The step size vector for cube.
-
Vector3i m_dim#
The minimum point in the cube.
-
std::vector<unsigned char> cubeCases#
-
std::vector<int> triCounter#
-
std::vector<unsigned char> edgeCases#
-
int m_progmin#
-
int m_progmax#
Protected Static Attributes
-
static const unsigned char m_numTris[256]#
These are the lookup tables for flying edges. Reference : sandialabs/miniIsosurface
-
static const bool m_isCut[256][12]#
-
static const char m_caseTriangles[256][16]#
-
static const unsigned char m_edgeVertices[12][2]#