isosurface.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                          isosurface.h  -  description
00003                              -------------------
00004     begin                : Fri Mar 11 2005
00005     copyright            : (C) 2005-2006 by Ben Swerts
00006     email                : bswerts@users.sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00020 
00021 #ifndef ISOSURFACE_H
00022 #define ISOSURFACE_H
00023 
00025 
00026 // STL includes
00027 #include <map>
00028 #include <vector>
00029 using std::map;
00030 using std::vector;
00031 
00032 // Xbrabo includes
00033 #include <point3d.h>
00034 
00036 class IsoSurface
00037 {
00038   public:
00039         IsoSurface();                       // constructor
00040           ~IsoSurface();                      // destructor
00041 
00042           void setParameters(const std::vector<double>* values, const Point3D<unsigned int>& pointDimension, const Point3D<float>& pointDelta, const Point3D<float>& pointOrigin);         // set up the parameters for the surface 
00043           void addSurface(const double isoDensity); // calculates a new surface
00044     void changeSurface(const unsigned int surface, const double isoDensity);      // recalculates a surface
00045 
00046     bool densityPresent() const;          // returns whether a density has been loaded
00047     unsigned int numSurfaces() const;     // returns the number of calculated surfaces
00048     unsigned int numTriangles(const unsigned int surface) const;        // returns the number of triangles a certain surface consists of
00049           unsigned int numVertices(const unsigned int surface) const;         // returns the number of points a certain surface consists of
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;// return the data of a triangle of a surface    
00052     Point3D<float> getPoint(const unsigned int surface, const unsigned int index) const;    // returns the coordinates of a point on a surface
00053     void clearParameters();               // clear all data
00054     void clearSurfaces();                 // removes all existing surfaces
00055     void removeSurface(const unsigned int surface); // removes a certain surface
00056     Point3D<float> getOrigin() const;               // returns the set origin
00057     Point3D<float> getDelta() const;                // returns the set deltas
00058     Point3D<unsigned int> getNumPoints() const;     // returns the number of points in all directions
00059 
00060   private:
00062           struct Triangle
00064           {
00065       unsigned int pointID[3];
00066           };
00067 
00069     void calculateSurface(const double isoDensity); // does the basic surface calculation
00070     Point3D<float> intersection(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge);    // calculates the intersection
00071     Point3D<float> interpolate(const Point3D<float> point1, const Point3D<float> point2, const double var1, const double var2);   // linear interpolation
00072           unsigned int getEdgeID(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int edge);  // returns the ID of the edge 
00073           unsigned int getVertexID(const unsigned int x, const unsigned int y, const unsigned int z);     // returns the ID of the vertex 
00074           void renameVerticesAndTriangles(vector<Point3D<float> >* singleVerticesList, vector<unsigned int>* singleTriangleIndices);  // renames the vertices and triangles
00075     void calculateNormals(vector<float>* singleNormals, const unsigned int surface);        // calculates the normals
00076     unsigned int getArrayIndex(const unsigned int x, const unsigned int y, const unsigned int z) const;         // returns the index into the densityValues array
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 

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