1 // Copyright (C) 2005 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
19 // Author : OPEN CASCADE
22 // File: GLViewer_Tools.h
23 // Created: April, 2005
25 #ifndef GLVIEWER_TOOLS_H
26 #define GLVIEWER_TOOLS_H
33 #include "GLViewer_Defs.h"
35 class GLViewer_LineField;
37 /****************************************************************************
38 ** Class: GLViewer_Tools
39 ** Descr: Tools for Viewer
41 ** Created: UI team, 27.10.05
42 *****************************************************************************/
43 class GLVIEWER_API GLViewer_Tools
47 //virtual ~GLViewer_Tools();
55 FD_X = 0, /*along x axis*/
60 Class GLViewer_LineList
61 Tools for distinct line
62 This class implmented interface for segment operations:
63 add, cut, remove and etc.
64 Memory does not changed and allocated only one time
66 class GLViewer_LineList
69 GLViewer_LineList( int );
70 virtual ~GLViewer_LineList();
72 //! Returns number of segments
73 int count() const { return mySegmentNumber; }
75 int size() const { return myRealSize; }
77 bool addSegment( double coord1, double coord2 );
78 bool removeSegment( int index );
79 bool removeSegment( double coord1, double coord2 );
81 bool readSegment( int index, double& coord1, double& coord2 );
83 //! Returns index of segment, else -1
84 int contains( double thePoint ) const;
86 //! Sets level of segments
87 void setMainCoord( double theVal ) { myMainCoord = theVal; }
88 double mainCoord() const { return myMainCoord; }
93 void show( FieldDim );
95 GLViewer_LineList& operator = ( GLViewer_LineList );
105 /*! struct GraphNode describe node in algorithm on rare grid*/
112 int prevNodeIndex; //feedback for searching for solution
115 /*! struct SearchPoint describe node for solving algorithm*/
125 /*! Class GLViewer_LineField
126 * Tools for solving algorithm of finding shortest path on rare grid with minimum of
129 class GLViewer_LineField
139 //! Status of interation
148 //! Final status of solving
156 GLViewer_LineField();
157 GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
158 virtual ~GLViewer_LineField();
161 /*!best way, if line is already sorted*/
162 void addLine( FieldDim, GLViewer_LineList* );
164 void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
166 //! Adds new line and sorted field
167 /*! Returns position*/
168 int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
170 int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
172 //! Returns other dimension
173 static FieldDim invertDim( FieldDim );
175 //! Returns line by index and dimension
176 GLViewer_LineList* getLine( int index, FieldDim );
178 //! Nullifys field and sets same continued segments
179 void setBorders( double X1, double X2, double Y1, double Y2 );
180 //! Cut rectangle in grid
181 void addRectangle( double top, double right, double bottom, double left );
183 //! returns arrey of intersects indexes with \param theLL
184 int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
190 int getDimSize( FieldDim );
191 //! Returns number of segment
194 //! Sets start/end search point
195 bool setPoint( FieldPoint, double x, double y );
198 /*! Removes all multiple segments*/
200 //! Some prepare actions
201 /*! Needs call setPoint before*/
204 EndStatus startAlgorithm();
206 //! Returns solution and size of solution
207 double* solution( int& size );
210 //! One iteration of algorithm
212 //! Checks for complete status
213 IterationStatus checkComplete();
215 //! Finds LileList by counts and returns indexes
216 int* findByCount( int& theParam );
217 //! Finds LileList by segment and dimension
218 int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
220 //! Returns current solution array
221 GraphNode* getCurArray();
223 GraphNode* getSecArray();
225 //! Returns maximum segment number
228 //! Returns list of LileList by dimension
229 GLViewer_LineList** getLLArray( FieldDim );
232 GLViewer_LineList** myXLineArray,
238 GraphNode* myGraphArray1,
242 SearchPoint myStartPoint,
247 #endif //GLVIEWER_TOOLS_H