Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef GLVIEWER_TOOLS_H
00028 #define GLVIEWER_TOOLS_H
00029
00030 #ifdef WIN32
00031 #include "windows.h"
00032 #endif
00033
00034 #include "GLViewer.h"
00035
00040 class GLVIEWER_API GLViewer_Tools
00041 {
00042 public:
00043
00044
00045
00046
00047 };
00048
00050 enum FieldDim
00051 {
00052 FD_X = 0,
00053 FD_Y
00054 };
00055
00063 class GLViewer_LineList
00064 {
00065 public:
00066 GLViewer_LineList( int );
00067 virtual ~GLViewer_LineList();
00068
00070 int count() const { return mySegmentNumber; }
00072 int size() const { return myRealSize; }
00073
00074 bool addSegment( double coord1, double coord2 );
00075 bool removeSegment( int index );
00076 bool removeSegment( double coord1, double coord2 );
00077
00078 bool readSegment( int index, double& coord1, double& coord2 );
00079
00081 int contains( double thePoint ) const;
00082
00084 void setMainCoord( double theVal ) { myMainCoord = theVal; }
00085 double mainCoord() const { return myMainCoord; }
00086
00087 void clear();
00088 void print();
00089
00090 void show( FieldDim );
00091
00092 GLViewer_LineList& operator = ( GLViewer_LineList );
00093
00094 private:
00095 double* myArray;
00096 int myRealSize;
00097 int mySegmentNumber;
00098
00099 double myMainCoord;
00100 };
00101
00103 struct GraphNode
00104 {
00105 int myCount;
00106 FieldDim myDim;
00107 int myLineIndex;
00108 int mySegmentindex;
00109 int prevNodeIndex;
00110 };
00111
00113 struct SearchPoint
00114 {
00115 int myXLineIndex;
00116 int myXSegmentIndex;
00117 int myYLineIndex;
00118 int myYSegmentIndex;
00119 int mySolveIndex;
00120 };
00121
00127 class GLViewer_LineField
00128 {
00129 public:
00131 enum FieldPoint
00132 {
00133 FP_Start = 0,
00134 FP_End = 1
00135 };
00136
00138 enum IterationStatus
00139 {
00140 IS_ERROR = 0,
00141 IS_LOOP,
00142 IS_NOT_SOLVED,
00143 IS_SOLVED
00144 };
00145
00147 enum EndStatus
00148 {
00149 ES_ERROR = 0,
00150 ES_LOOP,
00151 ES_SOLVED
00152 };
00153
00154 GLViewer_LineField();
00155 GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
00156 virtual ~GLViewer_LineField();
00157
00159
00160 void addLine( FieldDim, GLViewer_LineList* );
00162 void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
00163
00165
00166 int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
00168 int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
00169
00171 static FieldDim invertDim( FieldDim );
00172
00174 GLViewer_LineList* getLine( int index, FieldDim );
00175
00177 void setBorders( double X1, double X2, double Y1, double Y2 );
00179 void addRectangle( double top, double right, double bottom, double left );
00180
00182 int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
00183
00184 void print();
00185
00186 void show();
00187
00188 int getDimSize( FieldDim );
00190 int segmentNumber();
00191
00193 bool setPoint( FieldPoint, double x, double y );
00194
00196
00197 void optimize();
00199
00200 void initialize();
00202 EndStatus startAlgorithm();
00203
00205 double* solution( int& size );
00206
00207 protected:
00209 void iteration();
00211 IterationStatus checkComplete();
00212
00214 int* findByCount( int& theParam );
00216 int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
00217
00219 GraphNode* getCurArray();
00221 GraphNode* getSecArray();
00222
00224 int maxSegmentNum();
00225
00227 GLViewer_LineList** getLLArray( FieldDim );
00228
00229 private:
00230 GLViewer_LineList** myXLineArray,
00231 ** myYLineArray;
00232
00233 int myXSize,
00234 myYSize;
00235
00236 GraphNode* myGraphArray1,
00237 * myGraphArray2;
00238 int myCurArrayIndex;
00239
00240 SearchPoint myStartPoint,
00241 myEndPoint;
00242 int myCurCount;
00243 };
00244
00245 #endif //GLVIEWER_TOOLS_H