#include <MarchingCubesBase.h>
Inheritance diagram for MarchingCubesBase:
Public Member Functions | |
MarchingCubesBase () | |
Default constructor. | |
virtual | ~MarchingCubesBase () |
Destructor. | |
void | setGlobalData (MCGlobalData *gd) |
This has to be done first! | |
void | glRenderFrame () |
Renders the frame that borders the volume. | |
void | glRender () |
This function executes the code to render the marching cubes volume. | |
void | Size (int sz1, int sz2, int sz3) |
Size setter. | |
int | Size1 () |
Size 1 getter. | |
int | Size2 () |
Size 2 getter. | |
int | Size3 () |
Size 3 getter. | |
int | maxSize () |
Returns the bigges size. | |
void | Origin (float or1, float or2, float or3) |
Origin setter. | |
float | Origin1 () |
float | Origin2 () |
float | Origin3 () |
void | marchCubes () |
This function calculates the triangle mesh by marching trough the cubes. | |
long long | numVertices () |
long long | numTriangles () |
long long | numIndices () |
int | getCubeType (int x, int y, int z) |
The function determines the type of the cube. | |
float | valueAt (float px, float py, float pz) |
Takes a point inside the mesh and returns the value at that point. | |
void | SetProgressCallback (MCBProgressCallback *cb) |
void | SetHistoCallback (MCBHistoCallback *cb) |
Protected Member Functions | |
void | SetProgressText (const char *txt) |
void | StartProgress () |
void | UpdateProgress (int v) |
void | EndProgress () |
Protected Attributes | |
int * | _data |
Hold's the volume data. | |
Private Member Functions | |
void | drawHorCylinder (int pos, float angle, float r, float l) |
Draws a horizontal cylinder. | |
void | drawVertCylinder (int pos, float r, float l) |
Draw a vertical cylinder. | |
void | drawCorner (int pos, float r) |
Draws a ball at the coordinate p. | |
void | drawSpot (int pos) |
void | drawTriangles () |
vuVector | calcVertex (int x, int y, int z, int edge) |
Calculates the vertex position from the cube position (x, y, z), the edge number (edge) and the threshold (_thres). | |
Private Attributes | |
int | _size [3] |
Data size. | |
float | _origin1 |
Origin in first direction. | |
float | _origin2 |
Origin in second direction. | |
float | _origin3 |
Origin in third direction. | |
MCGlobalData * | _gd |
A reference to the global data structure. | |
bool | _valueRangeAdjusted |
Range calculation state machine. | |
MCBProgressCallback * | _progCB |
MCBHistoCallback * | _histoCB |
MCMesh * | _mesh |
int | _theCube |
MCMesh * | _cube |
Static Private Attributes | |
const GLfloat | _vertOffset [8][3] |
As described in the class documentation, this table defines the cube geometry. | |
const int | _marchingCubesTable [256][16] |
This is the marching cubes table. | |
const int | _edgeConnect [12][2] |
Describes the connection between the edges and it's end points in the cube. | |
const int | _edgeSizeConnect [12] |
Defines which MCGlobalData::cubeSize value is relevant for each edge. | |
const int | _edgeMapping [12][3][3][3] |
This mapping table connectes edges of neighbouring cubes (see The Marching Cubes Engine and Edge mapping table). | |
const GLfloat | _edgeDir [12][3] |
const int | _edgeFlags [256] |
This class does the actual scanning of the data.
Geometry
The variable _vertOffset defines the cube geometry which (according to the actual values in _vertOffset) is:
(3)-----2-----(2) /| /| 11 | 10 | / | / | (7)-----6-----(6) 1 | 3 | | | | | | | | | | 7 (0)-----0--|--(1) y | / 5 / | | 8 | 9 o-- x |/ |/ / (4)-----4-----(5) z
The above picture also shows the edge numbering. All code in this class referes to this geometry.
Cube Type
The type of a cube is calculated by testing every edge vertex of the cube against the threshold saved in _thres. A value that is higher means the vertex is inside. Each edge is associated with a bit in the type integer where the position of the bit corresponds with the nomber of the edge in the above given geometry.
Definition at line 75 of file MarchingCubesBase.h.
|
Default constructor.
Definition at line 591 of file MarchingCubesBase.cpp. |
|
Destructor.
Definition at line 606 of file MarchingCubesBase.cpp. References DEBUGD. |
|
Calculates the vertex position from the cube position (x, y, z), the edge number (edge) and the threshold (_thres).
Definition at line 903 of file MarchingCubesBase.cpp. References _data, _edgeConnect, _gd, _vertOffset, assert, DEBUG0, DEBUG5, vuVector::makeUnit(), MCB_IDX, vuVector::norm(), and MCGlobalData::thres. Referenced by marchCubes(). |
Here is the call graph for this function:
|
Draws a ball at the coordinate p.
Definition at line 789 of file MarchingCubesBase.cpp. References _gd, _size, _vertOffset, MCGlobalData::cubeSize, glPopMatrix(), glPushMatrix(), and glTranslated(). Referenced by glRenderFrame(). |
Here is the call graph for this function:
|
Draws a horizontal cylinder.
Definition at line 761 of file MarchingCubesBase.cpp. References _gd, _size, _vertOffset, assert, MCGlobalData::cubeSize, DEBUG0, glPopMatrix(), glPushMatrix(), glRotated(), and glTranslated(). Referenced by glRenderFrame(). |
Here is the call graph for this function:
|
Definition at line 800 of file MarchingCubesBase.cpp. References _gd, _size, _vertOffset, MCGlobalData::cubeSize, glPopMatrix(), glPushMatrix(), glTranslatef(), and maxSize(). Referenced by glRender(). |
Here is the call graph for this function:
|
Definition at line 812 of file MarchingCubesBase.cpp. References _cube, _edgeConnect, _edgeDir, _edgeSizeConnect, _gd, _marchingCubesTable, _size, _theCube, _vertOffset, MCMesh::AddTriangle(), MCMesh::AddVertex(), MCGlobalData::cube, DEBUG7, MCMesh::GetVertex(), and MCMesh::render(). Referenced by glRender(). |
Here is the call graph for this function:
|
Draw a vertical cylinder.
Definition at line 776 of file MarchingCubesBase.cpp. References _gd, _size, _vertOffset, MCGlobalData::cubeSize, glPopMatrix(), glPushMatrix(), glRotated(), and glTranslated(). Referenced by glRenderFrame(). |
Here is the call graph for this function:
|
Definition at line 1064 of file MarchingCubesBase.cpp. References _progCB, DEBUG0, and MCBProgressCallback::End(). Referenced by marchCubes(), and vu1112211::read(). |
Here is the call graph for this function:
|
The function determines the type of the cube. According to the values in _vertOffset each vertex in the cube gets the value of true if it is inside the volume defined by the threshold. Otherwise it is false. Each vertex is associated with a bit in the returned integer and this integer represents the cube type. Definition at line 856 of file MarchingCubesBase.cpp. References _data, _gd, _size, _vertOffset, assert, DEBUG0, DEBUG4, MCB_IDX, MCGlobalData::thres, MCGlobalData::valueMax, and MCGlobalData::valueMin. Referenced by marchCubes(), and vuMarchingCubes::onDblClick(). |
|
This function executes the code to render the marching cubes volume.
Definition at line 643 of file MarchingCubesBase.cpp. References _gd, _mesh, _origin1, _origin2, _origin3, _size, MCGlobalData::cube, MCGlobalData::cubeBrowser, MCGlobalData::cullMode, DEBUG0, MCGlobalData::drawObject, drawSpot(), drawTriangles(), GL_BACK, GL_CULL_FACE, glCullFace(), glDisable(), glEnable(), glPopMatrix(), glPushMatrix(), glRotatef(), glTranslatef(), MCMesh::render(), and MCGlobalData::termProgress. Referenced by vuMarchingCubes::glRender(), and vu1112211::render(). |
Here is the call graph for this function:
|
Renders the frame that borders the volume.
Definition at line 617 of file MarchingCubesBase.cpp. References _gd, _origin1, _origin2, _origin3, _size, assert, MCGlobalData::cubeSize, DEBUG0, drawCorner(), drawHorCylinder(), drawVertCylinder(), MCGlobalData::frameRadius, glPopMatrix(), glPushMatrix(), glTranslatef(), and NULL. Referenced by vuMarchingCubes::glRender(). |
Here is the call graph for this function:
|
This function calculates the triangle mesh by marching trough the cubes. As described in the class documentation the function visits every cube, calculates it's type and then determines the part of the mesh introduced by this cube. For more information see The Marching Cubes Engine. Definition at line 954 of file MarchingCubesBase.cpp. References _gd, _histoCB, _marchingCubesTable, _mesh, _progCB, _size, _valueRangeAdjusted, MCMesh::AddTriangle(), MCMesh::AddVertex(), assert, calcVertex(), MCBHistoCallback::Clear(), DEBUG0, DEBUG5, DEBUG6, EndProgress(), MCBHistoCallback::Flush(), getCubeType(), MCMesh::GetVertex(), MCBHistoCallback::Inc(), MC_FAIL_EXIT, MCGlobalData::meshSize, NULL, MCMesh::prepare(), SetProgressText(), StartProgress(), MCGlobalData::termProgress, UpdateProgress(), MCGlobalData::valueMax, and MCGlobalData::valueMin. Referenced by vuMarchingCubes::init(), and vuMarchingCubes::OnThresChange(). |
Here is the call graph for this function:
|
Returns the bigges size.
Definition at line 720 of file MarchingCubesBase.cpp. References _size, DEBUG0, and max. Referenced by drawSpot(), vuMarchingCubes::glResize(), vuMarchingCubes::init(), vuMarchingCubes::onDblClick(), vuMarchingCubes::onMouseLeftMoving(), vuMarchingCubes::onMouseRightMoving(), and Size(). |
|
Definition at line 744 of file MarchingCubesBase.cpp. References _mesh, DEBUG0, and MCMesh::numIndices(). Referenced by vuMarchingCubes::doThresChange(). |
Here is the call graph for this function:
|
Definition at line 736 of file MarchingCubesBase.cpp. References _mesh, DEBUG0, and MCMesh::numTriangles(). Referenced by vuMarchingCubes::doThresChange(). |
Here is the call graph for this function:
|
Definition at line 728 of file MarchingCubesBase.cpp. References _mesh, DEBUG0, and MCMesh::numVertices(). Referenced by vuMarchingCubes::doThresChange(). |
Here is the call graph for this function:
|
Origin setter.
Definition at line 752 of file MarchingCubesBase.cpp. References _origin1, _origin2, _origin3, and DEBUG0. Referenced by vuMarchingCubes::OnCubeSizeChange(), and Size(). |
|
Definition at line 171 of file MarchingCubesBase.h. |
|
Definition at line 172 of file MarchingCubesBase.h. |
|
Definition at line 173 of file MarchingCubesBase.h. |
|
This has to be done first!
Definition at line 144 of file MarchingCubesBase.h. Referenced by vuMarchingCubes::init(). |
|
Definition at line 1036 of file MarchingCubesBase.cpp. References _histoCB, and DEBUG0. Referenced by vuMarchingCubes::init(). |
|
Definition at line 1029 of file MarchingCubesBase.cpp. References _progCB, and DEBUG0. Referenced by vuMarchingCubes::init(). |
|
Definition at line 1043 of file MarchingCubesBase.cpp. References _progCB, DEBUG0, and MCBProgressCallback::SetText(). Referenced by marchCubes(), and vu1112211::read(). |
Here is the call graph for this function:
|
Size setter. This is the point where the _data array is created. This function also does some other settings. In other words, when this function has not been called, the class will not work correctly. Definition at line 703 of file MarchingCubesBase.cpp. References _data, _gd, _size, assert, DEBUG0, maxSize(), MCGlobalData::normalsLength, Origin(), and MCGlobalData::termProgress. Referenced by vu1112211::read(). |
Here is the call graph for this function:
|
Size 1 getter.
Definition at line 162 of file MarchingCubesBase.h. Referenced by vuMarchingCubes::init(), vuMarchingCubes::OnCubeSizeChange(), and vuMarchingCubes::onDblClick(). |
|
Size 2 getter.
Definition at line 164 of file MarchingCubesBase.h. Referenced by vuMarchingCubes::init(), vuMarchingCubes::OnCubeSizeChange(), and vuMarchingCubes::onDblClick(). |
|
Size 3 getter.
Definition at line 166 of file MarchingCubesBase.h. Referenced by vuMarchingCubes::init(), vuMarchingCubes::OnCubeSizeChange(), and vuMarchingCubes::onDblClick(). |
|
Definition at line 1050 of file MarchingCubesBase.cpp. References _progCB, DEBUG0, and MCBProgressCallback::Start(). Referenced by marchCubes(), and vu1112211::read(). |
Here is the call graph for this function:
|
Definition at line 1057 of file MarchingCubesBase.cpp. References _progCB, DEBUG0, and MCBProgressCallback::Update(). Referenced by marchCubes(), and vu1112211::read(). |
Here is the call graph for this function:
|
Takes a point inside the mesh and returns the value at that point. The calculation of the value is done using trilinear interpolation. Definition at line 880 of file MarchingCubesBase.cpp. References _data, DEBUG0, DEBUG8, and MCB_IDX. Referenced by vuMarchingCubes::onDblClick(). |
|
Definition at line 134 of file MarchingCubesBase.h. Referenced by drawTriangles(). |
|
Hold's the volume data. This member is protected, because it should be accessable from derived classes. Definition at line 89 of file MarchingCubesBase.h. Referenced by calcVertex(), getCubeType(), Size(), and valueAt(). |
|
Initial value: { {0,1}, {1,2}, {2,3}, {3,0}, {4,5}, {5,6}, {6,7}, {7,4}, {0,4}, {1,5}, {2,6}, {3,7} }
Definition at line 290 of file MarchingCubesBase.cpp. Referenced by calcVertex(), and drawTriangles(). |
|
Initial value: { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, { 0.0, 0.0, 1.0}, {0.0, 0.0, 1.0} } Definition at line 548 of file MarchingCubesBase.cpp. Referenced by drawTriangles(). |
|
Definition at line 555 of file MarchingCubesBase.cpp. |
|
This mapping table connectes edges of neighbouring cubes (see The Marching Cubes Engine and Edge mapping table).
Definition at line 304 of file MarchingCubesBase.cpp. |
|
Initial value: { 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2 }
Definition at line 297 of file MarchingCubesBase.cpp. Referenced by drawTriangles(). |
|
A reference to the global data structure. This need not be destroyed. Definition at line 97 of file MarchingCubesBase.h. Referenced by calcVertex(), drawCorner(), drawHorCylinder(), drawSpot(), drawTriangles(), drawVertCylinder(), getCubeType(), glRender(), glRenderFrame(), marchCubes(), and Size(). |
|
Definition at line 129 of file MarchingCubesBase.h. Referenced by marchCubes(), and SetHistoCallback(). |
|
This is the marching cubes table. It connects the cube type with a number of edges. Each edge on it's part represents a vertex of a triangle. Also this table assumes, that a set bit in the type means, that the corrseponding edge is outside the volume. Definition at line 30 of file MarchingCubesBase.cpp. Referenced by drawTriangles(), and marchCubes(). |
|
Definition at line 131 of file MarchingCubesBase.h. Referenced by glRender(), marchCubes(), numIndices(), numTriangles(), and numVertices(). |
|
Origin in first direction.
Definition at line 81 of file MarchingCubesBase.h. Referenced by glRender(), glRenderFrame(), and Origin(). |
|
Origin in second direction.
Definition at line 82 of file MarchingCubesBase.h. Referenced by glRender(), glRenderFrame(), and Origin(). |
|
Origin in third direction.
Definition at line 83 of file MarchingCubesBase.h. Referenced by glRender(), glRenderFrame(), and Origin(). |
|
Definition at line 128 of file MarchingCubesBase.h. Referenced by EndProgress(), marchCubes(), SetProgressCallback(), SetProgressText(), StartProgress(), and UpdateProgress(). |
|
Data size.
Definition at line 80 of file MarchingCubesBase.h. Referenced by drawCorner(), drawHorCylinder(), drawSpot(), drawTriangles(), drawVertCylinder(), getCubeType(), glRender(), glRenderFrame(), marchCubes(), maxSize(), and Size(). |
|
Definition at line 133 of file MarchingCubesBase.h. Referenced by drawTriangles(). |
|
Range calculation state machine.
Definition at line 102 of file MarchingCubesBase.h. Referenced by marchCubes(). |
|
Initial value: { {0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {0.0, 1.0, 1.0} }
Definition at line 24 of file MarchingCubesBase.cpp. Referenced by calcVertex(), drawCorner(), drawHorCylinder(), drawSpot(), drawTriangles(), drawVertCylinder(), and getCubeType(). |