1 // File: IntPatch_WLine.cxx
2 // Created: Mon May 27 13:18:45 1991
3 // Author: Isabelle GRIGNON
4 // Copyright: OPEN CASCADE 1991, 1992
6 #include <IntPatch_WLine.ixx>
11 #include <IntSurf_PntOn2S.hxx>
12 #include <Precision.hxx>
16 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
17 const Standard_Boolean Tang,
18 const IntSurf_TypeTrans Trans1,
19 const IntSurf_TypeTrans Trans2) :
20 IntPatch_Line(Tang,Trans1,Trans2),fipt(Standard_False),lapt(Standard_False),
21 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
23 typ = IntPatch_Walking;
28 u1period=v1period=u2period=v2period=0.0;
32 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
33 const Standard_Boolean Tang,
34 const IntSurf_Situation Situ1,
35 const IntSurf_Situation Situ2) :
36 IntPatch_Line(Tang,Situ1,Situ2),fipt(Standard_False),lapt(Standard_False),
37 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
39 typ = IntPatch_Walking;
44 u1period=v1period=u2period=v2period=0.0;
48 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
49 const Standard_Boolean Tang) :
50 IntPatch_Line(Tang),fipt(Standard_False),lapt(Standard_False),
51 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
53 typ = IntPatch_Walking;
58 u1period=v1period=u2period=v2period=0.0;
62 void IntPatch_WLine::SetPoint(const Standard_Integer Index,
63 const IntPatch_Point& thepoint)
65 curv->Value(Index,thepoint.PntOn2S());
69 Handle(IntSurf_LineOn2S) IntPatch_WLine::Curve() const
74 static void RecadreMemePeriode(Standard_Real& u1,Standard_Real& v1,
75 Standard_Real& u2,Standard_Real& v2,
76 const Standard_Real anu1,const Standard_Real anv1,
77 const Standard_Real anu2,const Standard_Real anv2,
78 const Standard_Real U1Period,const Standard_Real V1Period,
79 const Standard_Real U2Period,const Standard_Real V2Period) {
81 while(anu1-u1 > 0.8*U1Period) { u1+=U1Period; }
82 while(u1-anu1 > 0.8*U1Period) { u1-=U1Period; }
85 while(anu2-u2 > 0.8*U2Period) { u2+=U2Period; }
86 while(u2-anu2 > 0.8*U2Period) { u2-=U2Period; }
89 while(anv1-v1 > 0.8*V1Period) { v1+=V1Period; }
90 while(v1-anv1 > 0.8*V1Period) { v1-=V1Period; }
93 while(anv2-v2 > 0.8*V2Period) { v2+=V2Period; }
94 while(v2-anv2 > 0.8*V2Period) { v2-=V2Period; }
99 static void RecadreMemePeriode(IntSurf_PntOn2S& POn2S,const IntSurf_PntOn2S& RefPOn2S,
100 const Standard_Real up1,
101 const Standard_Real vp1,
102 const Standard_Real up2,
103 const Standard_Real vp2) {
104 Standard_Real u1,v1,u2,v2,pu1,pv1,pu2,pv2;
105 POn2S.Parameters(u1,v1,u2,v2);
106 RefPOn2S.Parameters(pu1,pv1,pu2,pv2);
107 RecadreMemePeriode(u1,v1,u2,v2,pu1,pv1,pu2,pv2,up1,vp1,up2,vp2);
108 POn2S.SetValue(u1,v1,u2,v2);
111 static Standard_Boolean CompareVertexAndPoint(const gp_Pnt& V,const gp_Pnt& P,const Standard_Real& Tol) {
112 return(V.Distance(P)<=Tol);
115 void IntPatch_WLine::SetPeriod(const Standard_Real pu1,
116 const Standard_Real pv1,
117 const Standard_Real pu2,
118 const Standard_Real pv2) {
119 u1period=pu1; v1period=pv1; u2period=pu2; v2period=pv2;
121 Standard_Real IntPatch_WLine::U1Period() const { return(u1period); }
122 Standard_Real IntPatch_WLine::V1Period() const { return(v1period); }
123 Standard_Real IntPatch_WLine::U2Period() const { return(u2period); }
124 Standard_Real IntPatch_WLine::V2Period() const { return(v2period); }
127 //------------------------------------------------------------------------
128 //-- En Entree : Une ligne de cheminement + Une Liste de Vetex
130 //-- LineOn2S : 1------2-------3-------4-----5---- ----nbp
132 //-- Vertex : a b c d e f
137 //-- 1--2-3-4--5--------6----7--8--9--10--------
139 //-- avec a de parametre 1
145 //-- !!!!!!!!!!!!!!! On considere que deux vertex ne peuvent pas etre
146 //-- !!!!!!!!!!!!!!! a une distance inferieure a Tol
147 //------------------------------------------------------------------------
149 //-- On Teste si la LineOn2S contient des points confondus.
150 //-- Dans ce cas, on remove ces points.
152 //------------------------------------------------------------------------
154 Standard_Boolean SameVtxRst(const IntPatch_Point& vtx1,const IntPatch_Point& vtx2) {
155 if(vtx1.IsOnDomS1()) {
156 if(vtx2.IsOnDomS1()) {
157 if(vtx1.ArcOnS1() == vtx2.ArcOnS1()) {
158 if(vtx1.ParameterOnArc1() == vtx2.ParameterOnArc1()) {
162 return(Standard_False);
166 return(Standard_False);
170 return(Standard_False);
174 if(vtx2.IsOnDomS1()) {
175 return(Standard_False);
178 if(vtx1.IsOnDomS2()) {
179 if(vtx2.IsOnDomS2()) {
180 if(vtx1.ArcOnS2() == vtx2.ArcOnS2()) {
181 if(vtx1.ParameterOnArc2() == vtx2.ParameterOnArc2()) {
185 return(Standard_False);
189 return(Standard_False);
193 return(Standard_False);
197 if(vtx2.IsOnDomS2()) {
198 return(Standard_False);
201 return(Standard_True);
205 static Standard_Boolean CompareVerticesOnSurf(const IntPatch_Point& vtx1,
206 const IntPatch_Point& vtx2,
207 const Standard_Boolean onFirst)
209 Standard_Real u1,v1,u2,v2, tolU, tolV;
211 vtx1.ParametersOnS1(u1,v1);
212 vtx2.ParametersOnS1(u2,v2);
215 vtx1.ParametersOnS2(u1,v1);
216 vtx2.ParametersOnS2(u2,v2);
218 tolU = Precision::PConfusion();
219 tolV = Precision::PConfusion();
220 return (Abs(u1-u2) <= tolU && Abs(v1-v2) <= tolV);
223 inline Standard_Boolean CompareVerticesOnS1(const IntPatch_Point& vtx1, const IntPatch_Point& vtx2)
224 {return CompareVerticesOnSurf (vtx1, vtx2, Standard_True);}
226 inline Standard_Boolean CompareVerticesOnS2(const IntPatch_Point& vtx1, const IntPatch_Point& vtx2)
227 {return CompareVerticesOnSurf (vtx1, vtx2, Standard_False);}
230 void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) {
232 // MSV Oct 15, 2001: use tolerance of vertex instead of RTol where
235 Standard_Integer i,j,k,nbvtx,nbponline;
236 Standard_Integer indicevertexonline;
237 Standard_Real indicevertex;
239 Standard_Real ParamMinOnLine,ParamMaxOnLine;
240 if(fipt) { ParamMinOnLine = Vertex(indf).ParameterOnLine(); } else { ParamMinOnLine = -100000.0; }
241 if(lapt) { ParamMaxOnLine = Vertex(indl).ParameterOnLine(); } else { ParamMaxOnLine = 100000.0; }
242 Standard_Boolean APointDeleted = Standard_False;
243 //----------------------------------------------------------
244 //-- F i l t r e s u r r e s t r i c t i o n s --
245 //----------------------------------------------------------
246 //-- deux vertex sur la meme restriction et seulement
247 //-- sur celle ci ne doivent pas avoir le meme parametre
249 Standard_Real Tol=RTol;
253 cout<<"\n----------- avant ComputeVertexParameters -------------"<<endl;
254 for(i=1;i<=nbvtx;i++) {
256 Standard_Real polr = Vertex(i).ParameterOnLine();
257 Standard_Real pol = (Standard_Integer)polr;
258 if(pol>=1 && pol<=nbvtx) {
259 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
260 <<","<<Vertex(pol).Value().Y()
261 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
264 cout<<"\n----------------------------------------------------------"<<endl;
268 //-- ----------------------------------------------------------------------
269 //-- Traitement des aretes de couture : On duplique les points situes
270 //-- sur des restrictions differentes
272 //-- Phase Creation de nouveaux points sur S1
273 Standard_Boolean encoreunefois;
276 encoreunefois=Standard_False;
277 for(i=1; i<=nbvtx && encoreunefois==Standard_False; i++) {
278 IntPatch_Point& VTXi = svtx.ChangeValue(i);
279 for(j=1; j<=nbvtx && encoreunefois==Standard_False; j++) {
281 IntPatch_Point& VTXj = svtx.ChangeValue(j);
282 if(VTXi.ParameterOnLine() != VTXj.ParameterOnLine()) {
283 Standard_Real d = VTXi.Value().Distance(VTXj.Value());
284 Standard_Real toli = VTXi.Tolerance();
285 Standard_Real tolj = VTXj.Tolerance();
286 Standard_Real maxtol = Max(toli,tolj);
287 // MSV Oct 30, 2001: compare in 2D space also;
288 // increase tolerances
290 CompareVerticesOnS1(VTXi,VTXj) || CompareVerticesOnS2(VTXi,VTXj)) {
291 //-- Creation Vtx (REF:S1(i) S2(j)) (On Garde S1(i))
292 Standard_Real newtoli = Max (toli, tolj+d*1.01);
293 Standard_Real newtolj = Max (tolj, toli+d*1.01);
294 Standard_Boolean acreer=Standard_False;
295 if(VTXi.IsOnDomS1()) {
296 if(VTXj.IsOnDomS1()) {
297 if(VTXj.ArcOnS1() != VTXi.ArcOnS1()) {
298 acreer=Standard_True;
302 acreer=Standard_True;
308 vtx.SetArc(Standard_True,
310 VTXi.ParameterOnArc1(),
311 VTXi.TransitionLineArc1(),
312 VTXi.TransitionOnS1());
313 for(k=1; encoreunefois==Standard_False && k<=nbvtx; k++) {
314 const IntPatch_Point& VTXk = svtx.Value(k);
315 if(SameVtxRst(VTXk,vtx)) {
316 encoreunefois=Standard_True;
319 if(encoreunefois==Standard_False) {
320 VTXi.SetTolerance(newtoli);
321 VTXj.SetTolerance(newtolj);
322 vtx.SetTolerance(newtolj);
324 encoreunefois=Standard_True;
327 encoreunefois=Standard_False;
330 //-- -----------------------------------------------------
331 //-- Creation Vtx (REF:S2(i) S1(j)) (On Garde S2(i))
332 acreer=Standard_False;
333 if(VTXi.IsOnDomS2()) {
334 if(VTXj.IsOnDomS2()) {
335 if(VTXj.ArcOnS2() != VTXi.ArcOnS2()) {
336 acreer=Standard_True;
340 acreer=Standard_True;
346 vtx.SetArc(Standard_False,
348 VTXi.ParameterOnArc2(),
349 VTXi.TransitionLineArc2(),
350 VTXi.TransitionOnS2());
351 for(k=1; encoreunefois==Standard_False && k<=nbvtx; k++) {
352 const IntPatch_Point& VTXk = svtx.Value(k);
353 if(SameVtxRst(VTXk,vtx)) {
354 encoreunefois=Standard_True;
357 if(encoreunefois==Standard_False) {
358 VTXi.SetTolerance(newtoli);
359 VTXj.SetTolerance(newtolj);
360 vtx.SetTolerance(newtolj);
362 encoreunefois=Standard_True;
365 encoreunefois=Standard_False;
374 while(encoreunefois);
378 //-- ----------------------------------------------------------------------
383 APointDeleted = Standard_False;
384 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
385 const IntPatch_Point& VTXi = svtx.Value(i);
386 if(VTXi.Tolerance() > Tol) Tol = VTXi.Tolerance(); //-- 9 oct 97
387 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
388 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
390 const IntPatch_Point& VTXj = svtx.Value(j);
391 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
392 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
393 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
396 if(lapt) { if(indl>=j) indl--; }
397 if(fipt) { if(indf>=j) indf--; }
398 APointDeleted = Standard_True;
407 while(APointDeleted == Standard_True);
411 APointDeleted = Standard_False;
412 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
413 const IntPatch_Point& VTXi = svtx.Value(i);
414 if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) {
415 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
417 const IntPatch_Point& VTXj = svtx.Value(j);
418 if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) {
419 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
420 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
423 if(lapt) { if(indl>=j) indl--; }
424 if(fipt) { if(indf>=j) indf--; }
425 APointDeleted = Standard_True;
434 while(APointDeleted == Standard_True);
437 nbponline = NbPnts();
439 //----------------------------------------------------
440 //-- On trie les Vertex
441 Standard_Boolean SortIsOK;
443 SortIsOK = Standard_True;
444 for(i=2; i<=nbvtx; i++) {
445 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
446 SortIsOK = Standard_False;
447 svtx.Exchange(i-1,i);
453 //----------------------------------------------------
454 //-- On detecte les points confondus dans la LineOn2S
455 Standard_Real dmini = Precision::Confusion();
457 for(i=2; i<=nbponline; i++) {
458 //const IntSurf_PntOn2S& aPntOn2S1=curv->Value(i-1);
459 //const IntSurf_PntOn2S& aPntOn2S2=curv->Value(i);
460 Standard_Real d = (curv->Value(i-1).Value()).SquareDistance((curv->Value(i).Value()));
462 curv->RemovePoint(i);
464 //----------------------------------------------
465 //-- On recadre les Vertex si besoin
467 for(j=1; j<=nbvtx; j++) {
468 indicevertex = svtx.Value(j).ParameterOnLine();
469 if(indicevertex >= i) {
470 svtx.ChangeValue(j).SetParameter(indicevertex-1.0);
473 //modified by NIZNHY-PKV Mon Feb 11 09:28:02 2002 f
475 //modified by NIZNHY-PKV Mon Feb 11 09:28:04 2002 t
478 //----------------------------------------------------
479 for(i=1; i<=nbvtx; i++) {
480 const gp_Pnt& P = svtx.Value(i).Value();
481 Standard_Real vTol = svtx.Value(i).Tolerance();
482 indicevertex = svtx.Value(i).ParameterOnLine();
483 indicevertexonline = (Standard_Integer)indicevertex;
484 //--------------------------------------------------
485 //-- On Compare le vertex avec les points de la ligne
486 //-- d indice indicevertexOnLine-1
487 //-- indicevertexOnLine
488 //-- indicevertexOnLine+1
489 //--------------------------------------------------
490 if(indicevertexonline<1) {
491 if(CompareVertexAndPoint(P,curv->Value(1).Value(),vTol)) {
492 //-------------------------------------------------------
493 //-- On remplace le point cheminement(1) par vertex(i)
494 //-- et vertex(i) prend pour parametre 1
495 //-------------------------------------------------------
497 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
498 RecadreMemePeriode(POn2S,curv->Value(1),U1Period(),V1Period(),U2Period(),V2Period());
499 curv->Value(1,POn2S);
501 //--curv->Value(1,svtx.Value(i).PntOn2S());
502 svtx.ChangeValue(i).SetParameter(1.0);
505 //-------------------------------------------------------
506 //-- On insere le point de cheminement Vertex(i)
507 //-- On recadre les parametres des autres vertex
508 //-------------------------------------------------------
509 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
510 RecadreMemePeriode(POn2S,curv->Value(1),U1Period(),V1Period(),U2Period(),V2Period());
511 curv->InsertBefore(1,POn2S);
513 //-- curv->InsertBefore(1,svtx.Value(i).PntOn2S());
514 svtx.ChangeValue(i).SetParameter(1.0);
516 for(j=1;j<=nbvtx;j++) {
518 Standard_Real t = svtx.Value(j).ParameterOnLine();
520 svtx.ChangeValue(j).SetParameter(t+1.0);
525 } //--- fin : if(indicevertexonline<1)
527 //---------------------------------------------------------
528 //-- vertex(i) == cheminement (indicevertexonline-1)
529 //-- vertex(i) == cheminement (indicevertexonline)
530 //-- vertex(i) == cheminement (indicevertexonline+1)
531 //---------------------------------------------------------
532 Standard_Boolean Substitution = Standard_False;
533 //-- for(k=indicevertexonline+1; !Substitution && k>=indicevertexonline-1;k--) { avant le 9 oct 97
534 for(k=indicevertexonline+1; k>=indicevertexonline-1;k--) {
535 if(k>0 && k<=nbponline) {
536 if(CompareVertexAndPoint(P,curv->Value(k).Value(),vTol)) {
537 //-------------------------------------------------------
538 //-- On remplace le point cheminement(k)
539 //-- par vertex(i) et vertex(i) prend pour parametre k
540 //-------------------------------------------------------
541 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
542 RecadreMemePeriode(POn2S,curv->Value(k),U1Period(),V1Period(),U2Period(),V2Period());
543 curv->Value(k,POn2S);
544 Standard_Real mu1,mv1,mu2,mv2;
545 POn2S.Parameters(mu1,mv1,mu2,mv2);
546 svtx.ChangeValue(i).SetParameter(k);
547 svtx.ChangeValue(i).SetParameters(mu1,mv1,mu2,mv2);
548 Substitution = Standard_True;
553 //--static int deb6nov98=1; Ne resout rien (a part partiellement BUC60409)
555 //--Substitution=Standard_True;
558 if(Substitution==Standard_False) {
559 //-------------------------------------------------------
560 //-- On insere le point de cheminement Vertex(i)
561 //-- On recadre les parametres des autres vertex
562 //-------------------------------------------------------
563 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
564 if(indicevertexonline >= nbponline) {
565 RecadreMemePeriode(POn2S,curv->Value(nbponline),U1Period(),V1Period(),U2Period(),V2Period());
569 RecadreMemePeriode(POn2S,curv->Value(indicevertexonline+1),U1Period(),V1Period(),U2Period(),V2Period());
570 curv->InsertBefore(indicevertexonline+1,POn2S);
572 //-- curv->InsertBefore(indicevertexonline+1,svtx.Value(i).PntOn2S());
573 svtx.ChangeValue(i).SetParameter(indicevertexonline+1);
575 for(j=1;j<=nbvtx;j++) {
577 Standard_Real t = svtx.Value(j).ParameterOnLine();
578 if(t>(Standard_Real)indicevertexonline) {
579 svtx.ChangeValue(j).SetParameter(t+1.0);
584 } //-- indicevertexonline>=1
586 } //-- boucle i sur vertex
592 APointDeleted = Standard_False;
593 for(i=1; i<=nbvtx && (APointDeleted == Standard_False); i++) {
594 const IntPatch_Point& VTX = svtx.Value(i);
595 for(j=1; j<=nbvtx && (APointDeleted == Standard_False) ; j++) {
597 const IntPatch_Point& VTXM1 = svtx.Value(j);
599 Standard_Boolean kill = Standard_False;
600 Standard_Boolean killm1 = Standard_False;
601 if(VTXM1.ParameterOnLine() == VTX.ParameterOnLine()) {
602 if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) { //-- OnS1 OnS1
603 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS1 == OnS1
604 if(VTXM1.IsOnDomS2()) { //-- OnS1 == OnS1 OnS2
605 if(VTX.IsOnDomS2()==Standard_False) { //-- OnS1 == OnS1 OnS2 PasOnS2
609 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1 OnS2 == OnS2
614 else { //-- OnS1 == OnS1 PasOnS2
615 if(VTX.IsOnDomS2()) { //-- OnS1 == OnS1 PasOnS2 OnS2
616 killm1=Standard_True;
622 if(!(kill || killm1)) {
623 if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) { //-- OnS2 OnS2
624 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS2 == OnS2
625 if(VTXM1.IsOnDomS1()) { //-- OnS2 == OnS2 OnS1
626 if(VTX.IsOnDomS1()==Standard_False) { //-- OnS2 == OnS2 OnS1 PasOnS1
630 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2 OnS1 == OnS1
635 else { //-- OnS2 == OnS2 PasOnS1
636 if(VTX.IsOnDomS1()) { //-- OnS2 == OnS2 PasOnS1 OnS1
637 killm1=Standard_True;
644 APointDeleted = Standard_True;
649 APointDeleted = Standard_True;
658 while(APointDeleted == Standard_True);
661 SortIsOK = Standard_True;
662 for(i=2; i<=nbvtx && SortIsOK; i++) {
663 const IntPatch_Point& Pim1=svtx.Value(i-1);
664 const IntPatch_Point& Pii =svtx.Value(i);
665 if(Pim1.ParameterOnLine()==Pii.ParameterOnLine()) {
666 if( (Pii.IsOnDomS1() == Standard_False)
667 && (Pii.IsOnDomS2() == Standard_False)) {
668 SortIsOK = Standard_False;
673 if( (Pim1.IsOnDomS1() == Standard_False)
674 && (Pim1.IsOnDomS2() == Standard_False)) {
675 SortIsOK = Standard_False;
684 //-- ----------------------------------------------------------------------------
685 //-- On ajoute les vertex de debut et de fin de ligne s il ne sont pas presents.
687 //-- Existe t il un vertex de debut de ligne, de fin .
689 //-- Si Besoin : il faudra dedoubler les points de debut et de fin sur les periodiques ??????
694 Standard_Boolean bFirst = Standard_False;
695 Standard_Boolean bLast = Standard_False;
696 nbponline = NbPnts();
697 for(i=1;i<=nbvtx;i++) {
698 Standard_Real pol = svtx.Value(i).ParameterOnLine();
700 bFirst = fipt = Standard_True;
704 bLast = lapt = Standard_True;
708 if(bFirst == Standard_False) {
709 Standard_Real pu1,pv1,pu2,pv2;
710 Standard_Boolean vtxfound = Standard_False;
712 curv->Value(1).Parameters(pu1,pv1,pu2,pv2);
714 (vtxfound==Standard_False) && (i<=nbvtx);i++) {
715 const IntPatch_Point& V = svtx.Value(i);
716 Standard_Real vTol = V.Tolerance();
717 if(CompareVertexAndPoint(V.Value(),curv->Value(1).Value(),vTol)) {
719 vtx.SetParameters(pu1,pv1,pu2,pv2);
720 vtxfound = Standard_True;
723 if(vtxfound == Standard_False) {
724 vtx.SetValue(curv->Value(1).Value(),Tol,Standard_False);
725 vtx.SetParameters(pu1,pv1,pu2,pv2);
728 svtx.Prepend(vtx); nbvtx++;
729 fipt = Standard_True;
732 if(bLast == Standard_False) {
733 Standard_Real pu1,pv1,pu2,pv2;
734 Standard_Boolean vtxfound = Standard_False;
736 curv->Value(nbponline).Parameters(pu1,pv1,pu2,pv2);
738 (vtxfound==Standard_False) && (i<=nbvtx);i++) {
739 const IntPatch_Point& V = svtx.Value(i);
740 Standard_Real vTol = V.Tolerance();
741 if(CompareVertexAndPoint(V.Value(),curv->Value(nbponline).Value(),vTol)) {
743 vtx.SetParameters(pu1,pv1,pu2,pv2);
744 vtxfound = Standard_True;
747 if(vtxfound == Standard_False) {
748 vtx.SetValue(curv->Value(nbponline).Value(),Tol,Standard_False);
749 vtx.SetParameters(pu1,pv1,pu2,pv2);
751 vtx.SetParameter(nbponline);
752 svtx.Append(vtx); nbvtx++;
753 lapt = Standard_True;
760 //--------------------------------------------------------------
761 //-- ** Detection de points trouves sur une meme restriction
762 //-- avec la meme transition et avec des params on line
764 //-- ** Dans ce cas (-> donnerait un baillemenmt) on supprime
765 //-- le point 'intermediaire'.
766 //-- ** (exemple Vtx(1) ..... Vtx(204) Vtx(205))
767 //-- on supprime le Vtx(204)
768 //-- ** (exemple Vtx(1) Vtx(2) ..... Vtx(205))
769 //-- on supprime le Vtx(2)
770 //-- ** (exemple Vtx(1) ... Vtx(100) Vtx(101) ... Vtx(205))
771 //-- on supprime le Vtx(100) (Vtx(100)et101 sur m restr)
773 //--------------------------------------------------------------
776 APointDeleted = Standard_False;
777 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
778 const IntPatch_Point& VTXi = svtx.Value(i);
779 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
780 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
782 const IntPatch_Point& VTXj = svtx.Value(j);
783 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
784 if( (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()+1)
785 || (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()-1)) {
786 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
787 IntSurf_Transition t1 = VTXi.TransitionLineArc1();
788 IntSurf_Transition t2 = VTXj.TransitionLineArc1();
789 if(t1.TransitionType()==t2.TransitionType()) {
790 if((VTXj.ParameterOnLine()!=1) && (VTXj.ParameterOnLine()!=NbPnts())) {
793 if(lapt) { if(indl>=j) indl--; }
794 if(fipt) { if(indf>=j) indf--; }
795 APointDeleted = Standard_True;
807 //-- meme traitement sur les restrictions du second shape
809 while(APointDeleted == Standard_True);
812 APointDeleted = Standard_False;
813 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
814 const IntPatch_Point& VTXi = svtx.Value(i);
815 if((VTXi.IsOnDomS1()==Standard_False) && (VTXi.IsOnDomS2()==Standard_True)) {
816 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
818 const IntPatch_Point& VTXj = svtx.Value(j);
819 if((VTXj.IsOnDomS1()==Standard_False) && (VTXj.IsOnDomS2()==Standard_True)) {
820 if( (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()+1)
821 || (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()-1)) {
822 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
823 IntSurf_Transition t1 = VTXi.TransitionLineArc2();
824 IntSurf_Transition t2 = VTXj.TransitionLineArc2();
825 if(t1.TransitionType()==t2.TransitionType()) {
826 if((VTXj.ParameterOnLine()!=1) && (VTXj.ParameterOnLine()!=NbPnts())) {
829 if(lapt) { if(indl>=j) indl--; }
830 if(fipt) { if(indf>=j) indf--; }
831 APointDeleted = Standard_True;
842 while(APointDeleted == Standard_True);
843 //--------------------------------------------------------------
845 //--------------------------------------------------------------
846 //-- dans le cas de lignes periodiques du type :
847 //-- Un point sur restriction R1 de param p1 -> P3d1 Vtx1
848 //-- Un point sur restriction R2 de param p2 -> P3d1 Vtx2
850 //-- Un point sur restriction R1 de param p1 -> P3d1 Vtx3
851 //-- pas de point sur R2
853 //-- On doit dans ce cas creer un nouveau Vtx4 = Vtx3 sur la
856 //-- Ce cas se produit qd on a corrige un baillement avec le filtre
867 SortIsOK = Standard_True;
868 for(i=2; i<=nbvtx; i++) {
869 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
870 SortIsOK = Standard_False;
871 svtx.Exchange(i-1,i);
880 cout<<"\n----------- apres ComputeVertexParameters -------------"<<endl;
881 for(i=1;i<=nbvtx;i++) {
883 Standard_Real polr = Vertex(i).ParameterOnLine();
884 Standard_Real pol = (Standard_Integer)polr;
885 if(pol>=1 && pol<=nbvtx) {
886 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
887 <<","<<Vertex(pol).Value().Y()
888 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
891 cout<<"\n----------------------------------------------------------"<<endl;
899 Standard_Boolean IntPatch_WLine::IsOutSurf1Box(const gp_Pnt2d& P1uv) {
901 Standard_Integer n=NbPnts();
902 Standard_Real pu1,pu2,pv1,pv2;
904 for(Standard_Integer i=1;i<=n;i++) {
905 curv->Value(i).Parameters(pu1,pv1,pu2,pv2);
906 Buv1.Add(gp_Pnt2d(pu1,pv1));
908 Buv1.Get(pu1,pv1,pu2,pv2);
912 Buv1.Enlarge(pu2*0.01);
915 Buv1.Enlarge(pv2*0.01);
918 Standard_Boolean out=Buv1.IsOut(P1uv);
922 Standard_Boolean IntPatch_WLine::IsOutSurf2Box(const gp_Pnt2d& P2uv) {
924 Standard_Integer n=NbPnts();
925 Standard_Real pu1,pu2,pv1,pv2;
927 for(Standard_Integer i=1;i<=n;i++) {
928 curv->Value(i).Parameters(pu1,pv1,pu2,pv2);
929 Buv2.Add(gp_Pnt2d(pu2,pv2));
931 Buv2.Get(pu1,pv1,pu2,pv2);
935 Buv2.Enlarge(pu2*0.01);
938 Buv2.Enlarge(pv2*0.01);
941 Standard_Boolean out=Buv2.IsOut(P2uv);
945 Standard_Boolean IntPatch_WLine::IsOutBox(const gp_Pnt& Pxyz) {
947 Standard_Integer n=NbPnts();
949 for(Standard_Integer i=1;i<=n;i++) {
950 gp_Pnt P=curv->Value(i).Value();
953 Standard_Real x0,y0,z0,x1,y1,z1;
954 Bxyz.Get(x0,y0,z0,x1,y1,z1);
955 x1-=x0; y1-=y0; z1-=z0;
958 Bxyz.Enlarge(x1*0.01);
961 Bxyz.Enlarge(z1*0.01);
966 Bxyz.Enlarge(y1*0.01);
969 Bxyz.Enlarge(z1*0.01);
973 Standard_Boolean out=Bxyz.IsOut(Pxyz);
978 Standard_Boolean IntPatch_WLine::HasArcOnS1() const {
982 void IntPatch_WLine::SetArcOnS1(const Handle(Adaptor2d_HCurve2d)& A) {
983 hasArcOnS1=Standard_True;
987 const Handle(Adaptor2d_HCurve2d)& IntPatch_WLine::GetArcOnS1() const {
991 Standard_Boolean IntPatch_WLine::HasArcOnS2() const {
995 void IntPatch_WLine::SetArcOnS2(const Handle(Adaptor2d_HCurve2d)& A) {
996 hasArcOnS2=Standard_True;
1000 const Handle(Adaptor2d_HCurve2d)& IntPatch_WLine::GetArcOnS2() const {
1005 void IntPatch_WLine::Dump() const {
1007 cout<<" ----------- D u m p I n t P a t c h _ W L i n e --------------"<<endl;
1009 Standard_Integer nbp = NbPnts();
1010 printf("Num [X Y Z] [U1 V1] [U2 V2]\n");
1011 // for(Standard_Integer i=1;i<=nbp;i++) {
1012 for(i=1;i<=nbp;i++) {
1013 Standard_Real u1,v1,u2,v2;
1014 Point(i).Parameters(u1,v1,u2,v2);
1015 printf("%4d [%+5.8e %+5.8e %+5.8e] [%+5.8e %+5.8e] [%+5.8e %+5.8e]\n",
1017 Point(i).Value().X(),
1018 Point(i).Value().Y(),
1019 Point(i).Value().Z(),
1023 //cout<<"IntSurf_PntOn2S : "<<i<<" Pnt ("<<curv->Value(i).Value().X()
1024 // <<","<<curv->Value(i).Value().Y()
1025 // <<","<<curv->Value(i).Value().Z()<<")"<<endl;
1026 //cout<<" : u1("<<u1<<") v1("<<v1<<") u2("<<u2<<") v2("<<v2<<")"<<endl;
1029 for(i=1;i<=nbp;i++) {
1031 Standard_Real polr = Vertex(i).ParameterOnLine();
1032 Standard_Integer pol = (Standard_Integer)polr;
1033 if(pol>=1 && pol<=nbp) {
1034 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
1035 <<","<<Vertex(pol).Value().Y()
1036 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
1039 cout<<"\n----------------------------------------------------------"<<endl;