OpenWalnut  1.5.0dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
WMarchingCubesAlgorithm Class Reference

This class does the actual computation of marching cubes. More...

#include <WMarchingCubesAlgorithm.h>

+ Collaboration diagram for WMarchingCubesAlgorithm:

Public Member Functions

 WMarchingCubesAlgorithm ()
 Constructor needed for matrix initalization. More...
 
template<typename T >
std::shared_ptr< WTriangleMeshgenerateSurface (size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ, const WMatrix< double > &mat, const std::vector< T > *vals, double isoValue, std::shared_ptr< WProgressCombiner > mainProgress)
 Generate the triangles for the surface on the given dataSet (inGrid, vals). More...
 

Private Member Functions

template<typename T >
WPointXYZId calculateIntersection (const std::vector< T > *vals, unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo)
 Calculates the intersection point id of the isosurface with an edge. More...
 
WPointXYZId interpolate (double fX1, double fY1, double fZ1, double fX2, double fY2, double fZ2, double tVal1, double tVal2)
 Interpolates between two grid points to produce the point at which the isosurface intersects an edge. More...
 
int getEdgeID (unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo)
 Returns the edge ID. More...
 
unsigned int getVertexID (unsigned int nX, unsigned int nY, unsigned int nZ)
 Returns the ID of the vertex given by by the IDs along the axis. More...
 

Private Attributes

unsigned int m_nCellsX
 No. of cells in x direction. More...
 
unsigned int m_nCellsY
 No. of cells in y direction. More...
 
unsigned int m_nCellsZ
 No. of cells in z direction. More...
 
double m_tIsoLevel
 The isovalue. More...
 
WMatrix< double > m_matrix
 The 4x4 transformation matrix for the triangle vertices. More...
 
ID2WPointXYZId m_idToVertices
 List of WPointXYZIds which form the isosurface. More...
 
WMCTriangleVECTOR m_trivecTriangles
 List of WMCTriangleS which form the triangulation of the isosurface. More...
 

Friends

class WMarchingCubesAlgorithmTest
 Only UnitTests may be friends. More...
 

Detailed Description

This class does the actual computation of marching cubes.

Definition at line 86 of file WMarchingCubesAlgorithm.h.

Constructor & Destructor Documentation

◆ WMarchingCubesAlgorithm()

WMarchingCubesAlgorithm::WMarchingCubesAlgorithm ( )

Constructor needed for matrix initalization.

Definition at line 29 of file WMarchingCubesAlgorithm.cpp.

Member Function Documentation

◆ calculateIntersection()

template<typename T >
WPointXYZId WMarchingCubesAlgorithm::calculateIntersection ( const std::vector< T > *  vals,
unsigned int  nX,
unsigned int  nY,
unsigned int  nZ,
unsigned int  nEdgeNo 
)
private

Calculates the intersection point id of the isosurface with an edge.

Parameters
valsthe values at the vertices
nXid of cell in x direction
nYid of cell in y direction
nZid of cell in z direction
nEdgeNoid of the edge the point that will be interpolates lies on
Returns
intersection point id

Definition at line 396 of file WMarchingCubesAlgorithm.h.

References interpolate(), m_nCellsX, and m_nCellsY.

Referenced by generateSurface(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), and WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateSurface()

template<typename T >
std::shared_ptr< WTriangleMesh > WMarchingCubesAlgorithm::generateSurface ( size_t  nbCoordsX,
size_t  nbCoordsY,
size_t  nbCoordsZ,
const WMatrix< double > &  mat,
const std::vector< T > *  vals,
double  isoValue,
std::shared_ptr< WProgressCombiner mainProgress 
)

Generate the triangles for the surface on the given dataSet (inGrid, vals).

The texture coordinates in the resulting mesh are relative to the grid. This means they are NOT transformed. This ensure faster grid matrix updates in texture space. This might be useful where texture transformation matrices are used.

