#include <MarchingCubesData.h>
Collaboration diagram for MCMesh:
Public Types | |
typedef unsigned int | index_t |
Type of the index in _vertices. | |
Public Member Functions | |
MCMesh (MCGlobalData *gd, MCBProgressCallback *cb=0) | |
Default constructor. | |
virtual | ~MCMesh () |
Destructor. | |
index_t | AddVertex (int x, int y, int z, int edge, int triangle, vuVector &v) |
Add a vertex at the specified position. | |
index_t | AddVertex (int idx, int triangle) |
Adds a already existing vertex to the triangle given by triangle. | |
index_t | GetVertex (int x, int y, int z, int edge) |
Determines if the vertex already exists in _vertices. | |
int | AddTriangle (int type) |
Adds a new triangle to _triangles and returns the index in the array. | |
void | DebugPrint (void) |
Prints the actual triangle buffer. | |
void | prepare (void) |
Does last preparations on the data before the rendering can start. | |
void | render () |
Renders the triangles. | |
void | drawNormals (bool mode) |
Turn on and off the normals rendering. | |
bool | drawNormals () |
Returns the actual value of the rendering mode for the normals lines (see drawNormals(bool mode) for more information). | |
void | drawNormalsSize (float size) |
Sets the size of the line drawn for each normal (see drawNormals(bool mode) for more information). | |
float | drawNormalsSize () |
Returns the size of the line drawn for each normal (see drawNormals(bool mode) for more information). | |
index_t | numTriangles () |
Returns the actual number of triangles in the data structure. | |
index_t | numVertices () |
Returns the number of vertices in the data structure. | |
index_t | numIndices () |
Returns the number of elements in the indices array. | |
Private Member Functions | |
index_t | _getIndex (int x, int y, int z, int edge) |
Calculates the index of a vertex in _vertices. | |
void | _compileData () |
Takes the data from the mesh (MCTriangle and MCVertex) and compiles an array which is passed to the graphics card. | |
void | _compileNormalsArray () |
Generates a vertex array and an index array which holds data for drawing the normals. | |
Private Attributes | |
MCData * | _data |
This array holds the data passed to the graphics card. | |
index_t | _dataSize |
The size of the data array. | |
index_t * | _indices [256] |
This indexes will be passed to glDrawElements. | |
index_t | _indexSize [256] |
The size of the index array. | |
float * | _normalsArray |
index_t | _normalsArraySize |
std::map< index_t, MCVertex * > | _vertices |
Each vertex in the mesh is referenced here four times. | |
std::list< MCVertex * > | _vertexList |
For easyer access to all real vertices in _vertices this list also holds the vertices (see also Marching Cubes Data). | |
std::vector< MCTriangle * > | _triangles |
Holds all triangles in the mesh. | |
bool | _normalsPrepared |
Indicates that the normals are calcualted. | |
index_t | _vertexSize |
The number of bytes occupied by a MCVertex object in memory. | |
index_t | _triangleSize |
The number of bytes occupied by a MCTriangle object in memory. | |
MCGlobalData * | _gd |
Data structure holding data used by several classes. | |
MCBProgressCallback * | _progCB |
A callback to update a progress bar in the GUI. | |
Static Private Attributes | |
const int | _edgeMapping [12][3][4] |
A spezial edge mapping table for this data structure. |
This class represents the entry point to the geometry data. For more informations see MCData.
Destroying objects
Many of the objects are not only refereces in the base class but also in many classes in the hierarchy. Such objects must not be destroyed in this classes but in the base class.
Definition at line 179 of file MarchingCubesData.h.
|
Type of the index in _vertices. If you want to use the results of AddVertex or GetVertex you should use this type. Definition at line 188 of file MarchingCubesData.h. Referenced by _compileData(), _compileNormalsArray(), _getIndex(), AddVertex(), GetVertex(), MCMesh::MCTriangle::GetVertexIdx(), MCMesh::MCVertex::Idx(), numIndices(), numTriangles(), and numVertices(). |
|
Default constructor. The constructor also disables OpenGL array data.
Definition at line 246 of file MarchingCubesData.cpp. References _data, _dataSize, _gd, _indexSize, _indices, _normalsArray, _normalsArraySize, _normalsPrepared, _progCB, _triangleSize, _vertexSize, assert, MCGlobalData::compileNormals, DEBUGC, GL_COLOR_ARRAY, GL_NORMAL_ARRAY, GL_VERTEX_ARRAY, glDisableClientState(), MCGlobalData::meshSize, and NULL. |
Here is the call graph for this function:
|
Destructor.
Definition at line 270 of file MarchingCubesData.cpp. References _indices, _triangles, _vertexList, and DEBUGD. |
|
Takes the data from the mesh (MCTriangle and MCVertex) and compiles an array which is passed to the graphics card.
Definition at line 290 of file MarchingCubesData.cpp. References _data, _dataSize, _gd, _indexSize, _indices, _progCB, _triangles, _vertexList, assert, MCGlobalData::compileData, MCMesh::MCData::copyNormalFrom(), MCGlobalData::cubeSize, DEBUG0, DEBUG4, DEBUG5, MCGlobalData::doMeshStatistics, MCBProgressCallback::End(), vuVector::getData(), MCMesh::MCVertex::Idx(), index_t, MCMesh::MCVertex::Indexed(), vuVector::makeUnit(), MC_FAIL_EXIT, MCGlobalData::meshSize, numTriangles(), numVertices(), MCBProgressCallback::SetText(), MCBProgressCallback::Start(), MCGlobalData::termProgress, MCBProgressCallback::Update(), MCMesh::MCVertex::Vertex(), and MCMesh::MCData::vertex. Referenced by prepare(). |
Here is the call graph for this function:
|
Generates a vertex array and an index array which holds data for drawing the normals.
Definition at line 422 of file MarchingCubesData.cpp. References _data, _dataSize, _gd, _normalsArray, _normalsArraySize, assert, MCGlobalData::compileNormals, DEBUG0, DEBUG1, DEBUG3, index_t, MC_FAIL_EXIT, MCGlobalData::normalsLength, and MCMesh::MCData::vertex. Referenced by prepare(). |
|
Calculates the index of a vertex in _vertices. For informations on the composition of the index see _vertices.
Definition at line 283 of file MarchingCubesData.cpp. References DEBUG0, and index_t. Referenced by AddVertex(), and GetVertex(). |
|
Adds a new triangle to _triangles and returns the index in the array.
Definition at line 512 of file MarchingCubesData.cpp. References _gd, _normalsPrepared, _triangles, DEBUG0, MCGlobalData::doMeshStatistics, and MCGlobalData::meshSize. Referenced by MarchingCubesBase::drawTriangles(), main(), and MarchingCubesBase::marchCubes(). |
|
Adds a already existing vertex to the triangle given by triangle. In contrast to AddVertex(int, int, int, int, int, vuVector &) this function only adds a already existing vertex to a triangle. If the vertex does not exist, the function fails and returns MCD_ERROR.
Definition at line 491 of file MarchingCubesData.cpp. References _normalsPrepared, _triangles, _vertices, assert, DEBUG0, and index_t. |
|
Add a vertex at the specified position. With x, y, z and edge the position of a vertex in the grid is completly defined. With these parameters a uniqe index in the map _vertices is calculated. This function also adds the newly created MCVertex to the three corresonding positions in the map (see also Edge mapping table). Mode of Operation The function first looks, if the vertex is already added to _vertices by looking it up at the index, given by the parameters. If it exists a neighbouring cube of the given edge has added the vertex. In this case the vertex is only added to the triangle given by triangle. Otherwise the vertex is added to all four positions in _vertices according to Edge mapping table and after this added to the triangle.
Definition at line 455 of file MarchingCubesData.cpp. References _edgeMapping, _gd, _getIndex(), _vertexList, _vertices, assert, DEBUG0, DEBUG1, MCGlobalData::doMeshStatistics, index_t, MCGlobalData::meshSize, and MCMesh::MCVertex::Vertex(). Referenced by MarchingCubesBase::drawTriangles(), main(), and MarchingCubesBase::marchCubes(). |
Here is the call graph for this function:
|
Prints the actual triangle buffer. This function is for debug use only. If debugging is turned off, this function does print nothing. Definition at line 521 of file MarchingCubesData.cpp. References DEBUG0. Referenced by main(). |
|
Returns the actual value of the rendering mode for the normals lines (see drawNormals(bool mode) for more information).
|
|
Turn on and off the normals rendering.
If mode is set to true, there will be drawn a line for each normal using _drawNormalsSize as their size. The start point of such a line is the position of the corresponding vertex, and the end point is |
|
Returns the size of the line drawn for each normal (see drawNormals(bool mode) for more information).
|
|
Sets the size of the line drawn for each normal (see drawNormals(bool mode) for more information).
|
|
Determines if the vertex already exists in _vertices.
Definition at line 502 of file MarchingCubesData.cpp. References _getIndex(), _vertices, DEBUG0, and index_t. Referenced by MarchingCubesBase::drawTriangles(), main(), and MarchingCubesBase::marchCubes(). |
Here is the call graph for this function:
|
Returns the number of elements in the indices array.
Definition at line 626 of file MarchingCubesData.cpp. References _indexSize, DEBUG0, and index_t. Referenced by MarchingCubesBase::numIndices(). |
|
Returns the actual number of triangles in the data structure.
Definition at line 613 of file MarchingCubesData.cpp. References _triangles, DEBUG0, and index_t. Referenced by _compileData(), and MarchingCubesBase::numTriangles(). |
|
Returns the number of vertices in the data structure.
Definition at line 619 of file MarchingCubesData.cpp. References _vertexList, DEBUG0, and index_t. Referenced by _compileData(), and MarchingCubesBase::numVertices(). |
|
Does last preparations on the data before the rendering can start. These preparations are:
Definition at line 538 of file MarchingCubesData.cpp. References _compileData(), _compileNormalsArray(), _data, _gd, MCGlobalData::compileData, MCGlobalData::compileNormals, DEBUG0, DEBUG3, and MCGlobalData::drawNormals. Referenced by main(), MarchingCubesBase::marchCubes(), and render(). |
Here is the call graph for this function:
|
Here is the call graph for this function:
|
This array holds the data passed to the graphics card.
Definition at line 377 of file MarchingCubesData.h. Referenced by _compileData(), _compileNormalsArray(), MCMesh(), prepare(), and render(). |
|
The size of the data array.
Definition at line 379 of file MarchingCubesData.h. Referenced by _compileData(), _compileNormalsArray(), and MCMesh(). |
|
A spezial edge mapping table for this data structure. Because this class only needs to traverse through all possible neighbour cubes this is a simple 12/3/4 list. The data for each edge is ordered counter clockwise if you look in the positive direction of the coordiante axis. Definition at line 183 of file MarchingCubesData.cpp. Referenced by AddVertex(). |
|
Data structure holding data used by several classes.
Definition at line 418 of file MarchingCubesData.h. Referenced by _compileData(), _compileNormalsArray(), AddTriangle(), AddVertex(), MCMesh(), prepare(), and render(). |
|
The size of the index array.
Definition at line 385 of file MarchingCubesData.h. Referenced by _compileData(), MCMesh(), numIndices(), and render(). |
|
This indexes will be passed to glDrawElements.
Definition at line 383 of file MarchingCubesData.h. Referenced by _compileData(), MCMesh(), render(), and ~MCMesh(). |
|
Definition at line 387 of file MarchingCubesData.h. Referenced by _compileNormalsArray(), MCMesh(), and render(). |
|
Definition at line 388 of file MarchingCubesData.h. Referenced by _compileNormalsArray(), MCMesh(), and render(). |
|
Indicates that the normals are calcualted.
Definition at line 412 of file MarchingCubesData.h. Referenced by AddTriangle(), AddVertex(), and MCMesh(). |
|
A callback to update a progress bar in the GUI.
Definition at line 420 of file MarchingCubesData.h. Referenced by _compileData(), and MCMesh(). |
|
Holds all triangles in the mesh.
Definition at line 410 of file MarchingCubesData.h. Referenced by _compileData(), AddTriangle(), AddVertex(), numTriangles(), and ~MCMesh(). |
|
The number of bytes occupied by a MCTriangle object in memory.
Definition at line 416 of file MarchingCubesData.h. Referenced by MCMesh(). |
|
For easyer access to all real vertices in _vertices this list also holds the vertices (see also Marching Cubes Data).
Definition at line 408 of file MarchingCubesData.h. Referenced by _compileData(), AddVertex(), numVertices(), and ~MCMesh(). |
|
The number of bytes occupied by a MCVertex object in memory.
Definition at line 414 of file MarchingCubesData.h. Referenced by MCMesh(). |
|
Each vertex in the mesh is referenced here four times. One for each neighbour cube of the edge. The hash for this map corresponds with the index of the edge in the volume. The index is composed of a 4 bit number for the edge and a number of 9 bits for each direction. This leads to a 31 bit number. The ordering of the numbers in the index is as follows (bit display):
0zzzzzzz zzyyyyyy yyyxxxxx xxxxeeee B
Where Definition at line 403 of file MarchingCubesData.h. Referenced by AddVertex(), and GetVertex(). |