0027930: XMT file conversion loops infinitely
[occt.git] / src / IntPatch / IntPatch_TheIWalking.hxx
1 // Created on: 1992-05-06
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _IntPatch_TheIWalking_HeaderFile
18 #define _IntPatch_TheIWalking_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 #include <IntSurf_SequenceOfPathPoint.hxx>
26 #include <Standard_Real.hxx>
27 #include <math_Vector.hxx>
28 #include <IntWalk_VectorOfWalkingData.hxx>
29 #include <IntWalk_VectorOfInteger.hxx>
30 #include <IntSurf_PntOn2S.hxx>
31 #include <gp_Vec.hxx>
32 #include <gp_Dir2d.hxx>
33 #include <TColStd_SequenceOfInteger.hxx>
34 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
35 #include <IntPatch_SequenceOfIWLineOfTheIWalking.hxx>
36 #include <IntSurf_SequenceOfInteriorPoint.hxx>
37 #include <Standard_Integer.hxx>
38 #include <TColStd_SequenceOfReal.hxx>
39 #include <IntWalk_StatusDeflection.hxx>
40 #include <Bnd_Range.hxx>
41 class StdFail_NotDone;
42 class Standard_OutOfRange;
43 class IntSurf_PathPoint;
44 class IntSurf_PathPointTool;
45 class IntSurf_InteriorPoint;
46 class IntSurf_InteriorPointTool;
47 class Adaptor3d_HSurface;
48 class Adaptor3d_HSurfaceTool;
49 class IntPatch_TheSurfFunction;
50 class IntPatch_TheIWLineOfTheIWalking;
51 class IntSurf_PntOn2S;
52
53 class IntPatch_TheIWalking 
54 {
55 public:
56
57   DEFINE_STANDARD_ALLOC
58
59   
60   //! Deflection is the maximum deflection admitted between two
61   //! consecutive points on a resulting polyline.
62   //! Step is the maximum increment admitted between two
63   //! consecutive points (in 2d space).
64   //! Epsilon is the tolerance beyond which 2 points
65   //! are confused.
66   //! theToFillHoles is the flag defining whether possible holes
67   //! between resulting curves are filled or not
68   //! in case of IntPatch walking theToFillHoles is False
69   Standard_EXPORT IntPatch_TheIWalking(const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Step,
70                                        const Standard_Boolean theToFillHoles = Standard_False);
71   
72   //! Deflection is the maximum deflection admitted between two
73   //! consecutive points on a resulting polyline.
74   //! Step is the maximum increment admitted between two
75   //! consecutive points (in 2d space).
76   //! Epsilon is the tolerance beyond which 2 points
77   //! are confused
78     void SetTolerance (const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Step);
79   
80   //! Searches a set of polylines starting on a point of Pnts1
81   //! or Pnts2.
82   //! Each point on a resulting polyline verifies F(u,v)=0
83   Standard_EXPORT void Perform (const IntSurf_SequenceOfPathPoint& Pnts1, const IntSurf_SequenceOfInteriorPoint& Pnts2, IntPatch_TheSurfFunction& Func, const Handle(Adaptor3d_HSurface)& S, const Standard_Boolean Reversed = Standard_False);
84   
85   //! Searches a set of polylines starting on a point of Pnts1.
86   //! Each point on a resulting polyline verifies F(u,v)=0
87   Standard_EXPORT void Perform (const IntSurf_SequenceOfPathPoint& Pnts1, IntPatch_TheSurfFunction& Func, const Handle(Adaptor3d_HSurface)& S, const Standard_Boolean Reversed = Standard_False);
88   
89   //! Returns true if the calculus was successful.
90     Standard_Boolean IsDone() const;
91   
92   //! Returns the number of resulting polylines.
93   //! An exception is raised if IsDone returns False.
94     Standard_Integer NbLines() const;
95   
96   //! Returns the polyline of range Index.
97   //! An exception is raised if IsDone is False.
98   //! An exception is raised if Index<=0 or Index>NbLines.
99     const Handle(IntPatch_TheIWLineOfTheIWalking)& Value (const Standard_Integer Index) const;
100   
101   //! Returns the number of points belonging to Pnts on which no
102   //! line starts or ends.
103   //! An exception is raised if IsDone returns False.
104     Standard_Integer NbSinglePnts() const;
105   
106   //! Returns the point of range Index .
107   //! An exception is raised if IsDone returns False.
108   //! An exception is raised if Index<=0 or
109   //! Index > NbSinglePnts.
110     const IntSurf_PathPoint& SinglePnt (const Standard_Integer Index) const;
111
112
113
114
115 protected:
116
117   
118   Standard_EXPORT Standard_Boolean Cadrage (math_Vector& BornInf, math_Vector& BornSup, math_Vector& UVap, Standard_Real& Step, const Standard_Integer StepSign) const;
119   
120   Standard_EXPORT Standard_Boolean TestArretPassage (const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, IntPatch_TheSurfFunction& Section, math_Vector& UV, Standard_Integer& Irang);
121   
122   Standard_EXPORT Standard_Boolean TestArretPassage (const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const math_Vector& UV, const Standard_Integer Index, Standard_Integer& Irang);
123   
124   Standard_EXPORT Standard_Boolean TestArretAjout (IntPatch_TheSurfFunction& Section, math_Vector& UV, Standard_Integer& Irang, IntSurf_PntOn2S& PSol);
125   
126   Standard_EXPORT void FillPntsInHoles (IntPatch_TheSurfFunction& Section,
127                                         TColStd_SequenceOfInteger& CopySeqAlone,
128                                         IntSurf_SequenceOfInteriorPoint& PntsInHoles);
129   
130   Standard_EXPORT void TestArretCadre (const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const Handle(IntPatch_TheIWLineOfTheIWalking)& Line, IntPatch_TheSurfFunction& Section, math_Vector& UV, Standard_Integer& Irang);
131   
132   Standard_EXPORT IntWalk_StatusDeflection TestDeflection (IntPatch_TheSurfFunction& Section, const Standard_Boolean Finished, const math_Vector& UV, const IntWalk_StatusDeflection StatusPrecedent, Standard_Integer& NbDivision, Standard_Real& Step, const Standard_Integer StepSign);
133   
134   Standard_EXPORT void ComputeOpenLine (const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const IntSurf_SequenceOfPathPoint& Pnts1, IntPatch_TheSurfFunction& Section, Standard_Boolean& Rajout);
135   
136   Standard_EXPORT void OpenLine (const Standard_Integer N, const IntSurf_PntOn2S& Psol, const IntSurf_SequenceOfPathPoint& Pnts1, IntPatch_TheSurfFunction& Section, const Handle(IntPatch_TheIWLineOfTheIWalking)& Line);
137   
138   Standard_EXPORT Standard_Boolean IsValidEndPoint (const Standard_Integer IndOfPoint, const Standard_Integer IndOfLine);
139   
140   Standard_EXPORT void RemoveTwoEndPoints (const Standard_Integer IndOfPoint);
141   
142   Standard_EXPORT Standard_Boolean IsPointOnLine (const gp_Pnt2d& theP2d, const Standard_Integer Irang);
143   
144   Standard_EXPORT void ComputeCloseLine (const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const IntSurf_SequenceOfPathPoint& Pnts1, const IntSurf_SequenceOfInteriorPoint& Pnts2, IntPatch_TheSurfFunction& Section, Standard_Boolean& Rajout);
145   
146   Standard_EXPORT void AddPointInCurrentLine (const Standard_Integer N, const IntSurf_PathPoint& PathPnt, const Handle(IntPatch_TheIWLineOfTheIWalking)& CurrentLine) const;
147   
148   Standard_EXPORT void MakeWalkingPoint (const Standard_Integer Case, const Standard_Real U, const Standard_Real V, IntPatch_TheSurfFunction& Section, IntSurf_PntOn2S& Psol);
149   
150   //! Clears up internal containers
151   Standard_EXPORT void Clear();
152
153
154
155
156 private:
157
158
159
160   Standard_Boolean done;
161   IntSurf_SequenceOfPathPoint seqSingle;
162   Standard_Real fleche;
163   Standard_Real pas;
164   math_Vector tolerance;
165   Standard_Real epsilon;
166   Standard_Boolean reversed;
167   IntWalk_VectorOfWalkingData wd1;
168   IntWalk_VectorOfWalkingData wd2;
169   IntWalk_VectorOfInteger nbMultiplicities;
170   Bnd_Range mySRangeU; // Estimated U-range for section curve
171   Bnd_Range mySRangeV; // Estimated V-range for section curve
172   Standard_Real Um;
173   Standard_Real UM;
174   Standard_Real Vm;
175   Standard_Real VM;
176   IntSurf_PntOn2S previousPoint;
177   gp_Vec previousd3d;
178   gp_Dir2d previousd2d;
179   TColStd_SequenceOfInteger seqAjout;
180   TColStd_SequenceOfInteger seqAlone;
181   TColStd_DataMapOfIntegerListOfInteger PointLineLine;
182   IntPatch_SequenceOfIWLineOfTheIWalking lines;
183   Standard_Boolean ToFillHoles;
184
185
186 };
187
188 #define ThePointOfPath IntSurf_PathPoint
189 #define ThePointOfPath_hxx <IntSurf_PathPoint.hxx>
190 #define ThePointOfPathTool IntSurf_PathPointTool
191 #define ThePointOfPathTool_hxx <IntSurf_PathPointTool.hxx>
192 #define ThePOPIterator IntSurf_SequenceOfPathPoint
193 #define ThePOPIterator_hxx <IntSurf_SequenceOfPathPoint.hxx>
194 #define ThePointOfLoop IntSurf_InteriorPoint
195 #define ThePointOfLoop_hxx <IntSurf_InteriorPoint.hxx>
196 #define ThePointOfLoopTool IntSurf_InteriorPointTool
197 #define ThePointOfLoopTool_hxx <IntSurf_InteriorPointTool.hxx>
198 #define ThePOLIterator IntSurf_SequenceOfInteriorPoint
199 #define ThePOLIterator_hxx <IntSurf_SequenceOfInteriorPoint.hxx>
200 #define ThePSurface Handle(Adaptor3d_HSurface)
201 #define ThePSurface_hxx <Adaptor3d_HSurface.hxx>
202 #define ThePSurfaceTool Adaptor3d_HSurfaceTool
203 #define ThePSurfaceTool_hxx <Adaptor3d_HSurfaceTool.hxx>
204 #define TheIWFunction IntPatch_TheSurfFunction
205 #define TheIWFunction_hxx <IntPatch_TheSurfFunction.hxx>
206 #define IntWalk_TheIWLine IntPatch_TheIWLineOfTheIWalking
207 #define IntWalk_TheIWLine_hxx <IntPatch_TheIWLineOfTheIWalking.hxx>
208 #define IntWalk_SequenceOfIWLine IntPatch_SequenceOfIWLineOfTheIWalking
209 #define IntWalk_SequenceOfIWLine_hxx <IntPatch_SequenceOfIWLineOfTheIWalking.hxx>
210 #define Handle_IntWalk_TheIWLine Handle(IntPatch_TheIWLineOfTheIWalking)
211 #define IntWalk_IWalking IntPatch_TheIWalking
212 #define IntWalk_IWalking_hxx <IntPatch_TheIWalking.hxx>
213
214 #include <IntWalk_IWalking.lxx>
215
216 #undef ThePointOfPath
217 #undef ThePointOfPath_hxx
218 #undef ThePointOfPathTool
219 #undef ThePointOfPathTool_hxx
220 #undef ThePOPIterator
221 #undef ThePOPIterator_hxx
222 #undef ThePointOfLoop
223 #undef ThePointOfLoop_hxx
224 #undef ThePointOfLoopTool
225 #undef ThePointOfLoopTool_hxx
226 #undef ThePOLIterator
227 #undef ThePOLIterator_hxx
228 #undef ThePSurface
229 #undef ThePSurface_hxx
230 #undef ThePSurfaceTool
231 #undef ThePSurfaceTool_hxx
232 #undef TheIWFunction
233 #undef TheIWFunction_hxx
234 #undef IntWalk_TheIWLine
235 #undef IntWalk_TheIWLine_hxx
236 #undef IntWalk_SequenceOfIWLine
237 #undef IntWalk_SequenceOfIWLine_hxx
238 #undef Handle_IntWalk_TheIWLine
239 #undef IntWalk_IWalking
240 #undef IntWalk_IWalking_hxx
241
242
243
244
245 #endif // _IntPatch_TheIWalking_HeaderFile