Parameters
nbCoordsXnumber of vertices in X direction
nbCoordsYnumber of vertices in Y direction
nbCoordsZnumber of vertices in Z direction
matthe matrix transforming the vertices from canonical space
valsthe values at the vertices
isoValueThe surface will run through all positions with this value.
mainProgressprogress combiner used to report our progress to
Returns
the genereated surface

Definition at line 190 of file WMarchingCubesAlgorithm.h.

References calculateIntersection(), getEdgeID(), m_idToVertices, m_matrix, m_nCellsX, m_nCellsY, m_nCellsZ, m_tIsoLevel, m_trivecTriangles, and WMCTriangle::pointID.

+ Here is the call graph for this function:

◆ getEdgeID()

int WMarchingCubesAlgorithm::getEdgeID ( unsigned int  nX,
unsigned int  nY,
unsigned int  nZ,
unsigned int  nEdgeNo 
)
private

Returns the edge ID.

Parameters
nXID of desired cell along x axis
nYID of desired cell along y axis
nZID of desired cell along z axis
nEdgeNoid of edge inside cell
Returns
The id of the edge in the large array.

Definition at line 49 of file WMarchingCubesAlgorithm.cpp.

References getVertexID().

Referenced by generateSurface(), and WMarchingCubesAlgorithmTest::testGetEdgeID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVertexID()

unsigned int WMarchingCubesAlgorithm::getVertexID ( unsigned int  nX,
unsigned int  nY,
unsigned int  nZ 
)
private

Returns the ID of the vertex given by by the IDs along the axis.

Parameters
nXID of desired vertex along x axis
nYID of desired vertex along y axis
nZID of desired vertex along z axis
Returns
ID of vertex with the given coordinates

Definition at line 83 of file WMarchingCubesAlgorithm.cpp.

References m_nCellsX, and m_nCellsY.

Referenced by getEdgeID(), and WMarchingCubesAlgorithmTest::testGetVertexID().

+ Here is the caller graph for this function:

◆ interpolate()

WPointXYZId WMarchingCubesAlgorithm::interpolate ( double  fX1,
double  fY1,
double  fZ1,
double  fX2,
double  fY2,
double  fZ2,
double  tVal1,
double  tVal2 
)
private

Interpolates between two grid points to produce the point at which the isosurface intersects an edge.

Parameters
fX1x coordinate of first position
fY1y coordinate of first position
fZ1z coordinate of first position
fX2x coordinate of second position
fY2y coordinate of first position
fZ2z coordinate of first position
tVal1scalar value at first position
tVal2scalar value at second position
Returns
interpolated point

Definition at line 34 of file WMarchingCubesAlgorithm.cpp.

References m_tIsoLevel, WPointXYZId::newID, WPointXYZId::x, WPointXYZId::y, and WPointXYZId::z.

Referenced by calculateIntersection(), and WMarchingCubesAlgorithmTest::testInterpolate().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WMarchingCubesAlgorithmTest

friend class WMarchingCubesAlgorithmTest
friend

Only UnitTests may be friends.

Definition at line 91 of file WMarchingCubesAlgorithm.h.

Member Data Documentation

◆ m_idToVertices

ID2WPointXYZId WMarchingCubesAlgorithm::m_idToVertices
private

List of WPointXYZIds which form the isosurface.

Definition at line 185 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().

◆ m_matrix

WMatrix< double > WMarchingCubesAlgorithm::m_matrix
private

The 4x4 transformation matrix for the triangle vertices.

Definition at line 183 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().

◆ m_nCellsX

unsigned int WMarchingCubesAlgorithm::m_nCellsX
private

◆ m_nCellsY

unsigned int WMarchingCubesAlgorithm::m_nCellsY
private

◆ m_nCellsZ

unsigned int WMarchingCubesAlgorithm::m_nCellsZ
private

◆ m_tIsoLevel

double WMarchingCubesAlgorithm::m_tIsoLevel
private

◆ m_trivecTriangles

WMCTriangleVECTOR WMarchingCubesAlgorithm::m_trivecTriangles
private

List of WMCTriangleS which form the triangulation of the isosurface.

Definition at line 186 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().


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