00001
00002
00003
#ifndef GUARD_Node_h
00004
#define GUARD_Node_h
00005
00006
#include <string>
00007
#include <list>
00008
#include <iostream>
00009
#include <sstream>
00010
#include <iomanip>
00011
#include <fstream>
00012
#include <assert.h>
00013
00014
#include "Debug.hpp"
00015
00016
#include "PNG.hpp"
00017
#include "EPSWriter.hpp"
00018
00019
using namespace std;
00020
00021
static Channel channelGraph(&cout);
00022
class Edge;
00023
class Node_Iterator;
00024
class Edge_Iterator;
00025
class PixelMap;
00026
00027
00028
00029
00030
00031
00032
00033 class Node{
00034
friend class Node_Leaf;
00035
friend class Node_Graph;
00036
friend class Node_Iterator;
00037
friend class Edge_Iterator;
00038
00039 Node_Leaf*
p;
00040
00041
Node(
Node_Leaf*);
00042
public:
00043
00044
Node();
00045
00046
static Node CreateLeaf(string =
"");
00047
00048
static Node Node::CreateGraph(string =
"");
00049
00050
static Node CreateGridGraph(
PNG, string =
"");
00051
00052
Node(
const Node&);
00053
00054
Node&
operator=(
const Node&);
00055
00056
~Node();
00057
00058 string
toString(
int,
bool child =
false,
bool edge =
false)
const;
00059
00060
int getRank() const;
00061
00062
void setRank(
int);
00063
00064
Pixel getPixel()const;
00065
00066
void setPixel(
Pixel);
00067
00068
double getWeight();
00069
00070
void setWeight(
double);
00071
00072
PixelMap* makeMap(
int)const;
00073
00074
void drawPNG(string,
int)const;
00075
00076
void drawBorderPNG(string,
int)const;
00077
00078
void drawEPS(string,
int)const;
00079
00080
int getNodeSize();
00081
00082
int getLeafSize();
00083
00084
int getEdgeSize();
00085
00086
void sortEdge();
00087
00088
void sortEdge(
float& min,
float& max);
00089
00090
void addNode(
Node);
00091
00092
void addEdge(
Edge);
00093
00094
Node_Iterator getNodeIterator();
00095
00096
Edge_Iterator getEdgeIterator();
00097
00098
void merge(Node);
00099 };
00100 #include "Edge.hpp"
00101 #include "Iterator.hpp"
00102 #include "
PixelMap.hpp"
00103
00104
00105
00106
00107
00108 class
Node_Leaf {
00109
friend class Node;
00110
friend class Node_Graph;
00111
friend class Node_Iterator;
00112
friend class Edge_Iterator;
00113
00114 Node_Leaf();
00115
protected:
00116
00117 int use;
00118
00119 int rank;
00120
00121 double weight;
00122
00123
virtual string toString(
int level,
bool child,
bool edge)
const;
00124
00125 Pixel pixel;
00126
00127
int getRank()const;
00128
00129
void setRank(
int);
00130
00131
double getWeight() const;
00132
00133
void setWeight(
double);
00134
00135 Pixel getPixel() const;
00136
00137
void setPixel(Pixel);
00138
00139 virtual
PixelMap* makeMap(
PixelMap*,
int,
int,
int)const;
00140
00141 virtual
void drawPNG(
PNG,
int,
Color,
int);
00142
00143 virtual
void drawNodeEPS(
EPSWriter&,
int, Color,
int,
int);
00144
00145 virtual
void drawEdgeEPS(EPSWriter&,
int){}
00146
00147
virtual int getNodeSize()const;
00148
00149 virtual
int getLeafSize()const;
00150
00151 virtual
int getEdgeSize()const;
00152
00153 virtual
void addNode(Node);
00154
00155 virtual
void addEdge(Edge);
00156
00157 virtual
void sortEdge(){}
00158
00159 virtual void sortEdge(
float&,
float&){}
00160
00161 virtual void merge(Node){}
00162
00163
virtual Node_Iterator getNodeIterator() const ;
00164
00165 virtual
Edge_Iterator getEdgeIterator() const ;
00166
00167 virtual
void _size(
int&,
int&,
int&,
int&);
00168 };
00169
00170
00171
00172
00173
00174 class
Node_Graph : public Node_Leaf {
00175
00176
friend class Node_Leaf;
00177
00178
friend class Node;
00179
00180
friend class Node_Iterator;
00181
00182
friend class Edge_Iterator;
00183
00184 vector<Node> vNode;
00185
00186 vector<Edge> vEdge;
00187
00188
Node_Graph();
00189
00190 string toString(
int,
bool,
bool) const ;
00191
00192
void _size(
int&,
int&,
int&,
int&);
00193
00194
PixelMap* makeMap(
PixelMap*,
int,
int,
int)const;
00195
00196
void drawPNG(
PNG,
int,
Color,
int);
00197
00198
void drawNodeEPS(
EPSWriter&,
int, Color,
int,
int);
00199
00200
void drawEdgeEPS(EPSWriter&,
int);
00201
00202
int getNodeSize() const;
00203
00204
int getLeafSize() const;
00205
00206
int getEdgeSize() const;
00207
00208
void sortEdge();
00209
00210
void sortEdge(
float&,
float&);
00211
00212
void addNode(Node);
00213
00214
void addEdge(Edge);
00215
00216
void merge(Node);
00217
00218
Node_Iterator getNodeIterator() const;
00219
00220
Edge_Iterator getEdgeIterator() const;
00221
00222
00223 };
00224 #endif
00225
00226
00227