My Project
Classes | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ParaEngine::IsoSurfaceBuilder Class Reference

building triangles from 3d grid data. More...

#include <IsoSurfaceBuilder.h>

Classes

struct  GridCell
 Grid cell. More...
 
struct  IsoTriangle
 Definition of a triangle in an iso surface. More...
 

Public Types

enum  SurfaceFlags { GEN_NORMALS = 0x01, GEN_VERTEX_COLOURS = 0x02, GEN_TEX_COORDS = 0x04 }
 Flags describing what data is generated for rendering the iso surface. More...
 
enum  NormalType { NORMAL_WEIGHTED_AVERAGE, NORMAL_AVERAGE, NORMAL_GRADIENT }
 

Public Member Functions

 IsoSurfaceBuilder ()
 Constructor.
 
virtual ~IsoSurfaceBuilder ()
 Virtual Destructor.
 
virtual void initialize (DataGrid *dg, int flags)
 Initializes the iso surface. More...
 
void update (IsoSurfaceRenderable *isr)
 Rebuilds the iso surface, and updates the IsoSurfaceRenderable.
 
DataGridgetDataGrid ()
 Returns the pointer to the data grid.
 
float getIsoValue () const
 Returns the iso value of the surface.
 
void setIsoValue (float isoValue)
 Sets the iso value of the surface.
 
bool getFlipNormals () const
 Returns whether normals are flipped.
 
void setFlipNormals (bool flipNormals)
 Sets whether to flip normals. More...
 
NormalType getNormalType () const
 Gets the method used for normal generation.
 
void setNormalType (NormalType normalType)
 Sets the method used for normal generation.
 
virtual int getNumIsoVertices ()
 Returns the total number of iso vertices to be allocated.
 
virtual void createGridCellIsoVertices ()
 Creates and initializes the iso vertex index arrays of all grid cells.
 
virtual void buildIsoSurface ()
 Builds the iso surface by looping through all grid cells generating triangles.
 

Public Attributes

int mNumIsoVertices
 The number of iso vertices, calculated on first call of getNumIsoVertices().
 
int isoVertexGroupOffsets [3]
 Array with offsets to the different iso vertex groups.
 

Protected Types

typedef std::vector< int > IsoVertexVector
 
typedef std::vector< IsoTriangleIsoTriangleVector
 

Protected Member Functions

void createIsoVertices ()
 Creates the iso vertex arrays. More...
 
void createGridCells ()
 Creates and initializes the grid cells. More...
 
void destroyGridCells ()
 Destroys the grid cells, including their iso vertex index arrays.
 
int useIsoVertex (int isoVertex, int corner0, int corner1)
 Calculates properties of the iso vertex. More...
 
void addIsoTriangle (const IsoTriangle &isoTriangle)
 ...
 

Protected Attributes

DataGridPtr mDataGrid
 Reference-counted shared pointer to the data grid associated with this iso surface.
 
int mSurfaceFlags
 Flags describing what data is generated for rendering the iso surface (see IsoSurface::SurfaceFlags).
 
float mIsoValue
 Iso value of the surface, the default is 1.0.
 
bool mFlipNormals
 Flip normals of the surface, the default is false.
 
NormalType mNormalType
 The method used for normal generation.
 
int * mIsoVertexIndices
 Hardware vertex buffer indices for all iso vertices. More...
 
Vector3mIsoVertexPositions
 Positions of all iso vertices. More...
 
Vector3mIsoVertexNormals
 Normals for all iso vertices. More...
 
ColormIsoVertexColours
 Vertex colours for all iso vertices. More...
 
Vector2mIsoVertexTexCoords
 Texture coordinates for all iso vertices. More...
 
GridCellmGridCells
 Array of grid cells.
 
IsoVertexVector mIsoVertices
 Vector to which the indices of all used iso vertices are added. More...
 
IsoTriangleVector mIsoTriangles
 Vector to which all generated iso triangles are added. More...
 

Static Protected Attributes

static const int msEdgeTable [256]
 ... More...
 
static const int msTriangleTable [256][16]
 ...
 

Friends

class IsoSurfaceRenderable
 

Detailed Description

building triangles from 3d grid data.

It uses the matching cubes algorithm.

Member Enumeration Documentation

§ NormalType

Enumerator
NORMAL_WEIGHTED_AVERAGE 

Normals are calculated as a weighted average of face normals.

NORMAL_AVERAGE 

Normals are calculated as an average of face normals.

NORMAL_GRADIENT 

Normals are calculated by interpolating the gradient in the data grid.

