Loading...
Searching...
No Matches
MeshGenerator Class Reference

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

`#include <avogadro/qtgui/meshgenerator.h>`

Inheritance diagram for MeshGenerator:

## Classes

struct | gridEdge

## 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
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 ()
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 https://github.com/sandialabs/miniIsosurface/blob/master/flyingEdges/
void | FlyingEdgesAlgorithmPass1 ()
void | FlyingEdgesAlgorithmPass2 ()
void | FlyingEdgesAlgorithmPass3 ()
void | FlyingEdgesAlgorithmPass4 ()

## Protected Member Functions

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

## Protected Attributes

float | m_iso
int | m_passes
bool | m_reverseWinding
const Core::Cube * | m_cube
Core::Mesh * | m_mesh
Vector3f | m_stepSize
Vector3f | m_min
Vector3i | m_dim
Core::Array< Vector3f > | m_normals
Core::Array< Vector3f > | m_vertices
std::vector< gridEdge > | gridEdges
std::vector< unsigned char > | cubeCases
std::vector< int > | triCounter
std::vector< unsigned char > | edgeCases
Core::Array< Vector3f > | m_triangles
int | m_progmin
int | m_progmax

## Static Protected Attributes

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]

## Detailed Description

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.

## 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

  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.

## ~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

  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()

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.

## 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()

const Core::Cube * cube | ( |  | ) | const

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()

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.

## 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.

## 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_normals

Core::Array<Vector3f> m_normals

protected

The dimensions of the cube.

## m_numTris

const unsigned char m_numTris[256]

static protected

These are the lookup tables for flying edges. Reference : https://github.com/sandialabs/miniIsosurface/blob/master/flyingEdges/util/MarchingCubesTables.h

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

- meshgenerator.h