Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-01-27 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
d4b867e6 | 17 | #include <algorithm> |
18 | ||
7fd59977 | 19 | #include <GeomInt_IntSS.ixx> |
20 | ||
d4b867e6 | 21 | #include <GeomInt.hxx> |
22 | ||
7fd59977 | 23 | #include <Precision.hxx> |
24 | #include <gp_Pnt.hxx> | |
25 | #include <gp_Pnt2d.hxx> | |
26 | #include <gp_Pln.hxx> | |
27 | ||
28 | #include <TColStd_Array1OfReal.hxx> | |
29 | #include <TColStd_Array1OfInteger.hxx> | |
30 | #include <TColStd_Array1OfListOfInteger.hxx> | |
31 | #include <TColStd_SequenceOfReal.hxx> | |
32 | #include <TColStd_ListOfInteger.hxx> | |
33 | #include <TColStd_ListIteratorOfListOfInteger.hxx> | |
34 | ||
35 | #include <TColgp_Array1OfPnt.hxx> | |
36 | #include <TColgp_Array1OfPnt2d.hxx> | |
37 | ||
38 | #include <Adaptor3d_TopolTool.hxx> | |
39 | #include <IntPatch_Line.hxx> | |
40 | #include <IntPatch_WLine.hxx> | |
41 | #include <IntPatch_GLine.hxx> | |
e618b526 | 42 | #include <IntPatch_RLine.hxx> |
7fd59977 | 43 | #include <IntPatch_ALineToWLine.hxx> |
44 | #include <IntPatch_IType.hxx> | |
96a85238 RL |
45 | #include <NCollection_IncAllocator.hxx> |
46 | #include <NCollection_List.hxx> | |
47 | #include <NCollection_LocalArray.hxx> | |
48 | #include <NCollection_StdAllocator.hxx> | |
49 | #include <vector> | |
7fd59977 | 50 | |
51 | #include <AppParCurves_MultiBSpCurve.hxx> | |
52 | ||
53 | #include <GeomAbs_SurfaceType.hxx> | |
54 | #include <GeomAbs_CurveType.hxx> | |
55 | ||
e618b526 | 56 | #include <GeomAdaptor.hxx> |
7fd59977 | 57 | #include <Geom_Curve.hxx> |
58 | #include <Geom_Line.hxx> | |
59 | #include <Geom_Parabola.hxx> | |
60 | #include <Geom_Hyperbola.hxx> | |
61 | #include <Geom_TrimmedCurve.hxx> | |
62 | #include <Geom_Circle.hxx> | |
63 | #include <Geom_Ellipse.hxx> | |
64 | #include <Geom_BSplineCurve.hxx> | |
65 | ||
e618b526 | 66 | #include <Geom2dAdaptor.hxx> |
67 | #include <Adaptor2d_HCurve2d.hxx> | |
7fd59977 | 68 | #include <Geom2d_Curve.hxx> |
69 | #include <Geom2d_BSplineCurve.hxx> | |
70 | #include <Geom2d_TrimmedCurve.hxx> | |
71 | ||
72 | #include <GeomLib_CheckBSplineCurve.hxx> | |
73 | #include <GeomLib_Check2dBSplineCurve.hxx> | |
74 | #include <GeomProjLib.hxx> | |
e618b526 | 75 | #include <Approx_CurveOnSurface.hxx> |
7fd59977 | 76 | |
77 | #include <ElSLib.hxx> | |
78 | ||
79 | #include <GeomInt_WLApprox.hxx> | |
80 | #include <Extrema_ExtPS.hxx> | |
81 | ||
d4b867e6 | 82 | #include <GeomAdaptor_HSurface.hxx> |
83 | #include <gp_Lin2d.hxx> | |
84 | #include <Geom2d_Line.hxx> | |
85 | #include <IntPatch_RLine.hxx> | |
86 | #include <Geom2dAdaptor.hxx> | |
87 | #include <Adaptor2d_HCurve2d.hxx> | |
88 | #include <Approx_CurveOnSurface.hxx> | |
89 | #include <GeomAdaptor.hxx> | |
90 | #include <GeomProjLib.hxx> | |
d4b867e6 | 91 | #include <TColStd_Array1OfReal.hxx> |
92 | #include <TColgp_Array1OfPnt2d.hxx> | |
93 | #include <TColStd_Array1OfInteger.hxx> | |
94 | #include <Geom2d_BSplineCurve.hxx> | |
7a91ad6e | 95 | #include <Geom2dAdaptor_Curve.hxx> |
d4b867e6 | 96 | #include <IntRes2d_IntersectionPoint.hxx> |
7a91ad6e | 97 | #include <IntRes2d_IntersectionSegment.hxx> |
98 | #include <Geom2dInt_GInter.hxx> | |
7fd59977 | 99 | |
100 | static | |
101 | void Parameters(const Handle(GeomAdaptor_HSurface)& HS1, | |
102 | const Handle(GeomAdaptor_HSurface)& HS2, | |
103 | const gp_Pnt& Ptref, | |
104 | Standard_Real& U1, | |
105 | Standard_Real& V1, | |
106 | Standard_Real& U2, | |
107 | Standard_Real& V2); | |
108 | ||
109 | static | |
110 | Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, | |
111 | const Standard_Integer ideb, | |
112 | const Standard_Integer ifin); | |
113 | ||
114 | static | |
115 | Handle(Geom2d_BSplineCurve) MakeBSpline2d(const Handle(IntPatch_WLine)& theWLine, | |
116 | const Standard_Integer ideb, | |
117 | const Standard_Integer ifin, | |
118 | const Standard_Boolean onFirst); | |
119 | ||
120 | static | |
121 | Handle(IntPatch_WLine) ComputePurgedWLine(const Handle(IntPatch_WLine)& theWLine); | |
122 | ||
123 | ||
124 | static | |
125 | Standard_Boolean DecompositionOfWLine (const Handle(IntPatch_WLine)& theWLine, | |
126 | const Handle(GeomAdaptor_HSurface)& theSurface1, | |
127 | const Handle(GeomAdaptor_HSurface)& theSurface2, | |
128 | const Standard_Real aTolSum, | |
129 | const GeomInt_LineConstructor& theLConstructor, | |
130 | IntPatch_SequenceOfLine& theNewLines); | |
131 | ||
132 | static | |
133 | Standard_Real AdjustPeriodic(const Standard_Real theParameter, | |
134 | const Standard_Real parmin, | |
135 | const Standard_Real parmax, | |
136 | const Standard_Real thePeriod, | |
137 | Standard_Real& theOffset) ; | |
138 | static | |
139 | Standard_Boolean IsPointOnBoundary(const Standard_Real theParameter, | |
140 | const Standard_Real theFirstBoundary, | |
141 | const Standard_Real theSecondBoundary, | |
142 | const Standard_Real theResolution, | |
143 | Standard_Boolean& IsOnFirstBoundary); | |
144 | ||
145 | static | |
146 | Standard_Boolean FindPoint(const gp_Pnt2d& theFirstPoint, | |
147 | const gp_Pnt2d& theLastPoint, | |
148 | const Standard_Real theUmin, | |
149 | const Standard_Real theUmax, | |
150 | const Standard_Real theVmin, | |
151 | const Standard_Real theVmax, | |
152 | gp_Pnt2d& theNewPoint); | |
153 | ||
154 | ||
155 | static | |
156 | void AdjustUPeriodic (const Handle(Geom_Surface)& aS, | |
157 | Handle(Geom2d_Curve)& aC2D); | |
158 | static | |
159 | void GetQuadric(const Handle(GeomAdaptor_HSurface)& HS1, | |
160 | IntSurf_Quadric& quad1); | |
161 | ||
7fd59977 | 162 | class ProjectPointOnSurf |
163 | { | |
164 | public: | |
c24d4017 | 165 | ProjectPointOnSurf() : myIsDone (Standard_False),myIndex(0) {} |
7fd59977 | 166 | void Init(const Handle(Geom_Surface)& Surface, |
167 | const Standard_Real Umin, | |
168 | const Standard_Real Usup, | |
169 | const Standard_Real Vmin, | |
170 | const Standard_Real Vsup); | |
171 | void Init (); | |
172 | void Perform(const gp_Pnt& P); | |
173 | Standard_Boolean IsDone () const { return myIsDone; } | |
174 | void LowerDistanceParameters(Standard_Real& U, Standard_Real& V ) const; | |
175 | Standard_Real LowerDistance() const; | |
176 | protected: | |
177 | Standard_Boolean myIsDone; | |
178 | Standard_Integer myIndex; | |
179 | Extrema_ExtPS myExtPS; | |
180 | GeomAdaptor_Surface myGeomAdaptor; | |
181 | }; | |
182 | ||
183 | //======================================================================= | |
184 | //function : Init | |
185 | //purpose : | |
186 | //======================================================================= | |
187 | void ProjectPointOnSurf::Init (const Handle(Geom_Surface)& Surface, | |
188 | const Standard_Real Umin, | |
189 | const Standard_Real Usup, | |
190 | const Standard_Real Vmin, | |
191 | const Standard_Real Vsup ) | |
192 | { | |
193 | const Standard_Real Tolerance = Precision::PConfusion(); | |
194 | // | |
195 | myGeomAdaptor.Load(Surface, Umin,Usup,Vmin,Vsup); | |
196 | myExtPS.Initialize(myGeomAdaptor, Umin, Usup, Vmin, Vsup, Tolerance, Tolerance); | |
197 | myIsDone = Standard_False; | |
198 | } | |
199 | //======================================================================= | |
200 | //function : Init | |
201 | //purpose : | |
202 | //======================================================================= | |
203 | void ProjectPointOnSurf::Init () | |
204 | { | |
205 | myIsDone = myExtPS.IsDone() && (myExtPS.NbExt() > 0); | |
206 | if (myIsDone) { | |
207 | // evaluate the lower distance and its index; | |
208 | Standard_Real Dist2Min = myExtPS.SquareDistance(1); | |
209 | myIndex = 1; | |
210 | for (Standard_Integer i = 2; i <= myExtPS.NbExt(); i++) | |
211 | { | |
212 | const Standard_Real Dist2 = myExtPS.SquareDistance(i); | |
213 | if (Dist2 < Dist2Min) { | |
214 | Dist2Min = Dist2; | |
215 | myIndex = i; | |
216 | } | |
217 | } | |
218 | } | |
219 | } | |
220 | //======================================================================= | |
221 | //function : Perform | |
222 | //purpose : | |
223 | //======================================================================= | |
224 | void ProjectPointOnSurf::Perform(const gp_Pnt& P) | |
225 | { | |
226 | myExtPS.Perform(P); | |
227 | Init (); | |
228 | } | |
229 | //======================================================================= | |
230 | //function : LowerDistanceParameters | |
231 | //purpose : | |
232 | //======================================================================= | |
233 | void ProjectPointOnSurf::LowerDistanceParameters (Standard_Real& U, | |
234 | Standard_Real& V ) const | |
235 | { | |
236 | StdFail_NotDone_Raise_if(!myIsDone, "GeomInt_IntSS::ProjectPointOnSurf::LowerDistanceParameters"); | |
237 | (myExtPS.Point(myIndex)).Parameter(U,V); | |
238 | } | |
239 | //======================================================================= | |
240 | //function : LowerDistance | |
241 | //purpose : | |
242 | //======================================================================= | |
243 | Standard_Real ProjectPointOnSurf::LowerDistance() const | |
244 | { | |
245 | StdFail_NotDone_Raise_if(!myIsDone, "GeomInt_IntSS::ProjectPointOnSurf::LowerDistance"); | |
246 | return sqrt(myExtPS.SquareDistance(myIndex)); | |
247 | } | |
248 | // | |
249 | ||
250 | //======================================================================= | |
251 | //function : MakeCurve | |
252 | //purpose : | |
253 | //======================================================================= | |
d4b867e6 | 254 | void GeomInt_IntSS::MakeCurve(const Standard_Integer Index, |
255 | const Handle(Adaptor3d_TopolTool) & dom1, | |
256 | const Handle(Adaptor3d_TopolTool) & dom2, | |
257 | const Standard_Real Tol, | |
258 | const Standard_Boolean Approx, | |
259 | const Standard_Boolean ApproxS1, | |
260 | const Standard_Boolean ApproxS2) | |
7fd59977 | 261 | |
262 | { | |
263 | Standard_Boolean myApprox1, myApprox2, myApprox; | |
264 | Standard_Real Tolpc, myTolApprox; | |
265 | IntPatch_IType typl; | |
266 | Handle(Geom2d_BSplineCurve) H1; | |
267 | Handle(Geom_Surface) aS1, aS2; | |
268 | // | |
269 | Tolpc = Tol; | |
270 | myApprox=Approx; | |
271 | myApprox1=ApproxS1; | |
272 | myApprox2=ApproxS2; | |
273 | myTolApprox=0.0000001; | |
274 | // | |
275 | aS1=myHS1->ChangeSurface().Surface(); | |
276 | aS2=myHS2->ChangeSurface().Surface(); | |
277 | // | |
278 | Handle(IntPatch_Line) L = myIntersector.Line(Index); | |
279 | typl = L->ArcType(); | |
280 | // | |
281 | if(typl==IntPatch_Walking) { | |
282 | Handle(IntPatch_Line) anewL = | |
283 | ComputePurgedWLine(Handle(IntPatch_WLine)::DownCast(L)); | |
284 | // | |
285 | if(anewL.IsNull()) { | |
286 | return; | |
287 | } | |
288 | L = anewL; | |
289 | } | |
290 | // | |
291 | // Line Constructor | |
292 | myLConstruct.Perform(L); | |
293 | if (!myLConstruct.IsDone() || myLConstruct.NbParts() <= 0) { | |
294 | return; | |
295 | } | |
296 | // Do the Curve | |
297 | Standard_Boolean ok; | |
298 | Standard_Integer i, j, aNbParts; | |
299 | Standard_Real fprm, lprm; | |
300 | Handle(Geom_Curve) newc; | |
301 | ||
302 | switch (typl) { | |
e618b526 | 303 | //######################################## |
304 | // Line, Parabola, Hyperbola | |
305 | //######################################## | |
7fd59977 | 306 | case IntPatch_Lin: |
307 | case IntPatch_Parabola: | |
308 | case IntPatch_Hyperbola: { | |
309 | if (typl == IntPatch_Lin) { | |
310 | newc=new Geom_Line (Handle(IntPatch_GLine)::DownCast(L)->Line()); | |
311 | } | |
312 | else if (typl == IntPatch_Parabola) { | |
313 | newc=new Geom_Parabola(Handle(IntPatch_GLine)::DownCast(L)->Parabola()); | |
314 | } | |
315 | else if (typl == IntPatch_Hyperbola) { | |
316 | newc=new Geom_Hyperbola (Handle(IntPatch_GLine)::DownCast(L)->Hyperbola()); | |
317 | } | |
318 | // | |
319 | aNbParts=myLConstruct.NbParts(); | |
320 | for (i=1; i<=aNbParts; i++) { | |
321 | myLConstruct.Part(i, fprm, lprm); | |
e618b526 | 322 | |
7fd59977 | 323 | if (!Precision::IsNegativeInfinite(fprm) && |
e618b526 | 324 | !Precision::IsPositiveInfinite(lprm)) { |
325 | Handle(Geom_TrimmedCurve) aCT3D=new Geom_TrimmedCurve(newc, fprm, lprm); | |
326 | sline.Append(aCT3D); | |
327 | // | |
328 | if(myApprox1) { | |
329 | Handle (Geom2d_Curve) C2d; | |
330 | BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d); | |
331 | if(Tolpc>myTolReached2d || myTolReached2d==0.) { | |
332 | myTolReached2d=Tolpc; | |
333 | } | |
334 | slineS1.Append(new Geom2d_TrimmedCurve(C2d,fprm,lprm)); | |
335 | } | |
336 | else { | |
337 | slineS1.Append(H1); | |
338 | } | |
339 | // | |
340 | if(myApprox2) { | |
341 | Handle (Geom2d_Curve) C2d; | |
342 | BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d); | |
343 | if(Tolpc>myTolReached2d || myTolReached2d==0.) { | |
344 | myTolReached2d=Tolpc; | |
345 | } | |
346 | // | |
347 | slineS2.Append(new Geom2d_TrimmedCurve(C2d,fprm,lprm)); | |
348 | } | |
349 | else { | |
350 | slineS2.Append(H1); | |
351 | } | |
7fd59977 | 352 | } // if (!Precision::IsNegativeInfinite(fprm) && !Precision::IsPositiveInfinite(lprm)) |
353 | ||
354 | else { | |
7c4e9501 | 355 | GeomAbs_SurfaceType typS1 = myHS1->Surface().GetType(); |
356 | GeomAbs_SurfaceType typS2 = myHS2->Surface().GetType(); | |
357 | if( typS1 == GeomAbs_SurfaceOfExtrusion || | |
358 | typS1 == GeomAbs_OffsetSurface || | |
359 | typS1 == GeomAbs_SurfaceOfRevolution || | |
360 | typS2 == GeomAbs_SurfaceOfExtrusion || | |
361 | typS2 == GeomAbs_OffsetSurface || | |
362 | typS2 == GeomAbs_SurfaceOfRevolution) { | |
363 | sline.Append(newc); | |
364 | slineS1.Append(H1); | |
365 | slineS2.Append(H1); | |
366 | continue; | |
367 | } | |
368 | Standard_Boolean bFNIt, bLPIt; | |
369 | Standard_Real aTestPrm, dT=100.; | |
370 | Standard_Real u1, v1, u2, v2, TolX; | |
371 | // | |
372 | bFNIt=Precision::IsNegativeInfinite(fprm); | |
373 | bLPIt=Precision::IsPositiveInfinite(lprm); | |
374 | ||
375 | aTestPrm=0.; | |
376 | ||
377 | if (bFNIt && !bLPIt) { | |
378 | aTestPrm=lprm-dT; | |
379 | } | |
380 | else if (!bFNIt && bLPIt) { | |
381 | aTestPrm=fprm+dT; | |
382 | } | |
383 | // | |
384 | gp_Pnt ptref(newc->Value(aTestPrm)); | |
385 | // | |
386 | TolX = Precision::Confusion(); | |
387 | Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2); | |
388 | ok = (dom1->Classify(gp_Pnt2d(u1, v1), TolX) != TopAbs_OUT); | |
389 | if(ok) { | |
390 | ok = (dom2->Classify(gp_Pnt2d(u2,v2),TolX) != TopAbs_OUT); | |
391 | } | |
392 | if (ok) { | |
393 | sline.Append(newc); | |
394 | slineS1.Append(H1); | |
395 | slineS2.Append(H1); | |
396 | } | |
7fd59977 | 397 | } |
398 | }// end of for (i=1; i<=myLConstruct.NbParts(); i++) | |
e618b526 | 399 | }// case IntPatch_Lin: case IntPatch_Parabola: case IntPatch_Hyperbola: |
400 | break; | |
7fd59977 | 401 | |
e618b526 | 402 | //######################################## |
403 | // Circle and Ellipse | |
404 | //######################################## | |
7fd59977 | 405 | case IntPatch_Circle: |
406 | case IntPatch_Ellipse: { | |
407 | ||
408 | if (typl == IntPatch_Circle) { | |
409 | newc = new Geom_Circle | |
e618b526 | 410 | (Handle(IntPatch_GLine)::DownCast(L)->Circle()); |
7fd59977 | 411 | } |
412 | else { | |
413 | newc = new Geom_Ellipse | |
e618b526 | 414 | (Handle(IntPatch_GLine)::DownCast(L)->Ellipse()); |
7fd59977 | 415 | } |
416 | // | |
96a95605 | 417 | Standard_Real aPeriod, aRealEpsilon; |
7fd59977 | 418 | // |
419 | aRealEpsilon=RealEpsilon(); | |
c6541a0c | 420 | aPeriod=M_PI+M_PI; |
7fd59977 | 421 | // |
422 | aNbParts=myLConstruct.NbParts(); | |
423 | // | |
424 | for (i=1; i<=aNbParts; i++) { | |
425 | myLConstruct.Part(i, fprm, lprm); | |
426 | // | |
427 | if (Abs(fprm) > aRealEpsilon || Abs(lprm-aPeriod) > aRealEpsilon) { | |
e618b526 | 428 | //============================================== |
429 | Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm); | |
430 | // | |
431 | sline.Append(aTC3D); | |
432 | // | |
433 | fprm=aTC3D->FirstParameter(); | |
434 | lprm=aTC3D->LastParameter (); | |
435 | //// | |
436 | if(myApprox1) { | |
437 | Handle (Geom2d_Curve) C2d; | |
438 | BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d); | |
439 | if(Tolpc>myTolReached2d || myTolReached2d==0.) { | |
440 | myTolReached2d=Tolpc; | |
441 | } | |
442 | slineS1.Append(C2d); | |
443 | } | |
444 | else { //// | |
445 | slineS1.Append(H1); | |
446 | } | |
447 | // | |
448 | if(myApprox2) { | |
449 | Handle (Geom2d_Curve) C2d; | |
450 | BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d); | |
451 | if(Tolpc>myTolReached2d || myTolReached2d==0) { | |
452 | myTolReached2d=Tolpc; | |
453 | } | |
454 | slineS2.Append(C2d); | |
455 | } | |
456 | else { | |
457 | slineS2.Append(H1); | |
458 | } | |
459 | //============================================== | |
c6541a0c | 460 | } //if (Abs(fprm) > RealEpsilon() || Abs(lprm-2.*M_PI) > RealEpsilon()) |
7fd59977 | 461 | // |
462 | else {// on regarde si on garde | |
e618b526 | 463 | // |
464 | if (aNbParts==1) { | |
465 | if (Abs(fprm) < RealEpsilon() && Abs(lprm-2.*M_PI) < RealEpsilon()) { | |
466 | Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm); | |
467 | // | |
468 | sline.Append(aTC3D); | |
469 | fprm=aTC3D->FirstParameter(); | |
470 | lprm=aTC3D->LastParameter (); | |
471 | ||
472 | if(myApprox1) { | |
473 | Handle (Geom2d_Curve) C2d; | |
474 | BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d); | |
475 | if(Tolpc>myTolReached2d || myTolReached2d==0) { | |
476 | myTolReached2d=Tolpc; | |
477 | } | |
478 | slineS1.Append(C2d); | |
479 | } | |
480 | else { //// | |
481 | slineS1.Append(H1); | |
482 | } | |
483 | ||
484 | if(myApprox2) { | |
485 | Handle (Geom2d_Curve) C2d; | |
486 | BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d); | |
487 | if(Tolpc>myTolReached2d || myTolReached2d==0) { | |
488 | myTolReached2d=Tolpc; | |
489 | } | |
490 | slineS2.Append(C2d); | |
491 | } | |
492 | else { | |
493 | slineS2.Append(H1); | |
494 | } | |
495 | break; | |
496 | } | |
497 | } | |
498 | // | |
499 | Standard_Real aTwoPIdiv17, u1, v1, u2, v2, TolX; | |
500 | // | |
501 | aTwoPIdiv17=2.*M_PI/17.; | |
502 | // | |
503 | for (j=0; j<=17; j++) { | |
504 | gp_Pnt ptref (newc->Value (j*aTwoPIdiv17)); | |
505 | TolX = Precision::Confusion(); | |
506 | ||
507 | Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2); | |
508 | ok = (dom1->Classify(gp_Pnt2d(u1,v1),TolX) != TopAbs_OUT); | |
509 | if(ok) { | |
510 | ok = (dom2->Classify(gp_Pnt2d(u2,v2),TolX) != TopAbs_OUT); | |
511 | } | |
512 | if (ok) { | |
513 | sline.Append(newc); | |
514 | //============================================== | |
515 | if(myApprox1) { | |
516 | Handle (Geom2d_Curve) C2d; | |
517 | BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d); | |
518 | if(Tolpc>myTolReached2d || myTolReached2d==0) { | |
519 | myTolReached2d=Tolpc; | |
520 | } | |
521 | slineS1.Append(C2d); | |
522 | } | |
523 | else { | |
524 | slineS1.Append(H1); | |
525 | } | |
526 | ||
527 | if(myApprox2) { | |
528 | Handle (Geom2d_Curve) C2d; | |
529 | BuildPCurves(fprm, lprm, Tolpc,myHS2->ChangeSurface().Surface(), newc, C2d); | |
530 | if(Tolpc>myTolReached2d || myTolReached2d==0) { | |
531 | myTolReached2d=Tolpc; | |
532 | } | |
533 | slineS2.Append(C2d); | |
534 | } | |
535 | else { | |
536 | slineS2.Append(H1); | |
537 | } | |
538 | break; | |
539 | }// end of if (ok) { | |
540 | }// end of for (Standard_Integer j=0; j<=17; j++) | |
7fd59977 | 541 | }// end of else { on regarde si on garde |
542 | }// for (i=1; i<=myLConstruct.NbParts(); i++) | |
e618b526 | 543 | }// IntPatch_Circle: IntPatch_Ellipse |
544 | break; | |
545 | ||
546 | //######################################## | |
547 | // Analytic | |
548 | //######################################## | |
7fd59977 | 549 | case IntPatch_Analytic: { |
550 | IntSurf_Quadric quad1,quad2; | |
551 | // | |
552 | GetQuadric(myHS1, quad1); | |
553 | GetQuadric(myHS2, quad2); | |
554 | //========= | |
555 | IntPatch_ALineToWLine convert (quad1, quad2); | |
e618b526 | 556 | |
7fd59977 | 557 | if (!myApprox) { |
558 | Handle(Geom2d_BSplineCurve) aH1, aH2; | |
559 | // | |
560 | aNbParts=myLConstruct.NbParts(); | |
561 | for (i=1; i<=aNbParts; i++) { | |
e618b526 | 562 | myLConstruct.Part(i, fprm, lprm); |
563 | Handle(IntPatch_WLine) WL = | |
564 | convert.MakeWLine(Handle(IntPatch_ALine)::DownCast(L), fprm, lprm); | |
565 | // | |
566 | if(myApprox1) { | |
567 | aH1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True); | |
568 | } | |
569 | ||
570 | if(myApprox2) { | |
571 | aH2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False); | |
572 | } | |
573 | sline.Append(MakeBSpline(WL,1,WL->NbPnts())); | |
574 | slineS1.Append(aH1); | |
575 | slineS2.Append(aH2); | |
7fd59977 | 576 | } |
577 | } // if (!myApprox) | |
578 | ||
579 | else { // myApprox=TRUE | |
580 | GeomInt_WLApprox theapp3d; | |
581 | Standard_Real tol2d = myTolApprox; | |
582 | // | |
583 | theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True); | |
e618b526 | 584 | |
7fd59977 | 585 | aNbParts=myLConstruct.NbParts(); |
586 | for (i=1; i<=aNbParts; i++) { | |
e618b526 | 587 | myLConstruct.Part(i, fprm, lprm); |
588 | Handle(IntPatch_WLine) WL = | |
589 | convert.MakeWLine(Handle(IntPatch_ALine):: DownCast(L),fprm,lprm); | |
590 | ||
591 | theapp3d.Perform(myHS1,myHS2,WL,Standard_True,myApprox1,myApprox2, 1, WL->NbPnts()); | |
592 | if (!theapp3d.IsDone()) { | |
593 | // | |
594 | Handle(Geom2d_BSplineCurve) aH1, aH2; | |
595 | ||
596 | if(myApprox1) { | |
597 | aH1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True); | |
598 | } | |
599 | ||
600 | if(myApprox2) { | |
601 | aH2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False); | |
602 | } | |
603 | sline.Append(MakeBSpline(WL,1,WL->NbPnts())); | |
604 | slineS1.Append(aH1); | |
605 | slineS2.Append(aH1); | |
606 | } | |
607 | // | |
608 | else { | |
609 | if(myApprox1 || myApprox2) { | |
610 | if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0) { | |
611 | myTolReached2d = theapp3d.TolReached2d(); | |
612 | } | |
613 | } | |
614 | ||
615 | if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0) { | |
616 | myTolReached3d = theapp3d.TolReached3d(); | |
617 | } | |
618 | ||
619 | Standard_Integer aNbMultiCurves, nbpoles; | |
620 | aNbMultiCurves=theapp3d.NbMultiCurves(); | |
621 | for (j=1; j<=aNbMultiCurves; j++) { | |
622 | const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j); | |
623 | ||
624 | nbpoles = mbspc.NbPoles(); | |
625 | TColgp_Array1OfPnt tpoles(1, nbpoles); | |
626 | mbspc.Curve(1, tpoles); | |
627 | Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles, | |
628 | mbspc.Knots(), | |
629 | mbspc.Multiplicities(), | |
630 | mbspc.Degree()); | |
631 | ||
632 | GeomLib_CheckBSplineCurve Check(BS, myTolCheck, myTolAngCheck); | |
633 | Check.FixTangent(Standard_True,Standard_True); | |
634 | // | |
635 | sline.Append(BS); | |
636 | // | |
637 | if(myApprox1) { | |
638 | TColgp_Array1OfPnt2d tpoles2d(1,nbpoles); | |
639 | mbspc.Curve(2,tpoles2d); | |
640 | Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d, | |
641 | mbspc.Knots(), | |
642 | mbspc.Multiplicities(), | |
643 | mbspc.Degree()); | |
644 | ||
645 | GeomLib_Check2dBSplineCurve newCheck(BS2,myTolCheck,myTolAngCheck); | |
646 | newCheck.FixTangent(Standard_True,Standard_True); | |
647 | slineS1.Append(BS2); | |
648 | } | |
649 | else { | |
650 | slineS1.Append(H1); | |
651 | } | |
652 | ||
653 | if(myApprox2) { | |
654 | TColgp_Array1OfPnt2d tpoles2d(1, nbpoles); | |
655 | Standard_Integer TwoOrThree; | |
656 | TwoOrThree=myApprox1 ? 3 : 2; | |
657 | mbspc.Curve(TwoOrThree, tpoles2d); | |
658 | Handle(Geom2d_BSplineCurve) BS2 =new Geom2d_BSplineCurve(tpoles2d, | |
659 | mbspc.Knots(), | |
660 | mbspc.Multiplicities(), | |
661 | mbspc.Degree()); | |
662 | ||
663 | GeomLib_Check2dBSplineCurve newCheck(BS2,myTolCheck,myTolAngCheck); | |
664 | newCheck.FixTangent(Standard_True,Standard_True); | |
665 | // | |
666 | slineS2.Append(BS2); | |
667 | } | |
668 | else { | |
669 | slineS2.Append(H1); | |
670 | } | |
671 | // | |
672 | }// for (j=1; j<=aNbMultiCurves; j++) { | |
673 | }// else from if (!theapp3d.IsDone()) | |
7fd59977 | 674 | }// for (i=1; i<=aNbParts; i++) { |
675 | }// else { // myApprox=TRUE | |
676 | }// case IntPatch_Analytic: | |
e618b526 | 677 | break; |
678 | ||
679 | //######################################## | |
680 | // Walking | |
681 | //######################################## | |
7fd59977 | 682 | case IntPatch_Walking:{ |
683 | Handle(IntPatch_WLine) WL = | |
684 | Handle(IntPatch_WLine)::DownCast(L); | |
685 | // | |
686 | Standard_Integer ifprm, ilprm; | |
687 | // | |
688 | if (!myApprox) { | |
689 | aNbParts=myLConstruct.NbParts(); | |
690 | for (i=1; i<=aNbParts; i++) { | |
e618b526 | 691 | myLConstruct.Part(i, fprm, lprm); |
692 | ifprm=(Standard_Integer)fprm; | |
693 | ilprm=(Standard_Integer)lprm; | |
694 | // | |
695 | Handle(Geom2d_BSplineCurve) aH1, aH2; | |
696 | ||
697 | if(myApprox1) { | |
698 | aH1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True); | |
699 | } | |
700 | if(myApprox2) { | |
701 | aH2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False); | |
702 | } | |
703 | // | |
704 | Handle(Geom_Curve) aBSp=MakeBSpline(WL, ifprm, ilprm); | |
705 | // | |
706 | sline.Append(aBSp); | |
707 | slineS1.Append(aH1); | |
708 | slineS2.Append(aH2); | |
7fd59977 | 709 | } |
710 | } | |
711 | // | |
712 | else { | |
713 | Standard_Boolean bIsDecomposited; | |
714 | Standard_Integer nbiter, aNbSeqOfL; | |
715 | GeomInt_WLApprox theapp3d; | |
716 | IntPatch_SequenceOfLine aSeqOfL; | |
717 | Standard_Real tol2d, aTolSS; | |
718 | // | |
719 | tol2d = myTolApprox; | |
720 | aTolSS=2.e-7; | |
721 | if(myHS1 == myHS2) { | |
e618b526 | 722 | theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False); |
7fd59977 | 723 | } |
724 | else { | |
e618b526 | 725 | theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True); |
7fd59977 | 726 | } |
727 | // | |
728 | bIsDecomposited = | |
e618b526 | 729 | DecompositionOfWLine(WL, myHS1, myHS2, aTolSS, myLConstruct, aSeqOfL); |
7fd59977 | 730 | // |
731 | aNbParts=myLConstruct.NbParts(); | |
732 | aNbSeqOfL=aSeqOfL.Length(); | |
733 | // | |
734 | nbiter = (bIsDecomposited) ? aNbSeqOfL : aNbParts; | |
735 | // | |
736 | for(i = 1; i <= nbiter; i++) { | |
e618b526 | 737 | if(bIsDecomposited) { |
738 | WL = Handle(IntPatch_WLine)::DownCast(aSeqOfL.Value(i)); | |
739 | ifprm = 1; | |
740 | ilprm = WL->NbPnts(); | |
741 | } | |
742 | else { | |
743 | myLConstruct.Part(i, fprm, lprm); | |
744 | ifprm = (Standard_Integer)fprm; | |
745 | ilprm = (Standard_Integer)lprm; | |
746 | } | |
747 | //-- lbr : | |
748 | //-- Si une des surfaces est un plan , on approxime en 2d | |
749 | //-- sur cette surface et on remonte les points 2d en 3d. | |
750 | GeomAbs_SurfaceType typs1, typs2; | |
751 | typs1 = myHS1->Surface().GetType(); | |
752 | typs2 = myHS2->Surface().GetType(); | |
753 | // | |
754 | if(typs1 == GeomAbs_Plane) { | |
755 | theapp3d.Perform(myHS1, myHS2, WL, Standard_False, | |
756 | Standard_True, myApprox2, | |
757 | ifprm, ilprm); | |
758 | } | |
759 | else if(typs2 == GeomAbs_Plane) { | |
760 | theapp3d.Perform(myHS1,myHS2,WL,Standard_False, | |
761 | myApprox1,Standard_True, | |
762 | ifprm, ilprm); | |
763 | } | |
764 | else { | |
765 | // | |
766 | if (myHS1 != myHS2){ | |
767 | if ((typs1==GeomAbs_BezierSurface || typs1==GeomAbs_BSplineSurface) && | |
768 | (typs2==GeomAbs_BezierSurface || typs2==GeomAbs_BSplineSurface)) { | |
769 | ||
770 | theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True); | |
771 | //Standard_Boolean bUseSurfaces; | |
772 | //bUseSurfaces=NotUseSurfacesForApprox(myFace1, myFace2, WL, ifprm, ilprm); | |
773 | //if (bUseSurfaces) { | |
774 | //theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False); | |
775 | //} | |
776 | } | |
777 | } | |
778 | // | |
779 | theapp3d.Perform(myHS1,myHS2,WL,Standard_True, | |
780 | myApprox1,myApprox2, | |
781 | ifprm, ilprm); | |
782 | } | |
783 | ||
784 | if (!theapp3d.IsDone()) { | |
785 | // | |
786 | Handle(Geom2d_BSplineCurve) aH1, aH2; | |
787 | // | |
788 | Handle(Geom_Curve) aBSp=MakeBSpline(WL, ifprm, ilprm); | |
789 | if(myApprox1) { | |
790 | aH1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True); | |
791 | } | |
792 | if(myApprox2) { | |
793 | aH2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False); | |
794 | } | |
795 | // | |
796 | sline.Append(aBSp); | |
797 | slineS1.Append(aH1); | |
798 | slineS2.Append(aH2); | |
799 | }//if (!theapp3d.IsDone()) | |
800 | ||
801 | else { | |
802 | if(myApprox1 || myApprox2 || (typs1==GeomAbs_Plane || typs2==GeomAbs_Plane)) { | |
803 | if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0.) { | |
804 | myTolReached2d = theapp3d.TolReached2d(); | |
805 | } | |
806 | } | |
807 | if(typs1==GeomAbs_Plane || typs2==GeomAbs_Plane) { | |
808 | myTolReached3d = myTolReached2d; | |
809 | } | |
810 | else if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0.) { | |
811 | myTolReached3d = theapp3d.TolReached3d(); | |
812 | } | |
813 | ||
814 | Standard_Integer aNbMultiCurves, nbpoles; | |
815 | // | |
816 | aNbMultiCurves=theapp3d.NbMultiCurves(); | |
817 | for (j=1; j<=aNbMultiCurves; j++) { | |
818 | if(typs1 == GeomAbs_Plane) { | |
819 | const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j); | |
820 | nbpoles = mbspc.NbPoles(); | |
821 | ||
822 | TColgp_Array1OfPnt2d tpoles2d(1,nbpoles); | |
823 | TColgp_Array1OfPnt tpoles(1,nbpoles); | |
824 | ||
825 | mbspc.Curve(1,tpoles2d); | |
826 | const gp_Pln& Pln = myHS1->Surface().Plane(); | |
827 | // | |
828 | Standard_Integer ik; | |
829 | for(ik = 1; ik<= nbpoles; ik++) { | |
830 | tpoles.SetValue(ik, | |
831 | ElSLib::Value(tpoles2d.Value(ik).X(), | |
832 | tpoles2d.Value(ik).Y(), | |
833 | Pln)); | |
834 | } | |
835 | // | |
836 | Handle(Geom_BSplineCurve) BS = | |
837 | new Geom_BSplineCurve(tpoles, | |
838 | mbspc.Knots(), | |
839 | mbspc.Multiplicities(), | |
840 | mbspc.Degree()); | |
841 | GeomLib_CheckBSplineCurve Check(BS,myTolCheck,myTolAngCheck); | |
842 | Check.FixTangent(Standard_True, Standard_True); | |
843 | // | |
844 | sline.Append(BS); | |
845 | // | |
846 | if(myApprox1) { | |
847 | Handle(Geom2d_BSplineCurve) BS1 = | |
848 | new Geom2d_BSplineCurve(tpoles2d, | |
849 | mbspc.Knots(), | |
850 | mbspc.Multiplicities(), | |
851 | mbspc.Degree()); | |
852 | GeomLib_Check2dBSplineCurve Check1(BS1,myTolCheck,myTolAngCheck); | |
853 | Check1.FixTangent(Standard_True,Standard_True); | |
854 | // | |
855 | AdjustUPeriodic (aS1, BS1); | |
856 | // | |
857 | slineS1.Append(BS1); | |
858 | } | |
859 | else { | |
860 | slineS1.Append(H1); | |
861 | } | |
862 | ||
863 | if(myApprox2) { | |
864 | mbspc.Curve(2, tpoles2d); | |
865 | ||
866 | Handle(Geom2d_BSplineCurve) BS2 = new Geom2d_BSplineCurve(tpoles2d, | |
867 | mbspc.Knots(), | |
868 | mbspc.Multiplicities(), | |
869 | mbspc.Degree()); | |
870 | GeomLib_Check2dBSplineCurve newCheck(BS2,myTolCheck,myTolAngCheck); | |
871 | newCheck.FixTangent(Standard_True,Standard_True); | |
872 | // | |
873 | AdjustUPeriodic (aS2, BS2); | |
874 | // | |
875 | slineS2.Append(BS2); | |
876 | } | |
877 | else { | |
878 | slineS2.Append(H1); | |
879 | } | |
880 | }//if(typs1 == GeomAbs_Plane) | |
881 | // | |
882 | else if(typs2 == GeomAbs_Plane) { | |
883 | const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j); | |
884 | nbpoles = mbspc.NbPoles(); | |
885 | ||
886 | TColgp_Array1OfPnt2d tpoles2d(1,nbpoles); | |
887 | TColgp_Array1OfPnt tpoles(1,nbpoles); | |
888 | mbspc.Curve((myApprox1==Standard_True)? 2 : 1,tpoles2d); | |
889 | const gp_Pln& Pln = myHS2->Surface().Plane(); | |
890 | // | |
891 | Standard_Integer ik; | |
892 | for(ik = 1; ik<= nbpoles; ik++) { | |
893 | tpoles.SetValue(ik, | |
894 | ElSLib::Value(tpoles2d.Value(ik).X(), | |
895 | tpoles2d.Value(ik).Y(), | |
896 | Pln)); | |
897 | ||
898 | } | |
899 | // | |
900 | Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles, | |
901 | mbspc.Knots(), | |
902 | mbspc.Multiplicities(), | |
903 | mbspc.Degree()); | |
904 | GeomLib_CheckBSplineCurve Check(BS,myTolCheck,myTolAngCheck); | |
905 | Check.FixTangent(Standard_True,Standard_True); | |
906 | // | |
907 | sline.Append(BS); | |
908 | // | |
909 | if(myApprox2) { | |
910 | Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d, | |
911 | mbspc.Knots(), | |
912 | mbspc.Multiplicities(), | |
913 | mbspc.Degree()); | |
914 | GeomLib_Check2dBSplineCurve Check1(BS1,myTolCheck,myTolAngCheck); | |
915 | Check1.FixTangent(Standard_True,Standard_True); | |
916 | // | |
917 | // | |
918 | AdjustUPeriodic (aS2, BS1); | |
919 | // | |
920 | slineS2.Append(BS1); | |
921 | } | |
922 | else { | |
923 | slineS2.Append(H1); | |
924 | } | |
925 | ||
926 | if(myApprox1) { | |
927 | mbspc.Curve(1,tpoles2d); | |
928 | Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d, | |
929 | mbspc.Knots(), | |
930 | mbspc.Multiplicities(), | |
931 | mbspc.Degree()); | |
932 | GeomLib_Check2dBSplineCurve Check2(BS2,myTolCheck,myTolAngCheck); | |
933 | Check2.FixTangent(Standard_True,Standard_True); | |
934 | // | |
935 | // | |
936 | AdjustUPeriodic (aS1, BS2); | |
937 | // | |
938 | slineS1.Append(BS2); | |
939 | } | |
940 | else { | |
941 | slineS1.Append(H1); | |
942 | } | |
943 | } // else if(typs2 == GeomAbs_Plane) | |
944 | // | |
945 | else { // typs1!=GeomAbs_Plane && typs2!=GeomAbs_Plane | |
946 | const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j); | |
947 | nbpoles = mbspc.NbPoles(); | |
948 | TColgp_Array1OfPnt tpoles(1,nbpoles); | |
949 | mbspc.Curve(1,tpoles); | |
950 | Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles, | |
951 | mbspc.Knots(), | |
952 | mbspc.Multiplicities(), | |
953 | mbspc.Degree()); | |
954 | GeomLib_CheckBSplineCurve Check(BS,myTolCheck,myTolAngCheck); | |
955 | Check.FixTangent(Standard_True,Standard_True); | |
956 | // | |
957 | //Check IsClosed() | |
958 | Standard_Real aDist = Max(BS->StartPoint().XYZ().SquareModulus(), | |
959 | BS->EndPoint().XYZ().SquareModulus()); | |
960 | Standard_Real eps = Epsilon(aDist); | |
94f71cad | 961 | if(BS->StartPoint().SquareDistance(BS->EndPoint()) < 2.*eps) |
e618b526 | 962 | { |
94f71cad | 963 | // Avoid creating B-splines containing two coincident poles only |
964 | if (mbspc.Degree() == 1 && nbpoles == 2) | |
965 | continue; | |
966 | ||
967 | if (!BS->IsClosed() && !BS->IsPeriodic()) | |
968 | { | |
969 | //force Closed() | |
970 | gp_Pnt aPm((BS->Pole(1).XYZ() + BS->Pole(BS->NbPoles()).XYZ()) / 2.); | |
971 | BS->SetPole(1, aPm); | |
972 | BS->SetPole(BS->NbPoles(), aPm); | |
973 | } | |
e618b526 | 974 | } |
975 | sline.Append(BS); | |
976 | ||
977 | if(myApprox1) { | |
978 | TColgp_Array1OfPnt2d tpoles2d(1,nbpoles); | |
979 | mbspc.Curve(2,tpoles2d); | |
980 | Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d, | |
981 | mbspc.Knots(), | |
982 | mbspc.Multiplicities(), | |
983 | mbspc.Degree()); | |
984 | GeomLib_Check2dBSplineCurve newCheck(BS1,myTolCheck,myTolAngCheck); | |
985 | newCheck.FixTangent(Standard_True,Standard_True); | |
986 | // | |
987 | AdjustUPeriodic (aS1, BS1); | |
988 | // | |
989 | slineS1.Append(BS1); | |
990 | } | |
991 | else { | |
992 | slineS1.Append(H1); | |
993 | } | |
994 | if(myApprox2) { | |
995 | TColgp_Array1OfPnt2d tpoles2d(1,nbpoles); | |
996 | mbspc.Curve((myApprox1==Standard_True)? 3 : 2,tpoles2d); | |
997 | Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d, | |
998 | mbspc.Knots(), | |
999 | mbspc.Multiplicities(), | |
1000 | mbspc.Degree()); | |
1001 | GeomLib_Check2dBSplineCurve newCheck(BS2,myTolCheck,myTolAngCheck); | |
1002 | newCheck.FixTangent(Standard_True,Standard_True); | |
1003 | // | |
1004 | AdjustUPeriodic (aS2, BS2); | |
1005 | // | |
1006 | slineS2.Append(BS2); | |
1007 | } | |
1008 | else { | |
1009 | slineS2.Append(H1); | |
1010 | } | |
1011 | }// else { // typs1!=GeomAbs_Plane && typs2!=GeomAbs_Plane | |
1012 | }// for (j=1; j<=aNbMultiCurves; j++ | |
7c4e9501 | 1013 | } |
7fd59977 | 1014 | } |
1015 | } | |
1016 | } | |
e618b526 | 1017 | break; |
1018 | ||
7fd59977 | 1019 | case IntPatch_Restriction: |
e618b526 | 1020 | { |
1021 | GeomAbs_SurfaceType typS1 = myHS1->Surface().GetType(); | |
1022 | GeomAbs_SurfaceType typS2 = myHS2->Surface().GetType(); | |
1023 | Standard_Boolean isAnalS1 = Standard_False; | |
1024 | switch (typS1) | |
1025 | { | |
1026 | case GeomAbs_Plane: | |
1027 | case GeomAbs_Cylinder: | |
1028 | case GeomAbs_Sphere: | |
1029 | case GeomAbs_Cone: | |
1030 | case GeomAbs_Torus: isAnalS1 = Standard_True; break; | |
1031 | default: break; | |
1032 | } | |
1033 | ||
1034 | Standard_Integer isAnalS2 = Standard_False; | |
1035 | switch (typS2) | |
1036 | { | |
1037 | case GeomAbs_Plane: | |
1038 | case GeomAbs_Cylinder: | |
1039 | case GeomAbs_Sphere: | |
1040 | case GeomAbs_Cone: | |
1041 | case GeomAbs_Torus: isAnalS2 = Standard_True; break; | |
1042 | default: break; | |
1043 | } | |
1044 | ||
d4b867e6 | 1045 | Handle(IntPatch_RLine) RL = |
1046 | Handle(IntPatch_RLine)::DownCast(L); | |
1047 | Handle(Geom_Curve) aC3d; | |
1048 | Handle(Geom2d_Curve) aC2d1, aC2d2; | |
1049 | Standard_Real aTolReached; | |
1050 | TreatRLine(RL, myHS1, myHS2, aC3d, | |
1051 | aC2d1, aC2d2, aTolReached); | |
1052 | ||
1053 | if(aC3d.IsNull()) | |
1054 | break; | |
1055 | ||
1056 | Bnd_Box2d aBox1, aBox2; | |
1057 | ||
1058 | const Standard_Real aU1f = myHS1->FirstUParameter(), | |
1059 | aV1f = myHS1->FirstVParameter(), | |
1060 | aU1l = myHS1->LastUParameter(), | |
1061 | aV1l = myHS1->LastVParameter(); | |
1062 | const Standard_Real aU2f = myHS2->FirstUParameter(), | |
1063 | aV2f = myHS2->FirstVParameter(), | |
1064 | aU2l = myHS2->LastUParameter(), | |
1065 | aV2l = myHS2->LastVParameter(); | |
1066 | ||
1067 | aBox1.Add(gp_Pnt2d(aU1f, aV1f)); | |
1068 | aBox1.Add(gp_Pnt2d(aU1l, aV1l)); | |
1069 | aBox2.Add(gp_Pnt2d(aU2f, aV2f)); | |
1070 | aBox2.Add(gp_Pnt2d(aU2l, aV2l)); | |
1071 | ||
1072 | GeomInt_VectorOfReal anArrayOfParameters; | |
1073 | ||
1074 | //We consider here that the intersection line is same-parameter-line | |
1075 | anArrayOfParameters.Append(aC3d->FirstParameter()); | |
1076 | anArrayOfParameters.Append(aC3d->LastParameter()); | |
1077 | ||
1078 | TrimILineOnSurfBoundaries(aC2d1, aC2d2, aBox1, aBox2, anArrayOfParameters); | |
1079 | ||
1080 | const Standard_Integer aNbIntersSolutionsm1 = anArrayOfParameters.Length() - 1; | |
1081 | ||
1082 | //Trim RLine found. | |
1083 | for(Standard_Integer anInd = 0; anInd < aNbIntersSolutionsm1; anInd++) | |
e618b526 | 1084 | { |
d4b867e6 | 1085 | const Standard_Real aParF = anArrayOfParameters(anInd), |
1086 | aParL = anArrayOfParameters(anInd+1); | |
1087 | ||
1088 | if((aParL - aParF) <= Precision::PConfusion()) | |
1089 | continue; | |
1090 | ||
1091 | const Standard_Real aPar = 0.5*(aParF + aParL); | |
1092 | gp_Pnt2d aPt; | |
1093 | ||
1094 | Handle(Geom2d_Curve) aCurv2d1, aCurv2d2; | |
1095 | if(!aC2d1.IsNull()) | |
1096 | { | |
1097 | aC2d1->D0(aPar, aPt); | |
1098 | ||
1099 | if(aBox1.IsOut(aPt)) | |
1100 | continue; | |
1101 | ||
1102 | if(myApprox1) | |
1103 | aCurv2d1 = new Geom2d_TrimmedCurve(aC2d1, aParF, aParL); | |
1104 | } | |
1105 | ||
1106 | if(!aC2d2.IsNull()) | |
1107 | { | |
1108 | aC2d2->D0(aPar, aPt); | |
1109 | ||
1110 | if(aBox2.IsOut(aPt)) | |
1111 | continue; | |
1112 | ||
1113 | if(myApprox2) | |
1114 | aCurv2d2 = new Geom2d_TrimmedCurve(aC2d2, aParF, aParL); | |
1115 | } | |
1116 | ||
1117 | Handle(Geom_Curve) aCurv3d = new Geom_TrimmedCurve(aC3d, aParF, aParL); | |
1118 | ||
1119 | sline.Append(aCurv3d); | |
1120 | slineS1.Append(aCurv2d1); | |
1121 | slineS2.Append(aCurv2d2); | |
e618b526 | 1122 | } |
1123 | } | |
7fd59977 | 1124 | break; |
7fd59977 | 1125 | } |
1126 | } | |
1127 | // | |
1128 | //======================================================================= | |
1129 | //function : AdjustUPeriodic | |
1130 | //purpose : | |
1131 | //======================================================================= | |
1132 | void AdjustUPeriodic (const Handle(Geom_Surface)& aS, Handle(Geom2d_Curve)& aC2D) | |
1133 | { | |
1134 | if (aC2D.IsNull() || !aS->IsUPeriodic()) | |
1135 | return; | |
1136 | // | |
1137 | const Standard_Real aEps=Precision::PConfusion();//1.e-9 | |
1138 | const Standard_Real aEpsilon=Epsilon(10.);//1.77e-15 | |
1139 | // | |
1140 | Standard_Real umin,umax,vmin,vmax; | |
1141 | aS->Bounds(umin,umax,vmin,vmax); | |
1142 | const Standard_Real aPeriod = aS->UPeriod(); | |
1143 | ||
1144 | const Standard_Real aT1=aC2D->FirstParameter(); | |
1145 | const Standard_Real aT2=aC2D->LastParameter(); | |
1146 | const Standard_Real aTx=aT1+0.467*(aT2-aT1); | |
1147 | const gp_Pnt2d aPx=aC2D->Value(aTx); | |
1148 | // | |
1149 | Standard_Real aUx=aPx.X(); | |
1150 | if (fabs(aUx)<aEpsilon) | |
1151 | aUx=0.; | |
1152 | if (fabs(aUx-aPeriod)<aEpsilon) | |
1153 | aUx=aPeriod; | |
1154 | // | |
1155 | Standard_Real dU=0.; | |
1156 | while(aUx <(umin-aEps)) { | |
1157 | aUx+=aPeriod; | |
1158 | dU+=aPeriod; | |
1159 | } | |
1160 | while(aUx>(umax+aEps)) { | |
1161 | aUx-=aPeriod; | |
1162 | dU-=aPeriod; | |
1163 | } | |
1164 | // | |
1165 | if (dU!=0.) { | |
1166 | gp_Vec2d aV2D(dU, 0.); | |
1167 | aC2D->Translate(aV2D); | |
1168 | } | |
1169 | } | |
1170 | // | |
1171 | // | |
1172 | //======================================================================= | |
7fd59977 | 1173 | //function : GetQuadric |
1174 | //purpose : | |
1175 | //======================================================================= | |
1176 | void GetQuadric(const Handle(GeomAdaptor_HSurface)& HS1, IntSurf_Quadric& quad1) | |
1177 | { | |
1178 | switch (HS1->Surface().GetType()) | |
1179 | { | |
1180 | case GeomAbs_Plane: quad1.SetValue(HS1->Surface().Plane()); break; | |
1181 | case GeomAbs_Cylinder: quad1.SetValue(HS1->Surface().Cylinder()); break; | |
1182 | case GeomAbs_Cone: quad1.SetValue(HS1->Surface().Cone()); break; | |
1183 | case GeomAbs_Sphere: quad1.SetValue(HS1->Surface().Sphere()); break; | |
7eed5d29 | 1184 | case GeomAbs_Torus: quad1.SetValue(HS1->Surface().Torus()); break; |
7fd59977 | 1185 | default: Standard_ConstructionError::Raise("GeomInt_IntSS::MakeCurve"); |
1186 | } | |
1187 | } | |
1188 | ||
1189 | //======================================================================= | |
1190 | //function : Parameters | |
1191 | //purpose : | |
1192 | //======================================================================= | |
1193 | void Parameters(const Handle(GeomAdaptor_HSurface)& HS1, | |
1194 | const Handle(GeomAdaptor_HSurface)& HS2, | |
1195 | const gp_Pnt& Ptref, | |
1196 | Standard_Real& U1, | |
1197 | Standard_Real& V1, | |
1198 | Standard_Real& U2, | |
1199 | Standard_Real& V2) | |
1200 | { | |
1201 | IntSurf_Quadric quad1,quad2; | |
1202 | // | |
1203 | GetQuadric(HS1, quad1); | |
1204 | GetQuadric(HS2, quad2); | |
1205 | // | |
1206 | quad1.Parameters(Ptref,U1,V1); | |
1207 | quad2.Parameters(Ptref,U2,V2); | |
1208 | } | |
1209 | ||
1210 | //======================================================================= | |
1211 | //function : MakeBSpline | |
1212 | //purpose : | |
1213 | //======================================================================= | |
1214 | Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL, | |
1215 | const Standard_Integer ideb, | |
1216 | const Standard_Integer ifin) | |
1217 | { | |
1218 | const Standard_Integer nbpnt = ifin-ideb+1; | |
1219 | TColgp_Array1OfPnt poles(1,nbpnt); | |
1220 | TColStd_Array1OfReal knots(1,nbpnt); | |
1221 | TColStd_Array1OfInteger mults(1,nbpnt); | |
1222 | Standard_Integer i = 1, ipidebm1 = ideb; | |
1223 | for(; i<=nbpnt; ipidebm1++, i++) | |
1224 | { | |
1225 | poles(i) = WL->Point(ipidebm1).Value(); | |
1226 | mults(i) = 1; | |
1227 | knots(i) = i-1; | |
1228 | } | |
1229 | mults(1) = mults(nbpnt) = 2; | |
1230 | return new Geom_BSplineCurve(poles,knots,mults,1); | |
1231 | } | |
1232 | ||
1233 | //======================================================================= | |
1234 | //function : MakeBSpline2d | |
1235 | //purpose : | |
1236 | //======================================================================= | |
1237 | Handle(Geom2d_BSplineCurve) MakeBSpline2d(const Handle(IntPatch_WLine)& theWLine, | |
1238 | const Standard_Integer ideb, | |
1239 | const Standard_Integer ifin, | |
1240 | const Standard_Boolean onFirst) | |
1241 | { | |
1242 | const Standard_Integer nbpnt = ifin-ideb+1; | |
1243 | TColgp_Array1OfPnt2d poles(1,nbpnt); | |
1244 | TColStd_Array1OfReal knots(1,nbpnt); | |
1245 | TColStd_Array1OfInteger mults(1,nbpnt); | |
1246 | Standard_Integer i = 1, ipidebm1 = ideb; | |
1247 | for(; i <= nbpnt; ipidebm1++, i++) | |
1248 | { | |
1249 | Standard_Real U, V; | |
1250 | if(onFirst) | |
1251 | theWLine->Point(ipidebm1).ParametersOnS1(U, V); | |
1252 | else | |
1253 | theWLine->Point(ipidebm1).ParametersOnS2(U, V); | |
1254 | poles(i).SetCoord(U, V); | |
1255 | mults(i) = 1; | |
1256 | knots(i) = i-1; | |
1257 | } | |
1258 | mults(1) = mults(nbpnt) = 2; | |
1259 | return new Geom2d_BSplineCurve(poles,knots,mults,1); | |
1260 | } | |
1261 | ||
1262 | //========================================================================= | |
1263 | // static function : ComputePurgedWLine | |
1264 | // purpose : Removes equal points (leave one of equal points) from theWLine | |
1265 | // and recompute vertex parameters. | |
1266 | // Returns new WLine or null WLine if the number | |
1267 | // of the points is less than 2. | |
1268 | //========================================================================= | |
1269 | Handle(IntPatch_WLine) ComputePurgedWLine(const Handle(IntPatch_WLine)& theWLine) | |
1270 | { | |
1271 | Handle(IntPatch_WLine) aResult; | |
1272 | Handle(IntPatch_WLine) aLocalWLine; | |
1273 | Handle(IntPatch_WLine) aTmpWLine = theWLine; | |
1274 | ||
1275 | Handle(IntSurf_LineOn2S) aLineOn2S = new IntSurf_LineOn2S(); | |
1276 | aLocalWLine = new IntPatch_WLine(aLineOn2S, Standard_False); | |
1277 | Standard_Integer i, k, v, nb, nbvtx; | |
1278 | nbvtx = theWLine->NbVertex(); | |
1279 | nb = theWLine->NbPnts(); | |
1280 | ||
1281 | for(i = 1; i <= nb; i++) { | |
1282 | aLineOn2S->Add(theWLine->Point(i)); | |
1283 | } | |
1284 | ||
1285 | for(v = 1; v <= nbvtx; v++) { | |
1286 | aLocalWLine->AddVertex(theWLine->Vertex(v)); | |
1287 | } | |
1288 | ||
1289 | for(i = 1; i <= aLineOn2S->NbPoints(); i++) { | |
1290 | Standard_Integer aStartIndex = i + 1; | |
1291 | Standard_Integer anEndIndex = i + 5; | |
1292 | nb = aLineOn2S->NbPoints(); | |
1293 | anEndIndex = (anEndIndex > nb) ? nb : anEndIndex; | |
1294 | ||
1295 | if((aStartIndex >= nb) || (anEndIndex <= 1)) { | |
1296 | continue; | |
1297 | } | |
1298 | k = aStartIndex; | |
1299 | ||
1300 | while(k <= anEndIndex) { | |
1301 | ||
1302 | if(i != k) { | |
1303 | IntSurf_PntOn2S p1 = aLineOn2S->Value(i); | |
1304 | IntSurf_PntOn2S p2 = aLineOn2S->Value(k); | |
1305 | ||
1306 | if(p1.Value().IsEqual(p2.Value(), gp::Resolution())) { | |
1307 | aTmpWLine = aLocalWLine; | |
1308 | aLocalWLine = new IntPatch_WLine(aLineOn2S, Standard_False); | |
1309 | ||
1310 | for(v = 1; v <= aTmpWLine->NbVertex(); v++) { | |
1311 | IntPatch_Point aVertex = aTmpWLine->Vertex(v); | |
1312 | Standard_Integer avertexindex = (Standard_Integer)aVertex.ParameterOnLine(); | |
1313 | ||
1314 | if(avertexindex >= k) { | |
1315 | aVertex.SetParameter(aVertex.ParameterOnLine() - 1.); | |
1316 | } | |
1317 | aLocalWLine->AddVertex(aVertex); | |
1318 | } | |
1319 | aLineOn2S->RemovePoint(k); | |
1320 | anEndIndex--; | |
1321 | continue; | |
1322 | } | |
1323 | } | |
1324 | k++; | |
1325 | } | |
1326 | } | |
1327 | ||
1328 | if(aLineOn2S->NbPoints() > 1) { | |
1329 | aResult = aLocalWLine; | |
1330 | } | |
1331 | return aResult; | |
1332 | } | |
1333 | //======================================================================= | |
1334 | //function : DecompositionOfWLine | |
1335 | //purpose : | |
1336 | //======================================================================= | |
1337 | Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, | |
1338 | const Handle(GeomAdaptor_HSurface)& theSurface1, | |
1339 | const Handle(GeomAdaptor_HSurface)& theSurface2, | |
1340 | const Standard_Real aTolSum, | |
1341 | const GeomInt_LineConstructor& theLConstructor, | |
1342 | IntPatch_SequenceOfLine& theNewLines) | |
1343 | { | |
96a85238 RL |
1344 | typedef NCollection_List<Standard_Integer> ListOfInteger; |
1345 | //have to use std::vector, not NCollection_Vector in order to use copy constructor of | |
1346 | //ListOfInteger which will be created with specific allocator instance | |
1347 | typedef std::vector<ListOfInteger, NCollection_StdAllocator< | |
1348 | ListOfInteger> > ArrayOfListOfInteger; | |
1349 | ||
7fd59977 | 1350 | Standard_Boolean bIsPrevPointOnBoundary, bIsCurrentPointOnBoundary; |
1351 | Standard_Integer nblines, aNbPnts, aNbParts, pit, i, j, aNbListOfPointIndex; | |
1352 | Standard_Real aTol, umin, umax, vmin, vmax; | |
96a85238 RL |
1353 | |
1354 | //an inc allocator, it will contain wasted space (upon list's Clear()) but it should | |
1355 | //still be faster than the standard allocator, and wasted memory should not be | |
1356 | //significant and will be limited by time span of this function; | |
1357 | //this is a separate allocator from the anIncAlloc below what provides better data | |
1358 | //locality in the latter (by avoiding wastes which will only be in anIdxAlloc) | |
1359 | Handle(NCollection_IncAllocator) anIdxAlloc = new NCollection_IncAllocator(); | |
1360 | ListOfInteger aListOfPointIndex (anIdxAlloc); | |
1361 | ||
7fd59977 | 1362 | //GeomAPI_ProjectPointOnSurf aPrj1, aPrj2; |
1363 | ProjectPointOnSurf aPrj1, aPrj2; | |
1364 | Handle(Geom_Surface) aSurf1, aSurf2; | |
1365 | // | |
1366 | aNbParts=theLConstructor.NbParts(); | |
1367 | aNbPnts=theWLine->NbPnts(); | |
1368 | // | |
1369 | if((!aNbPnts) || (!aNbParts)){ | |
1370 | return Standard_False; | |
1371 | } | |
1372 | // | |
96a85238 RL |
1373 | Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator(); |
1374 | NCollection_StdAllocator<ListOfInteger> anAlloc (anIncAlloc); | |
1375 | const ListOfInteger aDummy (anIncAlloc); //empty list to be copy constructed from | |
1376 | ArrayOfListOfInteger anArrayOfLines (aNbPnts + 1, aDummy, anAlloc); | |
1377 | ||
1378 | NCollection_LocalArray<Standard_Integer> anArrayOfLineTypeArr (aNbPnts + 1); | |
1379 | Standard_Integer* anArrayOfLineType = anArrayOfLineTypeArr; | |
7fd59977 | 1380 | // |
1381 | nblines = 0; | |
1382 | aTol = Precision::Confusion(); | |
1383 | // | |
1384 | aSurf1 = theSurface1->ChangeSurface().Surface(); | |
1385 | aSurf1->Bounds(umin, umax, vmin, vmax); | |
1386 | aPrj1.Init(aSurf1, umin, umax, vmin, vmax); | |
1387 | // | |
1388 | aSurf2 = theSurface2->ChangeSurface().Surface(); | |
1389 | aSurf2->Bounds(umin, umax, vmin, vmax); | |
1390 | aPrj2.Init(aSurf2, umin, umax, vmin, vmax); | |
1391 | // | |
1392 | // | |
1393 | bIsPrevPointOnBoundary=Standard_False; | |
1394 | for(pit=1; pit<=aNbPnts; pit++) { | |
1395 | const IntSurf_PntOn2S& aPoint = theWLine->Point(pit); | |
1396 | bIsCurrentPointOnBoundary=Standard_False; | |
1397 | // | |
1398 | // whether aPoint is on boundary or not | |
1399 | // | |
1400 | for(i=0; i<2; i++) {// exploration Surface 1,2 | |
1401 | Handle(GeomAdaptor_HSurface) aGASurface = (!i) ? theSurface1 : theSurface2; | |
1402 | aGASurface->ChangeSurface().Surface()->Bounds(umin, umax, vmin, vmax); | |
1403 | // | |
1404 | for(j=0; j<2; j++) {// exploration of coordinate U,V | |
1405 | Standard_Boolean isperiodic; | |
1406 | // | |
1407 | isperiodic = (!j) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic(); | |
1408 | if(!isperiodic) { | |
1409 | continue; | |
1410 | } | |
1411 | // | |
1412 | Standard_Real aResolution, aPeriod, alowerboundary, aupperboundary, U, V; | |
1413 | Standard_Real aParameter, anoffset, anAdjustPar; | |
1414 | Standard_Boolean bIsOnFirstBoundary, bIsPointOnBoundary; | |
1415 | // | |
1416 | aResolution = (!j) ? aGASurface->UResolution(aTol) : aGASurface->VResolution(aTol); | |
1417 | aPeriod = (!j) ? aGASurface->UPeriod() : aGASurface->VPeriod(); | |
1418 | alowerboundary = (!j) ? umin : vmin; | |
1419 | aupperboundary = (!j) ? umax : vmax; | |
1420 | U=0.;V=0.;//? | |
1421 | // | |
1422 | if(!i){ | |
1423 | aPoint.ParametersOnS1(U, V); | |
1424 | } | |
1425 | else{ | |
1426 | aPoint.ParametersOnS2(U, V); | |
1427 | } | |
1428 | // | |
1429 | aParameter = (!j) ? U : V; | |
1430 | anoffset=0.; | |
1431 | anAdjustPar=AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset); | |
1432 | // | |
1433 | bIsOnFirstBoundary=Standard_True; | |
1434 | // | |
1435 | bIsPointOnBoundary= | |
1436 | IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary); | |
1437 | ||
1438 | if(bIsPointOnBoundary) { | |
1439 | bIsCurrentPointOnBoundary = Standard_True; | |
1440 | break; | |
1441 | } | |
1442 | }// for(j=0; j<2; j++) | |
1443 | ||
1444 | if(bIsCurrentPointOnBoundary){ | |
1445 | break; | |
1446 | } | |
1447 | }// for(i=0; i<2; i++) | |
1448 | // | |
1449 | if((bIsCurrentPointOnBoundary != bIsPrevPointOnBoundary)) { | |
1450 | ||
1451 | if(!aListOfPointIndex.IsEmpty()) { | |
1452 | nblines++; | |
96a85238 RL |
1453 | anArrayOfLines[nblines] = aListOfPointIndex; |
1454 | anArrayOfLineType[nblines] = bIsPrevPointOnBoundary; | |
7fd59977 | 1455 | aListOfPointIndex.Clear(); |
1456 | } | |
1457 | bIsPrevPointOnBoundary = bIsCurrentPointOnBoundary; | |
1458 | } | |
1459 | aListOfPointIndex.Append(pit); | |
1460 | } // for(pit=1; pit<=aNbPnts; pit++) | |
1461 | // | |
1462 | aNbListOfPointIndex=aListOfPointIndex.Extent(); | |
1463 | if(aNbListOfPointIndex) { | |
1464 | nblines++; | |
ddf2fe8e | 1465 | anArrayOfLines[nblines].Assign (aListOfPointIndex); |
96a85238 | 1466 | anArrayOfLineType[nblines] = bIsPrevPointOnBoundary; |
7fd59977 | 1467 | aListOfPointIndex.Clear(); |
1468 | } | |
1469 | // | |
1470 | if(nblines <= 1){ | |
1471 | return Standard_False; | |
1472 | } | |
1473 | // | |
1474 | // Correct wlines.begin | |
1475 | Standard_Integer aLineType; | |
1476 | TColStd_Array1OfListOfInteger anArrayOfLineEnds(1, nblines); | |
96a85238 | 1477 | Handle(IntSurf_LineOn2S) aSeqOfPntOn2S = new IntSurf_LineOn2S (new NCollection_IncAllocator()); |
7fd59977 | 1478 | // |
1479 | for(i = 1; i <= nblines; i++) { | |
96a85238 | 1480 | aLineType=anArrayOfLineType[i]; |
7fd59977 | 1481 | if(aLineType) { |
1482 | continue; | |
1483 | } | |
1484 | // | |
96a85238 | 1485 | const ListOfInteger& aListOfIndex = anArrayOfLines[i]; |
7fd59977 | 1486 | if(aListOfIndex.Extent() < 2) { |
1487 | continue; | |
1488 | } | |
1489 | // | |
1490 | TColStd_ListOfInteger aListOfFLIndex; | |
1491 | Standard_Integer aneighbourindex, aLineTypeNeib; | |
1492 | // | |
1493 | for(j = 0; j < 2; j++) {// neighbour line choice | |
1494 | aneighbourindex = (!j) ? (i-1) : (i+1); | |
1495 | if((aneighbourindex < 1) || (aneighbourindex > nblines)){ | |
1496 | continue; | |
1497 | } | |
1498 | // | |
96a85238 | 1499 | aLineTypeNeib=anArrayOfLineType[aneighbourindex]; |
7fd59977 | 1500 | if(!aLineTypeNeib){ |
1501 | continue; | |
1502 | } | |
1503 | // | |
96a85238 | 1504 | const ListOfInteger& aNeighbour = anArrayOfLines[aneighbourindex]; |
7fd59977 | 1505 | Standard_Integer anIndex = (!j) ? aNeighbour.Last() : aNeighbour.First(); |
1506 | const IntSurf_PntOn2S& aPoint = theWLine->Point(anIndex); | |
1507 | // check if need use derivative.begin .end [absence] | |
1508 | // | |
1509 | IntSurf_PntOn2S aNewP = aPoint; | |
1510 | Standard_Integer surfit, parit; | |
1511 | // | |
1512 | for(surfit = 0; surfit < 2; ++surfit) { | |
1513 | ||
1514 | Handle(GeomAdaptor_HSurface) aGASurface = (!surfit) ? theSurface1 : theSurface2; | |
1515 | ||
31cf9c5f | 1516 | umin = aGASurface->FirstUParameter(); |
1517 | umax = aGASurface->LastUParameter(); | |
1518 | vmin = aGASurface->FirstVParameter(); | |
1519 | vmax = aGASurface->LastVParameter(); | |
7fd59977 | 1520 | Standard_Real U=0., V=0.; |
1521 | ||
1522 | if(!surfit) { | |
1523 | aNewP.ParametersOnS1(U, V); | |
1524 | } | |
1525 | else { | |
1526 | aNewP.ParametersOnS2(U, V); | |
1527 | } | |
1528 | // | |
1529 | Standard_Integer nbboundaries = 0; | |
1530 | Standard_Integer bIsUBoundary = Standard_False; // use if nbboundaries == 1 | |
1531 | Standard_Integer bIsFirstBoundary = Standard_False; // use if nbboundaries == 1 | |
1532 | // | |
1533 | for(parit = 0; parit < 2; parit++) { | |
1534 | Standard_Boolean isperiodic = (!parit) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic(); | |
1535 | ||
1536 | Standard_Real aResolution = (!parit) ? aGASurface->UResolution(aTol) : aGASurface->VResolution(aTol); | |
1537 | Standard_Real alowerboundary = (!parit) ? umin : vmin; | |
1538 | Standard_Real aupperboundary = (!parit) ? umax : vmax; | |
1539 | ||
1540 | Standard_Real aParameter = (!parit) ? U : V; | |
1541 | Standard_Boolean bIsOnFirstBoundary = Standard_True; | |
1542 | ||
1543 | if(!isperiodic) { | |
1544 | if(IsPointOnBoundary(aParameter, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary)) { | |
1545 | bIsUBoundary = (!parit); | |
1546 | bIsFirstBoundary = bIsOnFirstBoundary; | |
1547 | nbboundaries++; | |
1548 | } | |
1549 | } | |
1550 | else { | |
1551 | Standard_Real aPeriod = (!parit) ? aGASurface->UPeriod() : aGASurface->VPeriod(); | |
1552 | Standard_Real anoffset = 0.; | |
1553 | Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset); | |
1554 | ||
1555 | if(IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary)) { | |
1556 | bIsUBoundary = (parit == 0); | |
1557 | bIsFirstBoundary = bIsOnFirstBoundary; | |
1558 | nbboundaries++; | |
1559 | } | |
1560 | } | |
1561 | } | |
1562 | // | |
1563 | Standard_Boolean bComputeLineEnd = Standard_False; | |
1564 | ||
1565 | if(nbboundaries == 2) { | |
1566 | bComputeLineEnd = Standard_True; | |
1567 | } | |
1568 | else if(nbboundaries == 1) { | |
1569 | Standard_Boolean isperiodic = (bIsUBoundary) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic(); | |
1570 | ||
1571 | if(isperiodic) { | |
1572 | Standard_Real alowerboundary = (bIsUBoundary) ? umin : vmin; | |
1573 | Standard_Real aupperboundary = (bIsUBoundary) ? umax : vmax; | |
1574 | Standard_Real aPeriod = (bIsUBoundary) ? aGASurface->UPeriod() : aGASurface->VPeriod(); | |
1575 | Standard_Real aParameter = (bIsUBoundary) ? U : V; | |
1576 | Standard_Real anoffset = 0.; | |
1577 | Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset); | |
1578 | ||
1579 | Standard_Real adist = (bIsFirstBoundary) ? fabs(anAdjustPar - alowerboundary) : fabs(anAdjustPar - aupperboundary); | |
1580 | Standard_Real anotherPar = (bIsFirstBoundary) ? (aupperboundary - adist) : (alowerboundary + adist); | |
1581 | anotherPar += anoffset; | |
1582 | Standard_Integer aneighbourpointindex = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last(); | |
1583 | const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex); | |
1584 | Standard_Real nU1, nV1; | |
1585 | ||
1586 | if(surfit == 0) | |
1587 | aNeighbourPoint.ParametersOnS1(nU1, nV1); | |
1588 | else | |
1589 | aNeighbourPoint.ParametersOnS2(nU1, nV1); | |
1590 | ||
1591 | Standard_Real adist1 = (bIsUBoundary) ? fabs(nU1 - U) : fabs(nV1 - V); | |
1592 | Standard_Real adist2 = (bIsUBoundary) ? fabs(nU1 - anotherPar) : fabs(nV1 - anotherPar); | |
1593 | bComputeLineEnd = Standard_True; | |
1594 | Standard_Boolean bCheckAngle1 = Standard_False; | |
1595 | Standard_Boolean bCheckAngle2 = Standard_False; | |
1596 | gp_Vec2d aNewVec; | |
1597 | Standard_Real anewU = (bIsUBoundary) ? anotherPar : U; | |
1598 | Standard_Real anewV = (bIsUBoundary) ? V : anotherPar; | |
1599 | // | |
1600 | if(((adist1 - adist2) > Precision::PConfusion()) && | |
1601 | (adist2 < (aPeriod / 4.))) { | |
1602 | bCheckAngle1 = Standard_True; | |
1603 | aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(anewU, anewV)); | |
1604 | ||
1605 | if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) { | |
1606 | aNewP.SetValue((surfit == 0), anewU, anewV); | |
1607 | bCheckAngle1 = Standard_False; | |
1608 | } | |
1609 | } | |
1610 | else if(adist1 < (aPeriod / 4.)) { | |
1611 | bCheckAngle2 = Standard_True; | |
1612 | aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(U, V)); | |
1613 | ||
1614 | if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) { | |
1615 | bCheckAngle2 = Standard_False; | |
1616 | } | |
1617 | } | |
1618 | // | |
1619 | if(bCheckAngle1 || bCheckAngle2) { | |
1620 | // assume there are at least two points in line (see "if" above) | |
1621 | Standard_Integer anindexother = aneighbourpointindex; | |
1622 | ||
1623 | while((anindexother <= aListOfIndex.Last()) && (anindexother >= aListOfIndex.First())) { | |
1624 | anindexother = (j == 0) ? (anindexother + 1) : (anindexother - 1); | |
1625 | const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(anindexother); | |
1626 | Standard_Real nU2, nV2; | |
1627 | ||
1628 | if(surfit == 0) | |
1629 | aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); | |
1630 | else | |
1631 | aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); | |
1632 | gp_Vec2d aVecOld(gp_Pnt2d(nU2, nV2), gp_Pnt2d(nU1, nV1)); | |
1633 | ||
1634 | if(aVecOld.SquareMagnitude() <= (gp::Resolution() * gp::Resolution())) { | |
1635 | continue; | |
1636 | } | |
1637 | else { | |
1638 | Standard_Real anAngle = aNewVec.Angle(aVecOld); | |
1639 | ||
c6541a0c | 1640 | if((fabs(anAngle) < (M_PI * 0.25)) && (aNewVec.Dot(aVecOld) > 0.)) { |
7fd59977 | 1641 | |
1642 | if(bCheckAngle1) { | |
1643 | Standard_Real U1, U2, V1, V2; | |
1644 | IntSurf_PntOn2S atmppoint = aNewP; | |
1645 | atmppoint.SetValue((surfit == 0), anewU, anewV); | |
1646 | atmppoint.Parameters(U1, V1, U2, V2); | |
1647 | gp_Pnt P1 = theSurface1->Value(U1, V1); | |
1648 | gp_Pnt P2 = theSurface2->Value(U2, V2); | |
1649 | gp_Pnt P0 = aPoint.Value(); | |
1650 | ||
1651 | if(P0.IsEqual(P1, aTol) && | |
1652 | P0.IsEqual(P2, aTol) && | |
1653 | P1.IsEqual(P2, aTol)) { | |
1654 | bComputeLineEnd = Standard_False; | |
1655 | aNewP.SetValue((surfit == 0), anewU, anewV); | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | if(bCheckAngle2) { | |
1660 | bComputeLineEnd = Standard_False; | |
1661 | } | |
1662 | } | |
1663 | break; | |
1664 | } | |
1665 | } // end while(anindexother...) | |
1666 | } | |
1667 | } | |
1668 | } | |
1669 | // | |
1670 | if(bComputeLineEnd) { | |
1671 | Standard_Integer aneighbourpointindex1 = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last(); | |
1672 | const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1); | |
1673 | Standard_Real nU1, nV1; | |
1674 | ||
1675 | if(surfit == 0) | |
1676 | aNeighbourPoint.ParametersOnS1(nU1, nV1); | |
1677 | else | |
1678 | aNeighbourPoint.ParametersOnS2(nU1, nV1); | |
1679 | gp_Pnt2d ap1(nU1, nV1); | |
1680 | gp_Pnt2d ap2(nU1, nV1); | |
1681 | Standard_Integer aneighbourpointindex2 = aneighbourpointindex1; | |
1682 | ||
1683 | while((aneighbourpointindex2 <= aListOfIndex.Last()) && (aneighbourpointindex2 >= aListOfIndex.First())) { | |
1684 | aneighbourpointindex2 = (j == 0) ? (aneighbourpointindex2 + 1) : (aneighbourpointindex2 - 1); | |
1685 | const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(aneighbourpointindex2); | |
1686 | Standard_Real nU2, nV2; | |
1687 | ||
1688 | if(surfit == 0) | |
1689 | aPrevNeighbourPoint.ParametersOnS1(nU2, nV2); | |
1690 | else | |
1691 | aPrevNeighbourPoint.ParametersOnS2(nU2, nV2); | |
1692 | ap2.SetX(nU2); | |
1693 | ap2.SetY(nV2); | |
1694 | ||
1695 | if(ap1.SquareDistance(ap2) > (gp::Resolution() * gp::Resolution())) { | |
1696 | break; | |
1697 | } | |
1698 | } | |
1699 | gp_Pnt2d anewpoint; | |
1700 | Standard_Boolean found = FindPoint(ap2, ap1, umin, umax, vmin, vmax, anewpoint); | |
1701 | ||
1702 | if(found) { | |
1703 | // check point | |
1704 | Standard_Real aCriteria =aTolSum;// BRep_Tool::Tolerance(theFace1) + BRep_Tool::Tolerance(theFace2); | |
1705 | //GeomAPI_ProjectPointOnSurf& aProjector = (surfit == 0) ? aPrj2 : aPrj1; | |
1706 | ProjectPointOnSurf& aProjector = (surfit == 0) ? aPrj2 : aPrj1; | |
1707 | Handle(GeomAdaptor_HSurface) aSurface = (surfit == 0) ? theSurface1 : theSurface2; | |
1708 | ||
1709 | gp_Pnt aP3d = aSurface->Value(anewpoint.X(), anewpoint.Y()); | |
1710 | aProjector.Perform(aP3d); | |
1711 | ||
1712 | if(aProjector.IsDone()) { | |
1713 | if(aProjector.LowerDistance() < aCriteria) { | |
1714 | Standard_Real foundU = U, foundV = V; | |
1715 | aProjector.LowerDistanceParameters(foundU, foundV); | |
1716 | ||
1717 | if(surfit == 0) | |
1718 | aNewP.SetValue(aP3d, anewpoint.X(), anewpoint.Y(), foundU, foundV); | |
1719 | else | |
1720 | aNewP.SetValue(aP3d, foundU, foundV, anewpoint.X(), anewpoint.Y()); | |
1721 | } | |
1722 | } | |
1723 | } | |
1724 | } | |
1725 | } | |
1726 | aSeqOfPntOn2S->Add(aNewP); | |
1727 | aListOfFLIndex.Append(aSeqOfPntOn2S->NbPoints()); | |
1728 | } | |
1729 | anArrayOfLineEnds.SetValue(i, aListOfFLIndex); | |
1730 | } | |
1731 | // Correct wlines.end | |
1732 | ||
1733 | // Split wlines.begin | |
1734 | for(j = 1; j <= theLConstructor.NbParts(); j++) { | |
1735 | Standard_Real fprm = 0., lprm = 0.; | |
1736 | theLConstructor.Part(j, fprm, lprm); | |
1737 | Standard_Integer ifprm = (Standard_Integer)fprm; | |
1738 | Standard_Integer ilprm = (Standard_Integer)lprm; | |
1739 | // | |
1740 | Handle(IntSurf_LineOn2S) aLineOn2S = new IntSurf_LineOn2S(); | |
1741 | // | |
1742 | for(i = 1; i <= nblines; i++) { | |
96a85238 | 1743 | if(anArrayOfLineType[i] != 0) { |
7fd59977 | 1744 | continue; |
1745 | } | |
96a85238 | 1746 | const ListOfInteger& aListOfIndex = anArrayOfLines[i]; |
7fd59977 | 1747 | |
1748 | if(aListOfIndex.Extent() < 2) { | |
1749 | continue; | |
1750 | } | |
1751 | const TColStd_ListOfInteger& aListOfFLIndex = anArrayOfLineEnds.Value(i); | |
1752 | Standard_Boolean bhasfirstpoint = (aListOfFLIndex.Extent() == 2); | |
1753 | Standard_Boolean bhaslastpoint = (aListOfFLIndex.Extent() == 2); | |
1754 | ||
1755 | if(!bhasfirstpoint && !aListOfFLIndex.IsEmpty()) { | |
1756 | bhasfirstpoint = (i != 1); | |
1757 | } | |
1758 | ||
1759 | if(!bhaslastpoint && !aListOfFLIndex.IsEmpty()) { | |
1760 | bhaslastpoint = (i != nblines); | |
1761 | } | |
1762 | Standard_Boolean bIsFirstInside = ((ifprm >= aListOfIndex.First()) && (ifprm <= aListOfIndex.Last())); | |
1763 | Standard_Boolean bIsLastInside = ((ilprm >= aListOfIndex.First()) && (ilprm <= aListOfIndex.Last())); | |
1764 | ||
1765 | if(!bIsFirstInside && !bIsLastInside) { | |
1766 | if((ifprm < aListOfIndex.First()) && (ilprm > aListOfIndex.Last())) { | |
1767 | // append whole line, and boundaries if neccesary | |
1768 | if(bhasfirstpoint) { | |
1769 | const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First()); | |
1770 | aLineOn2S->Add(aP); | |
1771 | } | |
96a85238 | 1772 | ListOfInteger::Iterator anIt(aListOfIndex); |
7fd59977 | 1773 | |
1774 | for(; anIt.More(); anIt.Next()) { | |
1775 | const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); | |
1776 | aLineOn2S->Add(aP); | |
1777 | } | |
1778 | ||
1779 | if(bhaslastpoint) { | |
1780 | const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.Last()); | |
1781 | aLineOn2S->Add(aP); | |
1782 | } | |
1783 | ||
1784 | // check end of split line (end is almost always) | |
1785 | Standard_Integer aneighbour = i + 1; | |
1786 | Standard_Boolean bIsEndOfLine = Standard_True; | |
1787 | ||
1788 | if(aneighbour <= nblines) { | |
96a85238 | 1789 | const ListOfInteger& aListOfNeighbourIndex = anArrayOfLines[aneighbour]; |
7fd59977 | 1790 | |
96a85238 | 1791 | if((anArrayOfLineType[aneighbour] != 0) && |
7fd59977 | 1792 | (aListOfNeighbourIndex.IsEmpty())) { |
1793 | bIsEndOfLine = Standard_False; | |
1794 | } | |
1795 | } | |
1796 | ||
1797 | if(bIsEndOfLine) { | |
1798 | if(aLineOn2S->NbPoints() > 1) { | |
1799 | Handle(IntPatch_WLine) aNewWLine = | |
1800 | new IntPatch_WLine(aLineOn2S, Standard_False); | |
1801 | theNewLines.Append(aNewWLine); | |
1802 | } | |
1803 | aLineOn2S = new IntSurf_LineOn2S(); | |
1804 | } | |
1805 | } | |
1806 | continue; | |
1807 | } | |
1808 | // end if(!bIsFirstInside && !bIsLastInside) | |
1809 | ||
1810 | if(bIsFirstInside && bIsLastInside) { | |
1811 | // append inside points between ifprm and ilprm | |
96a85238 | 1812 | ListOfInteger::Iterator anIt(aListOfIndex); |
7fd59977 | 1813 | |
1814 | for(; anIt.More(); anIt.Next()) { | |
1815 | if((anIt.Value() < ifprm) || (anIt.Value() > ilprm)) | |
1816 | continue; | |
1817 | const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); | |
1818 | aLineOn2S->Add(aP); | |
1819 | } | |
1820 | } | |
1821 | else { | |
1822 | ||
1823 | if(bIsFirstInside) { | |
1824 | // append points from ifprm to last point + boundary point | |
96a85238 | 1825 | ListOfInteger::Iterator anIt(aListOfIndex); |
7fd59977 | 1826 | |
1827 | for(; anIt.More(); anIt.Next()) { | |
1828 | if(anIt.Value() < ifprm) | |
1829 | continue; | |
1830 | const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); | |
1831 | aLineOn2S->Add(aP); | |
1832 | } | |
1833 | ||
1834 | if(bhaslastpoint) { | |
1835 | const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.Last()); | |
1836 | aLineOn2S->Add(aP); | |
1837 | } | |
1838 | // check end of split line (end is almost always) | |
1839 | Standard_Integer aneighbour = i + 1; | |
1840 | Standard_Boolean bIsEndOfLine = Standard_True; | |
1841 | ||
1842 | if(aneighbour <= nblines) { | |
96a85238 | 1843 | const ListOfInteger& aListOfNeighbourIndex = anArrayOfLines[aneighbour]; |
7fd59977 | 1844 | |
96a85238 | 1845 | if((anArrayOfLineType[aneighbour] != 0) && |
7fd59977 | 1846 | (aListOfNeighbourIndex.IsEmpty())) { |
1847 | bIsEndOfLine = Standard_False; | |
1848 | } | |
1849 | } | |
1850 | ||
1851 | if(bIsEndOfLine) { | |
1852 | if(aLineOn2S->NbPoints() > 1) { | |
1853 | Handle(IntPatch_WLine) aNewWLine = | |
1854 | new IntPatch_WLine(aLineOn2S, Standard_False); | |
1855 | theNewLines.Append(aNewWLine); | |
1856 | } | |
1857 | aLineOn2S = new IntSurf_LineOn2S(); | |
1858 | } | |
1859 | } | |
1860 | // end if(bIsFirstInside) | |
1861 | ||
1862 | if(bIsLastInside) { | |
1863 | // append points from first boundary point to ilprm | |
1864 | if(bhasfirstpoint) { | |
1865 | const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First()); | |
1866 | aLineOn2S->Add(aP); | |
1867 | } | |
96a85238 | 1868 | ListOfInteger::Iterator anIt(aListOfIndex); |
7fd59977 | 1869 | |
1870 | for(; anIt.More(); anIt.Next()) { | |
1871 | if(anIt.Value() > ilprm) | |
1872 | continue; | |
1873 | const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); | |
1874 | aLineOn2S->Add(aP); | |
1875 | } | |
1876 | } | |
1877 | //end if(bIsLastInside) | |
1878 | } | |
1879 | } | |
1880 | ||
1881 | if(aLineOn2S->NbPoints() > 1) { | |
1882 | Handle(IntPatch_WLine) aNewWLine = | |
1883 | new IntPatch_WLine(aLineOn2S, Standard_False); | |
1884 | theNewLines.Append(aNewWLine); | |
1885 | } | |
1886 | } | |
1887 | // Split wlines.end | |
1888 | // | |
1889 | // cda002/I3 | |
1890 | Standard_Real fprm, lprm; | |
1891 | Standard_Integer ifprm, ilprm, aNbPoints, aIndex; | |
1892 | // | |
1893 | aNbParts=theLConstructor.NbParts(); | |
1894 | // | |
1895 | for(j = 1; j <= aNbParts; j++) { | |
1896 | theLConstructor.Part(j, fprm, lprm); | |
1897 | ifprm=(Standard_Integer)fprm; | |
1898 | ilprm=(Standard_Integer)lprm; | |
1899 | // | |
1900 | if ((ilprm-ifprm)==1) { | |
1901 | for(i = 1; i <= nblines; i++) { | |
96a85238 | 1902 | aLineType=anArrayOfLineType[i]; |
7fd59977 | 1903 | if(aLineType) { |
1904 | continue; | |
1905 | } | |
1906 | // | |
96a85238 | 1907 | const ListOfInteger& aListOfIndex = anArrayOfLines[i]; |
7fd59977 | 1908 | aNbPoints=aListOfIndex.Extent(); |
1909 | if(aNbPoints==1) { | |
1910 | aIndex=aListOfIndex.First(); | |
1911 | if (aIndex==ifprm || aIndex==ilprm) { | |
1912 | Handle(IntSurf_LineOn2S) aLineOn2S = new IntSurf_LineOn2S(); | |
1913 | const IntSurf_PntOn2S& aP1 = theWLine->Point(ifprm); | |
1914 | const IntSurf_PntOn2S& aP2 = theWLine->Point(ilprm); | |
1915 | aLineOn2S->Add(aP1); | |
1916 | aLineOn2S->Add(aP2); | |
1917 | Handle(IntPatch_WLine) aNewWLine = | |
1918 | new IntPatch_WLine(aLineOn2S, Standard_False); | |
1919 | theNewLines.Append(aNewWLine); | |
1920 | } | |
1921 | } | |
1922 | } | |
1923 | } | |
1924 | } | |
1925 | // | |
1926 | return Standard_True; | |
1927 | } | |
1928 | ||
1929 | //======================================================================= | |
1930 | //function : AdjustPeriodic | |
1931 | //purpose : | |
1932 | //======================================================================= | |
1933 | Standard_Real AdjustPeriodic(const Standard_Real theParameter, | |
1934 | const Standard_Real parmin, | |
1935 | const Standard_Real parmax, | |
1936 | const Standard_Real thePeriod, | |
1937 | Standard_Real& theOffset) | |
1938 | { | |
1939 | Standard_Real aresult = theParameter; | |
1940 | theOffset = 0.; | |
1941 | while(aresult < parmin) { | |
1942 | aresult += thePeriod; | |
1943 | theOffset += thePeriod; | |
1944 | } | |
1945 | while(aresult > parmax) { | |
1946 | aresult -= thePeriod; | |
1947 | theOffset -= thePeriod; | |
1948 | } | |
1949 | return aresult; | |
1950 | } | |
1951 | ||
1952 | //======================================================================= | |
1953 | //function : IsPointOnBoundary | |
1954 | //purpose : | |
1955 | //======================================================================= | |
1956 | Standard_Boolean IsPointOnBoundary(const Standard_Real theParameter, | |
1957 | const Standard_Real theFirstBoundary, | |
1958 | const Standard_Real theSecondBoundary, | |
1959 | const Standard_Real theResolution, | |
1960 | Standard_Boolean& IsOnFirstBoundary) | |
1961 | { | |
1962 | IsOnFirstBoundary = Standard_True; | |
1963 | if(fabs(theParameter - theFirstBoundary) < theResolution) | |
1964 | return Standard_True; | |
1965 | if(fabs(theParameter - theSecondBoundary) < theResolution) | |
1966 | { | |
1967 | IsOnFirstBoundary = Standard_False; | |
1968 | return Standard_True; | |
1969 | } | |
1970 | return Standard_False; | |
1971 | } | |
1972 | //======================================================================= | |
1973 | //function : FindPoint | |
1974 | //purpose : | |
1975 | //======================================================================= | |
1976 | Standard_Boolean FindPoint(const gp_Pnt2d& theFirstPoint, | |
1977 | const gp_Pnt2d& theLastPoint, | |
1978 | const Standard_Real theUmin, | |
1979 | const Standard_Real theUmax, | |
1980 | const Standard_Real theVmin, | |
1981 | const Standard_Real theVmax, | |
1982 | gp_Pnt2d& theNewPoint) | |
1983 | { | |
1984 | gp_Vec2d aVec(theFirstPoint, theLastPoint); | |
1985 | Standard_Integer i = 0, j = 0; | |
1986 | ||
1987 | for(i = 0; i < 4; i++) { | |
1988 | gp_Vec2d anOtherVec; | |
1989 | gp_Vec2d anOtherVecNormal; | |
1990 | gp_Pnt2d aprojpoint = theLastPoint; | |
1991 | ||
1992 | if((i % 2) == 0) { | |
1993 | anOtherVec.SetX(0.); | |
1994 | anOtherVec.SetY(1.); | |
1995 | anOtherVecNormal.SetX(1.); | |
1996 | anOtherVecNormal.SetY(0.); | |
1997 | ||
1998 | if(i < 2) | |
1999 | aprojpoint.SetX(theUmin); | |
2000 | else | |
2001 | aprojpoint.SetX(theUmax); | |
2002 | } | |
2003 | else { | |
2004 | anOtherVec.SetX(1.); | |
2005 | anOtherVec.SetY(0.); | |
2006 | anOtherVecNormal.SetX(0.); | |
2007 | anOtherVecNormal.SetY(1.); | |
2008 | ||
2009 | if(i < 2) | |
2010 | aprojpoint.SetY(theVmin); | |
2011 | else | |
2012 | aprojpoint.SetY(theVmax); | |
2013 | } | |
2014 | gp_Vec2d anormvec = aVec; | |
2015 | anormvec.Normalize(); | |
2016 | Standard_Real adot1 = anormvec.Dot(anOtherVecNormal); | |
2017 | ||
2018 | if(fabs(adot1) < Precision::Angular()) | |
2019 | continue; | |
2020 | Standard_Real adist = 0.; | |
2021 | ||
2022 | if((i % 2) == 0) { | |
2023 | adist = (i < 2) ? fabs(theLastPoint.X() - theUmin) : fabs(theLastPoint.X() - theUmax); | |
2024 | } | |
2025 | else { | |
2026 | adist = (i < 2) ? fabs(theLastPoint.Y() - theVmin) : fabs(theLastPoint.Y() - theVmax); | |
2027 | } | |
2028 | Standard_Real anoffset = adist * anOtherVec.Dot(anormvec) / adot1; | |
2029 | ||
2030 | for(j = 0; j < 2; j++) { | |
2031 | anoffset = (j == 0) ? anoffset : -anoffset; | |
2032 | gp_Pnt2d acurpoint(aprojpoint.XY() + (anOtherVec.XY()*anoffset)); | |
2033 | gp_Vec2d acurvec(theLastPoint, acurpoint); | |
2034 | ||
2035 | // | |
2036 | Standard_Real aDotX, anAngleX, aPC; | |
2037 | // | |
2038 | aDotX=aVec.Dot(acurvec); | |
2039 | anAngleX=aVec.Angle(acurvec); | |
2040 | aPC=Precision::PConfusion(); | |
2041 | // | |
2042 | if(aDotX > 0. && fabs(anAngleX) < aPC) { | |
2043 | // | |
2044 | if((i % 2) == 0) { | |
2045 | if((acurpoint.Y() >= theVmin) && | |
2046 | (acurpoint.Y() <= theVmax)) { | |
2047 | theNewPoint = acurpoint; | |
2048 | return Standard_True; | |
2049 | } | |
2050 | } | |
2051 | else { | |
2052 | if((acurpoint.X() >= theUmin) && | |
2053 | (acurpoint.X() <= theUmax)) { | |
2054 | theNewPoint = acurpoint; | |
2055 | return Standard_True; | |
2056 | } | |
2057 | } | |
2058 | } | |
2059 | } | |
2060 | } | |
2061 | return Standard_False; | |
2062 | } | |
2063 | ||
7a91ad6e | 2064 | //======================================================================= |
2065 | //function : ParametersOfNearestPointOnSurface | |
2066 | //purpose : | |
2067 | //======================================================================= | |
2068 | static Standard_Boolean ParametersOfNearestPointOnSurface(const Extrema_ExtPS theExtr, | |
2069 | Standard_Real& theU, | |
2070 | Standard_Real& theV) | |
2071 | { | |
2072 | if(!theExtr.IsDone() || !theExtr.NbExt()) | |
2073 | return Standard_False; | |
2074 | ||
2075 | Standard_Integer anIndex = 1; | |
2076 | Standard_Real aMinSQDist = theExtr.SquareDistance(anIndex); | |
2077 | for(Standard_Integer i = 2; i <= theExtr.NbExt(); i++) | |
2078 | { | |
2079 | Standard_Real aSQD = theExtr.SquareDistance(i); | |
2080 | if (aSQD < aMinSQDist) | |
2081 | { | |
2082 | aMinSQDist = aSQD; | |
2083 | anIndex = i; | |
2084 | } | |
2085 | } | |
2086 | ||
2087 | theExtr.Point(anIndex).Parameter(theU, theV); | |
2088 | ||
2089 | return Standard_True; | |
2090 | } | |
2091 | ||
2092 | //======================================================================= | |
2093 | //function : GetSegmentBoundary | |
2094 | //purpose : | |
2095 | //======================================================================= | |
2096 | static void GetSegmentBoundary( const IntRes2d_IntersectionSegment& theSegm, | |
2097 | const Handle(Geom2d_Curve)& theCurve, | |
2098 | GeomInt_VectorOfReal& theArrayOfParameters) | |
2099 | { | |
2100 | Standard_Real aU1 = theCurve->FirstParameter(), aU2 = theCurve->LastParameter(); | |
2101 | ||
2102 | if(theSegm.HasFirstPoint()) | |
2103 | { | |
2104 | const IntRes2d_IntersectionPoint& anIPF = theSegm.FirstPoint(); | |
2105 | aU1 = anIPF.ParamOnFirst(); | |
2106 | } | |
2107 | ||
2108 | if(theSegm.HasLastPoint()) | |
2109 | { | |
2110 | const IntRes2d_IntersectionPoint& anIPL = theSegm.LastPoint(); | |
2111 | aU2 = anIPL.ParamOnFirst(); | |
2112 | } | |
2113 | ||
2114 | theArrayOfParameters.Append(aU1); | |
2115 | theArrayOfParameters.Append(aU2); | |
2116 | } | |
2117 | ||
2118 | //======================================================================= | |
2119 | //function : IntersectCurveAndBoundary | |
2120 | //purpose : | |
2121 | //======================================================================= | |
2122 | static void IntersectCurveAndBoundary(const Handle(Geom2d_Curve)& theC2d, | |
2123 | const Handle(Geom2d_Curve)* const theArrBounds, | |
2124 | const Standard_Integer theNumberOfCurves, | |
2125 | const Standard_Real theTol, | |
2126 | GeomInt_VectorOfReal& theArrayOfParameters) | |
2127 | { | |
2128 | if(theC2d.IsNull()) | |
2129 | return; | |
2130 | ||
2131 | Geom2dAdaptor_Curve anAC1(theC2d); | |
2132 | for(Standard_Integer aCurID = 0; aCurID < theNumberOfCurves; aCurID++) | |
2133 | { | |
2134 | if(theArrBounds[aCurID].IsNull()) | |
2135 | continue; | |
2136 | ||
2137 | Geom2dAdaptor_Curve anAC2(theArrBounds[aCurID]); | |
2138 | Geom2dInt_GInter anIntCC2d(anAC1, anAC2, theTol, theTol); | |
2139 | ||
2140 | if(!anIntCC2d.IsDone() || anIntCC2d.IsEmpty()) | |
2141 | continue; | |
2142 | ||
2143 | for (Standard_Integer aPntID = 1; aPntID <= anIntCC2d.NbPoints(); aPntID++) | |
2144 | { | |
2145 | const Standard_Real aParam = anIntCC2d.Point(aPntID).ParamOnFirst(); | |
2146 | theArrayOfParameters.Append(aParam); | |
2147 | } | |
2148 | ||
2149 | for (Standard_Integer aSegmID = 1; aSegmID <= anIntCC2d.NbSegments(); aSegmID++) | |
2150 | { | |
2151 | GetSegmentBoundary(anIntCC2d.Segment(aSegmID), theC2d, theArrayOfParameters); | |
2152 | } | |
2153 | } | |
2154 | } | |
2155 | ||
7fd59977 | 2156 | //======================================================================= |
d4b867e6 | 2157 | //function : TreatRLine |
2158 | //purpose : Approx of Restriction line | |
2159 | //======================================================================= | |
2160 | void GeomInt_IntSS::TreatRLine(const Handle(IntPatch_RLine)& theRL, | |
2161 | const Handle(GeomAdaptor_HSurface)& theHS1, | |
2162 | const Handle(GeomAdaptor_HSurface)& theHS2, | |
2163 | Handle(Geom_Curve)& theC3d, | |
2164 | Handle(Geom2d_Curve)& theC2d1, | |
2165 | Handle(Geom2d_Curve)& theC2d2, | |
2166 | Standard_Real& theTolReached) | |
2167 | { | |
2168 | Handle(GeomAdaptor_HSurface) aGAHS; | |
2169 | Handle(Adaptor2d_HCurve2d) anAHC2d; | |
2170 | Standard_Real tf, tl; | |
2171 | gp_Lin2d aL; | |
2172 | // It is assumed that 2d curve is 2d line (rectangular surface domain) | |
2173 | if(theRL->IsArcOnS1()) | |
2174 | { | |
2175 | aGAHS = theHS1; | |
2176 | anAHC2d = theRL->ArcOnS1(); | |
2177 | theRL->ParamOnS1(tf, tl); | |
2178 | theC2d1 = Geom2dAdaptor::MakeCurve(anAHC2d->Curve2d()); | |
2179 | } | |
2180 | else if (theRL->IsArcOnS2()) | |
2181 | { | |
2182 | aGAHS = theHS2; | |
2183 | anAHC2d = theRL->ArcOnS2(); | |
2184 | theRL->ParamOnS2(tf, tl); | |
2185 | theC2d2 = Geom2dAdaptor::MakeCurve(anAHC2d->Curve2d()); | |
2186 | } | |
2187 | else | |
2188 | { | |
2189 | return; | |
2190 | } | |
2191 | // | |
2192 | //To provide sameparameter it is necessary to get 3d curve as | |
2193 | //approximation of curve on surface. | |
2194 | Standard_Integer aMaxDeg = 8; | |
2195 | Standard_Integer aMaxSeg = 1000; | |
2196 | Approx_CurveOnSurface anApp(anAHC2d, aGAHS, tf, tl, Precision::Confusion(), | |
2197 | GeomAbs_C1, aMaxDeg, aMaxSeg, | |
2198 | Standard_True, Standard_False); | |
2199 | if(!anApp.HasResult()) | |
2200 | return; | |
2201 | ||
2202 | theC3d = anApp.Curve3d(); | |
2203 | theTolReached = anApp.MaxError3d(); | |
2204 | Standard_Real aTol = Precision::Confusion(); | |
2205 | if(theRL->IsArcOnS1()) | |
2206 | { | |
2207 | Handle(Geom_Surface) aS = GeomAdaptor::MakeSurface(theHS2->Surface()); | |
2208 | BuildPCurves (tf, tl, aTol, | |
2209 | aS, theC3d, theC2d2); | |
2210 | } | |
2211 | if(theRL->IsArcOnS2()) | |
2212 | { | |
2213 | Handle(Geom_Surface) aS = GeomAdaptor::MakeSurface(theHS1->Surface()); | |
2214 | BuildPCurves (tf, tl, aTol, | |
2215 | aS, theC3d, theC2d1); | |
2216 | } | |
2217 | theTolReached = Max(theTolReached, aTol); | |
2218 | } | |
2219 | ||
2220 | //======================================================================= | |
2221 | //function : BuildPCurves | |
7fd59977 | 2222 | //purpose : |
2223 | //======================================================================= | |
d4b867e6 | 2224 | void GeomInt_IntSS::BuildPCurves (Standard_Real f, |
2225 | Standard_Real l, | |
2226 | Standard_Real& Tol, | |
2227 | const Handle (Geom_Surface)& S, | |
2228 | const Handle (Geom_Curve)& C, | |
2229 | Handle (Geom2d_Curve)& C2d) | |
7fd59977 | 2230 | { |
d4b867e6 | 2231 | if (!C2d.IsNull()) { |
2232 | return; | |
2233 | } | |
2234 | // | |
2235 | Standard_Real umin,umax,vmin,vmax; | |
2236 | // | |
2237 | S->Bounds(umin, umax, vmin, vmax); | |
2238 | // in class ProjLib_Function the range of parameters is shrank by 1.e-09 | |
2239 | if((l - f) > 2.e-09) { | |
2240 | C2d = GeomProjLib::Curve2d(C,f,l,S,umin,umax,vmin,vmax,Tol); | |
2241 | // | |
2242 | if (C2d.IsNull()) { | |
2243 | // proj. a circle that goes through the pole on a sphere to the sphere | |
2244 | Tol += Precision::Confusion(); | |
2245 | C2d = GeomProjLib::Curve2d(C,f,l,S,Tol); | |
2246 | } | |
2247 | } | |
2248 | else { | |
7a91ad6e | 2249 | if((l - f) > Epsilon(Abs(f))) |
2250 | { | |
2251 | //The domain of C2d is [Epsilon(Abs(f)), 2.e-09] | |
2252 | //On this small range C2d can be considered as segment | |
2253 | //of line. | |
2254 | ||
2255 | Standard_Real aU=0., aV=0.; | |
2256 | GeomAdaptor_Surface anAS; | |
2257 | anAS.Load(S); | |
2258 | Extrema_ExtPS anExtr; | |
2259 | const gp_Pnt aP3d1 = C->Value(f); | |
2260 | const gp_Pnt aP3d2 = C->Value(l); | |
2261 | ||
2262 | anExtr.SetAlgo(Extrema_ExtAlgo_Grad); | |
2263 | anExtr.Initialize(anAS, umin, umax, vmin, vmax, | |
2264 | Precision::Confusion(), Precision::Confusion()); | |
2265 | anExtr.Perform(aP3d1); | |
2266 | ||
2267 | if(ParametersOfNearestPointOnSurface(anExtr, aU, aV)) | |
2268 | { | |
2269 | const gp_Pnt2d aP2d1(aU, aV); | |
2270 | ||
2271 | anExtr.Perform(aP3d2); | |
2272 | ||
2273 | if(ParametersOfNearestPointOnSurface(anExtr, aU, aV)) | |
2274 | { | |
2275 | const gp_Pnt2d aP2d2(aU, aV); | |
2276 | ||
2277 | if(aP2d1.Distance(aP2d2) > gp::Resolution()) | |
2278 | { | |
2279 | TColgp_Array1OfPnt2d poles(1,2); | |
2280 | TColStd_Array1OfReal knots(1,2); | |
2281 | TColStd_Array1OfInteger mults(1,2); | |
2282 | poles(1) = aP2d1; | |
2283 | poles(2) = aP2d2; | |
2284 | knots(1) = f; | |
2285 | knots(2) = l; | |
2286 | mults(1) = mults(2) = 2; | |
2287 | ||
2288 | C2d = new Geom2d_BSplineCurve(poles,knots,mults,1); | |
2289 | ||
2290 | //Check same parameter in middle point .begin | |
2291 | const gp_Pnt PMid(C->Value(0.5*(f+l))); | |
2292 | const gp_Pnt2d pmidcurve2d(0.5*(aP2d1.XY() + aP2d2.XY())); | |
2293 | const gp_Pnt aPC(anAS.Value(pmidcurve2d.X(), pmidcurve2d.Y())); | |
2294 | const Standard_Real aDist = PMid.Distance(aPC); | |
2295 | Tol = Max(aDist, Tol); | |
2296 | //Check same parameter in middle point .end | |
d4b867e6 | 2297 | } |
d4b867e6 | 2298 | } |
2299 | } | |
2300 | } | |
2301 | } | |
7fd59977 | 2302 | // |
d4b867e6 | 2303 | if (S->IsUPeriodic() && !C2d.IsNull()) { |
2304 | // Recadre dans le domaine UV de la face | |
2305 | Standard_Real aTm, U0, aEps, period, du, U0x; | |
2306 | Standard_Boolean bAdjust; | |
2307 | // | |
2308 | aEps = Precision::PConfusion(); | |
2309 | period = S->UPeriod(); | |
2310 | // | |
2311 | aTm = .5*(f + l); | |
2312 | gp_Pnt2d pm = C2d->Value(aTm); | |
2313 | U0 = pm.X(); | |
2314 | // | |
2315 | bAdjust = | |
2316 | GeomInt::AdjustPeriodic(U0, umin, umax, period, U0x, du, aEps); | |
2317 | if (bAdjust) { | |
2318 | gp_Vec2d T1(du, 0.); | |
2319 | C2d->Translate(T1); | |
2320 | } | |
2321 | } | |
2322 | } | |
2323 | ||
2324 | //======================================================================= | |
2325 | //function : TrimILineOnSurfBoundaries | |
2326 | //purpose : This function finds intersection points of given curves with | |
2327 | // surface boundaries and fills theArrayOfParameters by parameters | |
2328 | // along the given curves corresponding of these points. | |
2329 | //======================================================================= | |
2330 | void GeomInt_IntSS::TrimILineOnSurfBoundaries(const Handle(Geom2d_Curve)& theC2d1, | |
2331 | const Handle(Geom2d_Curve)& theC2d2, | |
2332 | const Bnd_Box2d& theBound1, | |
2333 | const Bnd_Box2d& theBound2, | |
2334 | GeomInt_VectorOfReal& theArrayOfParameters) | |
2335 | { | |
2336 | //Rectangular boundaries of two surfaces: [0]:U=Ufirst, [1]:U=Ulast, | |
2337 | // [2]:V=Vfirst, [3]:V=Vlast | |
2338 | const Standard_Integer aNumberOfCurves = 4; | |
2339 | Handle(Geom2d_Curve) aCurS1Bounds[aNumberOfCurves]; | |
2340 | Handle(Geom2d_Curve) aCurS2Bounds[aNumberOfCurves]; | |
2341 | ||
2342 | Standard_Real aU1f=0.0, aV1f=0.0, aU1l=0.0, aV1l=0.0; | |
2343 | Standard_Real aU2f=0.0, aV2f=0.0, aU2l=0.0, aV2l=0.0; | |
2344 | ||
2345 | theBound1.Get(aU1f, aV1f, aU1l, aV1l); | |
2346 | theBound2.Get(aU2f, aV2f, aU2l, aV2l); | |
2347 | ||
2348 | Standard_Real aDelta = aV1l-aV1f; | |
2349 | if(Abs(aDelta) > RealSmall()) | |
2350 | { | |
2351 | if(!Precision::IsInfinite(aU1f)) | |
2352 | { | |
2353 | aCurS1Bounds[0] = new Geom2d_Line(gp_Pnt2d(aU1f, aV1f), gp_Dir2d(0.0, 1.0)); | |
2354 | ||
2355 | if(!Precision::IsInfinite(aDelta)) | |
2356 | aCurS1Bounds[0] = new Geom2d_TrimmedCurve(aCurS1Bounds[0], 0, aDelta); | |
2357 | } | |
2358 | ||
2359 | if(!Precision::IsInfinite(aU1l)) | |
2360 | { | |
2361 | aCurS1Bounds[1] = new Geom2d_Line(gp_Pnt2d(aU1l, aV1f), gp_Dir2d(0.0, 1.0)); | |
2362 | if(!Precision::IsInfinite(aDelta)) | |
2363 | aCurS1Bounds[1] = new Geom2d_TrimmedCurve(aCurS1Bounds[1], 0, aDelta); | |
2364 | } | |
2365 | } | |
2366 | ||
2367 | aDelta = aU1l-aU1f; | |
2368 | if(Abs(aDelta) > RealSmall()) | |
2369 | { | |
2370 | if(!Precision::IsInfinite(aV1f)) | |
2371 | { | |
2372 | aCurS1Bounds[2] = new Geom2d_Line(gp_Pnt2d(aU1f, aV1f), gp_Dir2d(1.0, 0.0)); | |
2373 | if(!Precision::IsInfinite(aDelta)) | |
2374 | aCurS1Bounds[2] = new Geom2d_TrimmedCurve(aCurS1Bounds[2], 0, aDelta); | |
2375 | } | |
2376 | ||
2377 | if(!Precision::IsInfinite(aV1l)) | |
2378 | { | |
2379 | aCurS1Bounds[3] = new Geom2d_Line(gp_Pnt2d(aU1l, aV1l), gp_Dir2d(1.0, 0.0)); | |
2380 | if(!Precision::IsInfinite(aDelta)) | |
2381 | aCurS1Bounds[3] = new Geom2d_TrimmedCurve(aCurS1Bounds[3], 0, aDelta); | |
2382 | } | |
2383 | } | |
2384 | ||
2385 | aDelta = aV2l-aV2f; | |
2386 | if(Abs(aDelta) > RealSmall()) | |
2387 | { | |
2388 | if(!Precision::IsInfinite(aU2f)) | |
2389 | { | |
2390 | aCurS2Bounds[0] = new Geom2d_Line(gp_Pnt2d(aU2f, aV2f), gp_Dir2d(0.0, 1.0)); | |
2391 | if(!Precision::IsInfinite(aDelta)) | |
2392 | aCurS2Bounds[0] = new Geom2d_TrimmedCurve(aCurS2Bounds[0], 0, aDelta); | |
2393 | } | |
2394 | ||
2395 | if(!Precision::IsInfinite(aU2l)) | |
2396 | { | |
2397 | aCurS2Bounds[1] = new Geom2d_Line(gp_Pnt2d(aU2l, aV2f), gp_Dir2d(0.0, 1.0)); | |
2398 | if(!Precision::IsInfinite(aDelta)) | |
2399 | aCurS2Bounds[1] = new Geom2d_TrimmedCurve(aCurS2Bounds[1], 0, aDelta); | |
2400 | } | |
2401 | } | |
2402 | ||
2403 | aDelta = aU2l-aU2f; | |
2404 | if(Abs(aDelta) > RealSmall()) | |
2405 | { | |
2406 | if(!Precision::IsInfinite(aV2f)) | |
2407 | { | |
2408 | aCurS2Bounds[2] = new Geom2d_Line(gp_Pnt2d(aU2f, aV2f), gp_Dir2d(1.0, 0.0)); | |
2409 | if(!Precision::IsInfinite(aDelta)) | |
2410 | aCurS2Bounds[2] = new Geom2d_TrimmedCurve(aCurS2Bounds[2], 0, aDelta); | |
2411 | } | |
2412 | ||
2413 | if(!Precision::IsInfinite(aV2l)) | |
2414 | { | |
2415 | aCurS2Bounds[3] = new Geom2d_Line(gp_Pnt2d(aU2l, aV2l), gp_Dir2d(1.0, 0.0)); | |
2416 | if(!Precision::IsInfinite(aDelta)) | |
2417 | aCurS2Bounds[3] = new Geom2d_TrimmedCurve(aCurS2Bounds[3], 0, aDelta); | |
2418 | } | |
2419 | } | |
2420 | ||
7a91ad6e | 2421 | const Standard_Real anIntTol = 10.0*Precision::Confusion(); |
d4b867e6 | 2422 | |
7a91ad6e | 2423 | IntersectCurveAndBoundary(theC2d1, aCurS1Bounds, |
2424 | aNumberOfCurves, anIntTol, theArrayOfParameters); | |
d4b867e6 | 2425 | |
7a91ad6e | 2426 | IntersectCurveAndBoundary(theC2d2, aCurS2Bounds, |
2427 | aNumberOfCurves, anIntTol, theArrayOfParameters); | |
d4b867e6 | 2428 | |
2429 | std::sort(theArrayOfParameters.begin(), theArrayOfParameters.end()); | |
7fd59977 | 2430 | } |