1 // Created on: 1992-04-03
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _IntWalk_PWalking_HeaderFile
18 #define _IntWalk_PWalking_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
27 #include <Standard_Real.hxx>
28 #include <IntImp_ConstIsoparametric.hxx>
29 #include <IntSurf_PntOn2S.hxx>
30 #include <gp_Dir2d.hxx>
31 #include <IntWalk_TheInt2S.hxx>
32 #include <TColStd_Array1OfReal.hxx>
33 #include <IntWalk_StatusDeflection.hxx>
34 class IntSurf_LineOn2S;
35 class Standard_OutOfRange;
36 class StdFail_NotDone;
37 class Adaptor3d_HSurface;
38 class IntSurf_PntOn2S;
43 //! This class implements an algorithm to determine the
44 //! intersection between 2 parametrized surfaces, marching from
45 //! a starting point. The intersection line
46 //! starts and ends on the natural surface's boundaries .
47 class IntWalk_PWalking
54 //! Constructor used to set the data to compute intersection
55 //! lines between Caro1 and Caro2.
56 //! Deflection is the maximum deflection admitted between two
57 //! consecutive points on the resulting polyline.
58 //! TolTangency is the tolerance to find a tangent point.
59 //! Func is the criterion which has to be evaluated at each
60 //! solution point (each point of the line).
61 //! It is necessary to call the Perform method to compute
62 //! the intersection lines.
63 //! The line found starts at a point on or in 2 natural domains
64 //! of surfaces. It can be closed in the
65 //! standard case if it is open it stops and begins at the
66 //! border of one of the domains. If an open line
67 //! stops at the middle of a domain, one stops at the tangent point.
68 //! Epsilon is SquareTolerance of points confusion.
69 Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
71 //! Returns the intersection line containing the exact
72 //! point Poin. This line is a polygonal line.
73 //! Deflection is the maximum deflection admitted between two
74 //! consecutive points on the resulting polyline.
75 //! TolTangency is the tolerance to find a tangent point.
76 //! Func is the criterion which has to be evaluated at each
77 //! solution point (each point of the line).
78 //! The line found starts at a point on or in 2 natural domains
79 //! of surfaces. It can be closed in the
80 //! standard case if it is open it stops and begins at the
81 //! border of one of the domains. If an open line
82 //! stops at the middle of a domain, one stops at the tangent point.
83 //! Epsilon is SquareTolerance of points confusion.
84 Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2);
86 //! calculate the line of intersection
87 Standard_EXPORT void Perform (const TColStd_Array1OfReal& ParDep);
89 //! calculate the line of intersection. The regulation
90 //! of steps is done using min and max values on u and
91 //! v. (if this data is not presented as in the
92 //! previous method, the initial steps are calculated
93 //! starting from min and max uv of faces).
94 Standard_EXPORT void Perform (const TColStd_Array1OfReal& ParDep, const Standard_Real u1min, const Standard_Real v1min, const Standard_Real u2min, const Standard_Real v2min, const Standard_Real u1max, const Standard_Real v1max, const Standard_Real u2max, const Standard_Real v2max);
96 //! calculate the first point of a line of intersection
97 Standard_EXPORT Standard_Boolean PerformFirstPoint (const TColStd_Array1OfReal& ParDep, IntSurf_PntOn2S& FirstPoint);
99 //! Returns true if the calculus was successful.
100 Standard_Boolean IsDone() const;
102 //! Returns the number of points of the resulting polyline.
103 //! An exception is raised if IsDone returns False.
104 Standard_Integer NbPoints() const;
106 //! Returns the point of range Index on the polyline.
107 //! An exception is raised if IsDone returns False.
108 //! An exception is raised if Index<=0 or Index>NbPoints.
109 const IntSurf_PntOn2S& Value (const Standard_Integer Index) const;
111 const Handle(IntSurf_LineOn2S)& Line() const;
113 //! Returns True if the surface are tangent at the first point
115 //! An exception is raised if IsDone returns False.
116 Standard_Boolean TangentAtFirst() const;
118 //! Returns true if the surface are tangent at the last point
120 //! An exception is raised if IsDone returns False.
121 Standard_Boolean TangentAtLast() const;
123 //! Returns True if the line is closed.
124 //! An exception is raised if IsDone returns False.
125 Standard_Boolean IsClosed() const;
127 const gp_Dir& TangentAtLine (Standard_Integer& Index) const;
129 Standard_EXPORT IntWalk_StatusDeflection TestDeflection (const IntImp_ConstIsoparametric ChoixIso) ;
131 Standard_EXPORT Standard_Boolean TestArret (const Standard_Boolean DejaReparti, TColStd_Array1OfReal& Param, IntImp_ConstIsoparametric& ChoixIso);
133 Standard_EXPORT void RepartirOuDiviser (Standard_Boolean& DejaReparti, IntImp_ConstIsoparametric& ChoixIso, Standard_Boolean& Arrive);
135 void AddAPoint (Handle(IntSurf_LineOn2S)& line, const IntSurf_PntOn2S& POn2S);
137 Standard_EXPORT Standard_Boolean PutToBoundary (const Handle(Adaptor3d_HSurface)& theASurf1, const Handle(Adaptor3d_HSurface)& theASurf2);
139 Standard_EXPORT Standard_Boolean SeekAdditionalPoints (const Handle(Adaptor3d_HSurface)& theASurf1, const Handle(Adaptor3d_HSurface)& theASurf2, const Standard_Integer theMinNbPoints);
141 Standard_Real MaxStep(Standard_Integer theIndex)
143 Standard_OutOfRange_Raise_if ((theIndex < 0) || (theIndex > 3),
144 "IntWalk_PWalking::MaxStep() - index is out of range");
145 return pasInit[theIndex];
151 Standard_EXPORT void ComputePasInit(const Standard_Real theDeltaU1,
152 const Standard_Real theDeltaV1,
153 const Standard_Real theDeltaU2,
154 const Standard_Real theDeltaV2);
156 //! Uses Gradient method in order to find intersection point between the given surfaces
157 //! Arrays theInit (initial point to be precise) and theStep0 (steps-array) must contain
158 //! four items and must be filled strictly in following order:
159 //! {U-parameter on S1, V-parameter on S1, U-parameter on S2, V-parameter on S2}
160 Standard_EXPORT Standard_Boolean DistanceMinimizeByGradient(const Handle(Adaptor3d_HSurface)& theASurf1,
161 const Handle(Adaptor3d_HSurface)& theASurf2,
162 TColStd_Array1OfReal& theInit,
163 const Standard_Real* theStep0 = 0);
165 //! Finds the point on theASurf which is the nearest point to theP0.
166 //! theU0 and theV0 must be initialized (before calling the method) by initial
167 //! parameters on theASurf. Their values are changed while algorithm being launched.
168 //! Array theStep0 (steps-array) must contain two items and must be filled strictly in following order:
169 //! {U-parameter, V-parameter}
170 Standard_EXPORT Standard_Boolean DistanceMinimizeByExtrema (const Handle(Adaptor3d_HSurface)& theASurf,
172 Standard_Real& theU0,
173 Standard_Real& theV0,
174 const Standard_Real* theStep0 = 0);
176 //! Searches an intersection point which lies on the some surface boundary.
177 //! Found point (in case of successful result) is added in the line.
178 //! theU1, theV1, theU2 and theV2 parameters are initial parameters in
179 //! for used numeric algorithms. If isTheFirst == TRUE then
180 //! a point on theASurf1 is searched. Otherwise, the point on theASurf2 is searched.
183 //! This method can delete some points from the curve if it is necessary
184 //! (in order to obtain correct result after insertion).
185 //! Returns TRUE in case of success adding (i.e. can return FALSE even after
186 //! removing some points).
187 Standard_EXPORT Standard_Boolean SeekPointOnBoundary (const Handle(Adaptor3d_HSurface)& theASurf1,
188 const Handle(Adaptor3d_HSurface)& theASurf2,
189 const Standard_Real theU1,
190 const Standard_Real theV1,
191 const Standard_Real theU2,
192 const Standard_Real theV2,
193 const Standard_Boolean isTheFirst);
196 // Method to handle single singular point. Sub-method in SeekPointOnBoundary.
197 Standard_EXPORT Standard_Boolean HandleSingleSingularPoint(const Handle(Adaptor3d_HSurface) &theASurf1,
198 const Handle(Adaptor3d_HSurface) &theASurf2,
199 const Standard_Real the3DTol,
200 TColStd_Array1OfReal &thePnt);
202 Standard_EXPORT Standard_Boolean ExtendLineInCommonZone (const IntImp_ConstIsoparametric theChoixIso,
203 const Standard_Boolean theDirectionFlag);
206 Standard_Boolean done;
207 Handle(IntSurf_LineOn2S) line;
208 Standard_Boolean close;
209 Standard_Boolean tgfirst;
210 Standard_Boolean tglast;
211 Standard_Integer indextg;
213 Standard_Real fleche;
214 Standard_Real pasMax;
215 Standard_Real tolconf;
216 Standard_Real myTolTang;
217 Standard_Real pasuv[4];
218 Standard_Real myStepMin[4];
219 Standard_Real pasSav[4];
220 Standard_Real pasInit[4];
229 Standard_Real ResoU1;
230 Standard_Real ResoU2;
231 Standard_Real ResoV1;
232 Standard_Real ResoV2;
233 Standard_Integer sensCheminement;
234 IntImp_ConstIsoparametric choixIsoSav;
235 IntSurf_PntOn2S previousPoint;
236 Standard_Boolean previoustg;
242 IntWalk_TheInt2S myIntersectionOn2S;
243 Standard_Integer STATIC_BLOCAGE_SUR_PAS_TROP_GRAND;
244 Standard_Integer STATIC_PRECEDENT_INFLEXION;
250 #include <IntWalk_PWalking.lxx>
256 #endif // _IntWalk_PWalking_HeaderFile