0024058: Eliminate compiler warning C4702 in MSVC++ with warning level 4
[occt.git] / src / IntPatch / IntPatch_LineConstructor.cxx
CommitLineData
b311480e 1// Created on: 1996-11-07
2// Created by: Laurent BUCHARD
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <IntPatch_LineConstructor.ixx>
23
24#include <IntPatch_GLine.hxx>
25#include <IntPatch_ALine.hxx>
26#include <IntPatch_WLine.hxx>
27#include <IntPatch_RLine.hxx>
28#include <Adaptor2d_HCurve2d.hxx>
29
30#define XPU1009 1
31
32#include <gp_Pnt.hxx>
33#include <gp_Vec.hxx>
34#include <IntSurf_Quadric.hxx>
35#include <IntSurf_PntOn2S.hxx>
36#include <Standard_ConstructionError.hxx>
37#include <GeomAbs_SurfaceType.hxx>
38#include <ElCLib.hxx>
39#include <Geom2dInt_TheProjPCurOfGInter.hxx>
40#include <TColStd_SequenceOfInteger.hxx>
41#include <TColStd_IndexedMapOfTransient.hxx>
42#include <TColStd_Array1OfTransient.hxx>
43#include <TColStd_Array1OfReal.hxx>
44
45
46//=======================================================================
47//function : Recadre
48//purpose :
49//=======================================================================
50
51static void Recadre(const Handle(Adaptor3d_HSurface)& myHS1,
52 const Handle(Adaptor3d_HSurface)& myHS2,
53 Standard_Real& u1,
54 Standard_Real& v1,
55 Standard_Real& u2,
56 Standard_Real& v2) {
57 Standard_Real f,l,lmf;
58 GeomAbs_SurfaceType typs1 = myHS1->GetType();
59 GeomAbs_SurfaceType typs2 = myHS2->GetType();
60
61 Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
62 switch (typs1) {
63 case GeomAbs_Cylinder:
64 case GeomAbs_Cone:
65 case GeomAbs_Sphere:
66 {
67 myHS1IsUPeriodic = Standard_True;
68 myHS1IsVPeriodic = Standard_False;
69 break;
70 }
71 case GeomAbs_Torus:
72 {
73 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
74 break;
75 }
76 default:
77 {
78 //-- Le cas de biparametrees periodiques est gere en amont
79 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
80 break;
81 }
82 }
83
84 Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic;
85 switch (typs2) {
86 case GeomAbs_Cylinder:
87 case GeomAbs_Cone:
88 case GeomAbs_Sphere:
89 {
90 myHS2IsUPeriodic = Standard_True;
91 myHS2IsVPeriodic = Standard_False;
92 break;
93 }
94 case GeomAbs_Torus:
95 {
96 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True;
97 break;
98 }
99 default:
100 {
101 //-- Le cas de biparametrees periodiques est gere en amont
102 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False;
103 break;
104 }
105 }
106 if(myHS1IsUPeriodic) {
c6541a0c 107 lmf = M_PI+M_PI; //-- myHS1->UPeriod();
7fd59977 108 f = myHS1->FirstUParameter();
109 l = myHS1->LastUParameter();
110 while(u1 < f) { u1+=lmf; }
111 while(u1 > l) { u1-=lmf; }
112 }
113 if(myHS1IsVPeriodic) {
c6541a0c 114 lmf = M_PI+M_PI; //-- myHS1->VPeriod();
7fd59977 115 f = myHS1->FirstVParameter();
116 l = myHS1->LastVParameter();
117 while(v1 < f) { v1+=lmf; }
118 while(v1 > l) { v1-=lmf; }
119 }
120 if(myHS2IsUPeriodic) {
c6541a0c 121 lmf = M_PI+M_PI; //-- myHS2->UPeriod();
7fd59977 122 f = myHS2->FirstUParameter();
123 l = myHS2->LastUParameter();
124 while(u2 < f) { u2+=lmf; }
125 while(u2 > l) { u2-=lmf; }
126 }
127 if(myHS2IsVPeriodic) {
c6541a0c 128 lmf = M_PI+M_PI; //-- myHS2->VPeriod();
7fd59977 129 f = myHS2->FirstVParameter();
130 l = myHS2->LastVParameter();
131 while(v2 < f) { v2+=lmf; }
132 while(v2 > l) { v2-=lmf; }
133 }
134}
135
136//=======================================================================
137//function : Parameters
138//purpose :
139//=======================================================================
140
141static void Parameters(const Handle(Adaptor3d_HSurface)& myHS1,
142 const Handle(Adaptor3d_HSurface)& myHS2,
143 const gp_Pnt& Ptref,
144 Standard_Real& U1,
145 Standard_Real& V1,
146 Standard_Real& U2,
147 Standard_Real& V2)
148{
149 IntSurf_Quadric quad1,quad2;
150 GeomAbs_SurfaceType typs = myHS1->Surface().GetType();
151 switch (typs) {
152 case GeomAbs_Plane:
153 quad1.SetValue(myHS1->Surface().Plane());
154 break;
155 case GeomAbs_Cylinder:
156 quad1.SetValue(myHS1->Surface().Cylinder());
157 break;
158 case GeomAbs_Cone:
159 quad1.SetValue(myHS1->Surface().Cone());
160 break;
161 case GeomAbs_Sphere:
162 quad1.SetValue(myHS1->Surface().Sphere());
163 break;
164 default:
165 Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
166 }
167
168 typs = myHS2->Surface().GetType();
169 switch (typs) {
170 case GeomAbs_Plane:
171 quad2.SetValue(myHS2->Surface().Plane());
172 break;
173 case GeomAbs_Cylinder:
174 quad2.SetValue(myHS2->Surface().Cylinder());
175 break;
176 case GeomAbs_Cone:
177 quad2.SetValue(myHS2->Surface().Cone());
178 break;
179 case GeomAbs_Sphere:
180 quad2.SetValue(myHS2->Surface().Sphere());
181 break;
182 default:
183 Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
184 }
185 quad1.Parameters(Ptref,U1,V1);
186 quad2.Parameters(Ptref,U2,V2);
187}
188
189//=======================================================================
190//function : LocalFirstParameter
191//purpose :
192//=======================================================================
193
194static Standard_Real LocalFirstParameter (const Handle(IntPatch_Line)& L)
195{
196 Standard_Real firstp =0.;
197 IntPatch_IType typl = L->ArcType();
198 switch (typl) {
199 case IntPatch_Analytic:
200 {
201 Handle(IntPatch_ALine)& alin = *((Handle(IntPatch_ALine) *)&L);
202 if (alin->HasFirstPoint()) {
203 firstp = alin->FirstPoint().ParameterOnLine();
204 }
205 else {
206 Standard_Boolean included;
207 firstp = alin->FirstParameter(included);
208 if (!included) {
209 firstp +=Epsilon(firstp);
210 }
211 }
212 return firstp;
213 }
214
215 case IntPatch_Restriction:
216 {
217 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&L);
218 if (rlin->HasFirstPoint()) {
219 firstp = rlin->FirstPoint().ParameterOnLine();
220 }
221 else {
222 firstp = -Precision::Infinite(); // a voir selon le type de la ligne 2d
223 }
224 return firstp;
225 }
226 case IntPatch_Walking:
227 {
228
229 Handle(IntPatch_WLine)& wlin = *((Handle(IntPatch_WLine) *) &L);
230 if (wlin->HasFirstPoint()) {
231 firstp = wlin->FirstPoint().ParameterOnLine();
232 }
233 else {
234 firstp = 1.;
235 }
236 return firstp;
237 }
238
239 default:
240 {
241 Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine) *)&L);
242 if (glin->HasFirstPoint()) {
243 firstp = glin->FirstPoint().ParameterOnLine();
244 }
245 else {
246 switch (typl) {
247 case IntPatch_Lin:
248 case IntPatch_Parabola:
249 case IntPatch_Hyperbola:
250 firstp = -Precision::Infinite();
251 break;
252
253 case IntPatch_Circle:
254 case IntPatch_Ellipse:
255 firstp = 0.;
256 break;
257 default:
258 {
259 }
260 }
261 }
262 return firstp;
263 }
264 }
d3f26155 265// return firstp;
7fd59977 266}
267
268//=======================================================================
269//function : LocalLastParameter
270//purpose :
271//=======================================================================
272
273static Standard_Real LocalLastParameter (const Handle(IntPatch_Line)& L)
274{
275 Standard_Real lastp =0.;
276 IntPatch_IType typl = L->ArcType();
277 switch (typl) {
278 case IntPatch_Analytic:
279 {
280 Handle(IntPatch_ALine)& alin = *((Handle(IntPatch_ALine) *)&L);
281
282 if (alin->HasLastPoint()) {
283 lastp = alin->LastPoint().ParameterOnLine();
284 }
285 else {
286 Standard_Boolean included;
287 lastp = alin->LastParameter(included);
288 if (!included) {
289 lastp -=Epsilon(lastp);
290 }
291 }
292 return lastp;
293 }
294
295 case IntPatch_Restriction:
296 {
297 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&L);
298
299 if (rlin->HasLastPoint()) {
300 lastp = rlin->LastPoint().ParameterOnLine();
301 }
302 else {
303 lastp = Precision::Infinite(); // a voir selon le type de la ligne 2d
304 }
305 return lastp;
306 }
307 case IntPatch_Walking:
308 {
309 Handle(IntPatch_WLine)& wlin = *((Handle(IntPatch_WLine) *)&L);
310
311 if (wlin->HasLastPoint()) {
312 lastp = wlin->LastPoint().ParameterOnLine();
313 }
314 else {
315 lastp = wlin->NbPnts();
316 }
317 return lastp;
318 }
319
320 default:
321 {
322 Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine) *)&L);
323
324 if (glin->HasLastPoint()) {
325 lastp = glin->LastPoint().ParameterOnLine();
326 }
327 else {
328 switch (typl) {
329 case IntPatch_Lin:
330 case IntPatch_Parabola:
331 case IntPatch_Hyperbola:
332 lastp = Precision::Infinite();
333 break;
334
335 case IntPatch_Circle:
336 case IntPatch_Ellipse:
c6541a0c 337 lastp = M_PI+M_PI;
7fd59977 338 break;
339 default:
340 {
341 }
342 }
343 }
344 return lastp;
345 }
346 }
7fd59977 347}
348
349
350// modified by NIZHNY-MKK Tue Apr 3 15:03:06 2001.BEGIN
351//=======================================================================
352//function : ComputeParametricTolerance
353//purpose :
354//=======================================================================
355
356static Standard_Real ComputeParametricTolerance(const Standard_Real theTol3d,
357 const gp_Vec& theD1u,
358 const gp_Vec& theD1v) {
359 Standard_Real nad1u = theD1u.Magnitude();
360 Standard_Real nad1v = theD1v.Magnitude();
361 Standard_Real tolu = 0., tolv = 0.;
362 if(nad1u > 1e-12)
363 tolu = theTol3d/nad1u;
364 else tolu = 0.1;
365 if(nad1v > 1e-12)
366 tolv = theTol3d/nad1v;
367 else tolv = 0.1;
368 Standard_Real aTolerance = (tolu > tolv) ? tolu : tolv;
369 return aTolerance;
370}
371// modified by NIZHNY-MKK Tue Apr 3 15:03:11 2001.END
372
373
374//=======================================================================
375//function : IntPatch_LineConstructor
376//purpose :
377//=======================================================================
378
379IntPatch_LineConstructor::IntPatch_LineConstructor(const Standard_Integer )
380{
381}
382
383//=======================================================================
384//function : AppendSameVertexA
385//purpose :
386//=======================================================================
387
388static Standard_Integer AppendSameVertexA(Handle(IntPatch_ALine)&alig,
389 const Handle(IntPatch_ALine)& L,
390 const Standard_Integer index,
391 Standard_Integer *TabIndex) {
392 Standard_Integer i,a,n;
393 a=0;
394 n=L->NbVertex();
395 const IntPatch_Point& Vtxindex = L->Vertex(index);
396 Standard_Real thetol1=Vtxindex.Tolerance();
397 for(i=1;i<=n;i++) {
398 if(i!=index) {
399 const IntPatch_Point& Vtxi = L->Vertex(i);
400 Standard_Real thetol2=Vtxi.Tolerance();
401 if(thetol2<thetol1)
402 thetol2=thetol1;
403 Standard_Real d_4=Vtxindex.Value().Distance(Vtxi.Value());
404 if(d_4 <= thetol2) {
405 alig->AddVertex(Vtxi);
406 a++;
407 TabIndex[i]=TabIndex[index];
408 }
409 }
410 }
411 return(a);
412}
413
414//=======================================================================
415//function : AppendSameVertexG
416//purpose :
417//=======================================================================
418
419static Standard_Integer AppendSameVertexG(Handle(IntPatch_GLine)& glig,const Handle(IntPatch_GLine)&L,
420 const Standard_Integer index,
421 const Standard_Real decal,
422 Standard_Integer *TabIndex) {
423 Standard_Integer i,a,n;
424 Standard_Real p1,p2,d; //,tol
425 Standard_Boolean aajouter;
426 a=0;
427 n=L->NbVertex();
428 const IntPatch_Point& Vtxindex = L->Vertex(index);
429 Standard_Real thetol1=Vtxindex.Tolerance();
430 for(i=1;i<=n;i++) {
431 if(i!=index) {
432 const IntPatch_Point& Vtxi = L->Vertex(i);
433 aajouter=Standard_False;
434 Standard_Real thetol2=Vtxi.Tolerance();
435 if(thetol2<thetol1)
436 thetol2=thetol1;
437 d=Vtxindex.Value().Distance(Vtxi.Value());
438 if(d <= thetol2) {
439 aajouter=Standard_True;
440 }
441
442
443 //-- Le test suivant a ete ajoute le 20 aout 98 (??? mefiance ???)
444 else {
445 p1=Vtxindex.ParameterOnLine();
446 p2=Vtxi.ParameterOnLine();
447 if(Abs(p1-p2)<Precision::PConfusion()) {
448 aajouter=Standard_True;
449 }
450 }
451 if(aajouter) {
452 p1= Vtxindex.ParameterOnLine();
453 IntPatch_Point aVtx = Vtxi;
454 aVtx.SetParameter(p1+decal);
455 glig->AddVertex(aVtx);
456 a++;
457 TabIndex[i]=TabIndex[index];
458 }
459 }
460 }
461 return(a);
462}
463
464//=======================================================================
465//function : AppendSameVertexW
466//purpose :
467//=======================================================================
468
469static Standard_Integer AppendSameVertexW(Handle(IntPatch_WLine)& wlig,
470 const Handle(IntPatch_WLine)&L,
471 const Standard_Integer index,
472 const Standard_Real par,
473 Standard_Integer *TabIndex) {
474 Standard_Integer i,a,n;
475 a=0;
476 n=L->NbVertex();
477 const IntPatch_Point& Vtxindex = L->Vertex(index);
478 const gp_Pnt& Pntindex = Vtxindex.Value();
479 Standard_Real thetol1=Vtxindex.Tolerance();
480 for(i=1;i<=n;i++) {
481 if(i!=index) {
482 IntPatch_Point Vtxi = L->Vertex(i);
483 Standard_Real d_2 = Pntindex.Distance(Vtxi.Value());
484 Standard_Real thetol2=Vtxi.Tolerance();
485 if(thetol2<thetol1)
486 thetol2=thetol1;
487 //-- le debugger voit 2 fois la variable d ici. ???? -> d_2
488 if(d_2 <= thetol2) {
489 Vtxi.SetParameter(par);
490 Standard_Real u1,v1,u2,v2;
491 Vtxindex.ParametersOnS1(u1,v1);
492 Vtxindex.ParametersOnS2(u2,v2);
493 Vtxi.SetParameters(u1,v1,u2,v2);
494 Vtxi.SetValue(Pntindex);
495 wlig->AddVertex(Vtxi);
496 a++;
497 TabIndex[i]=TabIndex[index];
498 }
499 }
500 }
501 return(a);
502}
503
504//=======================================================================
505//function : AppendSameVertexR
506//purpose :
507//=======================================================================
508
509static Standard_Integer AppendSameVertexR(Handle(IntPatch_RLine)&rlig,
510 const Handle(IntPatch_RLine)& L,
511 const Standard_Integer index,
512 Standard_Integer *TabIndex) {
513 Standard_Integer i,a,n;
514 a=0;
515 n=L->NbVertex();
516 const IntPatch_Point& Vtxindex = L->Vertex(index);
517 Standard_Real thetol1=Vtxindex.Tolerance();
518 for(i=1;i<=n;i++) {
519 if(i!=index) {
520 const IntPatch_Point& Vtxi = L->Vertex(i);
521 Standard_Real d_3=Vtxindex.Value().Distance(Vtxi.Value());
522 Standard_Real thetol2=Vtxi.Tolerance();
523 if(thetol2<thetol1)
524 thetol2=thetol1;
525 if(d_3<thetol2) {
526 if(Vtxi.ParameterOnLine() != Vtxindex.ParameterOnLine()) {
527 IntPatch_Point Vtxicop = L->Vertex(i);
528 Vtxicop.SetParameter(Vtxindex.ParameterOnLine());
529 rlig->AddVertex(Vtxicop);
530 }
531 else {
532 rlig->AddVertex(Vtxi);
533 }
534 a++;
535 TabIndex[i]=TabIndex[index];
536 }
537 }
538 }
539 return(a);
540}
541
542//=======================================================================
543//function : AddLine
544//purpose :
545//=======================================================================
546
547static void AddLine(const Handle(IntPatch_Line)& L,
548 const Standard_Integer i,
549 const Standard_Integer j,
550// const GeomAbs_SurfaceType TypeS1,
551 const GeomAbs_SurfaceType ,
552// const GeomAbs_SurfaceType TypeS2,
553 const GeomAbs_SurfaceType ,
554 Standard_Integer *TabIndex,
555 IntPatch_SequenceOfLine& slin) {
556 Standard_Integer IndexFirstVertex = 1;
557 Standard_Integer IndexLastVertex = 2;
558 if(i==j) {
559 IndexLastVertex = 1;
560 }
561 IntPatch_IType typl = L->ArcType();
562 switch (typl) {
563 case IntPatch_Analytic: {
564 Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L);
565 Handle(IntPatch_ALine) alig;
566 if(L->TransitionOnS1() == IntSurf_Undecided)
567 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent());
568 else if(L->TransitionOnS1() == IntSurf_Touch)
569 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent(),L->SituationS1(),L->SituationS2());
570 else
571 alig = new IntPatch_ALine(ALine->Curve(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
572 alig->AddVertex(ALine->Vertex(i));
573 IndexLastVertex+=AppendSameVertexA(alig,ALine,i,TabIndex);
574 if(i!=j) {
575 alig->AddVertex(ALine->Vertex(j));
576 IndexLastVertex+=AppendSameVertexA(alig,ALine,j,TabIndex);
577 }
578 alig->SetFirstPoint(IndexFirstVertex);
579 alig->SetLastPoint(IndexLastVertex);
580 slin.Append(alig);
581 break;
582 }
583 case IntPatch_Walking: { //-- ****************************************
584 Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L);
585 const Handle(IntSurf_LineOn2S)& Lori = WLine->Curve();
586 Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
587 Standard_Integer ParamMinOnLine = (Standard_Integer) WLine->Vertex(i).ParameterOnLine();
588 Standard_Integer ParamMaxOnLine = (Standard_Integer) WLine->Vertex(j).ParameterOnLine();
589 for(Standard_Integer k=ParamMinOnLine; k<=ParamMaxOnLine; k++) {
590 LineOn2S->Add(Lori->Value(k));
591 }
592 Handle(IntPatch_WLine) wlig;
593 if(L->TransitionOnS1() == IntSurf_Undecided)
594 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent());
595 else if(L->TransitionOnS1() == IntSurf_Touch)
596 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent(),L->SituationS1(),L->SituationS2());
597 else
598 wlig = new IntPatch_WLine(LineOn2S,L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
599 if(WLine->HasArcOnS1()) {
600 wlig->SetArcOnS1(WLine->GetArcOnS1());
601 }
602 if(WLine->HasArcOnS2()) {
603 wlig->SetArcOnS2(WLine->GetArcOnS2());
604 }
605 IntPatch_Point Vtx=WLine->Vertex(i);
606 Vtx.SetParameter(1);
607 wlig->AddVertex(Vtx);
608 IndexLastVertex+=AppendSameVertexW(wlig,WLine,i,1,TabIndex);
609 if(i!=j) {
610 Vtx=WLine->Vertex(j);
611 Vtx.SetParameter(LineOn2S->NbPoints());
612 wlig->AddVertex(Vtx);
613 IndexLastVertex+=AppendSameVertexW(wlig,WLine,j,LineOn2S->NbPoints(),TabIndex);
614 }
615 wlig->SetFirstPoint(IndexFirstVertex);
616 wlig->SetLastPoint(IndexLastVertex);
617 wlig->SetPeriod(WLine->U1Period(),WLine->V1Period(),WLine->U2Period(),WLine->V2Period());
618 wlig->ComputeVertexParameters(Precision::Confusion());
619 slin.Append(wlig);
620 //-- **********************************************************************
621
622 break;
623 }
624 case IntPatch_Restriction: {
625 Handle(IntPatch_RLine)& RLine = *((Handle(IntPatch_RLine) *)&L);
626 IndexLastVertex=2;
627 IndexFirstVertex=1;
628 Handle(IntPatch_RLine) rlig;
629 if(L->TransitionOnS1() == IntSurf_Undecided)
630 rlig = new IntPatch_RLine(L->IsTangent());
631 else if(L->TransitionOnS1() == IntSurf_Touch)
632 rlig = new IntPatch_RLine(L->IsTangent(),L->SituationS1(),L->SituationS2());
633 else
634 rlig = new IntPatch_RLine(L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
635 if(RLine->IsArcOnS1()) { rlig->SetArcOnS1(RLine->ArcOnS1()); }
636 if(RLine->IsArcOnS2()) { rlig->SetArcOnS2(RLine->ArcOnS2()); }
637
638 rlig->AddVertex(RLine->Vertex(i));
639#if XPU1009
640 IndexLastVertex+=AppendSameVertexR(rlig,RLine,i,TabIndex);
641#endif
642 for(Standard_Integer k=i+1; k<j;k++) {
643 rlig->AddVertex(RLine->Vertex(k));
644 IndexLastVertex++;
645 }
646 if(i!=j) {
647 rlig->AddVertex(RLine->Vertex(j));
648#if XPU1009
649 IndexLastVertex+=AppendSameVertexR(rlig,RLine,j,TabIndex);
650#endif
651 }
652 rlig->SetFirstPoint(IndexFirstVertex);
653 rlig->SetLastPoint(IndexLastVertex);
654 rlig->ComputeVertexParameters(Precision::Confusion());
655 slin.Append(rlig);
656 break;
657 }
658 case IntPatch_Lin:
659 case IntPatch_Parabola:
660 case IntPatch_Hyperbola:
661 case IntPatch_Circle:
662 case IntPatch_Ellipse: {
663 Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L);
664 Handle(IntPatch_GLine) glig;
665 switch (typl) {
666 case IntPatch_Lin:
667 if(L->TransitionOnS1() == IntSurf_Undecided)
668 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent());
669 else if(L->TransitionOnS1() == IntSurf_Touch)
670 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent(),L->SituationS1(),L->SituationS2());
671 else
672 glig = new IntPatch_GLine(GLine->Line(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
673 break;
674 case IntPatch_Parabola:
675 if(L->TransitionOnS1() == IntSurf_Undecided)
676 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent());
677 else if(L->TransitionOnS1() == IntSurf_Touch)
678 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent(),L->SituationS1(),L->SituationS2());
679 else
680 glig = new IntPatch_GLine(GLine->Parabola(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
681 break;
682 case IntPatch_Hyperbola:
683 if(L->TransitionOnS1() == IntSurf_Undecided)
684 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent());
685 else if(L->TransitionOnS1() == IntSurf_Touch)
686 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent(),L->SituationS1(),L->SituationS2());
687 else
688 glig = new IntPatch_GLine(GLine->Hyperbola(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
689 break;
690 case IntPatch_Circle:
691 if(L->TransitionOnS1() == IntSurf_Undecided)
692 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent());
693 else if(L->TransitionOnS1() == IntSurf_Touch)
694 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent(),L->SituationS1(),L->SituationS2());
695 else
696 glig = new IntPatch_GLine(GLine->Circle(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
697 break;
698 case IntPatch_Ellipse: default:
699 if(L->TransitionOnS1() == IntSurf_Undecided)
700 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent());
701 else if(L->TransitionOnS1() == IntSurf_Touch)
702 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent(),L->SituationS1(),L->SituationS2());
703 else
704 glig = new IntPatch_GLine(GLine->Ellipse(),L->IsTangent(),L->TransitionOnS1(),L->TransitionOnS2());
705 break;
706 }
707 glig->AddVertex(GLine->Vertex(i));
708 IndexLastVertex+=AppendSameVertexG(glig,GLine,i,0,TabIndex);
709 if(i!=j) {
710 if ((typl == IntPatch_Circle || typl == IntPatch_Ellipse) && i>j) {
711 IntPatch_Point Vtx=GLine->Vertex(j);
c6541a0c 712 Vtx.SetParameter(GLine->Vertex(j).ParameterOnLine()+M_PI+M_PI);
7fd59977 713 glig->AddVertex(Vtx);
c6541a0c 714 IndexLastVertex+=AppendSameVertexG(glig,GLine,j,M_PI+M_PI,TabIndex);
7fd59977 715 }
716 else {
717 glig->AddVertex(GLine->Vertex(j));
718 IndexLastVertex+=AppendSameVertexG(glig,GLine,j,0,TabIndex);
719 }
720 }
721 glig->SetFirstPoint(IndexFirstVertex);
722 glig->SetLastPoint(IndexLastVertex);
723 slin.Append(glig);
724 break;
725 }
726 default: {
727 Standard_ConstructionError::Raise("IntPatch_LineConstructor::AddLine");
728 }
729 break;
730 }
731}
732
733//=======================================================================
734//function : Line
735//purpose :
736//=======================================================================
737
738Handle(IntPatch_Line) IntPatch_LineConstructor::Line(const Standard_Integer l) const {
739 return(slin.Value(l));
740}
741
742//=======================================================================
743//function : NbLines
744//purpose :
745//=======================================================================
746
747Standard_Integer IntPatch_LineConstructor::NbLines() const {
748 return(slin.Length());
749}
750
751//=======================================================================
752//function : GetVertexTolerance
753//purpose :
754//=======================================================================
755
756static Standard_Real GetVertexTolerance(const IntPatch_Point& vtx/*,
757 const Handle(Adaptor3d_TopolTool)& aDomain1,
758 const Handle(Adaptor3d_TopolTool)& aDomain2*/)
759{
760 Standard_Real tol = vtx.Tolerance();
761// if (aDomain1->Has3d() && vtx.IsVertexOnS1()) {
762// Standard_Real tolv = aDomain1->Tol3d(vtx.VertexOnS1());
763// if (tolv > tol) tol = tolv;
764// }
765// if (aDomain2->Has3d() && vtx.IsVertexOnS2()) {
766// Standard_Real tolv = aDomain2->Tol3d(vtx.VertexOnS2());
767// if (tolv > tol) tol = tolv;
768// }
769 return tol;
770}
771
772//=======================================================================
773//function : IsSegmentSmall
774//purpose :
775//=======================================================================
776
777static Standard_Boolean IsSegmentSmall(const Handle(IntPatch_WLine)& WLine,
778 const Standard_Integer ivFirst,
779 const Standard_Integer ivLast/*,
780 const Standard_Real TolArc*/)
781{
782 const IntPatch_Point& vtxF = WLine->Vertex(ivFirst);
783 const IntPatch_Point& vtxL = WLine->Vertex(ivLast);
784 Standard_Integer ipF = (Standard_Integer) vtxF.ParameterOnLine();
785 Standard_Integer ipL = (Standard_Integer) vtxL.ParameterOnLine();
786 if (ipF >= ipL) return Standard_True;
787
788 Standard_Real tolF = GetVertexTolerance(vtxF);
789 Standard_Real tolL = GetVertexTolerance(vtxL);
790 Standard_Real tol = Max (tolF, tolL);
791
792 Standard_Real len = 0.;
793 gp_Pnt p1 = WLine->Point(ipF).Value();
794 for (Standard_Integer i=ipF+1; i <= ipL; i++) {
795 const gp_Pnt& p2 = WLine->Point(i).Value();
796 len += p1.Distance(p2);
797 if (len > tol) break;
798 p1 = p2;
799 }
800 return len <= tol;
801}
802
803//=======================================================================
804//function : TestWLineIsARLine
805//purpose :
806//=======================================================================
807
808static Standard_Boolean TestWLineIsARLine(const IntPatch_SequenceOfLine& slinref,
809 const Handle(IntPatch_WLine)& wlin,
810 const Standard_Real tol2d) {
811 int nbpnt=wlin->NbPnts();
812 int indicepnt=nbpnt/2;
813 if(indicepnt<1) return(Standard_False);
814 const IntSurf_PntOn2S& POn2S=wlin->Point(indicepnt);
815 const IntSurf_PntOn2S& POn2S1=wlin->Point(indicepnt+1);
816 Standard_Integer lastl=slinref.Length();
817 for(int i=1;i<=lastl;i++) {
818 if(slinref.Value(i)->ArcType()==IntPatch_Restriction) {
819 Handle(IntPatch_RLine)& rlin = *((Handle(IntPatch_RLine) *)&(slinref(i)));
820 for (Standard_Integer is=0; is<2; is++) {
821 Standard_Boolean onFirst = is==0;
822 if(onFirst && rlin->IsArcOnS1() || !onFirst && rlin->IsArcOnS2()) {
823 Handle(Adaptor2d_HCurve2d) arc;
824 Standard_Real u,v,u1,v1;
825 if (onFirst) {
826 arc = rlin->ArcOnS1();
827 POn2S.ParametersOnS1(u,v);
828 POn2S1.ParametersOnS1(u1,v1);
829 }
830 else {
831 arc = rlin->ArcOnS2();
832 POn2S.ParametersOnS2(u,v);
833 POn2S1.ParametersOnS2(u1,v1);
834 }
835 if (indicepnt == 1) {
836 u = (u+u1)*0.5;
837 v = (v+v1)*0.5;
838 }
839 const Adaptor2d_Curve2d& C2d=arc->Curve2d();
840 gp_Pnt2d PObt,P2d(u,v);
841 Standard_Real par= Geom2dInt_TheProjPCurOfGInter::FindParameter(C2d,P2d,1e-7);
842 PObt=C2d.Value(par);
843 if(PObt.Distance(P2d) < tol2d) {
844 return Standard_True;
845 }
846 }
847 }
848 }
849 }
850 return Standard_False;
851}
852
853//=======================================================================
854//function : TestIfWLineIsRestriction
855//purpose :
856//=======================================================================
857
858static Standard_Boolean TestIfWLineIsRestriction(const IntPatch_SequenceOfLine& slinref,
859 const Handle(IntPatch_WLine)& wlin,
860 const Handle(Adaptor3d_HSurface)& S1,
861 const Handle(Adaptor3d_TopolTool)&D1,
862 const Handle(Adaptor3d_HSurface)& S2,
863 const Handle(Adaptor3d_TopolTool)&D2,
864 Standard_Real TolArc) {
865
866 Standard_Integer NbPnts = wlin->NbPnts();
867 Standard_Integer allon1=0,allon2=0,i;
868 Standard_Real tol2d1=0., tol2d2=0.;
869 for(i=1;i<=NbPnts;i++) {
870 const IntSurf_PntOn2S& Pmid = wlin->Point(i);
871 Standard_Real u1,v1,u2,v2;
872 Pmid.Parameters(u1,v1,u2,v2);
873 //-- Estimation d un majorant de Toluv a partir de Tol
874 gp_Pnt ap;
875 gp_Vec ad1u,ad1v;
876 Standard_Real tol;
877 //------------------------------------------
878 S1->D1(u1,v1,ap,ad1u,ad1v);
879 tol = ComputeParametricTolerance(TolArc,ad1u,ad1v);
880 if (tol > tol2d1) tol2d1 = tol;
881 //--
882 if(allon1+1 == i && D1->IsThePointOn(gp_Pnt2d(u1,v1),tol)) {
883 allon1++;
884 }
885 //------------------------------------------
886 S2->D1(u2,v2,ap,ad1u,ad1v);
887 tol = ComputeParametricTolerance(TolArc,ad1u,ad1v);
888 if (tol > tol2d2) tol2d2 = tol;
889 //--
890 if(allon2+1 == i && D2->IsThePointOn(gp_Pnt2d(u2,v2),tol)) {
891 allon2++;
892 }
893 if(allon1!=i && allon2!=i)
894 break;
895 }
896 if(allon1==NbPnts || allon2==NbPnts) {
897#ifdef DEB
898 cout<<" IntPatch_LineConstructor.gxx : CC**ONS"<<(allon1==NbPnts?1:2)<<"** Traitement WLIne + ARC CLASS "<<endl;
899#endif
900 Standard_Real tol2d = Max(tol2d1,tol2d2);
901 return TestWLineIsARLine(slinref,wlin,tol2d);
902 }
903 return Standard_False;
904}
905
906//=======================================================================
907//function : ProjectOnArc
908//purpose :
909//=======================================================================
910
911static Standard_Boolean ProjectOnArc(const Standard_Real u,
912 const Standard_Real v,
913 const Handle(Adaptor2d_HCurve2d)& arc,
914 const Handle(Adaptor3d_HSurface)& surf,
915 const Standard_Real TolArc,
916 Standard_Real& par,
917 Standard_Real& dist)
918{
919 gp_Pnt aPbid;
920 gp_Vec ad1u, ad1v;
921 surf->D1(u,v,aPbid,ad1u,ad1v);
922 Standard_Real tol2d = ComputeParametricTolerance(TolArc,ad1u,ad1v);
923 const Adaptor2d_Curve2d& C2d=arc->Curve2d();
924 gp_Pnt2d aP(u,v),aPprj;
925 par=Geom2dInt_TheProjPCurOfGInter::FindParameter(C2d,aP,1e-7);
926 aPprj=C2d.Value(par);
927 dist = aPprj.Distance(aP);
928 return dist <= tol2d;
929}
930
931//=======================================================================
932//function : TestWLineToRLine
933//purpose :
934//=======================================================================
935
936static void TestWLineToRLine(const IntPatch_SequenceOfLine& slinref,
937 IntPatch_SequenceOfLine& slin,
938 const Handle(Adaptor3d_HSurface)& mySurf1,
939 const Handle(Adaptor3d_TopolTool)& myDom1,
940 const Handle(Adaptor3d_HSurface)& mySurf2,
941 const Handle(Adaptor3d_TopolTool)& myDom2,
942 const Standard_Real TolArc) {
943
944 Standard_Integer lastwline=slin.Length();
945 Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)& (slin.Value(lastwline)));
946
947 Standard_Integer nbvtx=WLine->NbVertex();
948 if (nbvtx < 2) return;
949 Standard_Integer ParamMinOnLine = (Standard_Integer) WLine->Vertex(1).ParameterOnLine();
950 Standard_Integer ParamMaxOnLine = (Standard_Integer) WLine->Vertex(nbvtx).ParameterOnLine();
951 if (ParamMinOnLine >= ParamMaxOnLine) return;
952 Standard_Integer midInd = (ParamMaxOnLine + ParamMinOnLine) / 2;
953
954 TColStd_SequenceOfInteger indicesV1,indicesV2;
955 Standard_Integer iv;
956 for (iv=1; iv <= nbvtx; iv++) {
957 Standard_Integer plin = (Standard_Integer) WLine->Vertex(iv).ParameterOnLine();
958 if (plin == ParamMinOnLine) indicesV1.Append(iv);
959 else if (plin == ParamMaxOnLine) indicesV2.Append(iv);
960 }
961
962 Standard_Boolean isRLine = Standard_False;
963
964 typedef void (IntSurf_PntOn2S::* PiParOnS)(Standard_Real&,Standard_Real&) const;
965 typedef Standard_Boolean (IntPatch_Point::* PQuery)() const;
966 typedef const Handle(Adaptor2d_HCurve2d)& (IntPatch_Point::* PArcOnS)() const;
967 typedef Standard_Real (IntPatch_Point::* PParOnArc)() const;
968
969 // cycle for both surfaces
970 Standard_Integer is;
971 for (is=0; is<2; is++) {
972 Standard_Boolean onFirst = is==0;
973 if( onFirst && WLine->HasArcOnS1() ||
974 !onFirst && WLine->HasArcOnS2()) {
975 PiParOnS piParOnS;
976 PQuery pIsOnDomS;
977 PArcOnS pArcOnS;
978 PParOnArc pParOnArc;
979 Handle(Adaptor3d_HSurface) surf;
980 Handle(Adaptor3d_TopolTool) aDomain;
981 if (onFirst) {
982 piParOnS = &IntSurf_PntOn2S::ParametersOnS1;
983 pIsOnDomS = &IntPatch_Point::IsOnDomS1;
984 pArcOnS = &IntPatch_Point::ArcOnS1;
985 pParOnArc = &IntPatch_Point::ParameterOnArc1;
986 surf = mySurf1;
987 aDomain = myDom1;
988 }
989 else {
990 piParOnS = &IntSurf_PntOn2S::ParametersOnS2;
991 pIsOnDomS = &IntPatch_Point::IsOnDomS2;
992 pArcOnS = &IntPatch_Point::ArcOnS2;
993 pParOnArc = &IntPatch_Point::ParameterOnArc2;
994 surf = mySurf2;
995 aDomain = myDom2;
996 }
997
998 // resolve arcs for vertices not having a link to an arc
999 Standard_Real utst,vtst;
1000 TColStd_Array1OfReal paramsResolved(1,nbvtx);
1001 TColStd_Array1OfTransient arcsResolved(1,nbvtx);
1002 arcsResolved.Init(Handle(Adaptor2d_HCurve2d)());
1003 for (iv=1; iv <= nbvtx; iv++) {
1004 if (!(WLine->Vertex(iv).*pIsOnDomS)()) {
1005 Standard_Integer ip = (Standard_Integer) WLine->Vertex(iv).ParameterOnLine();
1006 (WLine->Point(ip).*piParOnS)(utst,vtst);
1007 Standard_Real distmin=RealLast();
1008 for (aDomain->Init(); aDomain->More(); aDomain->Next()) {
1009 const Handle(Adaptor2d_HCurve2d)& arc = aDomain->Value();
1010 Standard_Real par,dist;
1011 if (ProjectOnArc(utst,vtst,arc,surf,TolArc,par,dist) && dist < distmin) {
1012 arcsResolved(iv) = arc;
1013 paramsResolved(iv) = par;
1014 distmin = dist;
1015 }
1016 }
1017 }
1018 }
1019
1020 // prepare list of common arcs for both ends of wline
1021 TColStd_IndexedMapOfTransient mapArcsV1,mapArcs;
1022 Standard_Integer i;
1023 for (i=1; i <= indicesV1.Length(); i++) {
1024 iv = indicesV1(i);
1025 Handle(Adaptor2d_HCurve2d) arc;
1026 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc = (WLine->Vertex(iv).*pArcOnS)();
1027 else arc = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1028 if (!arc.IsNull()) mapArcsV1.Add(arc);
1029 }
1030 for (i=1; i <= indicesV2.Length(); i++) {
1031 iv = indicesV2(i);
1032 Handle(Adaptor2d_HCurve2d) arc;
1033 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc = (WLine->Vertex(iv).*pArcOnS)();
1034 else arc = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1035 if (!arc.IsNull() && mapArcsV1.Contains(arc)) mapArcs.Add(arc);
1036 }
1037
1038 // for each common arc
1039 for (Standard_Integer ia=1; ia <= mapArcs.Extent(); ia++) {
1040 const Handle(Adaptor2d_HCurve2d)& arc = (const Handle(Adaptor2d_HCurve2d)&) mapArcs(ia);
1041 // get end vertices of wline linked with this arc
1042 Standard_Integer iv1=0,iv2=0;
1043 for (i=1; i <= indicesV1.Length() && iv1==0; i++) {
1044 iv = indicesV1(i);
1045 Handle(Adaptor2d_HCurve2d) arc1;
1046 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc1 = (WLine->Vertex(iv).*pArcOnS)();
1047 else arc1 = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1048 if (!arc1.IsNull() && arc1 == arc) iv1 = iv;
1049 }
1050 for (i=1; i <= indicesV2.Length() && iv2==0; i++) {
1051 iv = indicesV2(i);
1052 Handle(Adaptor2d_HCurve2d) arc1;
1053 if ((WLine->Vertex(iv).*pIsOnDomS)()) arc1 = (WLine->Vertex(iv).*pArcOnS)();
1054 else arc1 = (const Handle(Adaptor2d_HCurve2d)&) arcsResolved(iv);
1055 if (!arc1.IsNull() && arc1 == arc) iv2 = iv;
1056 }
1057 if (!iv1 || !iv2) {
1058#ifdef DEB
1059 cout<<" Pb getting vertices linked with arc"<<endl;
1060#endif
1061 continue;
1062 }
1063 Standard_Real par1 = (arcsResolved(iv1).IsNull()
1064 ? (WLine->Vertex(iv1).*pParOnArc)()
1065 : paramsResolved(iv1));
1066 Standard_Real par2 = (arcsResolved(iv2).IsNull()
1067 ? (WLine->Vertex(iv2).*pParOnArc)()
1068 : paramsResolved(iv2));
1069#ifdef DEB
1070 cout<<"****** Parameters on arc on S"<<is+1<<": "<<par1<<" "<<par2<<endl;
1071#endif
1072
1073 // check that the middle point is on arc
1074 (WLine->Point(midInd).*piParOnS)(utst,vtst);
1075 if (midInd == ParamMinOnLine) {
1076 Standard_Real utst1,vtst1;
1077 (WLine->Point(midInd+1).*piParOnS)(utst1,vtst1);
1078 utst = (utst+utst1)*0.5;
1079 vtst = (vtst+vtst1)*0.5;
1080 }
1081 Standard_Real par,dist;
1082 if (!ProjectOnArc(utst,vtst,arc,surf,TolArc,par,dist)) {
1083#ifdef DEB
1084 cout<<" Pb en projection ds IntPatch_LineConstructor"<<endl;
1085#endif
1086 continue;
1087 }
1088
1089 //-- codage de la WLine en RLine
1090 Handle(IntPatch_RLine) rlig = new IntPatch_RLine(Standard_True,IntSurf_Unknown,IntSurf_Unknown);
1091 if (onFirst) rlig->SetArcOnS1(arc);
1092 else rlig->SetArcOnS2(arc);
1093
1094 Handle(IntSurf_LineOn2S) LineOn2S = new IntSurf_LineOn2S();
1095 const Handle(IntSurf_LineOn2S)& Lori = WLine->Curve();
1096 Standard_Integer ivmin,ivmax;
1097 Standard_Real parmin, parmax;
1098 Standard_Boolean reverse = Standard_False;
1099 TColStd_SequenceOfInteger *pIndVmin, *pIndVmax;
1100 if (par1<par2) {
1101 for(i=ParamMinOnLine; i<=ParamMaxOnLine; i++) {
1102 LineOn2S->Add(Lori->Value(i));
1103 }
1104 ivmin = iv1; ivmax = iv2;
1105 parmin = par1; parmax = par2;
1106 pIndVmin = &indicesV1; pIndVmax = &indicesV2;
1107 }
1108 else {
1109 for(i=ParamMaxOnLine; i>=ParamMinOnLine; i--) {
1110 LineOn2S->Add(Lori->Value(i));
1111 }
1112 ivmin = iv2; ivmax = iv1;
1113 parmin = par2; parmax = par1;
1114 pIndVmin = &indicesV2; pIndVmax = &indicesV1;
1115 reverse = Standard_True;
1116 }
1117 rlig->Add(LineOn2S);
1118 IntSurf_Transition TransitionUndecided;
1119 IntPatch_Point VtxFirst = WLine->Vertex(ivmin);
1120 VtxFirst.SetParameter(parmin);
1121 if (!arcsResolved(ivmin).IsNull())
1122 VtxFirst.SetArc(onFirst,arc,parmin,TransitionUndecided,TransitionUndecided);
1123 if (reverse)
1124 VtxFirst.ReverseTransition(); //-- inversion des transitions
1125 rlig->AddVertex(VtxFirst);
1126 for (i=1; i <= pIndVmin->Length(); i++) {
1127 iv = pIndVmin->Value(i);
1128 if (iv != ivmin) {
1129 IntPatch_Point Vtx=WLine->Vertex(iv);
1130 Vtx.SetParameter(parmin);
1131 if (!arcsResolved(iv).IsNull())
1132 Vtx.SetArc(onFirst,arc,parmin,TransitionUndecided,TransitionUndecided);
1133 if (reverse)
1134 Vtx.ReverseTransition();
1135 rlig->AddVertex(Vtx);
1136 }
1137 }
1138 for (i=1; i <= pIndVmax->Length(); i++) {
1139 iv = pIndVmax->Value(i);
1140 if (iv != ivmax) {
1141 IntPatch_Point Vtx=WLine->Vertex(iv);
1142 Vtx.SetParameter(parmax);
1143 if (!arcsResolved(iv).IsNull())
1144 Vtx.SetArc(onFirst,arc,parmax,TransitionUndecided,TransitionUndecided);
1145 if (reverse)
1146 Vtx.ReverseTransition();
1147 rlig->AddVertex(Vtx);
1148 }
1149 }
1150 IntPatch_Point VtxLast=WLine->Vertex(ivmax);
1151 VtxLast.SetParameter(parmax);
1152 if (!arcsResolved(ivmax).IsNull())
1153 VtxLast.SetArc(onFirst,arc,parmax,TransitionUndecided,TransitionUndecided);
1154 if (reverse)
1155 VtxLast.ReverseTransition();
1156 rlig->AddVertex(VtxLast);
1157 rlig->SetFirstPoint(1);
1158 rlig->SetLastPoint(indicesV1.Length()+indicesV2.Length());
1159 slin.Append(rlig);
1160 isRLine = Standard_True;
1161 }
1162 }
1163 }
1164
1165 if(isRLine ||
1166 TestIfWLineIsRestriction(slinref,WLine,
1167 mySurf1,myDom1,
1168 mySurf2,myDom2,
1169 TolArc)) {
1170 slin.Remove(lastwline);
1171 }
1172}
1173
1174//=======================================================================
1175//function : Perform
1176//purpose :
1177//=======================================================================
1178
1179void IntPatch_LineConstructor::Perform(const IntPatch_SequenceOfLine& slinref,
1180 const Handle(IntPatch_Line)& L,
1181 const Handle(Adaptor3d_HSurface)& mySurf1,
1182 const Handle(Adaptor3d_TopolTool)& myDom1,
1183 const Handle(Adaptor3d_HSurface)& mySurf2,
1184 const Handle(Adaptor3d_TopolTool)& myDom2,
1185 const Standard_Real TolArc) {
1186
7fd59977 1187 Standard_Integer i=1,nbvtx;
7fd59977 1188 Standard_Real firstp,lastp;
1189 Standard_Real Tol = Precision::PConfusion()*100.; // JMB le 13 Jan 2000. Report de la correction du PRO19653
1190 GeomAbs_SurfaceType typs1 = mySurf1->GetType();
1191 GeomAbs_SurfaceType typs2 = mySurf2->GetType();
1192
1193 IntPatch_IType typl = L->ArcType();
1194 if(typl == IntPatch_Analytic) {
1195 Standard_Real u1,v1,u2,v2;
1196 Handle(IntPatch_ALine)& ALine
1197 = *((Handle(IntPatch_ALine) *)&L);
1198 slin.Clear();
1199 nbvtx = ALine->NbVertex();
1200 //-- -------------------------------------------------------------------
1201 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1202 Standard_Integer numline=0;
1203 for(i=1;i<=nbvtx;i++) {
1204 //for(Standard_Integer i=1;i<=nbvtx;i++) {
1205 TabIndex[i]=0;
1206 }
1207 //-- -------------------------------------------------------------------
1208 for(i=1;i<nbvtx;i++) {
1209 const IntPatch_Point& ALine_Vertex_i =ALine->Vertex(i);
1210 const IntPatch_Point& ALine_Vertex_ip1=ALine->Vertex(i+1);
1211 firstp = ALine_Vertex_i.ParameterOnLine();
1212 lastp = ALine_Vertex_ip1.ParameterOnLine();
1213 if(firstp!=lastp) {
1214 Standard_Real pmid = (firstp+lastp)*0.5;
1215 gp_Pnt Pmid = ALine->Value(pmid);
1216 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1217 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1218 TopAbs_State in1,in2;
1219 in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1220 in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1221 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1222 }
1223 else {
1224 //-- cout<<"Analytic : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1225 TabIndex[i]=TabIndex[i+1]=++numline;
1226 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1227 }
1228 }
1229 }
1230 //-- -------------------------------------------------------------------
1231 //-- On recherche les vertex interference Edge Edge Externe
1232 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1233 //-- sur les 2 edges
1234 for(i=1;i<=nbvtx;i++) {
1235 if(TabIndex[i]==0) {
1236 const IntPatch_Point& ALine_Vertex_i =ALine->Vertex(i);
1237 if(ALine_Vertex_i.IsOnDomS1() && ALine_Vertex_i.IsOnDomS2()) {
1238 TabIndex[i]=++numline;
1239 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1240 }
1241 }
1242 }
1243 delete [] TabIndex;
1244 //-- -------------------------------------------------------------------
1245 return;
1246 }
1247 else if(typl == IntPatch_Walking) {
1248 Standard_Real u1,v1,u2,v2;
1249 Handle(IntPatch_WLine)& WLine
1250 = *((Handle(IntPatch_WLine) *)&L);
1251 slin.Clear();
1252 nbvtx = WLine->NbVertex();
1253 //-- -------------------------------------------------------------------
1254 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1255 Standard_Integer numline=0;
1256 for(i=1;i<=nbvtx;i++) {
1257 //for(Standard_Integer i=1;i<=nbvtx;i++) {
1258 TabIndex[i]=0;
1259 }
1260 //-- -------------------------------------------------------------------
1261 for(i=1;i<nbvtx;i++) {
1262 const IntPatch_Point& WLineVertex_i = WLine->Vertex(i);
1263 const IntPatch_Point& WLineVertex_ip1 = WLine->Vertex(i+1);
1264 firstp = WLineVertex_i.ParameterOnLine();
1265 lastp = WLineVertex_ip1.ParameterOnLine();
1266 if(firstp!=lastp && !IsSegmentSmall(WLine,i,i+1/*,TolArc*/)) {
1267 Standard_Integer pmid;
1268 pmid = (Standard_Integer)((firstp+lastp)/2);
1269 Standard_Integer int_lastp = (Standard_Integer)lastp;
1270 Standard_Integer int_firstp = (Standard_Integer)firstp;
1271 if(pmid==int_lastp) pmid=int_firstp;
1272 const IntSurf_PntOn2S& Pmid = WLine->Point(pmid);
1273 Pmid.Parameters(u1,v1,u2,v2);
1274 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1275
1276 // modified by NIZHNY-MKK Tue Apr 3 15:03:40 2001.BEGIN
1277 //------------------------------------------
1278 gp_Pnt ap;
1279 gp_Vec ad1u,ad1v;
1280 mySurf1->D1(u1,v1,ap,ad1u,ad1v);
1281 Standard_Real aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1282 //------------------------------------------
1283
1284 //TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1285 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1), aTolerance, Standard_False);
1286 //TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1287 TopAbs_State in2 = TopAbs_OUT;
1288 if (in1!=TopAbs_OUT) {
1289 //------------------------------------------
1290 mySurf2->D1(u2,v2,ap,ad1u,ad1v);
1291 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1292 //------------------------------------------
1293 in2 = myDom2->Classify(gp_Pnt2d(u2,v2), aTolerance, Standard_False);
1294 }
1295 // modified by NIZHNY-MKK Tue Apr 3 15:06:31 2001.END
1296
1297 // modified by NIZHNY-OFV Wed Jun 13 17:31:23 2001
1298 // --purpose: If on a face (lastp-firstp) == 1,
1299 // sometimes it could mean a bad parametrisation of WLine.
1300 // In this case we try to classify the "virtual" WLine point:
1301 // the geometrical point between two vertexes. This emulates
1302 // situation when (lastp-firstp) != 1.
1303 if(Abs(int_lastp-int_firstp) == 1)
1304 {
1305 Standard_Real vFu1,vFv1,vFu2,vFv2,vLu1,vLv1,vLu2,vLv2;
1306 const IntSurf_PntOn2S& vF = WLineVertex_i. PntOn2S();
1307 const IntSurf_PntOn2S& vL = WLineVertex_ip1. PntOn2S();
1308 vF.Parameters(vFu1,vFv1,vFu2,vFv2);
1309 Recadre(mySurf1,mySurf2,vFu1,vFv1,vFu2,vFv2);
1310 vL.Parameters(vLu1,vLv1,vLu2,vLv2);
1311 Recadre(mySurf1,mySurf2,vLu1,vLv1,vLu2,vLv2);
1312 if(in1 != TopAbs_IN)
1313 {
1314 Standard_Real du,dv;
1315 gp_Pnt2d pvF(vFu1,vFv1);
1316 gp_Pnt2d pvL(vLu1,vLv1);
1317 gp_Pnt2d pPm(u1,v1);
1318 Standard_Real dpvFpPm = pvF.Distance(pPm);
1319 Standard_Real dpvLpPm = pvL.Distance(pPm);
1320 if(dpvFpPm > dpvLpPm)
1321 {
1322 du = (vFu1 + u1) * 0.5;
1323 dv = (vFv1 + v1) * 0.5;
1324 }
1325 else
1326 {
1327 du = (vLu1 + u1) * 0.5;
1328 dv = (vLv1 + v1) * 0.5;
1329 }
1330 mySurf1->D1(du,dv,ap,ad1u,ad1v);
1331 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1332 in1 = myDom1->Classify(gp_Pnt2d(du,dv), aTolerance, Standard_False);
1333 }
1334 if(in2 != TopAbs_IN)
1335 {
1336 Standard_Real du,dv;
1337 gp_Pnt2d pvF(vFu2,vFv2);
1338 gp_Pnt2d pvL(vLu2,vLv2);
1339 gp_Pnt2d pPm(u2,v2);
1340 Standard_Real dpvFpPm = pvF.Distance(pPm);
1341 Standard_Real dpvLpPm = pvL.Distance(pPm);
1342 if(dpvFpPm > dpvLpPm)
1343 {
1344 du = (vFu2 + u2) * 0.5;
1345 dv = (vFv2 + v2) * 0.5;
1346 }
1347 else
1348 {
1349 du = (vLu2 + u2) * 0.5;
1350 dv = (vLv2 + v2) * 0.5;
1351 }
1352 mySurf2->D1(du,dv,ap,ad1u,ad1v);
1353 aTolerance = ComputeParametricTolerance(TolArc, ad1u, ad1v);
1354 in2 = myDom2->Classify(gp_Pnt2d(du,dv), aTolerance, Standard_False);
1355 }
1356 } //end of if(Abs(int_lastp-int_firstp) == 1)
1357
1358 if (in1 != TopAbs_OUT && in2 != TopAbs_OUT)
1359 {
1360 Standard_Boolean LignetropPetite=Standard_False;
1361 Standard_Real u1a,v1a,u2a,v2a;
1362 const IntSurf_PntOn2S& Pmid1 = WLine->Point((Standard_Integer)firstp);
1363 Pmid1.Parameters(u1a,v1a,u2a,v2a);
1364 Recadre(mySurf1,mySurf2,u1a,v1a,u2a,v2a);
1365
1366 const IntSurf_PntOn2S& Pmid2 = WLine->Point((Standard_Integer)lastp);
1367 Standard_Real u1b,v1b,u2b,v2b;
1368 Pmid2.Parameters(u1b,v1b,u2b,v2b);
1369 Recadre(mySurf1,mySurf2,u1b,v1b,u2b,v2b);
1370
1371 Standard_Real dd12_u=Abs(u1a-u1b);
1372 Standard_Real dd12_v=Abs(v1a-v1b);
1373 if(dd12_u+dd12_v < 1e-12) {
1374 dd12_u=Abs(u1-u1b);
1375 dd12_v=Abs(v1-v1b);
1376 if(dd12_u+dd12_v < 1e-12) {
1377 LignetropPetite=Standard_True;
1378 }
1379 }
1380 if(LignetropPetite==Standard_False) {
1381 //-- cout<<"WLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1382 TabIndex[i]=TabIndex[i+1]=++numline;
1383 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1384 TestWLineToRLine(slinref,slin,mySurf1,myDom1,mySurf2,myDom2,TolArc); //-- on teste la derniere entree de slin
1385 }
1386 } //end of if (in1 != TopAbs_OUT && in2 != TopAbs_OUT)
1387 } //end of if(firstp!=lastp && !IsSegmentSmall(WLine,i,i+1/*,TolArc*/))
1388 } //end of for(i=1;i<nbvtx;i++)
1389
1390 //-- -------------------------------------------------------------------
1391 //-- On recherche les vertex interference Edge Edge Externe
1392 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1393 //-- sur les 2 edges
1394 for(i=1;i<=nbvtx;i++) {
1395 if(TabIndex[i]==0) {
1396 const IntPatch_Point& WLine_Vertex_i =WLine->Vertex(i);
1397 if(WLine_Vertex_i.IsOnDomS1() && WLine_Vertex_i.IsOnDomS2()) {
1398 TabIndex[i]=++numline;
1399 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1400 }
1401 }
1402 }
1403 delete [] TabIndex;
1404 //-- -------------------------------------------------------------------
1405 return;
1406 }
1407 else if (typl != IntPatch_Restriction) { // JAG 01.07.96
1408 Standard_Real u1,v1,u2,v2;
7fd59977 1409 Handle(IntPatch_GLine)& GLine
1410 = *((Handle(IntPatch_GLine) *)&L);
1411 slin.Clear();
1412 nbvtx = GLine->NbVertex();
1413 //-- -------------------------------------------------------------------
1414 Standard_Integer *TabIndex=new Standard_Integer [nbvtx+2];
1415 Standard_Integer numline=0;
1416// for(Standard_Integer i=1;i<=nbvtx;i++) {
1417 for(i=1;i<=nbvtx;i++) {
1418 TabIndex[i]=0;
1419 }
1420 //-- -------------------------------------------------------------------
1421 Standard_Boolean intrvtested = Standard_False;
1422 for(i=1;i<nbvtx;i++) {
1423 firstp = GLine->Vertex(i).ParameterOnLine();
1424 lastp = GLine->Vertex(i+1).ParameterOnLine();
1425 if(Abs(firstp-lastp)>Precision::PConfusion()) {
1426 intrvtested = Standard_True;
1427 Standard_Real pmid = (firstp+lastp)*0.5;
1428 gp_Pnt Pmid;
1429 if (typl == IntPatch_Lin) {
1430 Pmid = ElCLib::Value(pmid,GLine->Line());
1431 }
1432 else if (typl == IntPatch_Circle) {
1433 Pmid = ElCLib::Value(pmid,GLine->Circle());
1434 }
1435 else if (typl == IntPatch_Ellipse) {
1436 Pmid = ElCLib::Value(pmid,GLine->Ellipse());
1437 }
1438 else if (typl == IntPatch_Hyperbola) {
1439 Pmid = ElCLib::Value(pmid,GLine->Hyperbola());
1440 }
1441 else if (typl == IntPatch_Parabola) {
1442 Pmid = ElCLib::Value(pmid,GLine->Parabola());
1443 }
1444 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1445 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1446
1447 gp_Vec Du,Dv;
1448 gp_Pnt P;
1449 myDom1->Init();
1450 if (myDom2->More()) {
1451 mySurf1->D1(u1,v1,P,Du,Dv);
1452 Tol = ComputeParametricTolerance( myDom1->Tol3d(myDom1->Value()) ,Du,Dv);
1453 }
1454 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1455
1456 myDom2->Init();
1457 if (in1 != TopAbs_OUT && myDom2->More() ) {
1458 mySurf2->D1(u2,v2,P,Du,Dv);
1459 Tol = ComputeParametricTolerance( myDom2->Tol3d(myDom2->Value()) ,Du,Dv);
1460 }
1461 TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1462 // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN
1463 // --purpose: section algo with infinite prism works now!!!
1464 if(in1 == TopAbs_UNKNOWN) in1 = TopAbs_OUT;
1465 if(in2 == TopAbs_UNKNOWN) in2 = TopAbs_OUT;
1466 // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END
1467 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1468 }
1469 else {
1470 //-- cout<<"GLine : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1471 TabIndex[i]=TabIndex[i+1]=++numline;
1472 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1473 }
1474 }
1475 }
1476 if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
1477 firstp = GLine->Vertex(nbvtx).ParameterOnLine();
c6541a0c 1478 lastp = M_PI + M_PI + GLine->Vertex(1).ParameterOnLine();
7fd59977 1479 Standard_Real cadrinf = LocalFirstParameter(L);
1480 Standard_Real cadrsup = LocalLastParameter(L);
1481 Standard_Real acadr = (firstp+lastp)*0.5;
c6541a0c
D
1482 while(acadr < cadrinf) { acadr+=M_PI+M_PI; }
1483 while(acadr > cadrsup) { acadr-=M_PI+M_PI; }
7fd59977 1484 if(acadr>=cadrinf && acadr<=cadrsup) {
1485 if(Abs(firstp-lastp)>Precision::PConfusion()) {
1486 intrvtested = Standard_True;
1487 Standard_Real pmid = (firstp+lastp)*0.5;
1488 gp_Pnt Pmid;
1489 if (typl == IntPatch_Circle) {
1490 Pmid = ElCLib::Value(pmid,GLine->Circle());
1491 }
1492 else {
1493 Pmid = ElCLib::Value(pmid,GLine->Ellipse());
1494 }
1495 Parameters(mySurf1,mySurf2,Pmid,u1,v1,u2,v2);
1496 Recadre(mySurf1,mySurf2,u1,v1,u2,v2);
1497 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol,Standard_False);
1498 TopAbs_State in2 = (in1!=TopAbs_OUT)? myDom2->Classify(gp_Pnt2d(u2,v2),Tol,Standard_False) : TopAbs_OUT;
1499 // modified by NIZHNY-OFV Wed May 30 17:04:08 2001.BEGIN
1500 // --purpose: section algo with infinite prism works now!!!
1501 if(in1 == TopAbs_UNKNOWN) in1 = TopAbs_OUT;
1502 if(in2 == TopAbs_UNKNOWN) in2 = TopAbs_OUT;
1503 // modified by NIZHNY-OFV Wed May 30 17:05:47 2001.END
1504 if(in1 == TopAbs_OUT || in2 == TopAbs_OUT) {
1505 }
1506 else {
1507 //-- cout<<"GLine bis : firtsp="<<firstp<<" lastp="<<lastp<<" Vtx:"<<i<<","<<i+1<<endl;
1508 TabIndex[nbvtx]=TabIndex[1]=++numline;
1509 AddLine(L,nbvtx,1,typs1,typs2,TabIndex,slin);
1510 }
1511 }
1512 }
1513 }
1514 if (!intrvtested) {
1515 // on garde a priori. Il faudrait un point 2d sur chaque
1516 // surface pour prendre la decision. Sera fait dans
1517 // l`appelant
1518 //if(nbvtx) {
1519 // TabIndex[nbvtx]=TabIndex[1]=++numline;
1520 // AddLine(L,1,nbvtx,typs1,typs2,TabIndex,slin);
1521#if DEB
1522 //cout<<"\nIntPatch_LineConstructor : Cas de ligne ou firstp==lastp"<<endl;
1523#endif
1524 //}
1525 }
1526 //-- -------------------------------------------------------------------
1527 //-- On recherche les vertex interference Edge Edge Externe
1528 //-- Ces vertex ne figurent sur aucune ligne et sont Restriction
1529 //-- sur les 2 edges
1530 for(i=1;i<=nbvtx;i++) {
1531 if(TabIndex[i]==0) {
1532 const IntPatch_Point& GLine_Vertex_i =GLine->Vertex(i);
1533 if(GLine_Vertex_i.IsOnDomS1() && GLine_Vertex_i.IsOnDomS2()) {
1534 TabIndex[i]=++numline;
1535 AddLine(L,i,i,typs1,typs2,TabIndex,slin);
1536 }
1537 }
1538 }
1539 delete [] TabIndex;
1540 //-- -------------------------------------------------------------------
1541 return;
1542 }
1543 else { //-- Restriction
1544 Handle(IntPatch_RLine)& RLine
1545 = *((Handle(IntPatch_RLine) *)&L);
1546 slin.Clear();
1547 Standard_Integer NbVtx = RLine->NbVertex();
1548 Standard_Boolean RestOnS1 = RLine->IsArcOnS1();
1549 Standard_Boolean RestOnS2 = RLine->IsArcOnS2();
1550 //-- -------------------------------------------------------------------
1551 Standard_Integer *TabIndex=new Standard_Integer [NbVtx+2];
1552 //Standard_Integer numline=0;
1553 for(i=1; i<=NbVtx; i++) {
1554 TabIndex[i]=0;
1555 }
1556 //-- -------------------------------------------------------------------
1557 for(i=1; i<NbVtx; i++) {
1558 const IntPatch_Point& Vtx1=RLine->Vertex(i);
1559 const IntPatch_Point& Vtx2=RLine->Vertex(i+1);
1560 if(RestOnS1 && RestOnS2) {
1561 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1562 }
1563 else if(RestOnS1) { //-- On na classifie pas sur 1
1564 Standard_Real u0 = Vtx1.ParameterOnLine();
1565 Standard_Real u1 = Vtx2.ParameterOnLine();
1566 if(Abs(u1-u0)>Precision::PConfusion()) {
1567 Standard_Real u = (999.0*u0+u1)*0.001;
1568
1569 gp_Pnt P0=Vtx1.Value();
1570 gp_Pnt2d Px2d=RLine->ArcOnS1()->Value(u);
1571 gp_Pnt Px = mySurf1->Value(Px2d.X(),Px2d.Y());
1572 gp_Vec P0Px=gp_Vec(P0,Px);
1573
1574 Standard_Real U1,V1,U2,V2;
1575 Vtx1.PntOn2S().Parameters(U1,V1,U2,V2);
1576
1577 gp_Vec D1u,D1v;
1578 gp_Pnt P;
1579 mySurf2->D1(U2,V2,P,D1u,D1v);
1580 myDom2->Init();
1581 if (myDom2->More())
1582 Tol = ComputeParametricTolerance( myDom2->Tol3d(myDom2->Value()), D1u,D1v);
1583
1584 //-- le 23 mars 1999
1585 TopAbs_State bornin = myDom2->Classify(gp_Pnt2d(U2,V2),Tol,Standard_False);
1586 if(bornin!=TopAbs_OUT) {
1587 Standard_Real U1t,V1t,U2t,V2t;
1588 Vtx2.PntOn2S().Parameters(U1t,V1t,U2t,V2t);
1589 bornin = myDom2->Classify(gp_Pnt2d(U2t,V2t),Tol,Standard_False);
1590 }
1591 if (bornin==TopAbs_OUT) continue;
1592
1593
1594 //-- Attention , on faisait une estimatoin de deltau et deltav
1595 //-- Maintenant :
1596 //-- POPx . D1u = deltau * D1u.D1u + deltav * D1u.D1v
1597 //-- POPx . D1v = deltau * D1u.D1v + deltav * D1v.D1v
1598 //--
1599 //-- deltau=
1600 Standard_Real D1uD1v,TgD1u,TgD1v,D1uD1u,D1vD1v,DIS;
1601 //Standard_Real DeltaU,DeltaV;
1602 D1uD1u = D1u.Dot(D1u);
1603 D1vD1v = D1v.Dot(D1v);
1604 D1uD1v = D1u.Dot(D1v);
1605 TgD1u = P0Px.Dot(D1u);
1606 TgD1v = P0Px.Dot(D1v);
1607 DIS = D1uD1u * D1vD1v - D1uD1v * D1uD1v;
1608
1609 Standard_Real deltau=1e-10;
1610 Standard_Real deltav=1e-10;
1611 if(DIS<-1e-10 || DIS>1e-10) {
1612 deltau=(TgD1u*D1vD1v-TgD1v*D1uD1v)/DIS;
1613 deltav=(TgD1v*D1uD1u-TgD1u*D1uD1v)/DIS;
1614 }
1615
1616 U2+=deltau;
1617 V2+=deltav;
1618 if(bornin!=TopAbs_OUT) {
1619 TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(U2,V2),Tol,Standard_False);
1620 deltau*=0.05;
1621 deltav*=0.05;
1622 if(in2==TopAbs_OUT) {
1623 in2 = myDom2->Classify(gp_Pnt2d(U2+deltau,V2),Tol,Standard_False);
1624 }
1625 if(in2==TopAbs_OUT) {
1626 in2 = myDom2->Classify(gp_Pnt2d(U2-deltau,V2),Tol,Standard_False);
1627 }
1628 if(in2==TopAbs_OUT) {
1629 in2 = myDom2->Classify(gp_Pnt2d(U2,V2+deltav),Tol,Standard_False);
1630 }
1631 if(in2==TopAbs_OUT) {
1632 in2 = myDom2->Classify(gp_Pnt2d(U2,V2-deltav),Tol,Standard_False);
1633 }
1634
1635 if(in2!=TopAbs_OUT) {
1636 //-- cout<<"RLine ons1 : u0 ="<<u0<<" u1 ="<<u1<<" Vtx:"<<i<<","<<i+1<<endl;
1637 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1638 }
1639 }
1640 }
1641 }
1642 else {
1643 Standard_Real u0 = Vtx1.ParameterOnLine();
1644 Standard_Real u1 = Vtx2.ParameterOnLine();
1645 if(Abs(u1-u0)>Precision::PConfusion()) {
1646 Standard_Real u = (999.0*u0+u1)*0.001;
1647
1648 gp_Pnt P0=Vtx1.Value();
1649 gp_Pnt2d Px2d=RLine->ArcOnS2()->Value(u);
1650 gp_Pnt Px = mySurf2->Value(Px2d.X(),Px2d.Y());
1651 gp_Vec P0Px=gp_Vec(P0,Px);
1652
1653 Standard_Real U1,V1,U2,V2;
1654 Vtx1.PntOn2S().Parameters(U1,V1,U2,V2);
1655
1656 gp_Vec D1u,D1v;
1657 gp_Pnt P;
1658 mySurf1->D1(U1,V1,P,D1u,D1v);
1659 myDom1->Init();
1660 if (myDom2->More())
1661 Tol = ComputeParametricTolerance( myDom1->Tol3d(myDom1->Value()) ,D1u,D1v);
1662
1663 //-- le 23 mars 1999
1664 TopAbs_State bornin = myDom1->Classify(gp_Pnt2d(U1,V1),Tol,Standard_False);
1665 if(bornin!=TopAbs_OUT) {
1666 Standard_Real U1t,V1t,U2t,V2t;
1667 Vtx2.PntOn2S().Parameters(U1t,V1t,U2t,V2t);
1668 bornin = myDom1->Classify(gp_Pnt2d(U1t,V1t),Tol,Standard_False);
1669 }
1670 if (bornin==TopAbs_OUT) continue;
1671
1672
1673 //-- Attention , on faisait une estimatoin de deltau et deltav
1674 //-- Maintenant :
1675 //-- POPx . D1u = deltau * D1u.D1u + deltav * D1u.D1v
1676 //-- POPx . D1v = deltau * D1u.D1v + deltav * D1v.D1v
1677 //--
1678 //-- deltau=
1679 Standard_Real D1uD1v,TgD1u,TgD1v,D1uD1u,D1vD1v,DIS;
1680 //Standard_Real DeltaU,DeltaV;
1681 D1uD1u = D1u.Dot(D1u);
1682 D1vD1v = D1v.Dot(D1v);
1683 D1uD1v = D1u.Dot(D1v);
1684 TgD1u = P0Px.Dot(D1u);
1685 TgD1v = P0Px.Dot(D1v);
1686 DIS = D1uD1u * D1vD1v - D1uD1v * D1uD1v;
1687
1688 Standard_Real deltau=1e-10;
1689 Standard_Real deltav=1e-10;
1690 if(DIS<-1e-10 || DIS>1e-10) {
1691 deltau=(TgD1u*D1vD1v-TgD1v*D1uD1v)/DIS;
1692 deltav=(TgD1v*D1uD1u-TgD1u*D1uD1v)/DIS;
1693 }
1694
1695 U1+=deltau;
1696 V1+=deltav;
1697
1698 if(bornin!=TopAbs_OUT) {
1699 TopAbs_State in2 = myDom1->Classify(gp_Pnt2d(U1,V1),Tol,Standard_False);
1700 deltau*=0.05;
1701 deltav*=0.05;
1702 if(in2==TopAbs_OUT) {
1703 in2 = myDom1->Classify(gp_Pnt2d(U1+deltau,V1),Tol,Standard_False);
1704 }
1705 if(in2==TopAbs_OUT) {
1706 in2 = myDom1->Classify(gp_Pnt2d(U1-deltau,V1),Tol,Standard_False);
1707 }
1708 if(in2==TopAbs_OUT) {
1709 in2 = myDom1->Classify(gp_Pnt2d(U1,V1+deltav),Tol,Standard_False);
1710 }
1711 if(in2==TopAbs_OUT) {
1712 in2 = myDom1->Classify(gp_Pnt2d(U1,V1-deltav),Tol,Standard_False);
1713 }
1714
1715 if(in2!=TopAbs_OUT) {
1716 //-- cout<<"RLine ons2 : u0 ="<<u0<<" u1 ="<<u1<<" Vtx:"<<i<<","<<i+1<<endl;
1717
1718 AddLine(L,i,i+1,typs1,typs2,TabIndex,slin);
1719 }
1720 }
1721 }
1722 }
1723 }
1724 delete [] TabIndex;
1725 }
1726}