#include <isosurface.h>
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< Triangle > | triangles |
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... |
|
The default constructor.
Definition at line 48 of file isosurface.cpp. |
|
The default destructor.
Definition at line 55 of file isosurface.cpp. |
|
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. |
|
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. |
|
Recalculates an existing isosurface for a new isodensity.
Definition at line 101 of file isosurface.cpp. |
|
Returns whether a density is loaded and parameters are set.
Definition at line 114 of file isosurface.cpp. |
|
Returns the number of calculated surfaces present.
Definition at line 121 of file isosurface.cpp. |
|
Returns the number of triangles the specified surface consists of.
Definition at line 128 of file isosurface.cpp. |
|
Returns the number of points the specified surface contains.
Definition at line 138 of file isosurface.cpp. |
|
Returns the data for a triangle on a specified surface.
Definition at line 148 of file isosurface.cpp. |
|
Definition at line 200 of file isosurface.cpp. |
|
Removes all data and surfaces.
Definition at line 212 of file isosurface.cpp. |
|
Removes all surfaces.
Definition at line 220 of file isosurface.cpp. |
|
Removes a surface.
Definition at line 236 of file isosurface.cpp. |
|
Returns the currently set origin.
Definition at line 260 of file isosurface.cpp. |
|
Returns the currently set deltas (spacing between the gridpoints).
Definition at line 267 of file isosurface.cpp. |
|
Returns the currently set number of points in each direction.
Definition at line 274 of file isosurface.cpp. |
|
Does the basic calculation of an isosurface.
Definition at line 285 of file isosurface.cpp. |
|
Calculates the intersection point.
Definition at line 423 of file isosurface.cpp. |
|
Performs linear interpolation of the given data.
Definition at line 489 of file isosurface.cpp. |
|
Returns the ID of an edge.
Definition at line 501 of file isosurface.cpp. |
|
Returns the ID of a vertex.
Definition at line 523 of file isosurface.cpp. |
|
Renames the vertices and triangles so that they can be accessed more efficiently.
Definition at line 530 of file isosurface.cpp. |
|
Calculates the normals on each vertex.
Definition at line 579 of file isosurface.cpp. |
|
Determines the index into the array of density values.
Definition at line 610 of file isosurface.cpp. |
|
a vector containing the input density values
Definition at line 79 of file isosurface.h. |
|
a Point3D containing the number of points in the 3 directions
Definition at line 80 of file isosurface.h. |
|
a Point3D containing the cell lengths in the 3 directions
Definition at line 81 of file isosurface.h. |
|
the origin of the density values
Definition at line 82 of file isosurface.h. |
|
the list of points forming the isosurface
Definition at line 83 of file isosurface.h. |
|
the list of triangles forming the isosurface
Definition at line 84 of file isosurface.h. |
|
holds the current isodensity value
Definition at line 85 of file isosurface.h. |
|
a list of isodensity values for each calculated surface
Definition at line 86 of file isosurface.h. |
|
an easily accessible list of vertices for each calculated surface
Definition at line 87 of file isosurface.h. |
|
an easily accessible list of vertex indices for each calculated surface
Definition at line 88 of file isosurface.h. |
|
a list of normals for each calculated surface
Definition at line 89 of file isosurface.h. |
|
lookup table for edges
Definition at line 92 of file isosurface.h. |
|
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. |