Version: 9.12.0
GLViewer_Tools.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // Author : OPEN CASCADE
24 // File: GLViewer_Tools.h
25 // Created: April, 2005
26 //
27 #ifndef GLVIEWER_TOOLS_H
28 #define GLVIEWER_TOOLS_H
29 
30 #ifdef WIN32
31 #include "windows.h"
32 #endif
33 
34 #include "GLViewer.h"
35 
41 {
42 public:
43  //GLViewer_Tools();
44  //virtual ~GLViewer_Tools();
45  //static
46 
47 };
48 
51 {
52  FD_X = 0, /*along x axis*/
53  FD_Y /*along y axis*/
54 };
55 
64 {
65 public:
66  GLViewer_LineList( int );
67  virtual ~GLViewer_LineList();
68 
70  int count() const { return mySegmentNumber; }
72  int size() const { return myRealSize; }
73 
74  bool addSegment( double coord1, double coord2 );
75  bool removeSegment( int index );
76  bool removeSegment( double coord1, double coord2 );
77 
78  bool readSegment( int index, double& coord1, double& coord2 );
79 
81  int contains( double thePoint ) const;
82 
84  void setMainCoord( double theVal ) { myMainCoord = theVal; }
85  double mainCoord() const { return myMainCoord; }
86 
87  void clear();
88  void print();
89 
90  void show( FieldDim );
91 
93 
94 private:
95  double* myArray;
98 
99  double myMainCoord;
100 };
101 
103 struct GraphNode
104 {
105  int myCount;
109  int prevNodeIndex; //feedback for searching for solution
110 };
111 
114 {
120 };
121 
128 {
129 public:
132  {
133  FP_Start = 0,
134  FP_End = 1
135  };
136 
139  {
140  IS_ERROR = 0,
143  IS_SOLVED
144  };
145 
148  {
149  ES_ERROR = 0,
151  ES_SOLVED
152  };
153 
155  GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
156  virtual ~GLViewer_LineField();
157 
159 
162  void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
163 
165 
166  int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
168  int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
169 
171  static FieldDim invertDim( FieldDim );
172 
174  GLViewer_LineList* getLine( int index, FieldDim );
175 
177  void setBorders( double X1, double X2, double Y1, double Y2 );
179  void addRectangle( double top, double right, double bottom, double left );
180 
182  int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
183 
184  void print();
185 
186  void show();
187 
188  int getDimSize( FieldDim );
190  int segmentNumber();
191 
193  bool setPoint( FieldPoint, double x, double y );
194 
196 
197  void optimize();
199 
200  void initialize();
203 
205  double* solution( int& size );
206 
207 protected:
209  void iteration();
212 
214  int* findByCount( int& theParam );
216  int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
217 
222 
224  int maxSegmentNum();
225 
228 
229 private:
232 
233  int myXSize,
235 
239 
243 };
244 
245 #endif //GLVIEWER_TOOLS_H
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
FieldDim
Dimension of line.
Definition: GLViewer_Tools.h:51
@ FD_Y
Definition: GLViewer_Tools.h:53
@ FD_X
Definition: GLViewer_Tools.h:52
Definition: GLViewer_Tools.h:128
int myYSize
Definition: GLViewer_Tools.h:234
IterationStatus
Status of interation.
Definition: GLViewer_Tools.h:139
@ IS_LOOP
Definition: GLViewer_Tools.h:141
@ IS_NOT_SOLVED
Definition: GLViewer_Tools.h:142
@ IS_ERROR
Definition: GLViewer_Tools.h:140
@ IS_SOLVED
Definition: GLViewer_Tools.h:143
int insertLine(FieldDim theDim, GLViewer_LineList *, int thePosition)
Adds new line and sorted field.
Definition: GLViewer_Tools.cxx:543
int myCurArrayIndex
Definition: GLViewer_Tools.h:238
GraphNode * myGraphArray1
Definition: GLViewer_Tools.h:236
int * findByCount(int &theParam)
Finds LineList by counts and returns indexes.
Definition: GLViewer_Tools.cxx:1050
int myXSize
Definition: GLViewer_Tools.h:233
virtual ~GLViewer_LineField()
Definition: GLViewer_Tools.cxx:489
GraphNode * getSecArray()
Returns.
Definition: GLViewer_Tools.cxx:1185
int segmentNumber()
Returns number of segment.
Definition: GLViewer_Tools.cxx:840
int * intersectIndexes(FieldDim theDim, int theIndex, const GLViewer_LineList *theLL, int &theSize)
returns arrey of intersects indexes with
Definition: GLViewer_Tools.cxx:757
IterationStatus checkComplete()
Checks for complete status.
Definition: GLViewer_Tools.cxx:997
void setBorders(double X1, double X2, double Y1, double Y2)
Nullifys field and sets same continued segments.
Definition: GLViewer_Tools.cxx:654
static FieldDim invertDim(FieldDim)
Returns other dimension.
Definition: GLViewer_Tools.cxx:613
SearchPoint myEndPoint
Definition: GLViewer_Tools.h:241
void optimize()
Optimize field.
Definition: GLViewer_Tools.cxx:856
void initialize()
Some prepare actions.
Definition: GLViewer_Tools.cxx:907
GLViewer_LineField()
Definition: GLViewer_Tools.cxx:438
bool setPoint(FieldPoint, double x, double y)
Sets start/end search point.
Definition: GLViewer_Tools.cxx:786
void addLine(FieldDim, GLViewer_LineList *)
Adds new line.
Definition: GLViewer_Tools.cxx:517
void iteration()
One iteration of algorithm.
Definition: GLViewer_Tools.cxx:963
GraphNode * myGraphArray2
Definition: GLViewer_Tools.h:237
GLViewer_LineList * getLine(int index, FieldDim)
Returns line by index and dimension.
Definition: GLViewer_Tools.cxx:626
void print()
Definition: GLViewer_Tools.cxx:701
EndStatus startAlgorithm()
Main method.
Definition: GLViewer_Tools.cxx:1101
GLViewer_LineList ** myYLineArray
Definition: GLViewer_Tools.h:231
void show()
Definition: GLViewer_Tools.cxx:715
SearchPoint myStartPoint
Definition: GLViewer_Tools.h:240
int getDimSize(FieldDim)
Definition: GLViewer_Tools.cxx:740
double * solution(int &size)
Returns solution and size of solution.
Definition: GLViewer_Tools.cxx:1125
int findBySegment(FieldDim, int coord1, int coord2, bool inCurArray=true)
Finds LineList by segment and dimension.
Definition: GLViewer_Tools.cxx:1077
GLViewer_LineList ** getLLArray(FieldDim)
Returns list of LileList by dimension.
Definition: GLViewer_Tools.cxx:1222
int maxSegmentNum()
Returns maximum segment number.
Definition: GLViewer_Tools.cxx:1199
GLViewer_LineList ** myXLineArray
Definition: GLViewer_Tools.h:230
GraphNode * getCurArray()
Returns current solution array.
Definition: GLViewer_Tools.cxx:1171
int myCurCount
Definition: GLViewer_Tools.h:242
void addRectangle(double top, double right, double bottom, double left)
Cut rectangle in grid.
Definition: GLViewer_Tools.cxx:679
FieldPoint
Searched point.
Definition: GLViewer_Tools.h:132
@ FP_Start
Definition: GLViewer_Tools.h:133
@ FP_End
Definition: GLViewer_Tools.h:134
EndStatus
Final status of solving.
Definition: GLViewer_Tools.h:148
@ ES_LOOP
Definition: GLViewer_Tools.h:150
@ ES_SOLVED
Definition: GLViewer_Tools.h:151
@ ES_ERROR
Definition: GLViewer_Tools.h:149
Definition: GLViewer_Tools.h:64
bool removeSegment(int index)
Definition: GLViewer_Tools.cxx:209
GLViewer_LineList & operator=(GLViewer_LineList)
int contains(double thePoint) const
Returns index of segment, else -1.
Definition: GLViewer_Tools.cxx:192
void setMainCoord(double theVal)
Sets level of segments.
Definition: GLViewer_Tools.h:84
int mySegmentNumber
Definition: GLViewer_Tools.h:97
void clear()
Definition: GLViewer_Tools.cxx:384
GLViewer_LineList(int)
Definition: GLViewer_Tools.cxx:42
double mainCoord() const
Definition: GLViewer_Tools.h:85
bool readSegment(int index, double &coord1, double &coord2)
Definition: GLViewer_Tools.cxx:177
void show(FieldDim)
Definition: GLViewer_Tools.cxx:406
int count() const
Returns number of segments.
Definition: GLViewer_Tools.h:70
bool addSegment(double coord1, double coord2)
Definition: GLViewer_Tools.cxx:71
void print()
Definition: GLViewer_Tools.cxx:393
double * myArray
Definition: GLViewer_Tools.h:95
virtual ~GLViewer_LineList()
Definition: GLViewer_Tools.cxx:62
double myMainCoord
Definition: GLViewer_Tools.h:99
int size() const
Returns real size.
Definition: GLViewer_Tools.h:72
int myRealSize
Definition: GLViewer_Tools.h:96
Definition: GLViewer_Tools.h:41
Definition: GLViewer_Tools.h:104
int myLineIndex
Definition: GLViewer_Tools.h:107
int myCount
Definition: GLViewer_Tools.h:105
FieldDim myDim
Definition: GLViewer_Tools.h:106
int mySegmentindex
Definition: GLViewer_Tools.h:108
int prevNodeIndex
Definition: GLViewer_Tools.h:109
Definition: GLViewer_Tools.h:114
int myXSegmentIndex
Definition: GLViewer_Tools.h:116
int myYLineIndex
Definition: GLViewer_Tools.h:117
int myYSegmentIndex
Definition: GLViewer_Tools.h:118
int mySolveIndex
Definition: GLViewer_Tools.h:119
int myXLineIndex
Definition: GLViewer_Tools.h:115