1 // File: GLViewer_Tools.h
2 // Created: April, 2005
4 // Copyright (C) CEA 2005
6 #ifndef GLVIEWER_TOOLS_H
7 #define GLVIEWER_TOOLS_H
14 #include "GLViewer_Defs.h"
16 class GLViewer_LineField;
18 /****************************************************************************
19 ** Class: GLViewer_Tools
20 ** Descr: Tools for Viewer
22 ** Created: UI team, 27.10.05
23 *****************************************************************************/
24 class GLVIEWER_API GLViewer_Tools
28 //virtual ~GLViewer_Tools();
36 FD_X = 0, /*along x axis*/
41 Class GLViewer_LineList
42 Tools for distinct line
43 This class implmented interface for segment operations:
44 add, cut, remove and etc.
45 Memory does not changed and allocated only one time
47 class GLViewer_LineList
50 GLViewer_LineList( int );
51 virtual ~GLViewer_LineList();
53 //! Returns number of segments
54 int count() const { return mySegmentNumber; }
56 int size() const { return myRealSize; }
58 bool addSegment( double coord1, double coord2 );
59 bool removeSegment( int index );
60 bool removeSegment( double coord1, double coord2 );
62 bool readSegment( int index, double& coord1, double& coord2 );
64 //! Returns index of segment, else -1
65 int contains( double thePoint ) const;
67 //! Sets level of segments
68 void setMainCoord( double theVal ) { myMainCoord = theVal; }
69 double mainCoord() const { return myMainCoord; }
74 void show( FieldDim );
76 GLViewer_LineList& operator = ( GLViewer_LineList );
86 /*! struct GraphNode describe node in algorithm on rare grid*/
93 int prevNodeIndex; //feedback for searching for solution
96 /*! struct SearchPoint describe node for solving algorithm*/
106 /*! Class GLViewer_LineField
107 * Tools for solving algorithm of finding shortest path on rare grid with minimum of
110 class GLViewer_LineField
120 //! Status of interation
129 //! Final status of solving
137 GLViewer_LineField();
138 GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
139 virtual ~GLViewer_LineField();
142 /*!best way, if line is already sorted*/
143 void addLine( FieldDim, GLViewer_LineList* );
145 void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
147 //! Adds new line and sorted field
148 /*! Returns position*/
149 int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
151 int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
153 //! Returns other dimension
154 static FieldDim invertDim( FieldDim );
156 //! Returns line by index and dimension
157 GLViewer_LineList* getLine( int index, FieldDim );
159 //! Nullifys field and sets same continued segments
160 void setBorders( double X1, double X2, double Y1, double Y2 );
161 //! Cut rectangle in grid
162 void addRectangle( double top, double right, double bottom, double left );
164 //! returns arrey of intersects indexes with \param theLL
165 int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
171 int getDimSize( FieldDim );
172 //! Returns number of segment
175 //! Sets start/end search point
176 bool setPoint( FieldPoint, double x, double y );
179 /*! Removes all multiple segments*/
181 //! Some prepare actions
182 /*! Needs call setPoint before*/
185 EndStatus startAlgorithm();
187 //! Returns solution and size of solution
188 double* solution( int& size );
191 //! One iteration of algorithm
193 //! Checks for complete status
194 IterationStatus checkComplete();
196 //! Finds LileList by counts and returns indexes
197 int* findByCount( int& theParam );
198 //! Finds LileList by segment and dimension
199 int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
201 //! Returns current solution array
202 GraphNode* getCurArray();
204 GraphNode* getSecArray();
206 //! Returns maximum segment number
209 //! Returns list of LileList by dimension
210 GLViewer_LineList** getLLArray( FieldDim );
213 GLViewer_LineList** myXLineArray,
219 GraphNode* myGraphArray1,
223 SearchPoint myStartPoint,
228 #endif //GLVIEWER_TOOLS_H