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;
41 class GLVIEWER_API GLViewer_Tools
45 //virtual ~GLViewer_Tools();
53 FD_X = 0, /*along x axis*/
58 \class GLViewer_LineList
59 Tools for distinct line
60 This class implmented interface for segment operations:
61 add, cut, remove and etc.
62 Memory does not changed and allocated only one time
64 class GLViewer_LineList
67 GLViewer_LineList( int );
68 virtual ~GLViewer_LineList();
70 //! Returns number of segments
71 int count() const { return mySegmentNumber; }
73 int size() const { return myRealSize; }
75 bool addSegment( double coord1, double coord2 );
76 bool removeSegment( int index );
77 bool removeSegment( double coord1, double coord2 );
79 bool readSegment( int index, double& coord1, double& coord2 );
81 //! Returns index of segment, else -1
82 int contains( double thePoint ) const;
84 //! Sets level of segments
85 void setMainCoord( double theVal ) { myMainCoord = theVal; }
86 double mainCoord() const { return myMainCoord; }
91 void show( FieldDim );
93 GLViewer_LineList& operator = ( GLViewer_LineList );
103 /*! struct GraphNode describe node in algorithm on rare grid*/
110 int prevNodeIndex; //feedback for searching for solution
113 /*! struct SearchPoint describe node for solving algorithm*/
124 \class GLViewer_LineField
125 Tools for solving algorithm of finding shortest path on rare grid with minimum of
128 class GLViewer_LineField
138 //! Status of interation
147 //! Final status of solving
155 GLViewer_LineField();
156 GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
157 virtual ~GLViewer_LineField();
160 /*!best way, if line is already sorted*/
161 void addLine( FieldDim, GLViewer_LineList* );
163 void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
165 //! Adds new line and sorted field
166 /*! Returns position*/
167 int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
169 int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
171 //! Returns other dimension
172 static FieldDim invertDim( FieldDim );
174 //! Returns line by index and dimension
175 GLViewer_LineList* getLine( int index, FieldDim );
177 //! Nullifys field and sets same continued segments
178 void setBorders( double X1, double X2, double Y1, double Y2 );
179 //! Cut rectangle in grid
180 void addRectangle( double top, double right, double bottom, double left );
182 //! returns arrey of intersects indexes with \param theLL
183 int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
189 int getDimSize( FieldDim );
190 //! Returns number of segment
193 //! Sets start/end search point
194 bool setPoint( FieldPoint, double x, double y );
197 /*! Removes all multiple segments*/
199 //! Some prepare actions
200 /*! Needs call setPoint before*/
203 EndStatus startAlgorithm();
205 //! Returns solution and size of solution
206 double* solution( int& size );
209 //! One iteration of algorithm
211 //! Checks for complete status
212 IterationStatus checkComplete();
214 //! Finds LineList by counts and returns indexes
215 int* findByCount( int& theParam );
216 //! Finds LineList by segment and dimension
217 int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
219 //! Returns current solution array
220 GraphNode* getCurArray();
222 GraphNode* getSecArray();
224 //! Returns maximum segment number
227 //! Returns list of LileList by dimension
228 GLViewer_LineList** getLLArray( FieldDim );
231 GLViewer_LineList** myXLineArray,
237 GraphNode* myGraphArray1,
241 SearchPoint myStartPoint,
246 #endif //GLVIEWER_TOOLS_H