OpenWalnut
1.5.0dev
|
This class does the actual computation of marching cubes. More...
#include <WMarchingCubesAlgorithm.h>
Public Member Functions | |
WMarchingCubesAlgorithm () | |
Constructor needed for matrix initalization. More... | |
template<typename T > | |
std::shared_ptr< WTriangleMesh > | 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). 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... | |
This class does the actual computation of marching cubes.
Definition at line 86 of file WMarchingCubesAlgorithm.h.
WMarchingCubesAlgorithm::WMarchingCubesAlgorithm | ( | ) |
Constructor needed for matrix initalization.
Definition at line 29 of file WMarchingCubesAlgorithm.cpp.
|
private |
Calculates the intersection point id of the isosurface with an edge.
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 |
Definition at line 396 of file WMarchingCubesAlgorithm.h.
References interpolate(), m_nCellsX, and m_nCellsY.
Referenced by generateSurface(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), and WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar().
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.
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 |
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.
|
private |
Returns the edge ID.
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 |
Definition at line 49 of file WMarchingCubesAlgorithm.cpp.
References getVertexID().
Referenced by generateSurface(), and WMarchingCubesAlgorithmTest::testGetEdgeID().
|
private |
Returns the ID of the vertex given by by the IDs along the axis.
nX | ID of desired vertex along x axis |
nY | ID of desired vertex along y axis |
nZ | ID of desired vertex along z axis |
Definition at line 83 of file WMarchingCubesAlgorithm.cpp.
References m_nCellsX, and m_nCellsY.
Referenced by getEdgeID(), and WMarchingCubesAlgorithmTest::testGetVertexID().
|
private |
Interpolates between two grid points to produce the point at which the isosurface intersects an edge.
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 |
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().
|
friend |
Only UnitTests may be friends.
Definition at line 91 of file WMarchingCubesAlgorithm.h.
|
private |
List of WPointXYZIds which form the isosurface.
Definition at line 185 of file WMarchingCubesAlgorithm.h.
Referenced by generateSurface().
|
private |
The 4x4 transformation matrix for the triangle vertices.
Definition at line 183 of file WMarchingCubesAlgorithm.h.
Referenced by generateSurface().
|
private |
No. of cells in x direction.
Definition at line 177 of file WMarchingCubesAlgorithm.h.
Referenced by calculateIntersection(), generateSurface(), getVertexID(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar(), WMarchingCubesAlgorithmTest::testGetEdgeID(), and WMarchingCubesAlgorithmTest::testGetVertexID().
|
private |
No. of cells in y direction.
Definition at line 178 of file WMarchingCubesAlgorithm.h.
Referenced by calculateIntersection(), generateSurface(), getVertexID(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar(), WMarchingCubesAlgorithmTest::testGetEdgeID(), and WMarchingCubesAlgorithmTest::testGetVertexID().
|
private |
No. of cells in z direction.
Definition at line 179 of file WMarchingCubesAlgorithm.h.
Referenced by generateSurface(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar(), WMarchingCubesAlgorithmTest::testGetEdgeID(), and WMarchingCubesAlgorithmTest::testGetVertexID().
|
private |
The isovalue.
Definition at line 181 of file WMarchingCubesAlgorithm.h.
Referenced by generateSurface(), interpolate(), WMarchingCubesAlgorithmTest::testCalculateIntersectionFloat(), WMarchingCubesAlgorithmTest::testCalculateIntersectionUnsignedChar(), and WMarchingCubesAlgorithmTest::testInterpolate().
|
private |
List of WMCTriangleS which form the triangulation of the isosurface.
Definition at line 186 of file WMarchingCubesAlgorithm.h.
Referenced by generateSurface().