Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MarchingCubesBase.h

Go to the documentation of this file.
00001 
00015 #ifndef __MARCHINGCUBESBASE_H__ // {{{ #endif
00016 #define __MARCHINGCUBESBASE_H__
00017 
00018 
00019 #include <GL/gl.h>
00020 #include <GL/glu.h>
00021 #define GLUT_DISABLE_ATEXIT_HACK
00022 #include <GL/glut.h>
00023 
00024 #include "General/vuLinAlg/vuVector.h"
00025 #include "MarchingCubesData.h"
00026 #include "MCBProgressCallback.h"
00027 
00028 
00032 #define MC_NUMCUBES     256
00033 
00034 
00038 #define MC_DEFAULT_BUFFER_SIZE 1000
00039 
00040 
00075 class MarchingCubesBase // {{{
00076 {
00077 
00078         private:
00079 
00080                 int _size[3];           
00081                 float _origin1;         
00082                 float _origin2;         
00083                 float _origin3;         
00084 
00085 #define MCB_IDX(x, y, z)        ( ((z)*_size[0]*_size[1]) + ((y)*_size[0]) + (x) )
00086 
00087         protected:
00088 
00089                 int* _data;             
00095         private:
00096 
00097                 MCGlobalData *_gd;      
00101                 bool _valueRangeAdjusted;
00107 
00108                 static const GLfloat _vertOffset[8][3];
00115                 static const int     _marchingCubesTable[256][16];
00117                 static const int     _edgeConnect[12][2];
00119                 static const int     _edgeSizeConnect[12];
00124                 static const int     _edgeMapping[12][3][3][3];
00125                 static const GLfloat _edgeDir[12][3];
00126                 static const int     _edgeFlags[256];
00127 
00128                 MCBProgressCallback  *_progCB;
00129                 MCBHistoCallback     *_histoCB;
00130 
00131                 MCMesh               *_mesh;
00132 
00133                 int                  _theCube;
00134                 MCMesh               *_cube;
00135 
00136         public:
00137 
00139                 MarchingCubesBase();
00141                 virtual ~MarchingCubesBase();
00142 
00144                 void setGlobalData(MCGlobalData *gd) { _gd = gd; }
00145 
00150                 void glRenderFrame();
00153                 void glRender();
00154 
00160                 void Size(int sz1, int sz2, int sz3);
00162                 int Size1() { return _size[0]; }
00164                 int Size2() { return _size[1]; }
00166                 int Size3() { return _size[2]; }
00168                 int maxSize();
00170                 void Origin(float or1, float or2, float or3);
00171                 float Origin1() { return _origin1; }
00172                 float Origin2() { return _origin2; }
00173                 float Origin3() { return _origin3; }
00174 
00181                 void marchCubes();
00182 
00183                 long long numVertices();
00184                 long long numTriangles();
00185                 long long numIndices();
00186 
00194                 int getCubeType(int x, int y, int z);
00195 
00202                 float valueAt(float px, float py, float pz);
00203 
00204         private:
00205 
00207                 void drawHorCylinder(int pos, float angle, float r, float l);
00209                 void drawVertCylinder(int pos, float r, float l);
00211                 void drawCorner(int pos, float r);
00212 
00213                 void drawSpot(int pos);
00214                 void drawTriangles();
00215 
00220                 inline vuVector calcVertex(int x, int y, int z, int edge);
00221 
00222         public:
00223 
00224                 void SetProgressCallback(MCBProgressCallback* cb);
00225                 void SetHistoCallback(MCBHistoCallback* cb);
00226 
00227         protected:
00228 
00229                 void SetProgressText(const char* txt);
00230                 void StartProgress();
00231                 void UpdateProgress(int v);
00232                 void EndProgress();
00233 
00234 }; /* }}} MarchingCubesBase */
00235 
00236 
00237 #endif /* }}} __MARCHINGCUBESBASE_H__ */
00238 
00239 
00240 // vim:fdm=marker:fdc=3:fdl=99:tw=100

Generated on Wed Dec 15 21:20:29 2004 for vuVolume by  doxygen 1.3.9.1