Files Classes Functions Hierarchy
00001 #ifndef D4GRID_H 00002 #define D4GRID_H 00003 00004 #include <cassert> 00005 using namespace std; 00006 00007 #include <d4tess.h> 00008 #include <d4tessdraw.h> 00009 00010 typedef unsigned int uint; 00011 typedef unsigned int const uintc; 00012 typedef double real; 00013 typedef double const realc; 00014 00015 00016 // 00017 // Marching Tetrahedrons on 3D grid implemented. 00018 // 00019 // Rushed code: 00020 // d4grid::draw calls d4tessdraw::eval which uses 00021 // d4marchdisp. 00022 // 00023 // Client calls setf to evaluate function over grid. 00024 class d4grid : public d4tess 00025 { 00026 uint dimX; 00027 uint dimY; 00028 uint dimZ; 00029 00030 void add( uintc i, uintc k, uintc m ); 00031 00032 public: 00033 00034 d4grid 00035 ( 00036 uintc _dimX, 00037 uintc _dimY, 00038 uintc _dimZ, 00039 realc x0, realc x1, // Ranges in the X dimension 00040 realc y0, realc y1, // Ranges in the Y dimension 00041 realc z0, realc z1 // Ranges in the Z dimension 00042 ); 00043 00044 // Function assigning a value at a point. 00045 // F::operator(double & f, doube const x, realc y) expected. 00046 template< typename F > 00047 void setf(F const & f); 00048 00049 // From the points linearly interpolate and draw. 00050 void draw(realc cut=0.0) const; 00051 00052 }; 00053 00054 00055 // -------------------------------------------------- 00056 // Implementation 00057 // 00058 00059 template< typename F > 00060 void d4grid::setf(F const & f ) 00061 { 00062 uint indx=0; 00063 00064 uint i,k,m; 00065 for (m=0; m<(dimZ+1); ++m) 00066 for (k=0; k<(dimY+1); ++k) 00067 for (i=0; i<(dimX+1); ++i) 00068 { 00069 f(pt[indx].a,pt[indx].x,pt[indx].y,pt[indx].z); 00070 ++indx; 00071 } 00072 } 00073 00074 00075 00076 00077 00078 #endif 00079 00080
1.5.8