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 85 of file WMarchingCubesAlgorithm.h.


Constructor & Destructor Documentation

WMarchingCubesAlgorithm::WMarchingCubesAlgorithm (  ) 

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:
vals the values at the vertices
nX id of cell in x direction
nY id of cell in y direction
nZ id of cell in z direction
nEdgeNo id of the edge the point that will be interpolates lies on
Returns:
intersection point id

Definition at line 395 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:
nbCoordsX number of vertices in X direction
nbCoordsY number of vertices in Y direction
nbCoordsZ number of vertices in Z direction
mat the matrix transforming the vertices from canonical space
vals the values at the vertices
isoValue The surface will run through all positions with this value.
mainProgress progress combiner used to report our progress to
Returns:
the genereated surface

Definition at line 189 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:
nX ID of desired cell along x axis
nY ID of desired cell along y axis
nZ ID of desired cell along z axis
nEdgeNo id 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:
nX ID of desired vertex along x axis
nY ID of desired vertex along y axis
nZ ID 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:
fX1 x coordinate of first position
fY1 y coordinate of first position
fZ1 z coordinate of first position
fX2 x coordinate of second position
fY2 y coordinate of first position
fZ2 z coordinate of first position
tVal1 scalar value at first position
tVal2 scalar 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 90 of file WMarchingCubesAlgorithm.h.


Member Data Documentation

ID2WPointXYZId WMarchingCubesAlgorithm::m_idToVertices [private]

List of WPointXYZIds which form the isosurface.

Definition at line 184 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().

The 4x4 transformation matrix for the triangle vertices.

Definition at line 182 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 185 of file WMarchingCubesAlgorithm.h.

Referenced by generateSurface().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends