00001
00002
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DAG_H
00023 #define DAG_H
00024
00025 #include <map>
00026 #include <vector>
00027 #include <cmath>
00028 #include <gl/glut.h>
00029
00030 using namespace std;
00031
00035 class DAG
00036 {
00037 public:
00039 DAG(int xRes, int yRes);
00041 virtual ~DAG();
00042
00044 void buildLeader(int bottomHit);
00045
00047 bool addSegment(int index, int neighbor);
00048
00050 void draw() { drawNode(_root); };
00051
00053 float*& drawOffscreen(int scale = 1);
00054
00056 void read(const char* filename);
00058 void write(const char* filename);
00059
00061 int xRes() { return _xRes; };
00063 int yRes() { return _yRes; };
00064
00066 int& inputWidth() { return _inputWidth; };
00068 int& inputHeight() { return _inputHeight; };
00069
00070 private:
00072 int _xRes;
00074 int _yRes;
00076 float _dx;
00078 float _dy;
00079
00083 struct NODE {
00084 int index;
00085 vector<NODE*> neighbors;
00086 NODE* parent;
00087 bool leader;
00088 bool secondary;
00089 int depth;
00090 NODE* maxDepthNode;
00091 float intensity;
00092
00093 NODE(int indexIn) {
00094 index = indexIn;
00095 parent = NULL;
00096 leader = false;
00097 depth = 0;
00098 maxDepthNode = NULL;
00099 };
00100 };
00102 void deleteNode(NODE* root);
00103
00105 NODE* _root;
00106
00108 map<int, NODE*> _hash;
00109
00111 void buildBranch(NODE* node, int depth);
00113 void drawNode(NODE* root);
00115 void findDeepest(NODE* root, NODE*& deepest);
00116
00118 void readNode(FILE* file);
00120 void writeNode(NODE* root, FILE* file);
00121
00123 int _totalNodes;
00124
00126 int _bottomHit;
00127
00129 void buildIntensity(NODE* root);
00130
00132 float _secondaryIntensity;
00134 float _leaderIntensity;
00135
00137
00140 float* _offscreenBuffer;
00141
00143 int _width;
00144
00146 int _height;
00147
00149 int _scale;
00150
00152 void drawOffscreenNode(NODE* root);
00153
00155 void drawLine(int begin[], int end[], float intensity);
00156
00158 int _inputWidth;
00160 int _inputHeight;
00161 };
00162
00163 #endif