OpenWalnut  1.4.0
Public Member Functions | Private Member Functions | Private Attributes | Friends
WMarchingCubesAlgorithm Class Reference

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

#include <WMarchingCubesAlgorithm.h>

List of all members.

Public Member Functions

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

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.
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.
int getEdgeID (unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo)
 Returns the edge ID.
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.

Private Attributes

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

Friends

class WMarchingCubesAlgorithmTest
 Only UnitTests may be friends.

Detailed Description

This class does the actual computation of marching cubes.

Definition at line 86 of file WMarchingCubesAlgorithm.h.


Constructor & Destructor Documentation

Constructor needed for matrix initalization.

Definition at line 29 of file WMarchingCubesAlgorithm.cpp.


Member Function Documentation

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

template<typename T >
boost::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,
boost::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.

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

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

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


Friends And Related Function Documentation

friend class WMarchingCubesAlgorithmTest [friend]

Only UnitTests may be friends.

Definition at line 91 of file WMarchingCubesAlgorithm.h.


Member Data Documentation

ID2WPointXYZId WMarchingCubesAlgorithm::m_idToVertices [private]

List of WPointXYZIds which form the isosurface.

Definition at line 185 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().

The 4x4 transformation matrix for the triangle vertices.

Definition at line 183 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().

unsigned int WMarchingCubesAlgorithm::m_nCellsX [private]
unsigned int WMarchingCubesAlgorithm::m_nCellsY [private]
unsigned int WMarchingCubesAlgorithm::m_nCellsZ [private]
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: