IsoSurface Class Reference

#include <isosurface.h>

List of all members.


Detailed Description

Generates an isosurface from a list of 3D density points.

These points are generated by Gaussian's cubegen or BRABO's potdicht. It is a rewrite of the code by Raghavendra Chandrashekara from the website http://astronomy.swin.edu.au/~pbourke/modelling/polygonise/ using the 'Marching Cubes' algorithm (patented!). The class stores the density points and an unlimited number of isosurfaces generated from them. Individual surfaces can be added, changed and removed.

Definition at line 36 of file isosurface.h.

Public Member Functions

 IsoSurface ()
 The default constructor.
 ~IsoSurface ()
 The default destructor.
void setParameters (const std::vector< double > *values, const Point3D< unsigned int > &pointDimension, const Point3D< float > &pointDelta, const Point3D< float > &pointOrigin)
 Sets up the input data needed for the calculation of the surface.
void addSurface (const double isoDensity)
 Calculates the isosurface determine by the given isodensity.
void changeSurface (const unsigned int surface, const double isoDensity)
 Recalculates an existing isosurface for a new isodensity.
bool densityPresent () const
 Returns whether a density is loaded and parameters are set.
unsigned int numSurfaces () const
 Returns the number of calculated surfaces present.
unsigned int numTriangles (const unsigned int surface) const
 Returns the number of triangles the specified surface consists of.
unsigned int numVertices (const unsigned int surface) const
 Returns the number of points the specified surface contains.
void getTriangle (const unsigned int surface, const unsigned int index, Point3D< float > &point1, Point3D< float > &point2, Point3D< float > &point3, Point3D< float > &normal1, Point3D< float > &normal2, Point3D< float > &normal3) const
 Returns the data for a triangle on a specified surface.
Point3D< float > getPoint (const unsigned int surface, const unsigned int index) const
void clearParameters ()
 Removes all data and surfaces.
void clearSurfaces ()
 Removes all surfaces.
void removeSurface (const unsigned int surface)
 Removes a surface.
Point3D< float > getOrigin () const
 Returns the currently set origin.
Point3D< float > getDelta () const
 Returns the currently set deltas (spacing between the gridpoints).
Point3D< unsigned int > getNumPoints () const
 Returns the currently set number of points in each direction.

Private Member Functions

void calculateSurface (const double isoDensity)
 Does the basic calculation of an isosurface.
Point3D< float > intersection (const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge)
 Calculates the intersection point.
Point3D< float > interpolate (const Point3D< float > point1, const Point3D< float > point2, const double var1, const double var2)
 Performs linear interpolation of the given data.
unsigned int getEdgeID (const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge)
 Returns the ID of an edge.
unsigned int getVertexID (const unsigned int x, const unsigned int y, const unsigned int z)
 Returns the ID of a vertex.
void renameVerticesAndTriangles (vector< Point3D< float > > *singleVerticesList, vector< unsigned int > *singleTriangleIndices)
 Renames the vertices and triangles so that they can be accessed more efficiently.
void calculateNormals (vector< float > *singleNormals, const unsigned int surface)
 Calculates the normals on each vertex.
unsigned int getArrayIndex (const unsigned int x, const unsigned int y, const unsigned int z) const
 Determines the index into the array of density values.

Private Attributes

vector< double > densityValues
 a vector containing the input density values
Point3D< unsigned int > numPoints
 a Point3D containing the number of points in the 3 directions
Point3D< float > delta
 a Point3D containing the cell lengths in the 3 directions
Point3D< float > origin
 the origin of the density values
map< unsigned int, Point3D<
float > > 
vertices
 the list of points forming the isosurface
vector< Triangletriangles
 the list of triangles forming the isosurface
double currentIsoLevel
 holds the current isodensity value
vector< double > isoLevels
 a list of isodensity values for each calculated surface
vector< vector< Point3D< float > > * > verticesList
 an easily accessible list of vertices for each calculated surface
vector< vector< unsigned int > * > triangleIndices
 an easily accessible list of vertex indices for each calculated surface
vector< vector< float > * > normals
 a list of normals for each calculated surface

Static Private Attributes

static const unsigned int edgeTable [256]
 lookup table for edges
static const int triTable [256][16]
 lookup table for triangles. strange as the table contains negative number. Works either way, though.

Classes

struct  Triangle
 A utility struct containing the ID's of 3 points making up a triangle. More...


Constructor & Destructor Documentation

IsoSurface::IsoSurface  ) 
 

The default constructor.

Definition at line 48 of file isosurface.cpp.

IsoSurface::~IsoSurface  ) 
 

The default destructor.

Definition at line 55 of file isosurface.cpp.


Member Function Documentation

void IsoSurface::setParameters const std::vector< double > *  values,
const Point3D< unsigned int > &  pointDimension,
const Point3D< float > &  pointDelta,
const Point3D< float > &  pointOrigin
 

Sets up the input data needed for the calculation of the surface.

The values are the density values in 3 dimensions stored as a linear vector. pointDimension provides the dimensions of the cube while pointOrigin provides the location of the origin of this cube. pointDelta provides the spacing between the points in each dimension.

Definition at line 62 of file isosurface.cpp.

void IsoSurface::addSurface const double  isoDensity  ) 
 

Calculates the isosurface determine by the given isodensity.

The surface is added to the list of surfaces.

Definition at line 80 of file isosurface.cpp.

void IsoSurface::changeSurface const unsigned int  surface,
const double  isoDensity
 

Recalculates an existing isosurface for a new isodensity.

Definition at line 101 of file isosurface.cpp.

bool IsoSurface::densityPresent  )  const
 

Returns whether a density is loaded and parameters are set.

Definition at line 114 of file isosurface.cpp.

unsigned int IsoSurface::numSurfaces  )  const
 

Returns the number of calculated surfaces present.

Definition at line 121 of file isosurface.cpp.

unsigned int IsoSurface::numTriangles const unsigned int  surface  )  const
 

Returns the number of triangles the specified surface consists of.

Definition at line 128 of file isosurface.cpp.

unsigned int IsoSurface::numVertices const unsigned int  surface  )  const
 

Returns the number of points the specified surface contains.

Definition at line 138 of file isosurface.cpp.

void IsoSurface::getTriangle const unsigned int  surface,
const unsigned int  index,
Point3D< float > &  point1,
Point3D< float > &  point2,
Point3D< float > &  point3,
Point3D< float > &  normal1,
Point3D< float > &  normal2,
Point3D< float > &  normal3
const
 

Returns the data for a triangle on a specified surface.

Parameters:
[in] surface : the surface from which a triangle should be returned
[in] index : the index of the required triangle
[out] point1,point2,point3 : the coordinates of the 3 vertices defining a triangle
[out] normal1,normal2,normal3 : the coordinates of the normal vectors for each vertex

Definition at line 148 of file isosurface.cpp.

Point3D< float > IsoSurface::getPoint const unsigned int  surface,
const unsigned int  index
const
 

Definition at line 200 of file isosurface.cpp.

void IsoSurface::clearParameters  ) 
 

Removes all data and surfaces.

Definition at line 212 of file isosurface.cpp.

void IsoSurface::clearSurfaces  ) 
 

Removes all surfaces.

Definition at line 220 of file isosurface.cpp.

void IsoSurface::removeSurface const unsigned int  surface  ) 
 

Removes a surface.

Definition at line 236 of file isosurface.cpp.

Point3D< float > IsoSurface::getOrigin  )  const
 

Returns the currently set origin.

Definition at line 260 of file isosurface.cpp.

Point3D< float > IsoSurface::getDelta  )  const
 

Returns the currently set deltas (spacing between the gridpoints).

Definition at line 267 of file isosurface.cpp.

Point3D< unsigned int > IsoSurface::getNumPoints  )  const
 

Returns the currently set number of points in each direction.

Definition at line 274 of file isosurface.cpp.

void IsoSurface::calculateSurface const double  isoDensity  )  [private]
 

Does the basic calculation of an isosurface.

Definition at line 285 of file isosurface.cpp.

Point3D< float > IsoSurface::intersection const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const unsigned int  edge
[private]
 

Calculates the intersection point.

Definition at line 423 of file isosurface.cpp.

Point3D< float > IsoSurface::interpolate const Point3D< float >  point1,
const Point3D< float >  point2,
const double  var1,
const double  var2
[private]
 

Performs linear interpolation of the given data.

Definition at line 489 of file isosurface.cpp.

unsigned int IsoSurface::getEdgeID const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const unsigned int  edge
[private]
 

Returns the ID of an edge.

Definition at line 501 of file isosurface.cpp.

unsigned int IsoSurface::getVertexID const unsigned int  x,
const unsigned int  y,
const unsigned int  z
[private]
 

Returns the ID of a vertex.

Definition at line 523 of file isosurface.cpp.

void IsoSurface::renameVerticesAndTriangles vector< Point3D< float > > *  singleVerticesList,
vector< unsigned int > *  singleTriangleIndices
[private]
 

Renames the vertices and triangles so that they can be accessed more efficiently.

Definition at line 530 of file isosurface.cpp.

void IsoSurface::calculateNormals vector< float > *  singleNormals,
const unsigned int  surface
[private]
 

Calculates the normals on each vertex.

Definition at line 579 of file isosurface.cpp.

unsigned int IsoSurface::getArrayIndex const unsigned int  x,
const unsigned int  y,
const unsigned int  z
const [private]
 

Determines the index into the array of density values.

Definition at line 610 of file isosurface.cpp.


Member Data Documentation

vector<double> IsoSurface::densityValues [private]
 

a vector containing the input density values

Definition at line 79 of file isosurface.h.

Point3D<unsigned int> IsoSurface::numPoints [private]
 

a Point3D containing the number of points in the 3 directions

Definition at line 80 of file isosurface.h.

Point3D<float> IsoSurface::delta [private]
 

a Point3D containing the cell lengths in the 3 directions

Definition at line 81 of file isosurface.h.

Point3D<float> IsoSurface::origin [private]
 

the origin of the density values

Definition at line 82 of file isosurface.h.

map<unsigned int, Point3D<float> > IsoSurface::vertices [private]
 

the list of points forming the isosurface

Definition at line 83 of file isosurface.h.

vector<Triangle> IsoSurface::triangles [private]
 

the list of triangles forming the isosurface

Definition at line 84 of file isosurface.h.

double IsoSurface::currentIsoLevel [private]
 

holds the current isodensity value

Definition at line 85 of file isosurface.h.

vector<double> IsoSurface::isoLevels [private]
 

a list of isodensity values for each calculated surface

Definition at line 86 of file isosurface.h.

vector< vector<Point3D<float> >* > IsoSurface::verticesList [private]
 

an easily accessible list of vertices for each calculated surface

Definition at line 87 of file isosurface.h.

vector< vector<unsigned int>* > IsoSurface::triangleIndices [private]
 

an easily accessible list of vertex indices for each calculated surface

Definition at line 88 of file isosurface.h.

vector< vector<float>* > IsoSurface::normals [private]
 

a list of normals for each calculated surface

Definition at line 89 of file isosurface.h.

const unsigned int IsoSurface::edgeTable [static, private]
 

lookup table for edges

Definition at line 92 of file isosurface.h.

const int IsoSurface::triTable [static, private]
 

lookup table for triangles. strange as the table contains negative number. Works either way, though.

The original implementation used unsigned ints which is very

Definition at line 93 of file isosurface.h.


Generated on Fri May 19 14:31:58 2006 for Brabosphere by  doxygen 1.4.6-NO