00001 #if !defined(__FLOWVIZ_H)
00002 #define __FLOWVIZ_H
00003
00004 #include "MyMathUtils.h"
00005 #include "Streamline.h"
00006
00007
00008 const int rasterPosX=350;
00009 const int rasterPosY=70;
00010 const int xOut=350;
00011 const int yOut=560;
00012
00013 const int maxIntegrationSteps=1000;
00014 const float eps = static_cast<float>(0.0001);
00015 const float stride = static_cast<float>(0.1);
00016
00017
00022 class Data
00023 {
00024 public:
00025 Vektor2f *position;
00026 GLubyte *show;
00027 float *flowX;
00028 float *flowY;
00029 float *pressure;
00030 float *vorticity;
00031 float *fx;
00032 float *fy;
00033 float *fv;
00034 float *fp;
00035 float *fvor;
00036 float length_interval_x;
00037 float length_interval_y;
00038 int dsep;
00039 float dtest;
00040 float dtestfactor;
00041 int method;
00042 int background;
00043 bool hedgehog;
00044 bool vel;
00045 float scale_SmallToBig_x;
00046 float scale_SmallToBig_y;
00047 float scale_BigToSmall_x;
00048 float scale_BigToSmall_y;
00049 int cells[9];
00050 Streamline *slByHand;
00051 vector<Streamline*> streamLines;
00052 vector<Vektor2i*> seedCandidates;
00053
00064 struct Header
00065 {
00066 short xDim;
00067 short yDim;
00068 short zDim;
00069 short nf;
00070 short nt;
00071 double dt;
00072 };
00073
00074 Header header;
00075
00076 public:
00077
00082 Data()
00083 {
00084 Initialize();
00085 }
00086
00091 virtual ~Data()
00092 {
00093 Destroy();
00094 }
00095
00099 void getData(CString fileName);
00100
00104 void showData();
00105
00109 void drawHedgehogPlot(int length);
00110
00114 void drawStreamlines();
00115
00119 void drawSingleStreamline(Streamline *sl);
00120
00125 void showSingleStreamline(int x, int y);
00126
00130 void processUserInput();
00131
00132
00133
00134 private:
00135
00139 void Initialize();
00140
00144 void Destroy();
00145
00149 void initializeGlobals();
00150
00155 void doCleanUp();
00156
00162 void extractData();
00163
00168 void addSamplePointsToCells(Streamline *sl);
00169
00173 void calculateStreamlines();
00174
00179 void addStreamLineToVector(Streamline *sl);
00180
00184 Streamline getStreamLineFromVector(int pos);
00185
00189 void calculateSeedCandidates(Streamline *sl);
00190
00195 void addSeedCandidate(int x, int y);
00196
00200 Vektor2i getSeedCandidate(int pos);
00201
00205 void deleteFirstSeedCandidate();
00206
00211 float* getInterpolatedMatrix(float *in, float *out, float *minval, float *maxval);
00212
00217 float getMaxValue(float *in, int xDim, int yDim);
00218
00223 float getMinValue(float *in, int xDim, int yDim);
00224
00228 float getMaxAbs(float a, float b);
00229
00235 float* getVelocityMatrix(float *in1, float *in2, float *out, int xDim, int yDim);
00236
00244 void generateShowArray(float *in, float posFactor, float negFactor);
00245
00250 float* addToMatrix(float *in, float val, int xDim, int yDim);
00251
00255 float round(float a);
00256
00260 float getDistance(Vektor2i v1, Vektor2i v2);
00261
00267 Vektor2f integrateEuler(Vektor2f old, float dt, int direction);
00268
00274 Vektor2f integrateRK2(Vektor2f old, float dt, int direction);
00275
00281 Vektor2f integrateRK4(Vektor2f old, float dt, int direction);
00282
00286 bool checkPoint(Vektor2f point);
00287
00291 bool checkCoordinates(int x, int y);
00292
00296 Vektor2f getFlow(Vektor2f in);
00297
00301 Vektor2f getInitialStreamlineSeedPoint();
00302
00308 bool checkValidity(Vektor2i sp, float mindistance);
00309
00316 void integrateStreamline(Streamline* sl, Vektor2f seed, int method, int direction, bool single);
00317
00324 Streamline* getStreamline(Vektor2f seed, int method, bool single);
00325
00330 void transformSmallToBig(float x, float y, int *res_x, int *res_y);
00331
00336 void transformBigToSmall(float *res_x, float *res_y, int x, int y);
00337
00343 int getAddress(float x, float y, int old_adr);
00344
00349 void drawLine(int x1, int y1, int x2, int y2);
00350
00355 float bilinearInterpolationRegular(float x,
00356 float y,
00357 float val_lxly,
00358 float val_uxly,
00359 float val_lxuy,
00360 float val_uxuy);
00361
00362
00367 float bilinearInterpolationIrregular(float x,
00368 float y,
00369 float lxb,
00370 float lyb,
00371 float uxb,
00372 float uyb,
00373 float val_lxly,
00374 float val_uxly,
00375 float val_lxuy,
00376 float val_uxuy);
00377
00378 };
00379 #endif //#if !defined(__FLOWVIZ_H)