00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020
00021 #ifndef ISOSURFACE_H
00022 #define ISOSURFACE_H
00023
00025
00026
00027 #include <map>
00028 #include <vector>
00029 using std::map;
00030 using std::vector;
00031
00032
00033 #include <point3d.h>
00034
00036 class IsoSurface
00037 {
00038 public:
00039 IsoSurface();
00040 ~IsoSurface();
00041
00042 void setParameters(const std::vector<double>* values, const Point3D<unsigned int>& pointDimension, const Point3D<float>& pointDelta, const Point3D<float>& pointOrigin);
00043 void addSurface(const double isoDensity);
00044 void changeSurface(const unsigned int surface, const double isoDensity);
00045
00046 bool densityPresent() const;
00047 unsigned int numSurfaces() const;
00048 unsigned int numTriangles(const unsigned int surface) const;
00049 unsigned int numVertices(const unsigned int surface) const;
00050 void getTriangle(const unsigned int surface, const unsigned int index, Point3D<float>& point1, Point3D<float>& point2, Point3D<float>& point3,
00051 Point3D<float>& normal1, Point3D<float>& normal2, Point3D<float>& normal3) const;
00052 Point3D<float> getPoint(const unsigned int surface, const unsigned int index) const;
00053 void clearParameters();
00054 void clearSurfaces();
00055 void removeSurface(const unsigned int surface);
00056 Point3D<float> getOrigin() const;
00057 Point3D<float> getDelta() const;
00058 Point3D<unsigned int> getNumPoints() const;
00059
00060 private:
00062 struct Triangle
00064 {
00065 unsigned int pointID[3];
00066 };
00067
00069 void calculateSurface(const double isoDensity);
00070 Point3D<float> intersection(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge);
00071 Point3D<float> interpolate(const Point3D<float> point1, const Point3D<float> point2, const double var1, const double var2);
00072 unsigned int getEdgeID(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge);
00073 unsigned int getVertexID(const unsigned int x, const unsigned int y, const unsigned int z);
00074 void renameVerticesAndTriangles(vector<Point3D<float> >* singleVerticesList, vector<unsigned int>* singleTriangleIndices);
00075 void calculateNormals(vector<float>* singleNormals, const unsigned int surface);
00076 unsigned int getArrayIndex(const unsigned int x, const unsigned int y, const unsigned int z) const;
00077
00079 vector<double> densityValues;
00080 Point3D<unsigned int> numPoints;
00081 Point3D<float> delta;
00082 Point3D<float> origin;
00083 map<unsigned int, Point3D<float> > vertices;
00084 vector<Triangle> triangles;
00085 double currentIsoLevel;
00086 vector<double> isoLevels;
00087 vector< vector<Point3D<float> >* > verticesList;
00088 vector< vector<unsigned int>* > triangleIndices;
00089 vector< vector<float>* > normals;
00090
00092 static const unsigned int edgeTable[256];
00093 static const int triTable[256][16];
00094
00095 };
00096
00097 #endif
00098