Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1992-05-07 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1992-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 | |
e2e0498b | 17 | #include <IntPatch_ImpPrmIntersection.hxx> |
7fd59977 | 18 | |
42cf5bc1 | 19 | #include <Adaptor3d_HSurface.hxx> |
20 | #include <Adaptor3d_TopolTool.hxx> | |
e2e0498b | 21 | #include <ElCLib.hxx> |
3306fdd9 | 22 | #include <ElSLib.hxx> |
42cf5bc1 | 23 | #include <IntPatch_ArcFunction.hxx> |
e2e0498b | 24 | #include <IntPatch_PointLine.hxx> |
42cf5bc1 | 25 | #include <IntPatch_RLine.hxx> |
26 | #include <IntPatch_RstInt.hxx> | |
e2e0498b | 27 | #include <IntPatch_SpecialPoints.hxx> |
7fd59977 | 28 | #include <IntPatch_TheIWLineOfTheIWalking.hxx> |
e2e0498b | 29 | #include <IntPatch_TheIWalking.hxx> |
7fd59977 | 30 | #include <IntPatch_TheSurfFunction.hxx> |
7fd59977 | 31 | #include <IntPatch_WLine.hxx> |
42cf5bc1 | 32 | #include <IntSurf.hxx> |
e2e0498b | 33 | #include <IntSurf_Quadric.hxx> |
34 | #include <IntSurf_QuadricTool.hxx> | |
42cf5bc1 | 35 | #include <IntSurf_SequenceOfPathPoint.hxx> |
e2e0498b | 36 | #include <TopAbs_Orientation.hxx> |
37 | #include <TopTrans_CurveTransition.hxx> | |
38 | #include <math_Matrix.hxx> | |
39 | #include <math_Vector.hxx> | |
42cf5bc1 | 40 | |
0797d9d3 | 41 | #ifndef OCCT_DEBUG |
191478a5 | 42 | #define No_Standard_RangeError |
43 | #define No_Standard_OutOfRange | |
44 | #endif | |
45 | ||
77dbd1f1 | 46 | static Standard_Boolean DecomposeResult(const Handle(IntPatch_PointLine)& theLine, |
4e14c88f | 47 | const Standard_Boolean IsReversed, |
48 | const IntSurf_Quadric& theQuad, | |
49 | const Handle(Adaptor3d_TopolTool)& thePDomain, | |
50 | const Handle(Adaptor3d_HSurface)& theQSurf, | |
51 | const Handle(Adaptor3d_HSurface)& theOtherSurf, | |
52 | const Standard_Real theArcTol, | |
a09c8f3a | 53 | const Standard_Real theTolTang, |
4e14c88f | 54 | IntPatch_SequenceOfLine& theLines); |
191478a5 | 55 | static |
56 | void ComputeTangency (const IntPatch_TheSOnBounds& solrst, | |
57 | IntSurf_SequenceOfPathPoint& seqpdep, | |
58 | const Handle(Adaptor3d_TopolTool)& Domain, | |
59 | IntPatch_TheSurfFunction& Func, | |
60 | const Handle(Adaptor3d_HSurface)& PSurf, | |
61 | TColStd_Array1OfInteger& Destination); | |
62 | static | |
63 | void Recadre(const Standard_Boolean , | |
64 | GeomAbs_SurfaceType typeS1, | |
65 | GeomAbs_SurfaceType typeS2, | |
66 | IntPatch_Point& pt, | |
67 | const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline, | |
68 | Standard_Integer Param, | |
69 | Standard_Real U1, | |
70 | Standard_Real V1, | |
71 | Standard_Real U2, | |
72 | Standard_Real V2); | |
7fd59977 | 73 | |
77dbd1f1 | 74 | static |
75 | Standard_Boolean IsCoincide(IntPatch_TheSurfFunction& theFunc, | |
76 | const Handle(IntPatch_PointLine)& theLine, | |
77 | const Handle(Adaptor2d_HCurve2d)& theArc, | |
78 | const Standard_Boolean isTheSurface1Using, | |
79 | const Standard_Real theToler3D, | |
80 | const Standard_Real theToler2D, | |
81 | const Standard_Real thePeriod); | |
d4b867e6 | 82 | |
e2e0498b | 83 | //======================================================================= |
84 | //function : IsSeamOrPole | |
85 | //purpose : | |
86 | //======================================================================= | |
87 | static IntPatch_SpecPntType IsSeamOrPole(const Handle(Adaptor3d_HSurface)& theQSurf, | |
88 | const Handle(IntSurf_LineOn2S)& theLine, | |
89 | const Standard_Boolean IsReversed, | |
90 | const Standard_Integer theRefIndex, | |
3306fdd9 | 91 | const Standard_Real theTol3D, |
e2e0498b | 92 | const Standard_Real theDeltaMax) |
a09c8f3a | 93 | { |
94 | if((theRefIndex < 1) || (theRefIndex >= theLine->NbPoints())) | |
e2e0498b | 95 | return IntPatch_SPntNone; |
a09c8f3a | 96 | |
97 | //Parameters on Quadric and on parametric for reference point | |
98 | Standard_Real aUQRef, aVQRef, aUPRef, aVPRef; | |
99 | Standard_Real aUQNext, aVQNext, aUPNext, aVPNext; | |
100 | ||
3306fdd9 | 101 | const gp_Pnt &aP3d = theLine->Value(theRefIndex + 1).Value(); |
102 | ||
a09c8f3a | 103 | if(IsReversed) |
104 | { | |
105 | theLine->Value(theRefIndex).Parameters (aUPRef, aVPRef, aUQRef, aVQRef); | |
106 | theLine->Value(theRefIndex+1).Parameters(aUPNext, aVPNext, aUQNext, aVQNext); | |
107 | } | |
108 | else | |
109 | { | |
110 | theLine->Value(theRefIndex).Parameters (aUQRef, aVQRef, aUPRef, aVPRef); | |
111 | theLine->Value(theRefIndex+1).Parameters(aUQNext, aVQNext, aUPNext, aVPNext); | |
112 | } | |
113 | ||
114 | const GeomAbs_SurfaceType aType = theQSurf->GetType(); | |
115 | ||
3306fdd9 | 116 | if ((aType == GeomAbs_Cone) && |
117 | (theQSurf->Cone().Apex().SquareDistance(aP3d) < theTol3D*theTol3D)) | |
118 | { | |
119 | return IntPatch_SPntPoleSeamU; | |
120 | } | |
121 | else if (aType == GeomAbs_Sphere) | |
122 | { | |
123 | const Standard_Real aSqTol = theTol3D*theTol3D; | |
124 | gp_Pnt aP(ElSLib::Value(0.0, M_PI_2, theQSurf->Sphere())); | |
125 | if (aP.SquareDistance(aP3d) < aSqTol) | |
126 | { | |
127 | return IntPatch_SPntPoleSeamU; | |
128 | } | |
129 | ||
130 | aP = ElSLib::Value(0.0, -M_PI_2, theQSurf->Sphere()); | |
131 | if (aP.SquareDistance(aP3d) < aSqTol) | |
132 | { | |
133 | return IntPatch_SPntPoleSeamU; | |
134 | } | |
135 | } | |
136 | ||
137 | ||
a09c8f3a | 138 | const Standard_Real aDeltaU = Abs(aUQRef - aUQNext); |
139 | ||
140 | if((aType != GeomAbs_Torus) && (aDeltaU < theDeltaMax)) | |
e2e0498b | 141 | return IntPatch_SPntNone; |
a09c8f3a | 142 | |
143 | switch(aType) | |
144 | { | |
145 | case GeomAbs_Cylinder: | |
e2e0498b | 146 | return IntPatch_SPntSeamU; |
a09c8f3a | 147 | |
148 | case GeomAbs_Torus: | |
149 | { | |
150 | const Standard_Real aDeltaV = Abs(aVQRef - aVQNext); | |
151 | ||
152 | if((aDeltaU >= theDeltaMax) && (aDeltaV >= theDeltaMax)) | |
e2e0498b | 153 | return IntPatch_SPntSeamUV; |
a09c8f3a | 154 | |
155 | if(aDeltaU >= theDeltaMax) | |
e2e0498b | 156 | return IntPatch_SPntSeamU; |
a09c8f3a | 157 | |
158 | if(aDeltaV >= theDeltaMax) | |
e2e0498b | 159 | return IntPatch_SPntSeamV; |
a09c8f3a | 160 | } |
161 | ||
162 | break; | |
163 | case GeomAbs_Sphere: | |
164 | case GeomAbs_Cone: | |
e2e0498b | 165 | return IntPatch_SPntPoleSeamU; |
a09c8f3a | 166 | default: |
167 | break; | |
168 | } | |
169 | ||
e2e0498b | 170 | return IntPatch_SPntNone; |
a09c8f3a | 171 | } |
172 | ||
7fd59977 | 173 | //======================================================================= |
174 | //function : IntPatch_ImpPrmIntersection | |
175 | //purpose : | |
176 | //======================================================================= | |
7fd59977 | 177 | IntPatch_ImpPrmIntersection::IntPatch_ImpPrmIntersection () |
191478a5 | 178 | : done(Standard_False), |
179 | empt(Standard_False), | |
180 | myIsStartPnt(Standard_False), | |
181 | myUStart(0.0), | |
182 | myVStart(0.0) | |
7fd59977 | 183 | { } |
184 | ||
185 | ||
186 | //======================================================================= | |
187 | //function : IntPatch_ImpPrmIntersection | |
188 | //purpose : | |
189 | //======================================================================= | |
190 | ||
191 | IntPatch_ImpPrmIntersection::IntPatch_ImpPrmIntersection | |
191478a5 | 192 | (const Handle(Adaptor3d_HSurface)& Surf1, |
193 | const Handle(Adaptor3d_TopolTool)& D1, | |
194 | const Handle(Adaptor3d_HSurface)& Surf2, | |
195 | const Handle(Adaptor3d_TopolTool)& D2, | |
196 | const Standard_Real TolArc, | |
197 | const Standard_Real TolTang, | |
198 | const Standard_Real Fleche, | |
199 | const Standard_Real Pas) | |
200 | : done(Standard_False), | |
201 | empt(Standard_False), | |
202 | myIsStartPnt(Standard_False), | |
203 | myUStart(0.0), | |
204 | myVStart(0.0) | |
7fd59977 | 205 | { |
206 | Perform(Surf1,D1,Surf2,D2,TolArc,TolTang,Fleche,Pas); | |
207 | } | |
208 | ||
209 | ||
210 | //======================================================================= | |
211 | //function : SetStartPoint | |
212 | //purpose : | |
213 | //======================================================================= | |
214 | ||
215 | void IntPatch_ImpPrmIntersection::SetStartPoint(const Standard_Real U, | |
191478a5 | 216 | const Standard_Real V) |
7fd59977 | 217 | { |
218 | myIsStartPnt = Standard_True; | |
219 | myUStart = U; myVStart = V; | |
220 | } | |
221 | ||
7fd59977 | 222 | //======================================================================= |
223 | //function : ComputeTangency | |
224 | //purpose : | |
225 | //======================================================================= | |
226 | void ComputeTangency (const IntPatch_TheSOnBounds& solrst, | |
191478a5 | 227 | IntSurf_SequenceOfPathPoint& seqpdep, |
228 | const Handle(Adaptor3d_TopolTool)& Domain, | |
229 | IntPatch_TheSurfFunction& Func, | |
230 | const Handle(Adaptor3d_HSurface)& PSurf, | |
231 | TColStd_Array1OfInteger& Destination) | |
7fd59977 | 232 | { |
233 | Standard_Integer i,k, NbPoints, seqlength; | |
234 | Standard_Real theparam,test; | |
235 | Standard_Boolean fairpt, ispassing; | |
236 | TopAbs_Orientation arcorien,vtxorien; | |
237 | Handle(Adaptor2d_HCurve2d) thearc; | |
238 | Handle(Adaptor3d_HVertex) vtx,vtxbis; | |
239 | //Standard_Boolean ispassing; | |
240 | IntPatch_ThePathPointOfTheSOnBounds PStart; | |
241 | IntSurf_PathPoint PPoint; | |
242 | gp_Vec vectg; | |
243 | gp_Dir2d dirtg; | |
244 | gp_Pnt ptbid; | |
245 | gp_Vec d1u,d1v,v1,v2; | |
246 | gp_Pnt2d p2d; | |
247 | gp_Vec2d d2d; | |
248 | // | |
1ef32e96 RL |
249 | double aX[2], aF[1], aD[1][2]; |
250 | math_Vector X(aX, 1, 2); | |
251 | math_Vector F(aF, 1, 1); | |
252 | math_Matrix D(aD, 1, 1, 1, 2); | |
7fd59977 | 253 | // |
254 | seqlength = 0; | |
255 | NbPoints = solrst.NbPoints(); | |
256 | for (i=1; i<= NbPoints; i++) { | |
257 | if (Destination(i) == 0) { | |
258 | PStart = solrst.Point(i); | |
259 | thearc = PStart.Arc(); | |
260 | theparam = PStart.Parameter(); | |
261 | arcorien = Domain->Orientation(thearc); | |
262 | ispassing = (arcorien == TopAbs_INTERNAL || | |
191478a5 | 263 | arcorien == TopAbs_EXTERNAL); |
264 | ||
7fd59977 | 265 | thearc->D0(theparam,p2d); |
266 | X(1) = p2d.X(); | |
267 | X(2) = p2d.Y(); | |
268 | PPoint.SetValue(PStart.Value(),X(1),X(2)); | |
191478a5 | 269 | |
7fd59977 | 270 | Func.Values(X,F,D); |
271 | if (Func.IsTangent()) { | |
191478a5 | 272 | PPoint.SetTangency(Standard_True); |
7fd59977 | 273 | Destination(i) = seqlength+1; |
191478a5 | 274 | if (!PStart.IsNew()) { |
275 | vtx = PStart.Vertex(); | |
276 | for (k=i+1; k<=NbPoints; k++) { | |
277 | if (Destination(k) ==0) { | |
278 | PStart = solrst.Point(k); | |
279 | if (!PStart.IsNew()) { | |
280 | vtxbis = PStart.Vertex(); | |
281 | if (Domain->Identical(vtx,vtxbis)) { | |
282 | thearc = PStart.Arc(); | |
283 | theparam = PStart.Parameter(); | |
284 | arcorien = Domain->Orientation(thearc); | |
285 | ispassing = ispassing && (arcorien == TopAbs_INTERNAL || | |
286 | arcorien == TopAbs_EXTERNAL); | |
287 | ||
288 | thearc->D0(theparam,p2d); | |
289 | PPoint.AddUV(p2d.X(),p2d.Y()); | |
290 | Destination(k) = seqlength+1; | |
291 | } | |
292 | } | |
293 | } | |
294 | } | |
295 | } | |
296 | PPoint.SetPassing(ispassing); | |
297 | seqpdep.Append(PPoint); | |
298 | seqlength++; | |
7fd59977 | 299 | } |
300 | else { // on a un point de depart potentiel | |
301 | ||
191478a5 | 302 | vectg = Func.Direction3d(); |
303 | dirtg = Func.Direction2d(); | |
304 | ||
305 | PSurf->D1(X(1),X(2),ptbid,d1u,d1v); | |
306 | thearc->D1(theparam,p2d,d2d); | |
307 | v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); | |
308 | v1 = d1u.Crossed(d1v); | |
309 | ||
310 | test = vectg.Dot(v1.Crossed(v2)); | |
311 | if (PStart.IsNew()) { | |
312 | if ((test < 0. && arcorien == TopAbs_FORWARD) || | |
313 | (test > 0. && arcorien == TopAbs_REVERSED)) { | |
314 | vectg.Reverse(); | |
315 | dirtg.Reverse(); | |
316 | } | |
317 | PPoint.SetDirections(vectg,dirtg); | |
318 | PPoint.SetPassing(ispassing); | |
7fd59977 | 319 | Destination(i) = seqlength+1; |
191478a5 | 320 | seqpdep.Append(PPoint); |
321 | seqlength++; | |
322 | } | |
323 | else { // traiter la transition complexe | |
324 | gp_Dir bidnorm(1.,1.,1.); | |
325 | Standard_Real tole = 1.e-8; | |
326 | TopAbs_Orientation LocTrans; | |
327 | TopTrans_CurveTransition comptrans; | |
328 | comptrans.Reset(vectg,bidnorm,0.); | |
329 | if (arcorien == TopAbs_FORWARD || | |
330 | arcorien == TopAbs_REVERSED) { | |
331 | // pour essai | |
332 | ||
333 | vtx = PStart.Vertex(); | |
334 | vtxorien = Domain->Orientation(vtx); | |
335 | if (Abs(test) <= tole) { | |
336 | LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL | |
337 | } | |
338 | else { | |
339 | if (((test > 0.)&& arcorien == TopAbs_FORWARD) || | |
340 | ((test < 0.)&& arcorien == TopAbs_REVERSED)){ | |
341 | LocTrans = TopAbs_FORWARD; | |
342 | } | |
343 | else { | |
344 | LocTrans = TopAbs_REVERSED; | |
345 | } | |
346 | if (arcorien == TopAbs_REVERSED) {v2.Reverse();} | |
347 | } | |
348 | ||
349 | comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien); | |
350 | } | |
7fd59977 | 351 | Destination(i) = seqlength+1; |
191478a5 | 352 | for (k= i+1; k<=NbPoints; k++) { |
353 | if (Destination(k) == 0) { | |
354 | PStart = solrst.Point(k); | |
355 | if (!PStart.IsNew()) { | |
356 | vtxbis = PStart.Vertex(); | |
357 | if (Domain->Identical(vtx,vtxbis)) { | |
358 | thearc = PStart.Arc(); | |
359 | theparam = PStart.Parameter(); | |
360 | arcorien = Domain->Orientation(thearc); | |
361 | ||
362 | PPoint.AddUV(X(1),X(2)); | |
363 | ||
364 | thearc->D1(theparam,p2d,d2d); | |
365 | PPoint.AddUV(p2d.X(),p2d.Y()); | |
366 | ||
367 | if (arcorien == TopAbs_FORWARD || | |
368 | arcorien == TopAbs_REVERSED) { | |
369 | ispassing = Standard_False; | |
370 | v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); | |
371 | ||
372 | test = vectg.Dot(v1.Crossed(v2)); | |
373 | vtxorien = Domain->Orientation(PStart.Vertex()); | |
374 | if (Abs(test) <= tole) { | |
375 | LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL | |
376 | } | |
377 | else { | |
378 | if (((test > 0.)&& arcorien == TopAbs_FORWARD) || | |
379 | ((test < 0.)&& arcorien == TopAbs_REVERSED)){ | |
380 | LocTrans = TopAbs_FORWARD; | |
381 | } | |
382 | else { | |
383 | LocTrans = TopAbs_REVERSED; | |
384 | } | |
385 | if (arcorien == TopAbs_REVERSED) {v2.Reverse();} | |
386 | } | |
387 | ||
388 | comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien); | |
389 | } | |
390 | Destination(k) = seqlength+1; | |
391 | } | |
392 | } | |
393 | } | |
394 | } | |
7fd59977 | 395 | fairpt = Standard_True; |
191478a5 | 396 | if (!ispassing) { |
397 | TopAbs_State Before = comptrans.StateBefore(); | |
398 | TopAbs_State After = comptrans.StateAfter(); | |
399 | if ((Before == TopAbs_UNKNOWN)||(After == TopAbs_UNKNOWN)) { | |
400 | fairpt = Standard_False; | |
401 | } | |
402 | else if (Before == TopAbs_IN) { | |
403 | if (After == TopAbs_IN) { | |
404 | ispassing = Standard_True; | |
405 | } | |
406 | else { | |
407 | vectg.Reverse(); | |
408 | dirtg.Reverse(); | |
409 | } | |
410 | } | |
411 | else { | |
412 | if (After !=TopAbs_IN) { | |
413 | fairpt = Standard_False; | |
414 | } | |
415 | } | |
416 | } | |
417 | if (fairpt) { | |
418 | PPoint.SetDirections(vectg,dirtg); | |
419 | PPoint.SetPassing(ispassing); | |
420 | seqpdep.Append(PPoint); | |
421 | seqlength++; | |
422 | } | |
423 | else { // il faut remettre en "ordre" si on ne garde pas le point. | |
424 | for (k=i; k <=NbPoints ; k++) { | |
425 | if (Destination(k)==seqlength + 1) { | |
426 | Destination(k) = -Destination(k); | |
427 | } | |
428 | } | |
429 | } | |
430 | } | |
7fd59977 | 431 | } |
432 | } | |
433 | } | |
434 | } | |
435 | //======================================================================= | |
436 | //function : Recadre | |
437 | //purpose : | |
438 | //======================================================================= | |
439 | void Recadre(const Standard_Boolean , | |
191478a5 | 440 | GeomAbs_SurfaceType typeS1, |
441 | GeomAbs_SurfaceType typeS2, | |
442 | IntPatch_Point& pt, | |
443 | const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline, | |
444 | Standard_Integer Param, | |
445 | Standard_Real U1, | |
446 | Standard_Real V1, | |
447 | Standard_Real U2, | |
448 | Standard_Real V2) | |
7fd59977 | 449 | { |
450 | Standard_Real U1p,V1p,U2p,V2p; | |
451 | iwline->Line()->Value(Param).Parameters(U1p,V1p,U2p,V2p); | |
452 | switch(typeS1) | |
453 | { | |
191478a5 | 454 | case GeomAbs_Torus: |
455 | while(V1<(V1p-1.5*M_PI)) V1+=M_PI+M_PI; | |
456 | while(V1>(V1p+1.5*M_PI)) V1-=M_PI+M_PI; | |
b1811c1d | 457 | Standard_FALLTHROUGH |
191478a5 | 458 | case GeomAbs_Cylinder: |
459 | case GeomAbs_Cone: | |
460 | case GeomAbs_Sphere: | |
461 | while(U1<(U1p-1.5*M_PI)) U1+=M_PI+M_PI; | |
462 | while(U1>(U1p+1.5*M_PI)) U1-=M_PI+M_PI; | |
463 | default: | |
464 | break; | |
7fd59977 | 465 | } |
466 | switch(typeS2) | |
467 | { | |
191478a5 | 468 | case GeomAbs_Torus: |
469 | while(V2<(V2p-1.5*M_PI)) V2+=M_PI+M_PI; | |
470 | while(V2>(V2p+1.5*M_PI)) V2-=M_PI+M_PI; | |
b1811c1d | 471 | Standard_FALLTHROUGH |
191478a5 | 472 | case GeomAbs_Cylinder: |
473 | case GeomAbs_Cone: | |
474 | case GeomAbs_Sphere: | |
475 | while(U2<(U2p-1.5*M_PI)) U2+=M_PI+M_PI; | |
476 | while(U2>(U2p+1.5*M_PI)) U2-=M_PI+M_PI; | |
477 | default: | |
478 | break; | |
7fd59977 | 479 | } |
480 | pt.SetParameters(U1,V1,U2,V2); | |
481 | } | |
482 | ||
483 | //======================================================================= | |
484 | //function : Perform | |
485 | //purpose : | |
486 | //======================================================================= | |
487 | void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
191478a5 | 488 | const Handle(Adaptor3d_TopolTool)& D1, |
489 | const Handle(Adaptor3d_HSurface)& Surf2, | |
490 | const Handle(Adaptor3d_TopolTool)& D2, | |
491 | const Standard_Real TolArc, | |
492 | const Standard_Real TolTang, | |
493 | const Standard_Real Fleche, | |
494 | const Standard_Real Pas) | |
7fd59977 | 495 | { |
496 | Standard_Boolean reversed, procf, procl, dofirst, dolast; | |
d4b867e6 | 497 | Standard_Integer indfirst = 0, indlast = 0, ind2, NbSegm; |
7fd59977 | 498 | Standard_Integer NbPointIns, NbPointRst, Nblines, Nbpts, NbPointDep; |
499 | Standard_Real U1,V1,U2,V2,paramf,paraml,currentparam; | |
191478a5 | 500 | |
7fd59977 | 501 | IntPatch_TheSegmentOfTheSOnBounds thesegm; |
502 | IntSurf_PathPoint PPoint; | |
503 | ||
504 | Handle(IntPatch_RLine) rline; | |
505 | Handle(IntPatch_WLine) wline; | |
506 | IntPatch_ThePathPointOfTheSOnBounds PStart,PStartf,PStartl; | |
507 | IntPatch_Point ptdeb,ptfin,ptbis; | |
191478a5 | 508 | |
7fd59977 | 509 | IntPatch_IType typ; |
510 | IntSurf_Transition TLine,TArc; | |
511 | IntSurf_TypeTrans trans1,trans2; | |
512 | gp_Pnt valpt,ptbid; | |
513 | gp_Vec tgline,tgrst,norm1,norm2,d1u,d1v; | |
514 | gp_Dir DirNormale; | |
515 | gp_Vec VecNormale; | |
191478a5 | 516 | |
7fd59977 | 517 | gp_Pnt2d p2d; |
518 | gp_Vec2d d2d; | |
191478a5 | 519 | |
7fd59977 | 520 | Handle(Adaptor2d_HCurve2d) currentarc; |
521 | GeomAbs_SurfaceType typeS1, typeS2; | |
522 | IntSurf_Quadric Quad; | |
523 | IntPatch_TheSurfFunction Func; | |
524 | IntPatch_ArcFunction AFunc; | |
525 | // | |
526 | typeS1 = Surf1->GetType(); | |
527 | typeS2 = Surf2->GetType(); | |
191478a5 | 528 | |
7fd59977 | 529 | paramf =0.; |
530 | paraml =0.; | |
531 | trans1 = IntSurf_Undecided; | |
532 | trans2 = IntSurf_Undecided; | |
533 | // | |
534 | done = Standard_False; | |
535 | empt = Standard_True; | |
536 | slin.Clear(); | |
537 | spnt.Clear(); | |
538 | // | |
539 | reversed = Standard_False; | |
191478a5 | 540 | switch (typeS1) |
541 | { | |
542 | case GeomAbs_Plane: | |
543 | Quad.SetValue(Surf1->Plane()); | |
544 | break; | |
7fd59977 | 545 | |
191478a5 | 546 | case GeomAbs_Cylinder: |
547 | Quad.SetValue(Surf1->Cylinder()); | |
548 | break; | |
7fd59977 | 549 | |
191478a5 | 550 | case GeomAbs_Sphere: |
551 | Quad.SetValue(Surf1->Sphere()); | |
552 | break; | |
7fd59977 | 553 | |
191478a5 | 554 | case GeomAbs_Cone: |
555 | Quad.SetValue(Surf1->Cone()); | |
556 | break; | |
7fd59977 | 557 | |
191478a5 | 558 | default: |
559 | { | |
7fd59977 | 560 | reversed = Standard_True; |
191478a5 | 561 | switch (typeS2) |
562 | { | |
563 | case GeomAbs_Plane: | |
564 | Quad.SetValue(Surf2->Plane()); | |
565 | break; | |
566 | ||
567 | case GeomAbs_Cylinder: | |
568 | Quad.SetValue(Surf2->Cylinder()); | |
569 | break; | |
570 | ||
571 | case GeomAbs_Sphere: | |
572 | Quad.SetValue(Surf2->Sphere()); | |
573 | break; | |
574 | ||
575 | case GeomAbs_Cone: | |
576 | Quad.SetValue(Surf2->Cone()); | |
577 | break; | |
578 | default: | |
579 | { | |
9775fa61 | 580 | throw Standard_ConstructionError(); |
191478a5 | 581 | break; |
582 | } | |
7fd59977 | 583 | } |
584 | } | |
585 | break; | |
586 | } | |
587 | // | |
588 | Func.SetImplicitSurface(Quad); | |
589 | Func.Set(IntSurf_QuadricTool::Tolerance(Quad)); | |
590 | AFunc.SetQuadric(Quad); | |
591 | // | |
592 | if (!reversed) { | |
593 | Func.Set(Surf2); | |
594 | AFunc.Set(Surf2); | |
595 | } | |
596 | else { | |
597 | Func.Set(Surf1); | |
598 | AFunc.Set(Surf1); | |
599 | } | |
600 | // | |
601 | if (!reversed) { | |
602 | solrst.Perform(AFunc,D2,TolArc,TolTang); | |
603 | } | |
604 | else { | |
605 | solrst.Perform(AFunc,D1,TolArc,TolTang); | |
606 | } | |
607 | if (!solrst.IsDone()) { | |
608 | return; | |
609 | } | |
610 | // | |
611 | IntSurf_SequenceOfPathPoint seqpdep; | |
612 | IntSurf_SequenceOfInteriorPoint seqpins; | |
613 | // | |
614 | NbPointRst = solrst.NbPoints(); | |
615 | TColStd_Array1OfInteger Destination(1,NbPointRst+1); Destination.Init(0); | |
616 | if (NbPointRst) { | |
617 | if (!reversed) { | |
618 | ComputeTangency(solrst,seqpdep,D2,Func,Surf2,Destination); | |
619 | } | |
620 | else { | |
621 | ComputeTangency(solrst,seqpdep,D1,Func,Surf1,Destination); | |
622 | } | |
623 | } | |
624 | // | |
e618b526 | 625 | Standard_Boolean SearchIns = Standard_True; |
626 | if(Quad.TypeQuadric() == GeomAbs_Plane && solrst.NbSegments() > 0) | |
627 | { | |
628 | //For such kind of cases it is possible that whole surface is on one side of plane, | |
629 | //plane only touches surface and does not cross it, | |
630 | //so no inner points exist. | |
631 | SearchIns = Standard_False; | |
632 | Handle(Adaptor3d_TopolTool) T; | |
633 | if(reversed) | |
634 | { | |
635 | T = D1; | |
636 | } | |
7fd59977 | 637 | else |
e618b526 | 638 | { |
639 | T = D2; | |
640 | } | |
641 | Standard_Integer aNbSamples = 0; | |
642 | aNbSamples = T->NbSamples(); | |
643 | gp_Pnt2d s2d; | |
644 | gp_Pnt s3d; | |
645 | Standard_Real aValf[1], aUVap[2]; | |
646 | math_Vector Valf(aValf,1,1), UVap(aUVap,1,2); | |
647 | T->SamplePoint(1,s2d, s3d); | |
648 | UVap(1)=s2d.X(); | |
649 | UVap(2)=s2d.Y(); | |
650 | Func.Value(UVap,Valf); | |
651 | Standard_Real rvalf = Sign(1.,Valf(1)); | |
d4b867e6 | 652 | for(Standard_Integer i = 2; i <= aNbSamples; ++i) |
e618b526 | 653 | { |
94f71cad | 654 | T->SamplePoint(i,s2d, s3d); |
e618b526 | 655 | UVap(1)=s2d.X(); |
656 | UVap(2)=s2d.Y(); | |
657 | Func.Value(UVap,Valf); | |
658 | if(rvalf * Valf(1) < 0.) | |
659 | { | |
660 | SearchIns = Standard_True; | |
661 | break; | |
662 | } | |
663 | } | |
7fd59977 | 664 | } |
e618b526 | 665 | // Recherche des points interieurs |
666 | NbPointIns = 0; | |
667 | if(SearchIns) { | |
668 | if (!reversed) { | |
669 | if (myIsStartPnt) | |
670 | solins.Perform(Func,Surf2,myUStart,myVStart); | |
671 | else | |
672 | solins.Perform(Func,Surf2,D2,TolTang); | |
673 | } | |
674 | else { | |
675 | if (myIsStartPnt) | |
676 | solins.Perform(Func,Surf1,myUStart,myVStart); | |
677 | else | |
678 | solins.Perform(Func,Surf1,D1,TolTang); | |
679 | } | |
680 | NbPointIns = solins.NbPoints(); | |
d4b867e6 | 681 | for (Standard_Integer i=1; i <= NbPointIns; i++) { |
e618b526 | 682 | seqpins.Append(solins.Value(i)); |
683 | } | |
7fd59977 | 684 | } |
685 | // | |
7fd59977 | 686 | NbPointDep=seqpdep.Length(); |
687 | // | |
688 | if (NbPointDep || NbPointIns) { | |
92a55b01 | 689 | IntPatch_TheIWalking iwalk(TolTang, Fleche, Pas); |
690 | iwalk.Perform(seqpdep, seqpins, Func, reversed ? Surf1 : Surf2, reversed); | |
691 | ||
7fd59977 | 692 | if(!iwalk.IsDone()) { |
693 | return; | |
694 | } | |
191478a5 | 695 | |
7fd59977 | 696 | Standard_Real Vmin, Vmax, TolV = 1.e-14; |
697 | if (!reversed) { //Surf1 is quadric | |
698 | Vmin = Surf1->FirstVParameter(); | |
699 | Vmax = Surf1->LastVParameter(); | |
700 | } | |
701 | else { //Surf2 is quadric | |
702 | Vmin = Surf2->FirstVParameter(); | |
703 | Vmax = Surf2->LastVParameter(); | |
704 | } | |
705 | // | |
706 | Nblines = iwalk.NbLines(); | |
d4b867e6 | 707 | for (Standard_Integer j=1; j<=Nblines; j++) { |
7fd59977 | 708 | const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline = iwalk.Value(j); |
709 | const Handle(IntSurf_LineOn2S)& thelin = iwline->Line(); | |
191478a5 | 710 | |
7fd59977 | 711 | Nbpts = thelin->NbPoints(); |
712 | if(Nbpts>=2) { | |
d4b867e6 | 713 | Standard_Integer k = 0; |
191478a5 | 714 | tgline = iwline->TangentVector(k); |
715 | if(k>=1 && k<=Nbpts) { } else { k=Nbpts>>1; } | |
716 | valpt = thelin->Value(k).Value(); | |
717 | ||
718 | if (!reversed) { | |
719 | thelin->Value(k).ParametersOnS2(U2,V2); | |
720 | norm1 = Quad.Normale(valpt); | |
721 | Surf2->D1(U2,V2,ptbid,d1u,d1v); | |
722 | norm2 = d1u.Crossed(d1v); | |
723 | } | |
724 | else { | |
725 | thelin->Value(k).ParametersOnS1(U2,V2); | |
726 | norm2 = Quad.Normale(valpt); | |
727 | Surf1->D1(U2,V2,ptbid,d1u,d1v); | |
728 | norm1 = d1u.Crossed(d1v); | |
729 | } | |
730 | if (tgline.DotCross(norm2,norm1) > 0.) { | |
731 | trans1 = IntSurf_Out; | |
732 | trans2 = IntSurf_In; | |
733 | } | |
734 | else { | |
735 | trans1 = IntSurf_In; | |
736 | trans2 = IntSurf_Out; | |
737 | } | |
738 | ||
739 | // | |
740 | Standard_Real AnU1,AnU2,AnV2; | |
741 | ||
742 | GeomAbs_SurfaceType typQuad = Quad.TypeQuadric(); | |
743 | Standard_Boolean arecadr=Standard_False; | |
744 | valpt = thelin->Value(1).Value(); | |
745 | Quad.Parameters(valpt,AnU1,V1); | |
746 | ||
747 | if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin; | |
748 | if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax; | |
749 | ||
750 | if(reversed) { | |
751 | thelin->SetUV(1,Standard_False,AnU1,V1); //-- on va lire u2,v2 | |
752 | thelin->Value(1).ParametersOnS1(AnU2,AnV2); | |
753 | } | |
754 | else { | |
755 | thelin->SetUV(1,Standard_True,AnU1,V1); //-- on va lire u1,v1 | |
756 | thelin->Value(1).ParametersOnS2(AnU2,AnV2); | |
757 | } | |
758 | ||
759 | if(typQuad==GeomAbs_Cylinder || | |
760 | typQuad==GeomAbs_Cone || | |
761 | typQuad==GeomAbs_Sphere) { | |
762 | arecadr=Standard_True; | |
763 | } | |
764 | // | |
765 | for (k=2; k<=Nbpts; ++k) { | |
766 | valpt = thelin->Value(k).Value(); | |
767 | Quad.Parameters(valpt,U1,V1); | |
768 | // | |
769 | if((V1 < Vmin) && (Vmin-V1 < TolV)) { | |
770 | V1 = Vmin; | |
771 | } | |
772 | if((V1 > Vmax) && (V1-Vmax < TolV)) { | |
773 | V1 = Vmax; | |
774 | } | |
775 | // | |
776 | if(arecadr) { | |
777 | //modified by NIZNHY-PKV Fri Mar 28 15:06:01 2008f | |
778 | Standard_Real aCf, aTwoPI; | |
779 | // | |
780 | aCf=0.; | |
781 | aTwoPI=M_PI+M_PI; | |
782 | if ((U1-AnU1) > 1.5*M_PI) { | |
783 | while ((U1-AnU1) > (1.5*M_PI+aCf*aTwoPI)) { | |
784 | aCf=aCf+1.; | |
785 | } | |
786 | U1=U1-aCf*aTwoPI; | |
787 | } | |
788 | // | |
789 | else { | |
790 | while ((U1-AnU1) < (-1.5*M_PI-aCf*aTwoPI)) { | |
791 | aCf=aCf+1.; | |
792 | } | |
793 | U1=U1+aCf*aTwoPI; | |
794 | } | |
795 | // was: | |
796 | //if ((U1-AnU1) > 1.5*M_PI) { | |
797 | // U1-=M_PI+M_PI; | |
798 | //} | |
799 | //else if ((U1-AnU1) < -1.5*M_PI) { | |
800 | // U1+=M_PI+M_PI; | |
801 | //} | |
802 | //modified by NIZNHY-PKV Fri Mar 28 15:06:11 2008t | |
803 | } | |
804 | // | |
805 | if(reversed) { | |
806 | thelin->SetUV(k,Standard_False,U1,V1); | |
807 | ||
808 | thelin->Value(k).ParametersOnS1(U2,V2); | |
809 | switch(typeS1) { | |
810 | case GeomAbs_Cylinder: | |
811 | case GeomAbs_Cone: | |
812 | case GeomAbs_Sphere: | |
813 | case GeomAbs_Torus: | |
814 | while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI; | |
815 | while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI; | |
816 | break; | |
817 | default: | |
818 | break; | |
819 | } | |
820 | if(typeS2==GeomAbs_Torus) { | |
821 | while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI; | |
822 | while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI; | |
823 | } | |
824 | thelin->SetUV(k,Standard_True,U2,V2); | |
825 | } | |
826 | else { | |
827 | thelin->SetUV(k,Standard_True,U1,V1); | |
828 | ||
829 | thelin->Value(k).ParametersOnS2(U2,V2); | |
830 | switch(typeS2) { | |
831 | case GeomAbs_Cylinder: | |
832 | case GeomAbs_Cone: | |
833 | case GeomAbs_Sphere: | |
834 | case GeomAbs_Torus: | |
835 | while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI; | |
836 | while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI; | |
837 | break; | |
838 | default: | |
839 | break; | |
840 | } | |
841 | if(typeS2==GeomAbs_Torus) { | |
842 | while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI; | |
843 | while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI; | |
844 | } | |
845 | thelin->SetUV(k,Standard_False,U2,V2); | |
846 | ||
847 | } | |
848 | ||
849 | AnU1=U1; | |
850 | AnU2=U2; | |
851 | AnV2=V2; | |
852 | } | |
853 | // <-A | |
854 | wline = new IntPatch_WLine(thelin,Standard_False,trans1,trans2); | |
98974dcc | 855 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLImpPrm); |
191478a5 | 856 | |
77dbd1f1 | 857 | #ifdef INTPATCH_IMPPRMINTERSECTION_DEBUG |
858 | wline->Dump(0); | |
4e14c88f | 859 | #endif |
860 | ||
191478a5 | 861 | if ( iwline->HasFirstPoint() |
e618b526 | 862 | && iwline->IsTangentAtBegining() == Standard_False) |
863 | { | |
864 | indfirst = iwline->FirstPointIndex(); | |
865 | PPoint = seqpdep(indfirst); | |
866 | tgline = PPoint.Direction3d(); | |
867 | Standard_Integer themult = PPoint.Multiplicity(); | |
d4b867e6 | 868 | for (Standard_Integer i=NbPointRst; i>=1; i--) { |
e618b526 | 869 | if (Destination(i) == indfirst) { |
870 | if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone | |
871 | Quad.Parameters(PPoint.Value(),U1,V1); | |
872 | ||
873 | if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin; | |
874 | if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax; | |
875 | ||
876 | PPoint.Parameters(themult,U2,V2); | |
877 | Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@ | |
878 | } | |
879 | else { //-- typeS1 != Pln && Cyl && Sph && Cone | |
880 | Quad.Parameters(PPoint.Value(),U2,V2); | |
191478a5 | 881 | |
e618b526 | 882 | if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin; |
883 | if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax; | |
191478a5 | 884 | |
e618b526 | 885 | PPoint.Parameters(themult,U1,V1); |
886 | Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@ | |
887 | } | |
191478a5 | 888 | |
e618b526 | 889 | VecNormale = d1u.Crossed(d1v); |
890 | //-- Modif du 27 Septembre 94 (Recadrage des pts U,V) | |
891 | ptdeb.SetValue(PPoint.Value(),TolArc,Standard_False); | |
892 | ptdeb.SetParameters(U1,V1,U2,V2); | |
893 | ptdeb.SetParameter(1.); | |
191478a5 | 894 | |
e618b526 | 895 | Recadre(reversed,typeS1,typeS2,ptdeb,iwline,1,U1,V1,U2,V2); |
191478a5 | 896 | |
e618b526 | 897 | currentarc = solrst.Point(i).Arc(); |
898 | currentparam = solrst.Point(i).Parameter(); | |
899 | currentarc->D1(currentparam,p2d,d2d); | |
900 | tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); | |
191478a5 | 901 | |
e618b526 | 902 | Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude(); |
903 | if(squaremagnitudeVecNormale > 1e-13) { | |
904 | DirNormale=VecNormale; | |
905 | IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc); | |
906 | } | |
907 | else { | |
908 | TLine.SetValue(Standard_True,IntSurf_Undecided); | |
909 | TArc.SetValue(Standard_True,IntSurf_Undecided); | |
910 | } | |
191478a5 | 911 | |
e618b526 | 912 | ptdeb.SetArc(reversed,currentarc,currentparam,TLine,TArc); |
913 | if (!solrst.Point(i).IsNew()) { | |
914 | ptdeb.SetVertex(reversed,solrst.Point(i).Vertex()); | |
915 | } | |
916 | wline->AddVertex(ptdeb); | |
917 | if (themult == 0) { | |
918 | wline->SetFirstPoint(wline->NbVertex()); | |
191478a5 | 919 | } |
e618b526 | 920 | |
921 | themult--; | |
191478a5 | 922 | } |
e618b526 | 923 | } |
191478a5 | 924 | } |
e618b526 | 925 | else if (iwline->IsTangentAtBegining()) |
926 | { | |
191478a5 | 927 | gp_Pnt psol = thelin->Value(1).Value(); |
928 | thelin->Value(1).ParametersOnS1(U1,V1); | |
929 | thelin->Value(1).ParametersOnS2(U2,V2); | |
930 | ptdeb.SetValue(psol,TolArc,Standard_True); | |
931 | ptdeb.SetParameters(U1,V1,U2,V2); | |
932 | ptdeb.SetParameter(1.); | |
933 | wline->AddVertex(ptdeb); | |
934 | wline->SetFirstPoint(wline->NbVertex()); | |
935 | } | |
e618b526 | 936 | else |
937 | { | |
191478a5 | 938 | gp_Pnt psol = thelin->Value(1).Value(); |
939 | thelin->Value(1).ParametersOnS1(U1,V1); | |
940 | thelin->Value(1).ParametersOnS2(U2,V2); | |
941 | ptdeb.SetValue(psol,TolArc,Standard_False); | |
942 | ptdeb.SetParameters(U1,V1,U2,V2); | |
943 | ptdeb.SetParameter(1.); | |
944 | wline->AddVertex(ptdeb); | |
945 | wline->SetFirstPoint(wline->NbVertex()); | |
946 | } | |
947 | ||
948 | ||
949 | if ( iwline->HasLastPoint() | |
e618b526 | 950 | && iwline->IsTangentAtEnd() == Standard_False) |
951 | { | |
952 | indlast = iwline->LastPointIndex(); | |
953 | PPoint = seqpdep(indlast); | |
954 | tgline = PPoint.Direction3d().Reversed(); | |
955 | Standard_Integer themult = PPoint.Multiplicity(); | |
d4b867e6 | 956 | for (Standard_Integer i=NbPointRst; i >=1; i--) { |
e618b526 | 957 | if (Destination(i) == indlast) { |
958 | if (!reversed) { | |
959 | Quad.Parameters(PPoint.Value(),U1,V1); | |
960 | ||
961 | if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin; | |
962 | if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax; | |
963 | ||
964 | PPoint.Parameters(themult,U2,V2); | |
965 | Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@ | |
966 | VecNormale = d1u.Crossed(d1v); //-- @@@@ | |
967 | } | |
968 | else { | |
969 | Quad.Parameters(PPoint.Value(),U2,V2); | |
191478a5 | 970 | |
e618b526 | 971 | if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin; |
972 | if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax; | |
191478a5 | 973 | |
e618b526 | 974 | PPoint.Parameters(themult,U1,V1); |
975 | Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@ | |
976 | VecNormale = d1u.Crossed(d1v); //-- @@@@ | |
977 | } | |
191478a5 | 978 | |
e618b526 | 979 | ptfin.SetValue(PPoint.Value(),TolArc,Standard_False); |
980 | ptfin.SetParameters(U1,V1,U2,V2); | |
981 | ptfin.SetParameter(Nbpts); | |
191478a5 | 982 | |
e618b526 | 983 | Recadre(reversed,typeS1,typeS2,ptfin,iwline,Nbpts-1,U1,V1,U2,V2); |
191478a5 | 984 | |
e618b526 | 985 | currentarc = solrst.Point(i).Arc(); |
986 | currentparam = solrst.Point(i).Parameter(); | |
987 | currentarc->D1(currentparam,p2d,d2d); | |
988 | tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); | |
191478a5 | 989 | |
191478a5 | 990 | |
e618b526 | 991 | Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude(); |
992 | if(squaremagnitudeVecNormale > 1e-13) { | |
993 | DirNormale=VecNormale; | |
994 | IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc); | |
995 | } | |
996 | else { | |
997 | TLine.SetValue(Standard_True,IntSurf_Undecided); | |
998 | TArc.SetValue(Standard_True,IntSurf_Undecided); | |
999 | } | |
191478a5 | 1000 | |
191478a5 | 1001 | |
e618b526 | 1002 | ptfin.SetArc(reversed,currentarc,currentparam,TLine,TArc); |
1003 | if (!solrst.Point(i).IsNew()) { | |
1004 | ptfin.SetVertex(reversed,solrst.Point(i).Vertex()); | |
191478a5 | 1005 | } |
e618b526 | 1006 | wline->AddVertex(ptfin); |
1007 | if (themult == 0) { | |
1008 | wline->SetLastPoint(wline->NbVertex()); | |
1009 | } | |
1010 | ||
1011 | themult--; | |
191478a5 | 1012 | } |
e618b526 | 1013 | } |
191478a5 | 1014 | } |
e618b526 | 1015 | else if (iwline->IsTangentAtEnd()) |
1016 | { | |
191478a5 | 1017 | gp_Pnt psol = thelin->Value(Nbpts).Value(); |
1018 | thelin->Value(Nbpts).ParametersOnS1(U1,V1); | |
1019 | thelin->Value(Nbpts).ParametersOnS2(U2,V2); | |
1020 | ptfin.SetValue(psol,TolArc,Standard_True); | |
1021 | ptfin.SetParameters(U1,V1,U2,V2); | |
1022 | ptfin.SetParameter(Nbpts); | |
1023 | wline->AddVertex(ptfin); | |
1024 | wline->SetLastPoint(wline->NbVertex()); | |
1025 | } | |
e618b526 | 1026 | else |
1027 | { | |
191478a5 | 1028 | gp_Pnt psol = thelin->Value(Nbpts).Value(); |
1029 | thelin->Value(Nbpts).ParametersOnS1(U1,V1); | |
1030 | thelin->Value(Nbpts).ParametersOnS2(U2,V2); | |
1031 | ptfin.SetValue(psol,TolArc,Standard_False); | |
1032 | ptfin.SetParameters(U1,V1,U2,V2); | |
1033 | ptfin.SetParameter(Nbpts); | |
1034 | wline->AddVertex(ptfin); | |
1035 | wline->SetLastPoint(wline->NbVertex()); | |
1036 | } | |
1037 | // | |
1038 | // Il faut traiter les points de passage. | |
1039 | slin.Append(wline); | |
7fd59977 | 1040 | }// if(Nbpts>=2) { |
1041 | }// for (j=1; j<=Nblines; j++) { | |
1042 | ||
1043 | // ON GERE LES RACCORDS ENTRE LIGNES. ELLE NE PEUVENT SE RACCORDER | |
1044 | // QUE SUR DES POINTS DE TANGENCE | |
1045 | ||
1046 | ||
1047 | Nblines = slin.Length(); | |
d4b867e6 | 1048 | for (Standard_Integer j=1; j<=Nblines-1; j++) { |
7fd59977 | 1049 | dofirst = dolast = Standard_False; |
1050 | const Handle(IntPatch_Line)& slinj = slin(j); | |
c5f3a425 | 1051 | Handle(IntPatch_WLine) wlin1 (Handle(IntPatch_WLine)::DownCast (slinj)); |
7fd59977 | 1052 | if (wlin1->HasFirstPoint()) { |
191478a5 | 1053 | ptdeb = wlin1->FirstPoint(indfirst); |
1054 | if (ptdeb.IsTangencyPoint()) { | |
1055 | dofirst = Standard_True; | |
1056 | } | |
7fd59977 | 1057 | } |
1058 | if (wlin1->HasLastPoint()) { | |
191478a5 | 1059 | ptfin = wlin1->LastPoint(indlast); |
1060 | if (ptfin.IsTangencyPoint()) { | |
1061 | dolast = Standard_True; | |
1062 | } | |
7fd59977 | 1063 | } |
191478a5 | 1064 | |
7fd59977 | 1065 | if (dofirst || dolast) { |
d4b867e6 | 1066 | for (Standard_Integer k=j+1; k<=Nblines;k++) { |
191478a5 | 1067 | const Handle(IntPatch_Line)& slink = slin(k); |
c5f3a425 | 1068 | Handle(IntPatch_WLine) wlin2 (Handle(IntPatch_WLine)::DownCast (slink)); |
191478a5 | 1069 | if (wlin2->HasFirstPoint()) { |
1070 | ptbis = wlin2->FirstPoint(ind2); | |
1071 | if (ptbis.IsTangencyPoint()) { | |
1072 | if (dofirst ) { | |
1073 | if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) { | |
1074 | ptdeb.SetMultiple(Standard_True); | |
1075 | if (!ptbis.IsMultiple()) { | |
1076 | ptbis.SetMultiple(Standard_True); | |
1077 | wlin2->Replace(ind2,ptbis); | |
1078 | } | |
1079 | } | |
1080 | } | |
1081 | if (dolast ) { | |
1082 | if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) { | |
1083 | ptfin.SetMultiple(Standard_True); | |
1084 | if (!ptbis.IsMultiple()) { | |
1085 | ptbis.SetMultiple(Standard_True); | |
1086 | wlin2->Replace(ind2,ptbis); | |
1087 | } | |
1088 | } | |
1089 | } | |
1090 | } | |
1091 | } | |
1092 | if (wlin2->HasLastPoint()) { | |
1093 | ptbis = wlin2->LastPoint(ind2); | |
1094 | if (ptbis.IsTangencyPoint()) { | |
1095 | if (dofirst ) { | |
1096 | if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) { | |
1097 | ptdeb.SetMultiple(Standard_True); | |
1098 | if (!ptbis.IsMultiple()) { | |
1099 | ptbis.SetMultiple(Standard_True); | |
1100 | wlin2->Replace(ind2,ptbis); | |
1101 | } | |
1102 | } | |
1103 | } | |
1104 | if (dolast ) { | |
1105 | if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) { | |
1106 | ptfin.SetMultiple(Standard_True); | |
1107 | if (!ptbis.IsMultiple()) { | |
1108 | ptbis.SetMultiple(Standard_True); | |
1109 | wlin2->Replace(ind2,ptbis); | |
1110 | } | |
1111 | } | |
1112 | } | |
1113 | } | |
1114 | } | |
1115 | } | |
1116 | if(dofirst) | |
1117 | wlin1->Replace(indfirst,ptdeb); | |
1118 | if(dolast) | |
1119 | wlin1->Replace(indlast,ptfin); | |
7fd59977 | 1120 | } |
1121 | } | |
1122 | }// if (seqpdep.Length() != 0 || seqpins.Length() != 0) { | |
1123 | // | |
1124 | // Treatment the segments | |
1125 | NbSegm = solrst.NbSegments(); | |
1126 | if (NbSegm) { | |
d4b867e6 | 1127 | for(Standard_Integer i=1; i<=NbSegm; i++) { |
7fd59977 | 1128 | thesegm = solrst.Segment(i); |
e618b526 | 1129 | //Check if segment is degenerated |
1130 | if(thesegm.HasFirstPoint() && thesegm.HasLastPoint()) | |
1131 | { | |
1132 | Standard_Real tol2 = Precision::Confusion(); | |
1133 | tol2 *= tol2; | |
1134 | const gp_Pnt& aPf = thesegm.FirstPoint().Value(); | |
1135 | const gp_Pnt& aPl = thesegm.LastPoint().Value(); | |
1136 | if(aPf.SquareDistance(aPl) <= tol2) | |
1137 | { | |
1138 | //segment can be degenerated - check inner point | |
1139 | paramf = thesegm.FirstPoint().Parameter(); | |
1140 | paraml = thesegm.LastPoint().Parameter(); | |
1141 | gp_Pnt2d _p2d = | |
1142 | thesegm.Curve()->Value(.57735 * paramf + 0.42265 * paraml); | |
1143 | gp_Pnt aPm; | |
1144 | if(reversed) | |
1145 | { | |
1146 | Surf1->D0(_p2d.X(), _p2d.Y(), aPm); | |
1147 | } | |
1148 | else | |
1149 | { | |
1150 | Surf2->D0(_p2d.X(), _p2d.Y(), aPm); | |
1151 | } | |
1152 | if(aPm.SquareDistance(aPf) <= tol2) | |
1153 | { | |
1154 | //Degenerated | |
1155 | continue; | |
1156 | } | |
1157 | } | |
1158 | } | |
1159 | ||
1160 | ||
7fd59977 | 1161 | //---------------------------------------------------------------------- |
1162 | // on cree une ligne d intersection contenant uniquement le segment. | |
1163 | // VOIR POUR LA TRANSITION DE LA LIGNE | |
1164 | // On ajoute aussi un polygone pour le traitement des intersections | |
1165 | // entre ligne et restrictions de la surface implicite (PutVertexOnLine) | |
1166 | //---------------------------------------------------------------------- | |
1167 | //-- Calcul de la transition sur la rline (12 fev 97) | |
1168 | //-- reversed a le sens de OnFirst | |
1169 | //-- | |
1170 | dofirst = dolast = Standard_False; | |
1171 | procf = Standard_False; | |
1172 | procl = Standard_False; | |
1173 | IntSurf_Transition TLineUnk,TArcUnk; | |
1174 | ||
1175 | IntPatch_Point _thepointAtBeg; | |
1176 | IntPatch_Point _thepointAtEnd; | |
191478a5 | 1177 | |
7fd59977 | 1178 | Standard_Boolean TransitionOK=Standard_False; |
1179 | ||
1180 | if(thesegm.HasFirstPoint()) { | |
191478a5 | 1181 | Standard_Real _u1,_v1,_u2,_v2; |
1182 | ||
1183 | dofirst = Standard_True; | |
1184 | PStartf = thesegm.FirstPoint(); | |
1185 | paramf = PStartf.Parameter(); | |
1186 | ||
1187 | gp_Pnt2d _p2d = thesegm.Curve()->Value(paramf); | |
1188 | Handle(Adaptor3d_HVertex) _vtx; | |
1189 | if(PStartf.IsNew()==Standard_False) | |
1190 | _vtx= PStartf.Vertex(); | |
1191 | const gp_Pnt& _Pp = PStartf.Value(); | |
1192 | _thepointAtBeg.SetValue(_Pp,PStartf.Tolerance(),Standard_False); | |
1193 | if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone | |
1194 | Quad.Parameters(_Pp,_u1,_v1); | |
1195 | _u2=_p2d.X(); _v2=_p2d.Y(); | |
1196 | } | |
1197 | else { //-- typeS1 != Pln && Cyl && Sph && Cone | |
1198 | Quad.Parameters(_Pp,_u2,_v2); | |
1199 | _u1=_p2d.X(); _v1=_p2d.Y(); | |
1200 | } | |
1201 | _thepointAtBeg.SetParameters(_u1,_v1,_u2,_v2); | |
1202 | _thepointAtBeg.SetParameter(paramf); | |
1203 | if(PStartf.IsNew()==Standard_False) | |
1204 | _thepointAtBeg.SetVertex(reversed,_vtx); | |
1205 | _thepointAtBeg.SetArc(reversed,thesegm.Curve(),paramf,TLineUnk,TArcUnk); | |
1206 | ||
1207 | ||
1208 | gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d; | |
1209 | Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1); | |
1210 | norm1 = d1u1.Crossed(d1v1); | |
1211 | Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2); | |
1212 | norm2 = d1u2.Crossed(d1v2); | |
1213 | ||
1214 | thesegm.Curve()->D1(paramf,_p2d,_d2d); | |
1215 | if(reversed) { | |
1216 | tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1); | |
1217 | } | |
1218 | else { | |
1219 | tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2); | |
1220 | } | |
1221 | _u1=tgline.DotCross(norm2,norm1); | |
1222 | TransitionOK=Standard_True; | |
1223 | if (_u1 > 0.00000001) { | |
1224 | trans1 = IntSurf_Out; | |
1225 | trans2 = IntSurf_In; | |
1226 | } | |
1227 | else if(_u1 < -0.00000001) { | |
1228 | trans1 = IntSurf_In; | |
1229 | trans2 = IntSurf_Out; | |
1230 | } | |
1231 | else { | |
1232 | TransitionOK=Standard_False; | |
1233 | } | |
7fd59977 | 1234 | } |
1235 | if(thesegm.HasLastPoint()) { | |
191478a5 | 1236 | Standard_Real _u1,_v1,_u2,_v2; |
1237 | ||
1238 | dolast = Standard_True; | |
1239 | PStartl = thesegm.LastPoint(); | |
1240 | paraml = PStartl.Parameter(); | |
1241 | ||
1242 | gp_Pnt2d _p2d = thesegm.Curve()->Value(paraml); | |
1243 | Handle(Adaptor3d_HVertex) _vtx; | |
1244 | if(PStartl.IsNew()==Standard_False) | |
1245 | _vtx = PStartl.Vertex(); | |
1246 | const gp_Pnt& _Pp = PStartl.Value(); | |
1247 | IntPatch_Point _thepoint; | |
1248 | _thepointAtEnd.SetValue(_Pp,PStartl.Tolerance(),Standard_False); | |
1249 | if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone | |
1250 | Quad.Parameters(_Pp,_u1,_v1); | |
1251 | _u2=_p2d.X(); _v2=_p2d.Y(); | |
1252 | } | |
1253 | else { //-- typeS1 != Pln && Cyl && Sph && Cone | |
1254 | Quad.Parameters(_Pp,_u2,_v2); | |
1255 | _u1=_p2d.X(); _v1=_p2d.Y(); | |
1256 | } | |
1257 | _thepointAtEnd.SetParameters(_u1,_v1,_u2,_v2); | |
1258 | _thepointAtEnd.SetParameter(paraml); | |
1259 | if(PStartl.IsNew()==Standard_False) | |
1260 | _thepointAtEnd.SetVertex(reversed,_vtx); | |
1261 | _thepointAtEnd.SetArc(reversed,thesegm.Curve(),paraml,TLineUnk,TArcUnk); | |
1262 | ||
1263 | ||
1264 | ||
1265 | gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d; | |
1266 | Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1); | |
1267 | norm1 = d1u1.Crossed(d1v1); | |
1268 | Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2); | |
1269 | norm2 = d1u2.Crossed(d1v2); | |
1270 | ||
1271 | thesegm.Curve()->D1(paraml,_p2d,_d2d); | |
1272 | if(reversed) { | |
1273 | tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1); | |
1274 | } | |
1275 | else { | |
1276 | tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2); | |
1277 | } | |
1278 | _u1=tgline.DotCross(norm2,norm1); | |
1279 | TransitionOK=Standard_True; | |
1280 | if (_u1 > 0.00000001) { | |
1281 | trans1 = IntSurf_Out; | |
1282 | trans2 = IntSurf_In; | |
1283 | } | |
1284 | else if(_u1 < -0.00000001) { | |
1285 | trans1 = IntSurf_In; | |
1286 | trans2 = IntSurf_Out; | |
1287 | } | |
1288 | else { | |
1289 | TransitionOK=Standard_False; | |
1290 | } | |
7fd59977 | 1291 | } |
1292 | if(TransitionOK==Standard_False) { | |
191478a5 | 1293 | //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False); |
1294 | rline = new IntPatch_RLine (Standard_False); | |
1295 | if(reversed) { | |
1296 | rline->SetArcOnS1(thesegm.Curve()); | |
1297 | } | |
1298 | else { | |
1299 | rline->SetArcOnS2(thesegm.Curve()); | |
1300 | } | |
7fd59977 | 1301 | } |
1302 | else { | |
191478a5 | 1303 | //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False,trans1,trans2); |
1304 | rline = new IntPatch_RLine (Standard_False,trans1,trans2); | |
1305 | if(reversed) { | |
1306 | rline->SetArcOnS1(thesegm.Curve()); | |
1307 | } | |
1308 | else { | |
1309 | rline->SetArcOnS2(thesegm.Curve()); | |
1310 | } | |
7fd59977 | 1311 | } |
1312 | ||
1313 | //------------------------------ | |
1314 | //-- Ajout des points | |
1315 | //-- | |
1316 | if (thesegm.HasFirstPoint()) { | |
191478a5 | 1317 | rline->AddVertex(_thepointAtBeg); |
1318 | rline->SetFirstPoint(rline->NbVertex()); | |
7fd59977 | 1319 | } |
191478a5 | 1320 | |
7fd59977 | 1321 | if (thesegm.HasLastPoint()) { |
191478a5 | 1322 | rline->AddVertex(_thepointAtEnd); |
1323 | rline->SetLastPoint(rline->NbVertex()); | |
7fd59977 | 1324 | } |
1325 | ||
1326 | // Polygone sur restriction solution | |
1327 | if (dofirst && dolast) { | |
191478a5 | 1328 | Standard_Real prm; |
1329 | gp_Pnt ptpoly; | |
1330 | IntSurf_PntOn2S p2s; | |
1331 | Handle(IntSurf_LineOn2S) Thelin = new IntSurf_LineOn2S (); | |
1332 | Handle(Adaptor2d_HCurve2d) arcsegm = thesegm.Curve(); | |
1333 | Standard_Integer nbsample = 100; | |
1334 | ||
1335 | if (!reversed) { | |
d4b867e6 | 1336 | for (Standard_Integer j=1; j<=nbsample; j++) { |
191478a5 | 1337 | prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1); |
1338 | arcsegm->D0(prm,p2d); | |
1339 | Surf2->D0(p2d.X(),p2d.Y(),ptpoly); | |
1340 | ||
1341 | Quad.Parameters(ptpoly,U1,V1); | |
1342 | p2s.SetValue(ptpoly,U1,V1,p2d.X(),p2d.Y()); | |
1343 | Thelin->Add(p2s); | |
1344 | } | |
1345 | } | |
1346 | else { | |
d4b867e6 | 1347 | for (Standard_Integer j=1; j<=nbsample; j++) { |
191478a5 | 1348 | prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1); |
1349 | arcsegm->D0(prm,p2d); | |
1350 | Surf1->D0(p2d.X(),p2d.Y(),ptpoly); | |
1351 | ||
1352 | Quad.Parameters(ptpoly,U2,V2); | |
1353 | p2s.SetValue(ptpoly,p2d.X(),p2d.Y(),U2,V2); | |
1354 | Thelin->Add(p2s); | |
1355 | } | |
1356 | } | |
1357 | rline->Add(Thelin); | |
7fd59977 | 1358 | } |
1359 | ||
1360 | if (dofirst || dolast) { | |
191478a5 | 1361 | Nblines = slin.Length(); |
d4b867e6 | 1362 | for (Standard_Integer j=1; j<=Nblines; j++) { |
191478a5 | 1363 | const Handle(IntPatch_Line)& slinj = slin(j); |
1364 | typ = slinj->ArcType(); | |
1365 | if (typ == IntPatch_Walking) { | |
c5f3a425 | 1366 | Nbpts = Handle(IntPatch_WLine)::DownCast (slinj)->NbVertex(); |
191478a5 | 1367 | } |
1368 | else { | |
c5f3a425 | 1369 | Nbpts = Handle(IntPatch_RLine)::DownCast (slinj)->NbVertex(); |
191478a5 | 1370 | } |
d4b867e6 | 1371 | for (Standard_Integer k=1; k<=Nbpts;k++) { |
191478a5 | 1372 | if (typ == IntPatch_Walking) { |
c5f3a425 | 1373 | ptdeb = Handle(IntPatch_WLine)::DownCast (slinj)->Vertex(k); |
191478a5 | 1374 | } |
1375 | else { | |
c5f3a425 | 1376 | ptdeb = Handle(IntPatch_RLine)::DownCast (slinj)->Vertex(k); |
191478a5 | 1377 | } |
1378 | if (dofirst) { | |
1379 | ||
1380 | if (ptdeb.Value().Distance(PStartf.Value()) <=TolArc) { | |
1381 | ptdeb.SetMultiple(Standard_True); | |
1382 | if (typ == IntPatch_Walking) { | |
c5f3a425 | 1383 | Handle(IntPatch_WLine)::DownCast (slinj)->Replace(k,ptdeb); |
191478a5 | 1384 | } |
1385 | else { | |
c5f3a425 | 1386 | Handle(IntPatch_RLine)::DownCast (slinj)->Replace(k,ptdeb); |
191478a5 | 1387 | } |
1388 | ptdeb.SetParameter(paramf); | |
1389 | rline->AddVertex(ptdeb); | |
1390 | if (!procf){ | |
1391 | procf=Standard_True; | |
1392 | rline->SetFirstPoint(rline->NbVertex()); | |
1393 | } | |
1394 | } | |
1395 | } | |
1396 | if (dolast) { | |
1397 | if(dofirst) { //-- on recharge le ptdeb | |
1398 | if (typ == IntPatch_Walking) { | |
c5f3a425 | 1399 | ptdeb = Handle(IntPatch_WLine)::DownCast (slinj)->Vertex(k); |
191478a5 | 1400 | } |
1401 | else { | |
c5f3a425 | 1402 | ptdeb = Handle(IntPatch_RLine)::DownCast (slinj)->Vertex(k); |
191478a5 | 1403 | } |
1404 | } | |
1405 | if (ptdeb.Value().Distance(PStartl.Value()) <=TolArc) { | |
1406 | ptdeb.SetMultiple(Standard_True); | |
1407 | if (typ == IntPatch_Walking) { | |
c5f3a425 | 1408 | Handle(IntPatch_WLine)::DownCast (slinj)->Replace(k,ptdeb); |
191478a5 | 1409 | } |
1410 | else { | |
c5f3a425 | 1411 | Handle(IntPatch_RLine)::DownCast (slinj)->Replace(k,ptdeb); |
191478a5 | 1412 | } |
1413 | ptdeb.SetParameter(paraml); | |
1414 | rline->AddVertex(ptdeb); | |
1415 | if (!procl){ | |
1416 | procl=Standard_True; | |
1417 | rline->SetLastPoint(rline->NbVertex()); | |
1418 | } | |
1419 | } | |
1420 | } | |
1421 | } | |
1422 | } | |
7fd59977 | 1423 | } |
1424 | slin.Append(rline); | |
1425 | } | |
1426 | }// if (NbSegm) | |
1427 | // | |
1428 | // on traite les restrictions de la surface implicite | |
71958f7d | 1429 | |
1430 | for (Standard_Integer i=1, aNbLin = slin.Length(); i<=aNbLin; i++) | |
7fd59977 | 1431 | { |
f73c584c | 1432 | Handle(IntPatch_PointLine) aL = Handle(IntPatch_PointLine)::DownCast(slin(i)); |
d4b867e6 | 1433 | |
7fd59977 | 1434 | if (!reversed) |
d4b867e6 | 1435 | IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang); |
7fd59977 | 1436 | else |
d4b867e6 | 1437 | IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang); |
71958f7d | 1438 | |
f73c584c | 1439 | if (aL->NbPnts() <= 2) |
1440 | { | |
1441 | Standard_Boolean aCond = aL->NbPnts() < 2; | |
1442 | if (!aCond) | |
1443 | aCond = (aL->Point(1).IsSame(aL->Point(2), Precision::Confusion())); | |
1444 | ||
1445 | if (aCond) | |
1446 | { | |
1447 | slin.Remove(i); | |
1448 | i--; | |
1449 | aNbLin--; | |
1450 | continue; | |
1451 | } | |
1452 | } | |
1453 | ||
71958f7d | 1454 | if(aL->ArcType() == IntPatch_Walking) |
1455 | { | |
1456 | const Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(aL); | |
1457 | slin.Append(aWL); | |
1458 | slin.Remove(i); | |
1459 | i--; | |
1460 | aNbLin--; | |
1461 | } | |
7fd59977 | 1462 | } |
d4b867e6 | 1463 | |
71958f7d | 1464 | // Now slin is filled as follows: lower indices correspond to Restriction line, |
1465 | // after (higher indices) - only Walking-line. | |
1466 | ||
1fbf69bb | 1467 | const Standard_Real aTol3d = Max(Func.Tolerance(), TolTang); |
77dbd1f1 | 1468 | const Handle(Adaptor3d_HSurface)& aQSurf = (reversed) ? Surf2 : Surf1; |
1469 | const Handle(Adaptor3d_HSurface)& anOtherSurf = (reversed) ? Surf1 : Surf2; | |
d4b867e6 | 1470 | |
1471 | for (Standard_Integer i = 1; i <= slin.Length(); i++) | |
1472 | { | |
77dbd1f1 | 1473 | const Handle(IntPatch_PointLine)& aL1 = Handle(IntPatch_PointLine)::DownCast(slin(i)); |
1474 | const Handle(IntPatch_RLine)& aRL1 = Handle(IntPatch_RLine)::DownCast(aL1); | |
1475 | ||
1476 | if(aRL1.IsNull()) | |
1477 | { | |
1478 | //Walking-Walking cases are not supported | |
1479 | break; | |
1480 | } | |
1481 | ||
1482 | const Handle(Adaptor2d_HCurve2d)& anArc = aRL1->IsArcOnS1() ? | |
1483 | aRL1->ArcOnS1() : | |
1484 | aRL1->ArcOnS2(); | |
1485 | if(anArc->Curve2d().GetType() != GeomAbs_Line) | |
1486 | { | |
1487 | //Restriction line must be isoline. | |
1488 | //Other cases are not supported by | |
1489 | //existing algorithms. | |
1490 | ||
1491 | break; | |
1492 | } | |
1493 | ||
1494 | Standard_Boolean isFirstDeleted = Standard_False; | |
1495 | ||
d4b867e6 | 1496 | for(Standard_Integer j = i + 1; j <= slin.Length(); j++) |
1497 | { | |
d4b867e6 | 1498 | Handle(IntPatch_PointLine) aL2 = Handle(IntPatch_PointLine)::DownCast(slin(j)); |
d4b867e6 | 1499 | Handle(IntPatch_RLine) aRL2 = Handle(IntPatch_RLine)::DownCast(aL2); |
1500 | ||
71958f7d | 1501 | //Here aL1 (i-th line) is Restriction-line and aL2 (j-th line) is |
1502 | //Restriction or Walking | |
d4b867e6 | 1503 | |
77dbd1f1 | 1504 | if(!aRL2.IsNull()) |
1505 | { | |
d677b214 | 1506 | const Handle(Adaptor2d_HCurve2d)& anArc2 = aRL2->IsArcOnS1() ? |
1507 | aRL2->ArcOnS1() : | |
1508 | aRL2->ArcOnS2(); | |
1509 | if(anArc2->Curve2d().GetType() != GeomAbs_Line) | |
d4b867e6 | 1510 | { |
77dbd1f1 | 1511 | //Restriction line must be isoline. |
1512 | //Other cases are not supported by | |
1513 | //existing algorithms. | |
d4b867e6 | 1514 | |
77dbd1f1 | 1515 | continue; |
d4b867e6 | 1516 | } |
77dbd1f1 | 1517 | } |
d4b867e6 | 1518 | |
77dbd1f1 | 1519 | //aDir can be equal to one of following four values only |
1520 | //(because Reastriction line is boundary of rectangular surface): | |
1521 | //either {0, 1} or {0, -1} or {1, 0} or {-1, 0}. | |
1522 | const gp_Dir2d aDir = anArc->Curve2d().Line().Direction(); | |
d4b867e6 | 1523 | |
77dbd1f1 | 1524 | Standard_Real aTol2d = anOtherSurf->UResolution(aTol3d), |
1525 | aPeriod = anOtherSurf->IsVPeriodic() ? anOtherSurf->VPeriod() : 0.0; | |
d4b867e6 | 1526 | |
77dbd1f1 | 1527 | if(Abs(aDir.X()) < 0.5) |
1528 | {//Restriction directs along V-direction | |
1529 | aTol2d = anOtherSurf->VResolution(aTol3d); | |
1530 | aPeriod = anOtherSurf->IsUPeriodic() ? anOtherSurf->UPeriod() : 0.0; | |
d4b867e6 | 1531 | } |
1532 | ||
77dbd1f1 | 1533 | const Standard_Boolean isCoincide = IsCoincide(Func, aL2, anArc, aRL1->IsArcOnS1(), |
1534 | aTol3d, aTol2d, aPeriod); | |
d4b867e6 | 1535 | |
1536 | if(isCoincide) | |
77dbd1f1 | 1537 | { |
1538 | if(aRL2.IsNull()) | |
1539 | {//Delete Walking-line | |
1540 | slin.Remove(j); | |
1541 | j--; | |
1542 | } | |
1543 | else | |
1544 | {//Restriction-Restriction | |
1545 | const Handle(Adaptor2d_HCurve2d)& anArc2 = aRL2->IsArcOnS1() ? | |
1546 | aRL2->ArcOnS1() : | |
1547 | aRL2->ArcOnS2(); | |
1548 | ||
1549 | const Standard_Real aRange2 = anArc2->LastParameter() - | |
1550 | anArc2->FirstParameter(); | |
1551 | const Standard_Real aRange1 = anArc->LastParameter() - | |
1552 | anArc->FirstParameter(); | |
1553 | ||
1554 | if(aRange2 > aRange1) | |
1555 | { | |
1556 | isFirstDeleted = Standard_True; | |
1557 | break; | |
1558 | } | |
1559 | else | |
1560 | {//Delete j-th line | |
1561 | slin.Remove(j); | |
1562 | j--; | |
1563 | } | |
1564 | } | |
d4b867e6 | 1565 | } |
77dbd1f1 | 1566 | } //for(Standard_Integer j = i + 1; j <= slin.Length(); j++) |
1567 | ||
1568 | if(isFirstDeleted) | |
1569 | {//Delete i-th line | |
1570 | slin.Remove(i--); | |
d4b867e6 | 1571 | } |
77dbd1f1 | 1572 | }//for (Standard_Integer i = 1; i <= slin.Length(); i++) |
d4b867e6 | 1573 | |
7fd59977 | 1574 | empt = (slin.Length() == 0 && spnt.Length() == 0); |
1575 | done = Standard_True; | |
d4b867e6 | 1576 | |
7fd59977 | 1577 | |
191478a5 | 1578 | if(slin.Length() == 0) |
1579 | return; | |
7fd59977 | 1580 | |
191478a5 | 1581 | Standard_Boolean isDecomposeRequired = (Quad.TypeQuadric() == GeomAbs_Cone) || |
a09c8f3a | 1582 | (Quad.TypeQuadric() == GeomAbs_Sphere) || |
1583 | (Quad.TypeQuadric() == GeomAbs_Cylinder) || | |
1584 | (Quad.TypeQuadric() == GeomAbs_Torus); | |
7fd59977 | 1585 | |
191478a5 | 1586 | if(!isDecomposeRequired) |
1587 | return; | |
7fd59977 | 1588 | |
d4b867e6 | 1589 | // post processing for cones and spheres |
1590 | ||
191478a5 | 1591 | const Handle(Adaptor3d_TopolTool)& PDomain = (reversed) ? D1 : D2; |
7fd59977 | 1592 | |
191478a5 | 1593 | IntPatch_SequenceOfLine dslin; |
1594 | Standard_Boolean isDecompose = Standard_False; | |
d4b867e6 | 1595 | for(Standard_Integer i = 1; i <= slin.Length(); i++ ) |
191478a5 | 1596 | { |
77dbd1f1 | 1597 | if(DecomposeResult( Handle(IntPatch_PointLine)::DownCast(slin(i)), |
1598 | reversed, Quad, PDomain, aQSurf, | |
a09c8f3a | 1599 | anOtherSurf, TolArc, aTol3d, dslin)) |
191478a5 | 1600 | { |
1601 | isDecompose = Standard_True; | |
7fd59977 | 1602 | } |
7fd59977 | 1603 | } |
1604 | ||
191478a5 | 1605 | if(!isDecompose) |
1606 | return; | |
1607 | ||
1608 | slin.Clear(); | |
d4b867e6 | 1609 | for(Standard_Integer i = 1; i <= dslin.Length(); i++ ) |
191478a5 | 1610 | slin.Append(dslin(i)); |
7fd59977 | 1611 | } |
1612 | ||
1613 | // correct U parameter of the start point of line on Quadric | |
1614 | // (change 0->2PI or vs, if necessary) | |
1615 | static Standard_Real AdjustUFirst(Standard_Real U1,Standard_Real U2) | |
1616 | { | |
1617 | Standard_Real u = U1; | |
1618 | ||
1619 | // case: no adjustment | |
c6541a0c | 1620 | if( U1 > 0. && U1 < (2.*M_PI) ) |
7fd59977 | 1621 | return u; |
1622 | ||
1623 | // case: near '0' | |
1624 | if( U1 == 0. || fabs(U1) <= 1.e-9 ) { | |
c6541a0c D |
1625 | if( U2 > 0. && U2 < (2.*M_PI) ) |
1626 | u = ( U2 < ((2.*M_PI)-U2) ) ? 0. : (2.*M_PI); | |
7fd59977 | 1627 | else { |
1628 | Standard_Real uu = U2; | |
c6541a0c | 1629 | if( U2 > (2.*M_PI) ) |
191478a5 | 1630 | while( uu > (2.*M_PI) ) |
1631 | uu -= (2.*M_PI); | |
7fd59977 | 1632 | else |
191478a5 | 1633 | while( uu < 0.) |
1634 | uu += (2.*M_PI); | |
1635 | ||
c6541a0c | 1636 | u = ( uu < ((2.*M_PI)-uu) ) ? 0. : (2.*M_PI); |
7fd59977 | 1637 | } |
1638 | } | |
1639 | // case: near '2PI' | |
c6541a0c D |
1640 | else if( U1 == (2.*M_PI) || fabs((2.*M_PI)-fabs(U1)) <= 1.e-9 ) { |
1641 | if( U2 > 0. && U2 < (2.*M_PI) ) | |
1642 | u = ( U2 < ((2.*M_PI)-U2) ) ? 0. : (2.*M_PI); | |
7fd59977 | 1643 | else { |
1644 | Standard_Real uu = U2; | |
c6541a0c | 1645 | if( U2 > (2.*M_PI) ) |
191478a5 | 1646 | while( uu > (2.*M_PI) ) |
1647 | uu -= (2.*M_PI); | |
7fd59977 | 1648 | else |
191478a5 | 1649 | while( uu < 0.) |
1650 | uu += (2.*M_PI); | |
1651 | ||
c6541a0c | 1652 | u = ( uu < ((2.*M_PI)-uu) ) ? 0. : (2.*M_PI); |
7fd59977 | 1653 | } |
1654 | } | |
1655 | // case: '<0. || >2PI' | |
1656 | else { | |
1657 | if(U1 < 0.) | |
1658 | while(u < 0.) | |
191478a5 | 1659 | u += 2.*M_PI; |
c6541a0c D |
1660 | if(U1 > (2.*M_PI)) |
1661 | while(u > (2.*M_PI)) | |
191478a5 | 1662 | u -= (2.*M_PI); |
7fd59977 | 1663 | } |
1664 | ||
1665 | return u; | |
1666 | } | |
1667 | ||
7fd59977 | 1668 | // collect vertices, reject equals |
77dbd1f1 | 1669 | static Handle(IntSurf_LineOn2S) GetVertices(const Handle(IntPatch_PointLine)& thePLine, |
191478a5 | 1670 | const Standard_Real TOL3D, |
1671 | const Standard_Real TOL2D) | |
7fd59977 | 1672 | { |
191478a5 | 1673 | // Standard_Real TOL3D = 1.e-12, TOL2D = 1.e-8; |
7fd59977 | 1674 | |
1675 | Handle(IntSurf_LineOn2S) vertices = new IntSurf_LineOn2S(); | |
1676 | ||
1677 | Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0.; | |
1678 | Standard_Integer i = 0, k = 0; | |
77dbd1f1 | 1679 | Standard_Integer NbVrt = thePLine->NbVertex(); |
191478a5 | 1680 | |
7fd59977 | 1681 | TColStd_Array1OfInteger anVrts(1,NbVrt); |
1682 | anVrts.Init(0); | |
1683 | ||
1684 | // check equal vertices | |
1685 | for(i = 1; i <= NbVrt; i++) { | |
1686 | ||
1687 | if( anVrts(i) == -1 ) continue; | |
1688 | ||
77dbd1f1 | 1689 | const IntPatch_Point& Pi = thePLine->Vertex(i); |
7fd59977 | 1690 | |
1691 | for(k = (i+1); k <= NbVrt; k++) { | |
1692 | ||
1693 | if( anVrts(k) == -1 ) continue; | |
1694 | ||
77dbd1f1 | 1695 | const IntPatch_Point& Pk = thePLine->Vertex(k); |
7fd59977 | 1696 | |
1697 | if(Pi.Value().Distance(Pk.Value()) <= TOL3D) { | |
191478a5 | 1698 | // suggest the points are equal; |
1699 | // test 2d parameters on surface | |
1700 | Standard_Boolean sameU1 = Standard_False; | |
1701 | Standard_Boolean sameV1 = Standard_False; | |
1702 | Standard_Boolean sameU2 = Standard_False; | |
1703 | Standard_Boolean sameV2 = Standard_False; | |
1704 | ||
1705 | Pi.ParametersOnS1(U1,V1); | |
1706 | Pk.ParametersOnS1(U2,V2); | |
1707 | if(fabs(U1-U2) <= TOL2D) sameU1 = Standard_True; | |
1708 | if(fabs(V1-V2) <= TOL2D) sameV1 = Standard_True; | |
1709 | ||
1710 | Pi.ParametersOnS2(U1,V1); | |
1711 | Pk.ParametersOnS2(U2,V2); | |
1712 | if(fabs(U1-U2) <= TOL2D) sameU2 = Standard_True; | |
1713 | if(fabs(V1-V2) <= TOL2D) sameV2 = Standard_True; | |
1714 | ||
1715 | if((sameU1 && sameV1) && (sameU2 && sameV2)) | |
1716 | anVrts(k) = -1; | |
7fd59977 | 1717 | } |
1718 | } | |
1719 | } | |
1720 | ||
1721 | // copy further processed vertices | |
1722 | for(i = 1; i <= NbVrt; i++) { | |
1723 | if( anVrts(i) == -1 ) continue; | |
77dbd1f1 | 1724 | vertices->Add(thePLine->Vertex(i).PntOn2S()); |
7fd59977 | 1725 | } |
1726 | return vertices; | |
1727 | } | |
1728 | ||
7fd59977 | 1729 | static void SearchVertices(const Handle(IntSurf_LineOn2S)& Line, |
191478a5 | 1730 | const Handle(IntSurf_LineOn2S)& Vertices, |
1731 | TColStd_Array1OfInteger& PTypes) | |
7fd59977 | 1732 | { |
1733 | Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints(); | |
1734 | Standard_Integer ip = 0, iv = 0; | |
1735 | for(ip = 1; ip <= nbp; ip++) { | |
1736 | const IntSurf_PntOn2S& aP = Line->Value(ip); | |
1737 | Standard_Integer type = 0; | |
1738 | for(iv = 1; iv <= nbv; iv++) { | |
1739 | const IntSurf_PntOn2S& aV = Vertices->Value(iv); | |
16423f20 | 1740 | if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) { |
191478a5 | 1741 | type = iv; |
1742 | break; | |
7fd59977 | 1743 | } |
1744 | } | |
1745 | PTypes(ip) = type; | |
1746 | } | |
1747 | } | |
1748 | ||
1749 | static inline Standard_Boolean IsSeamParameter(const Standard_Real U, | |
191478a5 | 1750 | const Standard_Real TOL2D) |
7fd59977 | 1751 | { |
c6541a0c | 1752 | return (fabs(U) <= TOL2D || fabs(2.*M_PI - U) <= TOL2D); |
7fd59977 | 1753 | } |
1754 | ||
1755 | static inline Standard_Real AdjustU(const Standard_Real U) | |
1756 | { | |
c6541a0c | 1757 | Standard_Real u = U, DBLPI = 2.*M_PI; |
7fd59977 | 1758 | if(u < 0. || u > DBLPI) { |
1759 | if(u < 0.) | |
1760 | while(u < 0.) | |
191478a5 | 1761 | u += DBLPI; |
7fd59977 | 1762 | else |
1763 | while(u > DBLPI) | |
191478a5 | 1764 | u -= DBLPI; |
7fd59977 | 1765 | } |
1766 | return u; | |
1767 | } | |
1768 | ||
1769 | static inline void Correct2DBounds(const Standard_Real UF, | |
191478a5 | 1770 | const Standard_Real UL, |
1771 | const Standard_Real VF, | |
1772 | const Standard_Real VL, | |
1773 | const Standard_Real TOL2D, | |
1774 | Standard_Real& U, | |
1775 | Standard_Real& V) | |
7fd59977 | 1776 | { |
1777 | Standard_Real Eps = 1.e-16; | |
1778 | Standard_Real dUF = fabs(U - UF); | |
1779 | Standard_Real dUL = fabs(U - UL); | |
1780 | Standard_Real dVF = fabs(V - VF); | |
1781 | Standard_Real dVL = fabs(V - VL); | |
1782 | if(dUF <= TOL2D && dUF > Eps) U = UF; | |
1783 | if(dUL <= TOL2D && dUL > Eps) U = UL; | |
1784 | if(dVF <= TOL2D && dVF > Eps) V = VF; | |
1785 | if(dVL <= TOL2D && dVL > Eps) V = VL; | |
1786 | } | |
1787 | ||
1788 | static void AdjustLine(Handle(IntSurf_LineOn2S)& Line, | |
191478a5 | 1789 | const Standard_Boolean IsReversed, |
1790 | const Handle(Adaptor3d_HSurface)& QSurf, | |
1791 | const Standard_Real TOL2D) | |
7fd59977 | 1792 | { |
1793 | Standard_Real VF = QSurf->FirstVParameter(); | |
1794 | Standard_Real VL = QSurf->LastVParameter(); | |
1795 | Standard_Real UF = QSurf->FirstUParameter(); | |
1796 | Standard_Real UL = QSurf->LastUParameter(); | |
1797 | ||
1798 | Standard_Integer nbp = Line->NbPoints(), ip = 0; | |
1799 | Standard_Real U = 0., V = 0.; | |
1800 | for(ip = 1; ip <= nbp; ip++) { | |
1801 | if(IsReversed) { | |
1802 | Line->Value(ip).ParametersOnS2(U,V); | |
1803 | U = AdjustU(U); | |
1804 | Correct2DBounds(UF,UL,VF,VL,TOL2D,U,V); | |
1805 | Line->SetUV(ip,Standard_False,U,V); | |
1806 | } | |
1807 | else { | |
1808 | Line->Value(ip).ParametersOnS1(U,V); | |
1809 | U = AdjustU(U); | |
1810 | Correct2DBounds(UF,UL,VF,VL,TOL2D,U,V); | |
1811 | Line->SetUV(ip,Standard_True,U,V); | |
1812 | } | |
1813 | } | |
1814 | } | |
1815 | ||
1816 | static Standard_Boolean InsertSeamVertices(Handle(IntSurf_LineOn2S)& Line, | |
191478a5 | 1817 | const Standard_Boolean IsReversed, |
1818 | Handle(IntSurf_LineOn2S)& Vertices, | |
1819 | const TColStd_Array1OfInteger& PTypes, | |
1820 | const Standard_Real TOL2D) | |
7fd59977 | 1821 | { |
1822 | Standard_Boolean result = Standard_False; | |
1823 | Standard_Integer ip = 0, nbp = Line->NbPoints(); | |
1824 | Standard_Real U = 0., V = 0.; | |
1825 | for(ip = 1; ip <= nbp; ip++) { | |
1826 | Standard_Integer ipt = PTypes(ip); | |
1827 | if(ipt != 0) { | |
1828 | const IntSurf_PntOn2S& aP = Line->Value(ip); | |
1829 | if(IsReversed) | |
191478a5 | 1830 | aP.ParametersOnS2(U,V); // S2 - quadric |
7fd59977 | 1831 | else |
191478a5 | 1832 | aP.ParametersOnS1(U,V); // S1 - quadric |
7fd59977 | 1833 | U = AdjustU(U); |
1834 | if(IsSeamParameter(U,TOL2D)) { | |
191478a5 | 1835 | if(ip == 1 || ip == nbp) { |
1836 | Standard_Real U1 = 0., V1 = 0.; | |
1837 | Standard_Integer ipp = (ip == 1) ? (ip+1) : (ip-1); | |
1838 | if(IsReversed) | |
1839 | Line->Value(ipp).ParametersOnS2(U1,V1); // S2 - quadric | |
1840 | else | |
1841 | Line->Value(ipp).ParametersOnS1(U1,V1); // S1 - quadric | |
1842 | Standard_Real u = AdjustUFirst(U,U1); | |
1843 | if(fabs(u-U) >= 1.5*M_PI) { | |
1844 | Standard_Real U2 = 0., V2 = 0.; | |
1845 | if(IsReversed) { | |
1846 | Line->Value(ip).ParametersOnS1(U2,V2); // prm | |
1847 | Line->SetUV(ip,Standard_False,u,V); | |
1848 | Line->SetUV(ip,Standard_True,U2,V2); | |
1849 | } | |
1850 | else { | |
1851 | Line->Value(ip).ParametersOnS2(U2,V2); // prm | |
1852 | Line->SetUV(ip,Standard_True,u,V); | |
1853 | Line->SetUV(ip,Standard_False,U2,V2); | |
1854 | } | |
1855 | } | |
1856 | } | |
1857 | else { | |
1858 | Standard_Integer ipp = ip - 1; | |
1859 | Standard_Integer ipn = ip + 1; | |
1860 | Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.; | |
1861 | if(IsReversed) { | |
1862 | Line->Value(ipp).ParametersOnS2(U1,V1); // quad | |
1863 | Line->Value(ipn).ParametersOnS2(U2,V2); // quad | |
1864 | } | |
1865 | else { | |
1866 | Line->Value(ipp).ParametersOnS1(U1,V1); // quad | |
1867 | Line->Value(ipn).ParametersOnS1(U2,V2); // quad | |
1868 | } | |
1869 | U1 = AdjustU(U1); | |
1870 | U2 = AdjustU(U2); | |
1871 | Standard_Boolean pnearZero = (fabs(U1) < fabs(2.*M_PI-U1)) ? Standard_True : Standard_False; | |
1872 | Standard_Boolean cnearZero = (fabs(U) < fabs(2.*M_PI-U)) ? Standard_True : Standard_False; | |
1873 | if(pnearZero == cnearZero) { | |
1874 | if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) { | |
1875 | Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.; | |
1876 | IntSurf_PntOn2S nP; | |
1877 | nP.SetValue(aP.Value()); | |
1878 | Standard_Real U3 = 0., V3 = 0.; | |
1879 | if(IsReversed) { | |
1880 | Line->Value(ip).ParametersOnS1(U3,V3); // prm | |
1881 | nP.SetValue(Standard_False,nU,V); | |
1882 | nP.SetValue(Standard_True,U3,V3); | |
1883 | } | |
1884 | else { | |
1885 | Line->Value(ip).ParametersOnS2(U3,V3); // prm | |
1886 | nP.SetValue(Standard_True,nU,V); | |
1887 | nP.SetValue(Standard_False,U3,V3); | |
1888 | } | |
1889 | Line->InsertBefore(ipn,nP); | |
1890 | Vertices->Add(nP); | |
1891 | result = Standard_True; | |
1892 | break; | |
1893 | } | |
1894 | } | |
1895 | else { | |
1896 | if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) { | |
1897 | Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.; | |
1898 | IntSurf_PntOn2S nP; | |
1899 | nP.SetValue(aP.Value()); | |
1900 | Standard_Real U3 = 0., V3 = 0.; | |
1901 | if(IsReversed) { | |
1902 | Line->Value(ip).ParametersOnS1(U3,V3); // prm | |
1903 | nP.SetValue(Standard_False,nU,V); | |
1904 | nP.SetValue(Standard_True,U3,V3); | |
1905 | } | |
1906 | else { | |
1907 | Line->Value(ip).ParametersOnS2(U3,V3); // prm | |
1908 | nP.SetValue(Standard_True,nU,V); | |
1909 | nP.SetValue(Standard_False,U3,V3); | |
1910 | } | |
1911 | Line->InsertBefore(ip,nP); | |
1912 | Vertices->Add(nP); | |
1913 | result = Standard_True; | |
1914 | break; | |
1915 | } | |
1916 | else { | |
1917 | // Line->InsertBefore(ip,Line->Value(ipn)); | |
1918 | // Line->RemovePoint(ip+2); | |
1919 | // result = Standard_True; | |
04232180 | 1920 | // std::cout << "swap vertex " << std::endl; |
191478a5 | 1921 | // break; |
1922 | } | |
1923 | } | |
1924 | } | |
7fd59977 | 1925 | } |
1926 | } | |
1927 | } | |
1928 | return result; | |
1929 | } | |
1930 | ||
191478a5 | 1931 | static void ToSmooth( const Handle(IntSurf_LineOn2S)& Line, |
d4b867e6 | 1932 | const Standard_Boolean IsReversed, |
1933 | const IntSurf_Quadric& Quad, | |
1934 | const Standard_Boolean IsFirst, | |
1935 | Standard_Real& D3D) | |
7fd59977 | 1936 | { |
1937 | if(Line->NbPoints() <= 10) | |
1938 | return; | |
191478a5 | 1939 | |
7fd59977 | 1940 | D3D = 0.; |
1941 | Standard_Integer NbTestPnts = Line->NbPoints() / 5; | |
1942 | if(NbTestPnts < 5) NbTestPnts = 5; | |
1943 | ||
1944 | Standard_Integer startp = (IsFirst) ? 2 : (Line->NbPoints() - NbTestPnts - 2); | |
1945 | Standard_Integer ip = 0; | |
1946 | Standard_Real Uc = 0., Vc = 0., Un = 0., Vn = 0., DDU = 0., DDV = 0.; | |
1947 | ||
1948 | for(ip = startp; ip <= NbTestPnts; ip++) { | |
1949 | if(IsReversed) { | |
1950 | Line->Value(ip).ParametersOnS2(Uc,Vc); // S2 - quadric | |
1951 | Line->Value(ip+1).ParametersOnS2(Un,Vn); | |
1952 | } | |
1953 | else { | |
1954 | Line->Value(ip).ParametersOnS1(Uc,Vc); // S1 - quadric | |
1955 | Line->Value(ip+1).ParametersOnS1(Un,Vn); | |
1956 | } | |
1957 | DDU += fabs(fabs(Uc)-fabs(Un)); | |
1958 | DDV += fabs(fabs(Vc)-fabs(Vn)); | |
191478a5 | 1959 | |
7fd59977 | 1960 | if(ip > startp) { |
1961 | Standard_Real DP = Line->Value(ip).Value().Distance(Line->Value(ip-1).Value()); | |
1962 | D3D += DP; | |
1963 | } | |
1964 | } | |
1965 | ||
1966 | DDU /= (Standard_Real) NbTestPnts + 1; | |
1967 | DDV /= (Standard_Real) NbTestPnts + 1; | |
191478a5 | 1968 | |
7fd59977 | 1969 | D3D /= (Standard_Real) NbTestPnts + 1; |
1970 | ||
1971 | ||
1972 | Standard_Integer Index1 = (IsFirst) ? 1 : (Line->NbPoints()); | |
1973 | Standard_Integer Index2 = (IsFirst) ? 2 : (Line->NbPoints()-1); | |
1974 | Standard_Integer Index3 = (IsFirst) ? 3 : (Line->NbPoints()-2); | |
1975 | ||
1976 | Standard_Boolean doU = Standard_False; | |
7fd59977 | 1977 | |
1978 | Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0., U3 = 0., V3 = 0.; | |
1979 | ||
1980 | if(IsReversed) { | |
1981 | Line->Value(Index1).ParametersOnS2(U1,V1); // S2 - quadric | |
1982 | Line->Value(Index2).ParametersOnS2(U2,V2); | |
1983 | Line->Value(Index3).ParametersOnS2(U3,V3); | |
1984 | } | |
1985 | else { | |
1986 | Line->Value(Index1).ParametersOnS1(U1,V1); // S1 - quadric | |
1987 | Line->Value(Index2).ParametersOnS1(U2,V2); | |
1988 | Line->Value(Index3).ParametersOnS1(U3,V3); | |
1989 | } | |
1990 | ||
1991 | if(!doU && Quad.TypeQuadric() == GeomAbs_Sphere) { | |
c6541a0c | 1992 | if(fabs(fabs(U1)-fabs(U2)) > (M_PI/16.)) doU = Standard_True; |
191478a5 | 1993 | |
c6541a0c D |
1994 | if(doU && (fabs(U1) <= 1.e-9 || fabs(U1-2.*M_PI) <= 1.e-9)) { |
1995 | if(fabs(V1-M_PI/2.) <= 1.e-9 || fabs(V1+M_PI/2.) <= 1.e-9) {} | |
7fd59977 | 1996 | else { |
191478a5 | 1997 | doU = Standard_False; |
7fd59977 | 1998 | } |
1999 | } | |
2000 | } | |
191478a5 | 2001 | |
7fd59977 | 2002 | if(Quad.TypeQuadric() == GeomAbs_Cone) { |
2003 | Standard_Real Uapx = 0., Vapx = 0.; | |
2004 | Quad.Parameters(Quad.Cone().Apex(),Uapx,Vapx); | |
2005 | ||
c6541a0c | 2006 | if(fabs(fabs(U1)-fabs(U2)) > M_PI/32.) doU = Standard_True; |
7fd59977 | 2007 | |
c6541a0c | 2008 | if(doU && (fabs(U1) <= 1.e-9 || fabs(U1-2.*M_PI) <= 1.e-9)) { |
7fd59977 | 2009 | if(fabs(V1-Vapx) <= 1.e-9) {} |
2010 | else { | |
191478a5 | 2011 | doU = Standard_False; |
7fd59977 | 2012 | } |
2013 | } | |
2014 | } | |
2015 | ||
7fd59977 | 2016 | if(doU) { |
2017 | Standard_Real dU = Min((DDU/10.),5.e-8); | |
2018 | Standard_Real U = (U2 > U3) ? (U2 + dU) : (U2 - dU); | |
2019 | if(IsReversed) | |
2020 | Line->SetUV(Index1,Standard_False,U,V1); | |
2021 | else | |
2022 | Line->SetUV(Index1,Standard_True,U,V1); | |
2023 | U1 = U; | |
2024 | } | |
2025 | } | |
2026 | ||
2027 | static Standard_Boolean TestMiddleOnPrm(const IntSurf_PntOn2S& aP, | |
d4b867e6 | 2028 | const IntSurf_PntOn2S& aV, |
2029 | const Standard_Boolean IsReversed, | |
2030 | const Standard_Real ArcTol, | |
2031 | const Handle(Adaptor3d_TopolTool)& PDomain) | |
191478a5 | 2032 | |
7fd59977 | 2033 | { |
2034 | Standard_Boolean result = Standard_False; | |
2035 | Standard_Real Up = 0., Vp = 0., Uv = 0., Vv = 0.; | |
2036 | if(IsReversed) { | |
2037 | aP.ParametersOnS1(Up,Vp); //S1 - parametric | |
2038 | aV.ParametersOnS1(Uv,Vv); | |
2039 | } | |
2040 | else { | |
2041 | aP.ParametersOnS2(Up,Vp); // S2 - parametric | |
2042 | aV.ParametersOnS2(Uv,Vv); | |
2043 | } | |
2044 | Standard_Real Um = (Up + Uv)*0.5, Vm = (Vp + Vv)*0.5; | |
2045 | gp_Pnt2d a2DPntM(Um,Vm); | |
2046 | TopAbs_State PosM = PDomain->Classify(a2DPntM,ArcTol); | |
2047 | if(PosM == TopAbs_ON || PosM == TopAbs_IN ) | |
2048 | result = Standard_True; | |
2049 | return result; | |
2050 | } | |
2051 | ||
191478a5 | 2052 | static void VerifyVertices( const Handle(IntSurf_LineOn2S)& Line, |
d4b867e6 | 2053 | const Standard_Boolean IsReversed, |
2054 | const Handle(IntSurf_LineOn2S)& Vertices, | |
2055 | const Standard_Real TOL2D, | |
2056 | const Standard_Real ArcTol, | |
2057 | const Handle(Adaptor3d_TopolTool)& PDomain, | |
2058 | IntSurf_PntOn2S& VrtF, | |
2059 | Standard_Boolean& AddFirst, | |
2060 | IntSurf_PntOn2S& VrtL, | |
2061 | Standard_Boolean& AddLast) | |
7fd59977 | 2062 | { |
2063 | Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints(); | |
2064 | Standard_Integer FIndexSame = 0, FIndexNear = 0, LIndexSame = 0, LIndexNear = 0; | |
2065 | const IntSurf_PntOn2S& aPF = Line->Value(1); | |
2066 | const IntSurf_PntOn2S& aPL = Line->Value(nbp); | |
2067 | Standard_Real UF = 0., VF = 0., UL = 0., VL = 0.; | |
2068 | if(IsReversed) { | |
2069 | aPF.ParametersOnS2(UF,VF); | |
2070 | aPL.ParametersOnS2(UL,VL); | |
2071 | } | |
2072 | else { | |
2073 | aPF.ParametersOnS1(UF,VF); | |
2074 | aPL.ParametersOnS1(UL,VL); | |
2075 | } | |
2076 | gp_Pnt2d a2DPF(UF,VF); | |
2077 | gp_Pnt2d a2DPL(UL,VL); | |
2078 | Standard_Real DistMinF = 1.e+100, DistMinL = 1.e+100; | |
2079 | Standard_Integer FConjugated = 0, LConjugated = 0; | |
2080 | ||
2081 | Standard_Integer iv = 0; | |
2082 | ||
2083 | for(iv = 1; iv <= nbv; iv++) { | |
2084 | Standard_Real Uv = 0., Vv = 0.; | |
2085 | if(IsReversed) { | |
2086 | Vertices->Value(iv).ParametersOnS2(Uv,Vv); | |
2087 | Uv = AdjustU(Uv); | |
2088 | Vertices->SetUV(iv,Standard_False,Uv,Vv); | |
2089 | } | |
2090 | else { | |
2091 | Vertices->Value(iv).ParametersOnS1(Uv,Vv); | |
2092 | Uv = AdjustU(Uv); | |
2093 | Vertices->SetUV(iv,Standard_True,Uv,Vv); | |
2094 | } | |
2095 | } | |
2096 | ||
2097 | for(iv = 1; iv <= nbv; iv++) { | |
2098 | const IntSurf_PntOn2S& aV = Vertices->Value(iv); | |
16423f20 | 2099 | if(aPF.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) { |
7fd59977 | 2100 | FIndexSame = iv; |
2101 | break; | |
2102 | } | |
2103 | else { | |
2104 | Standard_Real Uv = 0., Vv = 0.; | |
2105 | if(IsReversed) | |
2106 | aV.ParametersOnS2(Uv,Vv); | |
2107 | else | |
2108 | aV.ParametersOnS1(Uv,Vv); | |
2109 | gp_Pnt2d a2DV(Uv,Vv); | |
2110 | Standard_Real Dist = a2DV.Distance(a2DPF); | |
2111 | if(Dist < DistMinF) { | |
2112 | DistMinF = Dist; | |
2113 | FIndexNear = iv; | |
2114 | if(FConjugated != 0) | |
2115 | FConjugated = 0; | |
2116 | } | |
2117 | if(IsSeamParameter(Uv,TOL2D)) { | |
c6541a0c | 2118 | Standard_Real Ucv = (fabs(Uv) < fabs(2.*M_PI-Uv)) ? (2.*M_PI) : 0.; |
7fd59977 | 2119 | gp_Pnt2d a2DCV(Ucv,Vv); |
2120 | Standard_Real CDist = a2DCV.Distance(a2DPF); | |
2121 | if(CDist < DistMinF) { | |
2122 | DistMinF = CDist; | |
2123 | FConjugated = iv; | |
2124 | FIndexNear = iv; | |
2125 | } | |
2126 | } | |
2127 | } | |
2128 | } | |
2129 | ||
2130 | for(iv = 1; iv <= nbv; iv++) { | |
2131 | const IntSurf_PntOn2S& aV = Vertices->Value(iv); | |
16423f20 | 2132 | if(aPL.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) { |
7fd59977 | 2133 | LIndexSame = iv; |
2134 | break; | |
2135 | } | |
2136 | else { | |
2137 | Standard_Real Uv = 0., Vv = 0.; | |
2138 | if(IsReversed) | |
2139 | aV.ParametersOnS2(Uv,Vv); | |
2140 | else | |
2141 | aV.ParametersOnS1(Uv,Vv); | |
2142 | gp_Pnt2d a2DV(Uv,Vv); | |
2143 | Standard_Real Dist = a2DV.Distance(a2DPL); | |
2144 | if(Dist < DistMinL) { | |
2145 | DistMinL = Dist; | |
2146 | LIndexNear = iv; | |
2147 | if(LConjugated != 0) | |
2148 | LConjugated = 0; | |
2149 | } | |
2150 | if(IsSeamParameter(Uv,TOL2D)) { | |
c6541a0c | 2151 | Standard_Real Ucv = (fabs(Uv) < fabs(2.*M_PI-Uv)) ? (2.*M_PI) : 0.; |
7fd59977 | 2152 | gp_Pnt2d a2DCV(Ucv,Vv); |
2153 | Standard_Real CDist = a2DCV.Distance(a2DPL); | |
2154 | if(CDist < DistMinL) { | |
2155 | DistMinL = CDist; | |
2156 | LConjugated = iv; | |
2157 | LIndexNear = iv; | |
2158 | } | |
2159 | } | |
2160 | } | |
2161 | } | |
2162 | ||
2163 | AddFirst = Standard_False; | |
2164 | AddLast = Standard_False; | |
2165 | ||
2166 | if(FIndexSame == 0) { | |
2167 | if(FIndexNear != 0) { | |
2168 | const IntSurf_PntOn2S& aV = Vertices->Value(FIndexNear); | |
2169 | Standard_Real Uv = 0., Vv = 0.; | |
2170 | if(IsReversed) | |
2171 | aV.ParametersOnS2(Uv,Vv); | |
2172 | else | |
2173 | aV.ParametersOnS1(Uv,Vv); | |
2174 | if(IsSeamParameter(Uv,TOL2D)) { | |
c6541a0c | 2175 | Standard_Real Ucv = (fabs(Uv) < fabs(2.*M_PI-Uv)) ? (2.*M_PI) : 0.; |
7fd59977 | 2176 | Standard_Boolean test = TestMiddleOnPrm(aPF,aV,IsReversed,ArcTol,PDomain); |
2177 | if(test) { | |
2178 | VrtF.SetValue(aV.Value()); | |
2179 | if(IsReversed) { | |
2180 | Standard_Real U2 = 0., V2 = 0.; | |
2181 | aV.ParametersOnS1(U2,V2); // S1 - prm | |
2182 | VrtF.SetValue(Standard_True,U2,V2); | |
2183 | if(FConjugated == 0) | |
2184 | VrtF.SetValue(Standard_False,Uv,Vv); | |
2185 | else | |
2186 | VrtF.SetValue(Standard_False,Ucv,Vv); | |
2187 | } | |
2188 | else { | |
2189 | Standard_Real U2 = 0., V2 = 0.; | |
2190 | aV.ParametersOnS2(U2,V2); // S2 - prm | |
2191 | VrtF.SetValue(Standard_False,U2,V2); | |
2192 | if(FConjugated == 0) | |
2193 | VrtF.SetValue(Standard_True,Uv,Vv); | |
2194 | else | |
2195 | VrtF.SetValue(Standard_True,Ucv,Vv); | |
2196 | } | |
2197 | Standard_Real Dist3D = VrtF.Value().Distance(aPF.Value()); | |
2198 | if(Dist3D > 1.5e-7 && DistMinF > TOL2D) { | |
2199 | AddFirst = Standard_True; | |
2200 | } | |
2201 | } | |
2202 | } | |
2203 | else { | |
2204 | // to do: analyze internal vertex | |
2205 | } | |
2206 | } | |
2207 | } | |
191478a5 | 2208 | |
7fd59977 | 2209 | if(LIndexSame == 0) { |
2210 | if(LIndexNear != 0) { | |
2211 | const IntSurf_PntOn2S& aV = Vertices->Value(LIndexNear); | |
2212 | Standard_Real Uv = 0., Vv = 0.; | |
2213 | if(IsReversed) | |
2214 | aV.ParametersOnS2(Uv,Vv); | |
2215 | else | |
2216 | aV.ParametersOnS1(Uv,Vv); | |
2217 | if(IsSeamParameter(Uv,TOL2D)) { | |
c6541a0c | 2218 | Standard_Real Ucv = (fabs(Uv) < fabs(2.*M_PI-Uv)) ? (2.*M_PI) : 0.; |
7fd59977 | 2219 | Standard_Boolean test = TestMiddleOnPrm(aPL,aV,IsReversed,ArcTol,PDomain); |
2220 | if(test) { | |
2221 | VrtL.SetValue(aV.Value()); | |
2222 | if(IsReversed) { | |
2223 | Standard_Real U2 = 0., V2 = 0.; | |
2224 | aV.ParametersOnS1(U2,V2); // S1 - prm | |
2225 | VrtL.SetValue(Standard_True,U2,V2); | |
2226 | if(LConjugated == 0) | |
2227 | VrtL.SetValue(Standard_False,Uv,Vv); | |
2228 | else | |
2229 | VrtL.SetValue(Standard_False,Ucv,Vv); | |
2230 | } | |
2231 | else { | |
2232 | Standard_Real U2 = 0., V2 = 0.; | |
2233 | aV.ParametersOnS2(U2,V2); // S2 - prm | |
2234 | VrtL.SetValue(Standard_False,U2,V2); | |
2235 | if(LConjugated == 0) | |
2236 | VrtL.SetValue(Standard_True,Uv,Vv); | |
2237 | else | |
2238 | VrtL.SetValue(Standard_True,Ucv,Vv); | |
2239 | } | |
2240 | Standard_Real Dist3D = VrtL.Value().Distance(aPL.Value()); | |
2241 | if(Dist3D > 1.5e-7 && DistMinL > TOL2D) { | |
2242 | AddLast = Standard_True; | |
2243 | } | |
2244 | } | |
2245 | } | |
2246 | else { | |
2247 | // to do: analyze internal vertex | |
2248 | } | |
2249 | } | |
2250 | } | |
2251 | } | |
2252 | ||
2253 | static Standard_Boolean AddVertices(Handle(IntSurf_LineOn2S)& Line, | |
191478a5 | 2254 | const IntSurf_PntOn2S& VrtF, |
2255 | const Standard_Boolean AddFirst, | |
2256 | const IntSurf_PntOn2S& VrtL, | |
2257 | const Standard_Boolean AddLast, | |
2258 | const Standard_Real D3DF, | |
2259 | const Standard_Real D3DL) | |
7fd59977 | 2260 | { |
2261 | Standard_Boolean result = Standard_False; | |
2262 | if(AddFirst) { | |
2263 | Standard_Real DF = Line->Value(1).Value().Distance(VrtF.Value()); | |
2264 | if((D3DF*2.) > DF && DF > 1.5e-7) { | |
2265 | Line->InsertBefore(1,VrtF); | |
2266 | result = Standard_True; | |
2267 | } | |
2268 | } | |
2269 | if(AddLast) { | |
2270 | Standard_Real DL = Line->Value(Line->NbPoints()).Value().Distance(VrtL.Value()); | |
2271 | if((D3DL*2.) > DL && DL > 1.5e-7) { | |
2272 | Line->Add(VrtL); | |
2273 | result = Standard_True; | |
2274 | } | |
2275 | } | |
2276 | return result; | |
2277 | } | |
191478a5 | 2278 | |
7fd59977 | 2279 | |
16423f20 | 2280 | static void PutIntVertices(const Handle(IntPatch_PointLine)& Line, |
191478a5 | 2281 | Handle(IntSurf_LineOn2S)& Result, |
16423f20 | 2282 | Standard_Boolean theIsReversed, |
191478a5 | 2283 | Handle(IntSurf_LineOn2S)& Vertices, |
2284 | const Standard_Real ArcTol) | |
7fd59977 | 2285 | { |
2286 | Standard_Integer nbp = Result->NbPoints(), nbv = Vertices->NbPoints(); | |
2287 | ||
2288 | if(nbp < 3) | |
2289 | return; | |
2290 | ||
16423f20 | 2291 | const Handle(IntPatch_RLine) aRLine = Handle(IntPatch_RLine)::DownCast(Line); |
2292 | ||
7fd59977 | 2293 | Standard_Integer ip = 0, iv = 0; |
2294 | gp_Pnt aPnt; | |
2295 | IntPatch_Point thePnt; | |
2296 | Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.; | |
191478a5 | 2297 | |
7fd59977 | 2298 | for(ip = 2; ip <= (nbp-1); ip++) { |
2299 | const IntSurf_PntOn2S& aP = Result->Value(ip); | |
2300 | for(iv = 1; iv <= nbv; iv++) { | |
2301 | const IntSurf_PntOn2S& aV = Vertices->Value(iv); | |
16423f20 | 2302 | if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) { |
7fd59977 | 2303 | aPnt = Result->Value(ip).Value(); |
191478a5 | 2304 | Result->Value(ip).ParametersOnS1(U1,V1); |
2305 | Result->Value(ip).ParametersOnS2(U2,V2); | |
2306 | thePnt.SetValue(aPnt,ArcTol,Standard_False); | |
2307 | thePnt.SetParameters(U1,V1,U2,V2); | |
16423f20 | 2308 | |
2309 | Standard_Real aParam = (Standard_Real)ip; | |
2310 | ||
2311 | if(!aRLine.IsNull()) | |
2312 | { | |
2313 | //In fact, aRLine is always on the parametric surface. | |
2314 | //If (theIsReversed == TRUE) then (U1, V1) - point on | |
2315 | //parametric surface, otherwise - point on quadric. | |
2316 | const Handle(Adaptor2d_HCurve2d)& anArc = aRLine->IsArcOnS1() ? | |
2317 | aRLine->ArcOnS1() : | |
2318 | aRLine->ArcOnS2(); | |
2319 | ||
2320 | const gp_Lin2d aLin(anArc->Curve2d().Line()); | |
2321 | gp_Pnt2d aPSurf; | |
2322 | ||
2323 | if(theIsReversed) | |
2324 | { | |
2325 | aPSurf.SetCoord(U1, V1); | |
2326 | } | |
2327 | else | |
2328 | { | |
2329 | aPSurf.SetCoord(U2, V2); | |
2330 | } | |
2331 | ||
2332 | aParam = ElCLib::Parameter(aLin, aPSurf); | |
2333 | } | |
2334 | ||
2335 | thePnt.SetParameter(aParam); | |
2336 | Line->AddVertex(thePnt); | |
7fd59977 | 2337 | } |
2338 | } | |
2339 | } | |
2340 | } | |
2341 | ||
2342 | static Standard_Boolean HasInternals(Handle(IntSurf_LineOn2S)& Line, | |
191478a5 | 2343 | Handle(IntSurf_LineOn2S)& Vertices) |
7fd59977 | 2344 | { |
2345 | Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints(); | |
2346 | Standard_Integer ip = 0, iv = 0; | |
2347 | Standard_Boolean result = Standard_False; | |
191478a5 | 2348 | |
7fd59977 | 2349 | if(nbp < 3) |
2350 | return result; | |
2351 | ||
2352 | for(ip = 2; ip <= (nbp-1); ip++) { | |
2353 | const IntSurf_PntOn2S& aP = Line->Value(ip); | |
2354 | for(iv = 1; iv <= nbv; iv++) { | |
2355 | const IntSurf_PntOn2S& aV = Vertices->Value(iv); | |
16423f20 | 2356 | if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) { |
7fd59977 | 2357 | result = Standard_True; |
2358 | break; | |
2359 | } | |
2360 | } | |
2361 | if(result) | |
2362 | break; | |
2363 | } | |
191478a5 | 2364 | |
7fd59977 | 2365 | return result; |
2366 | } | |
2367 | static Handle(IntPatch_WLine) MakeSplitWLine (Handle(IntPatch_WLine)& WLine, | |
191478a5 | 2368 | Standard_Boolean Tang, |
2369 | IntSurf_TypeTrans Trans1, | |
2370 | IntSurf_TypeTrans Trans2, | |
2371 | Standard_Real ArcTol, | |
2372 | Standard_Integer ParFirst, | |
2373 | Standard_Integer ParLast) | |
7fd59977 | 2374 | { |
2375 | Handle(IntSurf_LineOn2S) SLine = WLine->Curve(); | |
2376 | Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S(); | |
191478a5 | 2377 | |
2378 | Standard_Integer ip = 0; | |
7fd59977 | 2379 | for(ip = ParFirst; ip <= ParLast; ip++) |
2380 | sline->Add(SLine->Value(ip)); | |
2381 | ||
2382 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(sline,Tang,Trans1,Trans2); | |
98974dcc | 2383 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLImpPrm); |
7fd59977 | 2384 | |
2385 | gp_Pnt aSPnt; | |
2386 | IntPatch_Point TPntF,TPntL; | |
2387 | Standard_Real uu1 = 0., vv1 = 0., uu2 = 0., vv2 = 0.; | |
2388 | ||
2389 | aSPnt = sline->Value(1).Value(); | |
2390 | sline->Value(1).ParametersOnS1(uu1,vv1); | |
2391 | sline->Value(1).ParametersOnS2(uu2,vv2); | |
2392 | TPntF.SetValue(aSPnt,ArcTol,Standard_False); | |
2393 | TPntF.SetParameters(uu1,vv1,uu2,vv2); | |
2394 | TPntF.SetParameter(1.); | |
2395 | wline->AddVertex(TPntF); | |
2396 | wline->SetFirstPoint(1); | |
191478a5 | 2397 | |
7fd59977 | 2398 | aSPnt = sline->Value(sline->NbPoints()).Value(); |
2399 | sline->Value(sline->NbPoints()).ParametersOnS1(uu1,vv1); | |
2400 | sline->Value(sline->NbPoints()).ParametersOnS2(uu2,vv2); | |
2401 | TPntL.SetValue(aSPnt,ArcTol,Standard_False); | |
2402 | TPntL.SetParameters(uu1,vv1,uu2,vv2); | |
2403 | TPntL.SetParameter((Standard_Real)sline->NbPoints()); | |
2404 | wline->AddVertex(TPntL); | |
a09c8f3a | 2405 | wline->SetLastPoint(wline->NbVertex()); |
7fd59977 | 2406 | |
2407 | return wline; | |
2408 | } | |
2409 | ||
2410 | static Standard_Boolean SplitOnSegments(Handle(IntPatch_WLine)& WLine, | |
191478a5 | 2411 | Standard_Boolean Tang, |
2412 | IntSurf_TypeTrans Trans1, | |
2413 | IntSurf_TypeTrans Trans2, | |
2414 | Standard_Real ArcTol, | |
2415 | IntPatch_SequenceOfLine& Segments) | |
7fd59977 | 2416 | { |
2417 | Standard_Boolean result = Standard_False; | |
2418 | Segments.Clear(); | |
2419 | ||
2420 | Standard_Integer nbv = WLine->NbVertex(); | |
2421 | if(nbv > 3) { | |
2422 | Standard_Integer iv = 0; | |
2423 | for(iv = 1; iv < nbv; iv++) { | |
191478a5 | 2424 | Standard_Integer firstPar = |
2425 | (Standard_Integer) WLine->Vertex(iv).ParameterOnLine(); | |
2426 | Standard_Integer lastPar = | |
2427 | (Standard_Integer) WLine->Vertex(iv+1).ParameterOnLine(); | |
7fd59977 | 2428 | if((lastPar - firstPar) <= 1) |
2429 | continue; | |
2430 | else { | |
191478a5 | 2431 | Handle(IntPatch_WLine) splitwline = MakeSplitWLine(WLine,Tang,Trans1,Trans2, |
2432 | ArcTol,firstPar,lastPar); | |
7fd59977 | 2433 | Segments.Append(splitwline); |
2434 | if(!result) | |
2435 | result = Standard_True; | |
2436 | } | |
2437 | } | |
2438 | } | |
2439 | return result; | |
2440 | } | |
2441 | ||
779d6bc6 | 2442 | //======================================================================= |
2443 | //function : IsPointOnBoundary | |
2444 | //purpose : Returns TRUE if point <theParam> matches <theBoundary +/- thePeriod> | |
2445 | // with given tolerance criterion. | |
2446 | // For not-periodic case, thePeriod must be equal to 0.0. | |
2447 | //======================================================================= | |
2448 | static Standard_Boolean IsPointOnBoundary(const Standard_Real theToler2D, | |
2449 | const Standard_Real theBoundary, | |
2450 | const Standard_Real thePeriod, | |
2451 | const Standard_Real theParam) | |
2452 | { | |
2453 | Standard_Real aDelta = Abs(theParam - theBoundary); | |
2454 | if (thePeriod != 0.0) | |
2455 | { | |
2456 | aDelta = fmod(aDelta, thePeriod); | |
2457 | ||
2458 | // 0 <= aDelta < thePeriod | |
2459 | return ((aDelta < theToler2D) || ((thePeriod - aDelta) < theToler2D)); | |
2460 | } | |
2461 | ||
2462 | // Here, thePeriod == 0.0, aDelta > 0.0 | |
2463 | ||
2464 | return (aDelta < theToler2D); | |
2465 | } | |
2466 | ||
2467 | //======================================================================= | |
2468 | //function : DetectOfBoundaryAchievement | |
2469 | //purpose : Can change values of theNewLine (by adding the computed point on boundary, | |
2470 | // which parameter will be adjusted) and theIsOnBoundary variables. | |
2471 | //======================================================================= | |
2472 | static void DetectOfBoundaryAchievement(const Handle(Adaptor3d_HSurface)& theQSurf, // quadric | |
2473 | const Standard_Boolean theIsReversed, | |
2474 | const Handle(IntSurf_LineOn2S)& theSourceLine, | |
2475 | const Standard_Integer thePointIndex, | |
2476 | const Standard_Real theToler2D, | |
2477 | Handle(IntSurf_LineOn2S)& theNewLine, | |
2478 | Standard_Boolean& theIsOnBoundary) | |
2479 | { | |
2480 | const Standard_Real aUPeriod = theQSurf->IsUPeriodic() ? theQSurf->UPeriod() : 0.0, | |
2481 | aVPeriod = theQSurf->IsVPeriodic() ? theQSurf->VPeriod() : 0.0; | |
2482 | const Standard_Real aUf = theQSurf->FirstUParameter(), | |
2483 | aUl = theQSurf->LastUParameter(), | |
2484 | aVf = theQSurf->FirstVParameter(), | |
2485 | aVl = theQSurf->LastVParameter(); | |
2486 | ||
2487 | const IntSurf_PntOn2S &aPPrev = theSourceLine->Value(thePointIndex - 1), | |
2488 | &aPCurr = theSourceLine->Value(thePointIndex); | |
2489 | Standard_Real aUPrev, aVPrev, aUCurr, aVCurr; | |
2490 | if (theIsReversed) | |
2491 | { | |
2492 | aPPrev.ParametersOnS2(aUPrev, aVPrev); // S2 - quadric, set U,V by Pnt3D | |
2493 | aPCurr.ParametersOnS2(aUCurr, aVCurr); // S2 - quadric, set U,V by Pnt3D | |
2494 | } | |
2495 | else | |
2496 | { | |
2497 | aPPrev.ParametersOnS1(aUPrev, aVPrev); // S1 - quadric, set U,V by Pnt3D | |
2498 | aPCurr.ParametersOnS1(aUCurr, aVCurr); // S1 - quadric, set U,V by Pnt3D | |
2499 | } | |
2500 | ||
2501 | // Ignore cases when the WLine goes along the surface boundary completely. | |
2502 | ||
2503 | if (IsPointOnBoundary(theToler2D, aUf, aUPeriod, aUCurr) && | |
2504 | !IsPointOnBoundary(theToler2D, aUf, aUPeriod, aUPrev)) | |
2505 | { | |
2506 | theIsOnBoundary = Standard_True; | |
2507 | } | |
2508 | else if (IsPointOnBoundary(theToler2D, aUl, aUPeriod, aUCurr) && | |
2509 | !IsPointOnBoundary(theToler2D, aUl, aUPeriod, aUPrev)) | |
2510 | { | |
2511 | theIsOnBoundary = Standard_True; | |
2512 | } | |
2513 | else if (IsPointOnBoundary(theToler2D, aVf, aVPeriod, aVCurr) && | |
2514 | !IsPointOnBoundary(theToler2D, aVf, aVPeriod, aVPrev)) | |
2515 | { | |
2516 | theIsOnBoundary = Standard_True; | |
2517 | } | |
2518 | else if (IsPointOnBoundary(theToler2D, aVl, aVPeriod, aVCurr) && | |
2519 | !IsPointOnBoundary(theToler2D, aVl, aVPeriod, aVPrev)) | |
2520 | { | |
2521 | theIsOnBoundary = Standard_True; | |
2522 | } | |
2523 | ||
2524 | if (theIsOnBoundary) | |
2525 | { | |
2526 | // Adjust, to avoid bad jumping of the WLine. | |
2527 | ||
2528 | const Standard_Real aDu = (aUPrev - aUCurr); | |
2529 | const Standard_Real aDv = (aVPrev - aVCurr); | |
2530 | if (aUPeriod > 0.0 && (2.0*Abs(aDu) > aUPeriod)) | |
2531 | { | |
2532 | aUCurr += Sign(aUPeriod, aDu); | |
2533 | } | |
2534 | ||
2535 | if (aVPeriod > 0.0 && (2.0*Abs(aDv) > aVPeriod)) | |
2536 | { | |
2537 | aVCurr += Sign(aVPeriod, aDv); | |
2538 | } | |
2539 | ||
2540 | IntSurf_PntOn2S aPoint = aPCurr; | |
2541 | aPoint.SetValue(!theIsReversed, aUCurr, aVCurr); | |
2542 | theNewLine->Add(aPoint); | |
2543 | } | |
2544 | } | |
4e14c88f | 2545 | //======================================================================= |
2546 | //function : DecomposeResult | |
2547 | //purpose : Split <theLine> in the places where it passes through seam edge | |
2548 | // or singularity (apex of cone or pole of sphere). | |
2549 | // This passage is detected by jump of U-parameter | |
2550 | // from point to point. | |
2551 | //======================================================================= | |
77dbd1f1 | 2552 | static Standard_Boolean DecomposeResult(const Handle(IntPatch_PointLine)& theLine, |
191478a5 | 2553 | const Standard_Boolean IsReversed, |
2554 | const IntSurf_Quadric& theQuad, | |
2555 | const Handle(Adaptor3d_TopolTool)& thePDomain, | |
4e14c88f | 2556 | const Handle(Adaptor3d_HSurface)& theQSurf, //quadric |
2557 | const Handle(Adaptor3d_HSurface)& thePSurf, //parametric | |
191478a5 | 2558 | const Standard_Real theArcTol, |
a09c8f3a | 2559 | const Standard_Real theTolTang, |
191478a5 | 2560 | IntPatch_SequenceOfLine& theLines) |
7fd59977 | 2561 | { |
77dbd1f1 | 2562 | if(theLine->ArcType() == IntPatch_Restriction) |
2563 | { | |
2564 | const Handle(IntPatch_RLine)& aRL = Handle(IntPatch_RLine)::DownCast(theLine); | |
2565 | if(!aRL.IsNull()) | |
2566 | { | |
2567 | const Handle(Adaptor2d_HCurve2d)& anArc = aRL->IsArcOnS1() ? | |
2568 | aRL->ArcOnS1() : | |
2569 | aRL->ArcOnS2(); | |
2570 | if(anArc->Curve2d().GetType() != GeomAbs_Line) | |
2571 | { | |
2572 | //Restriction line must be isoline. | |
2573 | //Other cases are not supported by | |
2574 | //existing algorithms. | |
2575 | ||
2576 | return Standard_False; | |
2577 | } | |
2578 | } | |
2579 | } | |
2580 | ||
4e14c88f | 2581 | const Standard_Real aDeltaUmax = M_PI_2; |
191478a5 | 2582 | const Standard_Real aTOL3D = 1.e-10, |
2583 | aTOL2D = Precision::PConfusion(), | |
2584 | aTOL2DS = Precision::PConfusion(); | |
7fd59977 | 2585 | |
77dbd1f1 | 2586 | const Handle(IntSurf_LineOn2S)& aSLine = theLine->Curve(); |
7fd59977 | 2587 | |
191478a5 | 2588 | if(aSLine->NbPoints() <= 2) |
2589 | { | |
2590 | return Standard_False; | |
2591 | } | |
2592 | ||
2593 | //Deletes repeated vertices | |
77dbd1f1 | 2594 | Handle(IntSurf_LineOn2S) aVLine = GetVertices(theLine,aTOL3D,aTOL2D); |
191478a5 | 2595 | |
2596 | Handle(IntSurf_LineOn2S) aSSLine(aSLine); | |
7fd59977 | 2597 | |
191478a5 | 2598 | if(aSSLine->NbPoints() <= 1) |
2599 | return Standard_False; | |
7fd59977 | 2600 | |
191478a5 | 2601 | AdjustLine(aSSLine,IsReversed,theQSurf,aTOL2D); |
7fd59977 | 2602 | |
77dbd1f1 | 2603 | if(theLine->ArcType() == IntPatch_Walking) |
191478a5 | 2604 | { |
2605 | Standard_Boolean isInserted = Standard_True; | |
2606 | while(isInserted) | |
2607 | { | |
2608 | const Standard_Integer aNbPnts = aSSLine->NbPoints(); | |
2609 | TColStd_Array1OfInteger aPTypes(1,aNbPnts); | |
2610 | SearchVertices(aSSLine,aVLine,aPTypes); | |
2611 | isInserted = InsertSeamVertices(aSSLine,IsReversed,aVLine,aPTypes,aTOL2D); | |
7fd59977 | 2612 | } |
7fd59977 | 2613 | } |
2614 | ||
191478a5 | 2615 | const Standard_Integer aLindex = aSSLine->NbPoints(); |
2616 | Standard_Integer aFindex = 1, aBindex = 0; | |
7fd59977 | 2617 | |
7fd59977 | 2618 | // build WLine parts (if any) |
191478a5 | 2619 | Standard_Boolean flNextLine = Standard_True; |
2620 | Standard_Boolean hasBeenDecomposed = Standard_False; | |
e2e0498b | 2621 | IntPatch_SpecPntType aPrePointExist = IntPatch_SPntNone; |
4e14c88f | 2622 | |
10ee9976 | 2623 | IntSurf_PntOn2S PrePoint; |
191478a5 | 2624 | while(flNextLine) |
2625 | { | |
2626 | // reset variables | |
2627 | flNextLine = Standard_False; | |
2628 | Standard_Boolean isDecomposited = Standard_False; | |
7fd59977 | 2629 | |
191478a5 | 2630 | Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S(); |
7fd59977 | 2631 | |
191478a5 | 2632 | //if((Lindex-Findex+1) <= 2 ) |
a09c8f3a | 2633 | if((aLindex <= aFindex) && !aPrePointExist) |
4e14c88f | 2634 | { |
2635 | //break of "while(flNextLine)" cycle | |
2636 | break; | |
2637 | } | |
10ee9976 | 2638 | |
a09c8f3a | 2639 | if(aPrePointExist) |
4e14c88f | 2640 | { |
4e14c88f | 2641 | const IntSurf_PntOn2S& aRefPt = aSSLine->Value(aFindex); |
2642 | ||
a09c8f3a | 2643 | const Standard_Real aURes = theQSurf->UResolution(theArcTol), |
e2e0498b | 2644 | aVRes = theQSurf->VResolution(theArcTol); |
4e14c88f | 2645 | |
e2e0498b | 2646 | const Standard_Real aTol2d = (aPrePointExist == IntPatch_SPntPole) ? -1.0 : |
2647 | (aPrePointExist == IntPatch_SPntSeamV)? aVRes : | |
2648 | (aPrePointExist == IntPatch_SPntSeamUV)? Max(aURes, aVRes) : aURes; | |
a09c8f3a | 2649 | |
e2e0498b | 2650 | if(IntPatch_SpecialPoints::ContinueAfterSpecialPoint(theQSurf, thePSurf, aRefPt, |
2651 | aPrePointExist, aTol2d, | |
2652 | PrePoint, IsReversed)) | |
4e14c88f | 2653 | { |
a09c8f3a | 2654 | sline->Add(PrePoint); |
3306fdd9 | 2655 | |
2656 | //Avoid adding duplicate points. | |
2657 | for (;aFindex <= aLindex; aFindex++) | |
2658 | { | |
2659 | if (!PrePoint.IsSame(aSSLine->Value(aFindex), theTolTang)) | |
2660 | { | |
2661 | break; | |
2662 | } | |
2663 | } | |
4e14c88f | 2664 | } |
2665 | else | |
2666 | { | |
2667 | //break of "while(flNextLine)" cycle | |
2668 | break; | |
2669 | } | |
2670 | } | |
2671 | ||
e2e0498b | 2672 | aPrePointExist = IntPatch_SPntNone; |
4e14c88f | 2673 | |
191478a5 | 2674 | // analyze other points |
2675 | for(Standard_Integer k = aFindex; k <= aLindex; k++) | |
2676 | { | |
2677 | if( k == aFindex ) | |
2678 | { | |
10ee9976 | 2679 | PrePoint = aSSLine->Value(k); |
a09c8f3a | 2680 | sline->Add(PrePoint); |
191478a5 | 2681 | continue; |
2682 | } | |
7fd59977 | 2683 | |
779d6bc6 | 2684 | //Check whether the current point is on the boundary of theQSurf. |
2685 | //If that is TRUE then the Walking-line will be decomposed in this point. | |
2686 | //However, this boundary is not singular-point (like seam or pole of sphere). | |
2687 | //Therefore, its processing will be simplified. | |
2688 | Standard_Boolean isOnBoundary = Standard_False; | |
2689 | ||
2690 | // Values of sline and isOnBoundary can be changed by this function | |
2691 | DetectOfBoundaryAchievement(theQSurf, IsReversed, aSSLine, | |
2692 | k, aTOL2D, sline, isOnBoundary); | |
2693 | ||
3306fdd9 | 2694 | aPrePointExist = IsSeamOrPole(theQSurf, aSSLine, IsReversed, |
2695 | k - 1, theTolTang, aDeltaUmax); | |
779d6bc6 | 2696 | |
2697 | if (isOnBoundary && (aPrePointExist != IntPatch_SPntPoleSeamU)) | |
191478a5 | 2698 | { |
779d6bc6 | 2699 | // If the considered point is on seam then its UV-parameters |
2700 | // are defined to within the surface period. Therefore, we can | |
2701 | // trust already computed parameters of this point. | |
2702 | // However, if this point (which is on the surface boundary) is | |
2703 | // a sphere pole or cone apex then its (point's) parameters | |
2704 | // have to be recomputed in the code below | |
2705 | // (see IntPatch_SpecialPoints::AddSingularPole() method). | |
2706 | // E.g. see "bugs modalg_6 bug26684_2" test case. | |
2707 | ||
2708 | aPrePointExist = IntPatch_SPntNone; | |
7fd59977 | 2709 | } |
7fd59977 | 2710 | |
779d6bc6 | 2711 | if (aPrePointExist != IntPatch_SPntNone) |
191478a5 | 2712 | { |
2713 | aBindex = k; | |
2714 | isDecomposited = Standard_True; | |
10ee9976 | 2715 | //// |
a09c8f3a | 2716 | const IntSurf_PntOn2S& aRefPt = aSSLine->Value(aBindex-1); |
2717 | ||
e2e0498b | 2718 | Standard_Real aCompareTol3D = Precision::Confusion(); |
2719 | Standard_Real aCompareTol2D = Precision::PConfusion(); | |
a09c8f3a | 2720 | |
e2e0498b | 2721 | IntSurf_PntOn2S aNewPoint = aRefPt; |
2722 | IntPatch_SpecPntType aLastType = IntPatch_SPntNone; | |
a09c8f3a | 2723 | |
e2e0498b | 2724 | if(aPrePointExist == IntPatch_SPntSeamUV) |
a09c8f3a | 2725 | { |
e2e0498b | 2726 | aPrePointExist = IntPatch_SPntNone; |
2727 | aLastType = IntPatch_SPntSeamUV; | |
2728 | IntPatch_SpecialPoints::AddCrossUVIsoPoint(theQSurf, thePSurf, | |
2729 | aRefPt, theTolTang, | |
2730 | aNewPoint, IsReversed); | |
2731 | } | |
2732 | else if(aPrePointExist == IntPatch_SPntSeamV) | |
2733 | {//WLine goes through seam | |
2734 | aPrePointExist = IntPatch_SPntNone; | |
2735 | aLastType = IntPatch_SPntSeamV; | |
a09c8f3a | 2736 | |
e2e0498b | 2737 | //Not quadric point |
2738 | Standard_Real aU0 = 0.0, aV0 = 0.0; | |
2739 | //Quadric point | |
2740 | Standard_Real aUQuadRef = 0.0, aVQuadRef = 0.0; | |
a09c8f3a | 2741 | |
e2e0498b | 2742 | if(IsReversed) |
10ee9976 | 2743 | { |
e2e0498b | 2744 | aRefPt.Parameters(aU0, aV0, aUQuadRef, aVQuadRef); |
10ee9976 | 2745 | } |
e2e0498b | 2746 | else |
10ee9976 | 2747 | { |
e2e0498b | 2748 | aRefPt.Parameters(aUQuadRef, aVQuadRef, aU0, aV0); |
10ee9976 | 2749 | } |
a09c8f3a | 2750 | |
bf714c84 | 2751 | math_Vector aTol(1, 3), aStartPoint(1,3), |
e2e0498b | 2752 | anInfBound(1, 3), aSupBound(1, 3); |
2753 | ||
a09c8f3a | 2754 | //Parameters on parametric surface |
779d6bc6 | 2755 | Standard_Real aUp = 0.0, aVp = 0.0, aUq = 0.0, aVq = 0.0; |
a09c8f3a | 2756 | if(IsReversed) |
10ee9976 | 2757 | { |
779d6bc6 | 2758 | aSSLine->Value(k).Parameters(aUp, aVp, aUq, aVq); |
10ee9976 | 2759 | } |
2760 | else | |
2761 | { | |
779d6bc6 | 2762 | aSSLine->Value(k).Parameters(aUq, aVq, aUp, aVp); |
10ee9976 | 2763 | } |
a09c8f3a | 2764 | |
2765 | aTol(1) = thePSurf->UResolution(theArcTol); | |
2766 | aTol(2) = thePSurf->VResolution(theArcTol); | |
2767 | aTol(3) = theQSurf->UResolution(theArcTol); | |
2768 | aStartPoint(1) = 0.5*(aU0 + aUp); | |
2769 | aStartPoint(2) = 0.5*(aV0 + aVp); | |
779d6bc6 | 2770 | aStartPoint(3) = 0.5*(aUQuadRef + aUq); |
bf714c84 | 2771 | anInfBound(1) = thePSurf->FirstUParameter(); |
2772 | anInfBound(2) = thePSurf->FirstVParameter(); | |
2773 | anInfBound(3) = theQSurf->FirstUParameter(); | |
2774 | aSupBound(1) = thePSurf->LastUParameter(); | |
2775 | aSupBound(2) = thePSurf->LastVParameter(); | |
2776 | aSupBound(3) = theQSurf->LastUParameter(); | |
a09c8f3a | 2777 | |
e2e0498b | 2778 | IntPatch_SpecialPoints:: |
3306fdd9 | 2779 | AddPointOnUorVIso(theQSurf, thePSurf, aRefPt, Standard_False, 0.0, |
e2e0498b | 2780 | aTol, aStartPoint, anInfBound, aSupBound, |
2781 | aNewPoint, IsReversed); | |
2782 | } | |
2783 | else if(aPrePointExist == IntPatch_SPntPoleSeamU) | |
2784 | { | |
779d6bc6 | 2785 | aPrePointExist = IntPatch_SPntNone; |
a09c8f3a | 2786 | |
e2e0498b | 2787 | IntPatch_Point aVert; |
2788 | aVert.SetValue(aRefPt); | |
3306fdd9 | 2789 | aVert.SetTolerance(theTolTang); |
a09c8f3a | 2790 | |
e2e0498b | 2791 | if(IntPatch_SpecialPoints:: |
3306fdd9 | 2792 | AddSingularPole(theQSurf, thePSurf, aRefPt, |
e2e0498b | 2793 | aVert, aNewPoint, IsReversed)) |
4e14c88f | 2794 | { |
e2e0498b | 2795 | aPrePointExist = IntPatch_SPntPole; |
2796 | aLastType = IntPatch_SPntPole; | |
779d6bc6 | 2797 | if (isOnBoundary) |
2798 | { | |
2799 | // It is necessary to replace earlier added point on | |
2800 | // the surface boundary with the pole. For that, | |
2801 | // here we delete excess point. New point will be added later. | |
2802 | isOnBoundary = Standard_False; | |
2803 | sline->RemovePoint(sline->NbPoints()); | |
2804 | } | |
2805 | ||
e2e0498b | 2806 | aCompareTol2D = -1.0; |
2807 | } //if(IntPatch_AddSpecialPoints::AddSingularPole(...)) | |
a09c8f3a | 2808 | else |
e2e0498b | 2809 | {//Pole is not an intersection point |
2810 | aPrePointExist = IntPatch_SPntSeamU; | |
a09c8f3a | 2811 | } |
2812 | } | |
4e14c88f | 2813 | |
e2e0498b | 2814 | if(aPrePointExist == IntPatch_SPntSeamU) |
2815 | {//WLine goes through seam | |
2816 | aPrePointExist = IntPatch_SPntNone; | |
2817 | aLastType = IntPatch_SPntSeamU; | |
4e14c88f | 2818 | |
e2e0498b | 2819 | //Not quadric point |
2820 | Standard_Real aU0 = 0.0, aV0 = 0.0; | |
2821 | //Quadric point | |
2822 | Standard_Real aUQuadRef = 0.0, aVQuadRef = 0.0; | |
4e14c88f | 2823 | |
e2e0498b | 2824 | if(IsReversed) |
a09c8f3a | 2825 | { |
e2e0498b | 2826 | aRefPt.Parameters(aU0, aV0, aUQuadRef, aVQuadRef); |
a09c8f3a | 2827 | } |
a09c8f3a | 2828 | else |
e2e0498b | 2829 | { |
2830 | aRefPt.Parameters(aUQuadRef, aVQuadRef, aU0, aV0); | |
a09c8f3a | 2831 | } |
a09c8f3a | 2832 | |
bf714c84 | 2833 | math_Vector aTol(1, 3), aStartPoint(1,3), |
2834 | anInfBound(1, 3), aSupBound(1, 3); | |
a09c8f3a | 2835 | |
2836 | //Parameters on parametric surface | |
779d6bc6 | 2837 | Standard_Real aUp = 0.0, aVp = 0.0, aUq = 0.0, aVq = 0.0; |
2838 | if (IsReversed) | |
a09c8f3a | 2839 | { |
779d6bc6 | 2840 | aSSLine->Value(k).Parameters(aUp, aVp, aUq, aVq); |
a09c8f3a | 2841 | } |
2842 | else | |
2843 | { | |
779d6bc6 | 2844 | aSSLine->Value(k).Parameters(aUq, aVq, aUp, aVp); |
a09c8f3a | 2845 | } |
2846 | ||
2847 | aTol(1) = thePSurf->UResolution(theArcTol); | |
2848 | aTol(2) = thePSurf->VResolution(theArcTol); | |
2849 | aTol(3) = theQSurf->VResolution(theArcTol); | |
2850 | aStartPoint(1) = 0.5*(aU0 + aUp); | |
2851 | aStartPoint(2) = 0.5*(aV0 + aVp); | |
779d6bc6 | 2852 | aStartPoint(3) = 0.5*(aVQuadRef + aVq); |
bf714c84 | 2853 | anInfBound(1) = thePSurf->FirstUParameter(); |
2854 | anInfBound(2) = thePSurf->FirstVParameter(); | |
2855 | anInfBound(3) = theQSurf->FirstVParameter(); | |
2856 | aSupBound(1) = thePSurf->LastUParameter(); | |
2857 | aSupBound(2) = thePSurf->LastVParameter(); | |
2858 | aSupBound(3) = theQSurf->LastVParameter(); | |
a09c8f3a | 2859 | |
e2e0498b | 2860 | IntPatch_SpecialPoints:: |
3306fdd9 | 2861 | AddPointOnUorVIso(theQSurf, thePSurf, aRefPt, Standard_True, 0.0, aTol, |
e2e0498b | 2862 | aStartPoint, anInfBound, aSupBound, aNewPoint, |
2863 | IsReversed); | |
2864 | } | |
a09c8f3a | 2865 | |
e2e0498b | 2866 | if(!aNewPoint.IsSame(aRefPt, aCompareTol3D, aCompareTol2D)) |
2867 | { | |
779d6bc6 | 2868 | if (isOnBoundary) |
2869 | break; | |
2870 | ||
e2e0498b | 2871 | sline->Add(aNewPoint); |
2872 | aPrePointExist = aLastType; | |
2873 | PrePoint = aNewPoint; | |
2874 | } | |
2875 | else | |
2876 | { | |
779d6bc6 | 2877 | if (isOnBoundary || (sline->NbPoints() == 1)) |
a09c8f3a | 2878 | { |
e2e0498b | 2879 | //FIRST point of the sline is the pole of the quadric. |
2880 | //Therefore, there is no point in decomposition. | |
a09c8f3a | 2881 | |
779d6bc6 | 2882 | // If the considered point is on surface boundary then |
2883 | // it is already marked as vertex. So, decomposition is | |
2884 | // not required, too. | |
2885 | ||
e2e0498b | 2886 | PrePoint = aRefPt; |
779d6bc6 | 2887 | aPrePointExist = isOnBoundary ? IntPatch_SPntNone : aLastType; |
a09c8f3a | 2888 | } |
4e14c88f | 2889 | } |
2890 | ||
10ee9976 | 2891 | //// |
191478a5 | 2892 | break; |
779d6bc6 | 2893 | } //if (aPrePointExist != IntPatch_SPntNone) cond. |
7fd59977 | 2894 | |
10ee9976 | 2895 | PrePoint = aSSLine->Value(k); |
779d6bc6 | 2896 | |
2897 | if (isOnBoundary) | |
2898 | { | |
2899 | aBindex = k; | |
2900 | isDecomposited = Standard_True; | |
2901 | aPrePointExist = IntPatch_SPntNone; | |
2902 | break; | |
2903 | } | |
2904 | else | |
2905 | { | |
2906 | sline->Add(aSSLine->Value(k)); | |
2907 | } | |
77dbd1f1 | 2908 | } //for(Standard_Integer k = aFindex; k <= aLindex; k++) |
2909 | ||
2910 | //Creation of new line as part of existing theLine. | |
2911 | //This part is defined by sline. | |
2912 | ||
2913 | if(sline->NbPoints() == 1) | |
2914 | { | |
2915 | flNextLine = Standard_True; | |
3306fdd9 | 2916 | |
2917 | if (aFindex < aBindex) | |
2918 | aFindex = aBindex; | |
77dbd1f1 | 2919 | |
2920 | //Go to the next part of aSSLine | |
2921 | //because we cannot create the line | |
2922 | //with single point. | |
2923 | ||
2924 | continue; | |
7fd59977 | 2925 | } |
7fd59977 | 2926 | |
191478a5 | 2927 | IntSurf_PntOn2S aVF, aVL; |
2928 | Standard_Boolean addVF = Standard_False, addVL = Standard_False; | |
2929 | VerifyVertices(sline,IsReversed,aVLine,aTOL2DS,theArcTol, | |
2930 | thePDomain,aVF,addVF,aVL,addVL); | |
2931 | ||
2932 | Standard_Boolean hasInternals = HasInternals(sline,aVLine); | |
2933 | ||
2934 | Standard_Real D3F = 0., D3L = 0.; | |
2935 | ToSmooth(sline,IsReversed,theQuad,Standard_True,D3F); | |
2936 | ToSmooth(sline,IsReversed,theQuad,Standard_False,D3L); | |
2937 | ||
2938 | //if(D3F <= 1.5e-7 && sline->NbPoints() >=3) { | |
2939 | // D3F = sline->Value(2).Value().Distance(sline->Value(3).Value()); | |
2940 | //} | |
2941 | //if(D3L <= 1.5e-7 && sline->NbPoints() >=3) { | |
2942 | // D3L = sline->Value(sline->NbPoints()-1).Value().Distance(sline-> | |
2943 | // Value(sline->NbPoints()-2).Value()); | |
2944 | //} | |
2945 | ||
2946 | if(addVF || addVL) | |
2947 | { | |
2948 | Standard_Boolean isAdded = AddVertices(sline,aVF,addVF,aVL,addVL,D3F,D3L); | |
2949 | if(isAdded) | |
2950 | { | |
2951 | ToSmooth(sline,IsReversed,theQuad,Standard_True,D3F); | |
2952 | ToSmooth(sline,IsReversed,theQuad,Standard_False,D3L); | |
2953 | } | |
7fd59977 | 2954 | } |
7fd59977 | 2955 | |
77dbd1f1 | 2956 | if(theLine->ArcType() == IntPatch_Walking) |
191478a5 | 2957 | { |
77dbd1f1 | 2958 | IntPatch_Point aTPntF, aTPntL; |
2959 | ||
2960 | Handle(IntPatch_WLine) wline = | |
2961 | new IntPatch_WLine(sline,Standard_False, | |
2962 | theLine->TransitionOnS1(),theLine->TransitionOnS2()); | |
98974dcc | 2963 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLImpPrm); |
77dbd1f1 | 2964 | |
779d6bc6 | 2965 | Standard_Real aU1 = 0.0, aV1 = 0.0, aU2 = 0.0, aV2 = 0.0; |
77dbd1f1 | 2966 | gp_Pnt aSPnt(sline->Value(1).Value()); |
779d6bc6 | 2967 | sline->Value(1).Parameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 2968 | aTPntF.SetValue(aSPnt,theArcTol,Standard_False); |
779d6bc6 | 2969 | aTPntF.SetParameters(aU1, aV1, aU2, aV2); |
2970 | aTPntF.SetParameter(1.0); | |
77dbd1f1 | 2971 | wline->AddVertex(aTPntF); |
2972 | wline->SetFirstPoint(1); | |
2973 | ||
2974 | if(hasInternals) | |
2975 | { | |
2976 | PutIntVertices(wline,sline,IsReversed,aVLine,theArcTol); | |
2977 | } | |
7fd59977 | 2978 | |
77dbd1f1 | 2979 | aSPnt = sline->Value(sline->NbPoints()).Value(); |
779d6bc6 | 2980 | sline->Value(sline->NbPoints()).Parameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 2981 | aTPntL.SetValue(aSPnt,theArcTol,Standard_False); |
779d6bc6 | 2982 | aTPntL.SetParameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 2983 | aTPntL.SetParameter(sline->NbPoints()); |
2984 | wline->AddVertex(aTPntL); | |
a09c8f3a | 2985 | wline->SetLastPoint(wline->NbVertex()); |
191478a5 | 2986 | |
77dbd1f1 | 2987 | IntPatch_SequenceOfLine segm; |
2988 | Standard_Boolean isSplited = SplitOnSegments(wline,Standard_False, | |
2989 | theLine->TransitionOnS1(),theLine->TransitionOnS2(),theArcTol,segm); | |
191478a5 | 2990 | |
77dbd1f1 | 2991 | if(!isSplited) |
2992 | { | |
2993 | theLines.Append(wline); | |
2994 | } | |
2995 | else | |
2996 | { | |
2997 | Standard_Integer nbsegms = segm.Length(); | |
2998 | Standard_Integer iseg = 0; | |
2999 | for(iseg = 1; iseg <= nbsegms; iseg++) | |
3000 | theLines.Append(segm(iseg)); | |
3001 | } | |
191478a5 | 3002 | } |
3003 | else | |
77dbd1f1 | 3004 | {//theLine->ArcType() == IntPatch_Restriction |
3005 | if(!isDecomposited && !hasBeenDecomposed) | |
3006 | { | |
3007 | //The line has not been changed | |
3008 | theLines.Append(Handle(IntPatch_RLine)::DownCast(theLine)); | |
3009 | return hasBeenDecomposed; | |
3010 | } | |
3011 | ||
3012 | IntPatch_Point aTPnt; | |
3013 | gp_Pnt2d aPSurf; | |
3014 | gp_Pnt aSPnt; | |
3015 | ||
3016 | Handle(IntPatch_RLine) aRLine = new IntPatch_RLine(*Handle(IntPatch_RLine)::DownCast(theLine)); | |
3017 | ||
3018 | aRLine->ClearVertexes(); | |
3019 | aRLine->SetCurve(sline); | |
3020 | ||
3021 | if(hasInternals) | |
3022 | { | |
3023 | PutIntVertices(aRLine,sline,IsReversed,aVLine,theArcTol); | |
3024 | } | |
3025 | ||
3026 | const Handle(Adaptor2d_HCurve2d)& anArc = aRLine->IsArcOnS1() ? | |
3027 | aRLine->ArcOnS1() : | |
3028 | aRLine->ArcOnS2(); | |
3029 | ||
3030 | Standard_Real aFPar = anArc->FirstParameter(), | |
3031 | aLPar = anArc->LastParameter(); | |
3032 | ||
3033 | const IntSurf_PntOn2S &aRFirst = sline->Value(1), | |
3034 | &aRLast = sline->Value(sline->NbPoints()); | |
3035 | ||
3036 | const gp_Lin2d aLin(anArc->Curve2d().Line()); | |
3037 | ||
3038 | for(Standard_Integer aFLIndex = 0; aFLIndex < 2; aFLIndex++) | |
3039 | { | |
779d6bc6 | 3040 | Standard_Real aU1 = 0.0, aV1 = 0.0, aU2 = 0.0, aV2 = 0.0; |
77dbd1f1 | 3041 | if(aFLIndex == 0) |
3042 | { | |
779d6bc6 | 3043 | aRFirst.Parameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 3044 | aSPnt.SetXYZ(aRFirst.Value().XYZ()); |
3045 | } | |
3046 | else | |
3047 | { | |
779d6bc6 | 3048 | aRLast.Parameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 3049 | aSPnt.SetXYZ(aRLast.Value().XYZ()); |
3050 | } | |
3051 | ||
3052 | if(IsReversed) | |
3053 | { | |
779d6bc6 | 3054 | aPSurf.SetCoord(aU1, aV1); |
77dbd1f1 | 3055 | } |
3056 | else | |
3057 | { | |
779d6bc6 | 3058 | aPSurf.SetCoord(aU2, aV2); |
77dbd1f1 | 3059 | } |
3060 | ||
3061 | Standard_Real aPar = ElCLib::Parameter(aLin, aPSurf); | |
3062 | ||
3063 | if(aFLIndex == 0) | |
3064 | { | |
3065 | aFPar = Max(aFPar, aPar); | |
3066 | aPar = aFPar; | |
3067 | } | |
3068 | else | |
3069 | { | |
3070 | aLPar = Min(aLPar, aPar); | |
3071 | aPar = aLPar; | |
3072 | } | |
3073 | ||
3074 | aTPnt.SetParameter(aPar); | |
3075 | aTPnt.SetValue(aSPnt,theArcTol,Standard_False); | |
779d6bc6 | 3076 | aTPnt.SetParameters(aU1, aV1, aU2, aV2); |
77dbd1f1 | 3077 | |
3078 | aRLine->AddVertex(aTPnt); | |
3079 | } | |
3080 | ||
a09c8f3a | 3081 | if(aLPar - aFPar > Precision::PConfusion()) |
3082 | { | |
3083 | aRLine->SetFirstPoint(1); | |
3084 | aRLine->SetLastPoint(aRLine->NbVertex()); | |
77dbd1f1 | 3085 | |
a09c8f3a | 3086 | anArc->Trim(aFPar, aLPar, theArcTol); |
77dbd1f1 | 3087 | |
a09c8f3a | 3088 | theLines.Append(aRLine); |
3089 | } | |
191478a5 | 3090 | } |
7fd59977 | 3091 | |
191478a5 | 3092 | if(isDecomposited) |
3093 | { | |
3094 | aFindex = aBindex; | |
3095 | flNextLine = hasBeenDecomposed = Standard_True; | |
3096 | } | |
7fd59977 | 3097 | } |
3098 | ||
191478a5 | 3099 | return hasBeenDecomposed; |
7fd59977 | 3100 | } |
d4b867e6 | 3101 | |
77dbd1f1 | 3102 | //======================================================================= |
3103 | //function : CheckSegmSegm | |
3104 | //purpose : Returns TRUE if the segment [theParF, theParL] is included | |
3105 | // in the segment [theRefParF, theRefParL] segment. | |
3106 | //======================================================================= | |
3107 | static Standard_Boolean CheckSegmSegm(const Standard_Real theRefParF, | |
3108 | const Standard_Real theRefParL, | |
3109 | const Standard_Real theParF, | |
3110 | const Standard_Real theParL) | |
191478a5 | 3111 | { |
77dbd1f1 | 3112 | if((theParF < theRefParF) || (theParF > theRefParL)) |
3113 | { | |
3114 | return Standard_False; | |
3115 | } | |
d4b867e6 | 3116 | |
77dbd1f1 | 3117 | if((theParL < theRefParF) || (theParL > theRefParL)) |
3118 | { | |
3119 | return Standard_False; | |
3120 | } | |
d4b867e6 | 3121 | |
77dbd1f1 | 3122 | return Standard_True; |
3123 | } | |
3124 | ||
3125 | //======================================================================= | |
3126 | //function : IsCoincide | |
3127 | //purpose : Check, if theLine is coincided with theArc (in 2d-space). | |
3128 | // | |
3129 | // Attention!!! | |
3130 | // Cases when theArc is not 2d-line adaptor are suppored by | |
3131 | // TopOpeBRep classes only (i.e. are archaic). | |
3132 | //======================================================================= | |
3133 | Standard_Boolean IsCoincide(IntPatch_TheSurfFunction& theFunc, | |
3134 | const Handle(IntPatch_PointLine)& theLine, | |
3135 | const Handle(Adaptor2d_HCurve2d)& theArc, | |
3136 | const Standard_Boolean isTheSurface1Using, //Surf1 is parametric? | |
3137 | const Standard_Real theToler3D, | |
3138 | const Standard_Real theToler2D, | |
3139 | const Standard_Real thePeriod) // Period of parametric surface in direction which is perpendicular to theArc direction. | |
3140 | { | |
3141 | if(theLine->ArcType() == IntPatch_Restriction) | |
3142 | {//Restriction-restriction processing | |
3143 | const Handle(IntPatch_RLine)& aRL2 = Handle(IntPatch_RLine)::DownCast(theLine); | |
3144 | const Handle(Adaptor2d_HCurve2d)& anArc = aRL2->IsArcOnS1() ? aRL2->ArcOnS1() : aRL2->ArcOnS2(); | |
3145 | ||
3146 | if(anArc->Curve2d().GetType() != GeomAbs_Line) | |
3147 | { | |
3148 | //Restriction line must be isoline. | |
3149 | //Other cases are not supported by | |
3150 | //existing algorithms. | |
3151 | ||
3152 | return Standard_False; | |
3153 | } | |
3154 | ||
3155 | const gp_Lin2d aLin1(theArc->Curve2d().Line()), | |
3156 | aLin2(anArc->Curve2d().Line()); | |
3157 | ||
3158 | if(!aLin1.Direction().IsParallel(aLin2.Direction(), Precision::Angular())) | |
3159 | { | |
3160 | return Standard_False; | |
3161 | } | |
3162 | ||
3163 | const Standard_Real aDist = | |
3164 | theArc->Curve2d().Line().Distance(anArc->Curve2d().Line()); | |
3165 | if((aDist < theToler2D) || (Abs(aDist - thePeriod) < theToler2D)) | |
3166 | { | |
3167 | const Standard_Real aRf = theArc->FirstParameter(), | |
3168 | aRl = theArc->LastParameter(); | |
3169 | const Standard_Real aParf = anArc->FirstParameter(), | |
3170 | aParl = anArc->LastParameter(); | |
3171 | const gp_Pnt2d aP1(ElCLib::Value(aParf, aLin2)), | |
3172 | aP2(ElCLib::Value(aParl, aLin2)); | |
3173 | ||
3174 | Standard_Real aParam1 = ElCLib::Parameter(aLin1, aP1), | |
3175 | aParam2 = ElCLib::Parameter(aLin1, aP2); | |
3176 | ||
3177 | if(CheckSegmSegm(aRf, aRl, aParam1, aParam2)) | |
3178 | return Standard_True; | |
3179 | ||
3180 | //Lines are parallel. Therefore, there is no point in | |
3181 | //projecting points to another line in order to check | |
3182 | //if segment second line is included in segment of first one. | |
3183 | ||
3184 | return CheckSegmSegm(aParam1, aParam2, aRf, aRl); | |
3185 | } | |
3186 | ||
3187 | return Standard_False; | |
3188 | } | |
3189 | ||
3190 | const Standard_Integer aNbPnts = theLine->NbPnts(); | |
3191 | const Standard_Real aUAf = theArc->FirstParameter(), | |
3192 | aUAl = theArc->LastParameter(); | |
3193 | const gp_Lin2d anArcLin(theArc->Curve2d().Line()); | |
3194 | ||
3195 | math_Vector aX(1, 2), aVal(1, 1); | |
d4b867e6 | 3196 | |
3197 | for(Standard_Integer aPtID = 1; aPtID <= aNbPnts; aPtID++) | |
3198 | { | |
77dbd1f1 | 3199 | Standard_Real aUf = 0.0, aVf = 0.0; |
d4b867e6 | 3200 | if(isTheSurface1Using) |
77dbd1f1 | 3201 | theLine->Point(aPtID).ParametersOnS1(aUf, aVf); |
d4b867e6 | 3202 | else |
77dbd1f1 | 3203 | theLine->Point(aPtID).ParametersOnS2(aUf, aVf); |
3204 | ||
3205 | //Take 2d-point in parametric surface (because theArc is | |
3206 | //2d-line in parametric surface). | |
3207 | const gp_Pnt2d aPloc(aUf, aVf); | |
3208 | ||
3209 | const Standard_Real aRParam = ElCLib::Parameter(anArcLin, aPloc); | |
d4b867e6 | 3210 | |
77dbd1f1 | 3211 | if((aRParam < aUAf) || (aRParam > aUAl)) |
3212 | return Standard_False; | |
3213 | ||
3214 | const gp_Pnt2d aPmin(ElCLib::Value(aRParam, anArcLin)); | |
3215 | ||
3216 | const Standard_Real aDist = aPloc.Distance(aPmin); | |
3217 | if((aDist < theToler2D) || (Abs(aDist - thePeriod) < theToler2D)) | |
3218 | {//Considered point is in Restriction line. | |
3219 | //Go to the next point. | |
d4b867e6 | 3220 | continue; |
77dbd1f1 | 3221 | } |
3222 | ||
3223 | //Check if intermediate points between aPloc and theArc are | |
3224 | //intersection point (i.e. if aPloc is in tangent zone between | |
3225 | //two intersected surfaces). | |
3226 | ||
3227 | const Standard_Real aUl = aPmin.X(), aVl = aPmin.Y(); | |
d4b867e6 | 3228 | |
77dbd1f1 | 3229 | const Standard_Integer aNbPoints = 4; |
3230 | const Standard_Real aStepU = (aUl - aUf)/aNbPoints, | |
3231 | aStepV = (aVl - aVf)/aNbPoints; | |
d4b867e6 | 3232 | |
77dbd1f1 | 3233 | Standard_Real aU = aUf+aStepU, aV = aVf+aStepV; |
3234 | for(Standard_Integer i = 1; i < aNbPoints; i++) | |
d4b867e6 | 3235 | { |
77dbd1f1 | 3236 | aX.Value(1) = aU; |
3237 | aX.Value(2) = aV; | |
3238 | ||
3239 | if(!theFunc.Value(aX, aVal)) | |
d4b867e6 | 3240 | { |
77dbd1f1 | 3241 | return Standard_False; |
d4b867e6 | 3242 | } |
3243 | ||
77dbd1f1 | 3244 | if(Abs(aVal(1)) > theToler3D) |
d4b867e6 | 3245 | { |
77dbd1f1 | 3246 | return Standard_False; |
d4b867e6 | 3247 | } |
77dbd1f1 | 3248 | |
3249 | aU += aStepU; | |
3250 | aV += aStepV; | |
d4b867e6 | 3251 | } |
d4b867e6 | 3252 | } |
77dbd1f1 | 3253 | |
d4b867e6 | 3254 | return Standard_True; |
77dbd1f1 | 3255 | } |