00001
00002
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef QUAD_DBM_2D_H
00023 #define QUAD_DBM_2D_H
00024
00025 #define USINGGLUT
00026
00027 #include <vector>
00028 #ifdef USINGGLUT
00029 #include <gl/glut.h>
00030 #endif
00031 #include "DAG.h"
00032 #include "QUAD_POISSON.h"
00033
00037 class QUAD_DBM_2D
00038 {
00039 public:
00045 QUAD_DBM_2D(int xRes = 128, int yRes = 128, int iterations = 10);
00046
00048 virtual ~QUAD_DBM_2D();
00049
00051 bool addParticle();
00052
00055 bool hitGround(CELL* cell = NULL);
00056
00057 #ifdef USINGGLUT
00058
00059 void draw();
00060
00062 void drawSegments() {
00063 glLineWidth(1.0f);
00064 glPushMatrix();
00065 glTranslatef(-0.5f, -0.5f, 0.0f);
00066 _dag->draw();
00067 glPopMatrix();
00068 };
00069 #endif
00070
00072
00074
00076 void writeFields(const char* filename);
00077
00079 void readFields(const char* filename);
00080
00091 bool readImage(unsigned char* initial,
00092 unsigned char* attractors,
00093 unsigned char* repulsors,
00094 unsigned char* terminators,
00095 int xRes, int yRes);
00096
00098 void readDAG(const char* filename) { _dag->read(filename); };
00099
00101 void writeDAG(const char* filename) { _dag->write(filename); };
00102
00106 float*& renderOffscreen(int scale = 1) { return _dag->drawOffscreen(scale); };
00107
00109 int xRes() { return _xRes; };
00111 int yRes() { return _yRes; };
00113 int xDagRes() { return _dag->xRes(); };
00115 int yDagRes() { return _dag->yRes(); };
00117 int inputWidth() { return _dag->inputWidth(); };
00119 int inputHeight() { return _dag->inputHeight(); };
00120
00121 private:
00122 void allocate();
00123 void deallocate();
00124
00126
00128
00129
00130 int _xRes;
00131 int _yRes;
00132 int _maxRes;
00133 float _dx;
00134 float _dy;
00135 int _iterations;
00136
00137
00138 int _bottomHit;
00139
00140 DAG* _dag;
00141
00142 QUAD_POISSON* _quadPoisson;
00143
00144
00145 vector<CELL*> _candidates;
00146
00147
00148
00149 void checkForCandidates(CELL* cell);
00150
00151
00152 int _skips;
00153
00154
00155 RNG _twister;
00156 };
00157
00158 #endif