§ SurfaceFlags

Flags describing what data is generated for rendering the iso surface.

Enumerator
GEN_NORMALS 

Generate vertex normals by interpolating the gradient stored in the data grid.

GEN_VERTEX_COLOURS 

Generate vertex colours by interpolating the colours stored in the data grid.

GEN_TEX_COORDS 

Generate texture coordinates.

Member Function Documentation

§ createGridCells()

void IsoSurfaceBuilder::createGridCells ( )
protected

Creates and initializes the grid cells.

Remarks
This function initializes the corner index arrays of the grid cells, and calls the abstract function createGridCellIsoVertices() to create and initialize iso vertex index arrays of all grid cells.

§ createIsoVertices()

void IsoSurfaceBuilder::createIsoVertices ( )
protected

Creates the iso vertex arrays.

Remarks
The function calls the abstract function getNumIsoVertices() to get the length of the arrays to be created. Arrays are created according to the flags specified in IsoSurface::mSurfaceFlags.

§ initialize()

void IsoSurfaceBuilder::initialize ( DataGrid dg,
int  flags 
)
virtual

Initializes the iso surface.

Remarks
This function should only be called once.
Parameters
dataGridPtrPointer to the data grid to use for iso surface generation.
flagsFlags describing what data is generated for rendering the iso surface (see IsoSurface::SurfaceFlags).

§ setFlipNormals()

void ParaEngine::IsoSurfaceBuilder::setFlipNormals ( bool  flipNormals)
inline

Sets whether to flip normals.

Remarks
When flip normals is false (the default), the outside of the surface is where the values of the data grid are lower than the iso value.

§ useIsoVertex()

int ParaEngine::IsoSurfaceBuilder::useIsoVertex ( int  isoVertex,
int  corner0,
int  corner1 
)
protected

Calculates properties of the iso vertex.

Remarks
If the properties of the iso vertex has already been calculated, the function returns immediately. Otherwise the iso vertex is initialized by calculating the necessary properties. Then it is assigned the next index in the hardware vertex buffer.
Parameters
isoVertexIndex of the iso vertex to use.
corner0Index of the first data grid value associated with the iso vertex.
corner1Index of the second data grid value associated with the iso vertex.
Returns
The index passed in the isoVertex parameter.

Member Data Documentation

§ mIsoTriangles

IsoTriangleVector ParaEngine::IsoSurfaceBuilder::mIsoTriangles
protected

Vector to which all generated iso triangles are added.

Remarks
This vector is iterated when filling the hardware index buffer.

§ mIsoVertexColours

Color* ParaEngine::IsoSurfaceBuilder::mIsoVertexColours
protected

Vertex colours for all iso vertices.

Remarks
This array is only allocated if GEN_VERTEX_COLOURS is set in IsoSurface::mSurfaceFlags, and colours are valid only for used iso vertices.

§ mIsoVertexIndices

int* ParaEngine::IsoSurfaceBuilder::mIsoVertexIndices
protected

Hardware vertex buffer indices for all iso vertices.

Remarks
A value of ~0 means that the iso vertex is not used. During iso surface generation all indices are reset to this value. On the first use of an iso vertex, its parameters are calculated, and it is assigned the next index in the hardware vertex buffer.

§ mIsoVertexNormals

Vector3* ParaEngine::IsoSurfaceBuilder::mIsoVertexNormals
protected

Normals for all iso vertices.

Remarks
This array is only allocated if GEN_NORMALS is set in IsoSurface::mSurfaceFlags, and normals are valid only for used iso vertices.

§ mIsoVertexPositions

Vector3* ParaEngine::IsoSurfaceBuilder::mIsoVertexPositions
protected

Positions of all iso vertices.

Remarks
Positions are valid only for used iso vertices.

§ mIsoVertexTexCoords

Vector2* ParaEngine::IsoSurfaceBuilder::mIsoVertexTexCoords
protected

Texture coordinates for all iso vertices.

Remarks
This array is only allocated if GEN_TEX_COORDS is set in IsoSurface::mSurfaceFlags, and texture coordinates are valid only for used iso vertices.

§ mIsoVertices

IsoVertexVector ParaEngine::IsoSurfaceBuilder::mIsoVertices
protected

Vector to which the indices of all used iso vertices are added.

Remarks
The iso vertex indices in this vector are iterated when filling the hardware vertex buffer.

§ msEdgeTable

const int ParaEngine::IsoSurfaceBuilder::msEdgeTable
staticprotected

...

the predefined values in the matching cube algorithm.


The documentation for this class was generated from the following files: