1 // Created on: 1991-05-27
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor2d_HCurve2d.hxx>
20 #include <gp_Pnt2d.hxx>
21 #include <IntPatch_Point.hxx>
22 #include <IntPatch_WLine.hxx>
23 #include <IntSurf_LineOn2S.hxx>
24 #include <IntSurf_PntOn2S.hxx>
25 #include <Standard_DomainError.hxx>
26 #include <Standard_OutOfRange.hxx>
27 #include <Standard_Type.hxx>
32 #include <IntSurf_PntOn2S.hxx>
33 #include <Precision.hxx>
37 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
38 const Standard_Boolean Tang,
39 const IntSurf_TypeTrans Trans1,
40 const IntSurf_TypeTrans Trans2) :
41 IntPatch_PointLine(Tang,Trans1,Trans2),fipt(Standard_False),lapt(Standard_False),
42 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
44 typ = IntPatch_Walking;
49 u1period=v1period=u2period=v2period=0.0;
53 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
54 const Standard_Boolean Tang,
55 const IntSurf_Situation Situ1,
56 const IntSurf_Situation Situ2) :
57 IntPatch_PointLine(Tang,Situ1,Situ2),fipt(Standard_False),lapt(Standard_False),
58 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
60 typ = IntPatch_Walking;
65 u1period=v1period=u2period=v2period=0.0;
69 IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
70 const Standard_Boolean Tang) :
71 IntPatch_PointLine(Tang),fipt(Standard_False),lapt(Standard_False),
72 hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
74 typ = IntPatch_Walking;
79 u1period=v1period=u2period=v2period=0.0;
83 void IntPatch_WLine::SetPoint(const Standard_Integer Index,
84 const IntPatch_Point& thepoint)
86 curv->Value(Index,thepoint.PntOn2S());
90 Handle(IntSurf_LineOn2S) IntPatch_WLine::Curve() const
95 static void RecadreMemePeriode(Standard_Real& u1,Standard_Real& v1,
96 Standard_Real& u2,Standard_Real& v2,
97 const Standard_Real anu1,const Standard_Real anv1,
98 const Standard_Real anu2,const Standard_Real anv2,
99 const Standard_Real U1Period,const Standard_Real V1Period,
100 const Standard_Real U2Period,const Standard_Real V2Period) {
102 while(anu1-u1 > 0.8*U1Period) { u1+=U1Period; }
103 while(u1-anu1 > 0.8*U1Period) { u1-=U1Period; }
106 while(anu2-u2 > 0.8*U2Period) { u2+=U2Period; }
107 while(u2-anu2 > 0.8*U2Period) { u2-=U2Period; }
110 while(anv1-v1 > 0.8*V1Period) { v1+=V1Period; }
111 while(v1-anv1 > 0.8*V1Period) { v1-=V1Period; }
114 while(anv2-v2 > 0.8*V2Period) { v2+=V2Period; }
115 while(v2-anv2 > 0.8*V2Period) { v2-=V2Period; }
120 static void RecadreMemePeriode(IntSurf_PntOn2S& POn2S,const IntSurf_PntOn2S& RefPOn2S,
121 const Standard_Real up1,
122 const Standard_Real vp1,
123 const Standard_Real up2,
124 const Standard_Real vp2) {
125 Standard_Real u1,v1,u2,v2,pu1,pv1,pu2,pv2;
126 POn2S.Parameters(u1,v1,u2,v2);
127 RefPOn2S.Parameters(pu1,pv1,pu2,pv2);
128 RecadreMemePeriode(u1,v1,u2,v2,pu1,pv1,pu2,pv2,up1,vp1,up2,vp2);
129 POn2S.SetValue(u1,v1,u2,v2);
132 static Standard_Boolean CompareVertexAndPoint(const gp_Pnt& V, const gp_Pnt& P, const Standard_Real& Tol) {
133 const Standard_Real aSQDist = V.SquareDistance(P);
134 const Standard_Real aSQTol = Tol*Tol;
135 return (aSQDist <= aSQTol);
138 void IntPatch_WLine::SetPeriod(const Standard_Real pu1,
139 const Standard_Real pv1,
140 const Standard_Real pu2,
141 const Standard_Real pv2) {
142 u1period=pu1; v1period=pv1; u2period=pu2; v2period=pv2;
144 Standard_Real IntPatch_WLine::U1Period() const { return(u1period); }
145 Standard_Real IntPatch_WLine::V1Period() const { return(v1period); }
146 Standard_Real IntPatch_WLine::U2Period() const { return(u2period); }
147 Standard_Real IntPatch_WLine::V2Period() const { return(v2period); }
150 //------------------------------------------------------------------------
151 //-- En Entree : Une ligne de cheminement + Une Liste de Vetex
153 //-- LineOn2S : 1------2-------3-------4-----5---- ----nbp
155 //-- Vertex : a b c d e f
160 //-- 1--2-3-4--5--------6----7--8--9--10--------
162 //-- avec a de parametre 1
168 //-- !!!!!!!!!!!!!!! On considere que deux vertex ne peuvent pas etre
169 //-- !!!!!!!!!!!!!!! a une distance inferieure a Tol
170 //------------------------------------------------------------------------
172 //-- On Teste si la LineOn2S contient des points confondus.
173 //-- Dans ce cas, on remove ces points.
175 //------------------------------------------------------------------------
177 Standard_Boolean SameVtxRst(const IntPatch_Point& vtx1,const IntPatch_Point& vtx2) {
178 if(vtx1.IsOnDomS1()) {
179 if(vtx2.IsOnDomS1()) {
180 if(vtx1.ArcOnS1() == vtx2.ArcOnS1()) {
181 if(vtx1.ParameterOnArc1() == vtx2.ParameterOnArc1()) {
185 return(Standard_False);
189 return(Standard_False);
193 return(Standard_False);
197 if(vtx2.IsOnDomS1()) {
198 return(Standard_False);
201 if(vtx1.IsOnDomS2()) {
202 if(vtx2.IsOnDomS2()) {
203 if(vtx1.ArcOnS2() == vtx2.ArcOnS2()) {
204 if(vtx1.ParameterOnArc2() == vtx2.ParameterOnArc2()) {
208 return(Standard_False);
212 return(Standard_False);
216 return(Standard_False);
220 if(vtx2.IsOnDomS2()) {
221 return(Standard_False);
224 return(Standard_True);
228 static Standard_Boolean CompareVerticesOnSurf(const IntPatch_Point& vtx1,
229 const IntPatch_Point& vtx2,
230 const Standard_Boolean onFirst)
232 Standard_Real u1,v1,u2,v2, tolU, tolV;
234 vtx1.ParametersOnS1(u1,v1);
235 vtx2.ParametersOnS1(u2,v2);
238 vtx1.ParametersOnS2(u1,v1);
239 vtx2.ParametersOnS2(u2,v2);
241 tolU = Precision::PConfusion();
242 tolV = Precision::PConfusion();
243 return (Abs(u1-u2) <= tolU && Abs(v1-v2) <= tolV);
246 inline Standard_Boolean CompareVerticesOnS1(const IntPatch_Point& vtx1, const IntPatch_Point& vtx2)
247 {return CompareVerticesOnSurf (vtx1, vtx2, Standard_True);}
249 inline Standard_Boolean CompareVerticesOnS2(const IntPatch_Point& vtx1, const IntPatch_Point& vtx2)
250 {return CompareVerticesOnSurf (vtx1, vtx2, Standard_False);}
253 void IntPatch_WLine::ComputeVertexParameters( const Standard_Real RTol,
254 const Standard_Boolean hasBeenAdded)
256 // MSV Oct 15, 2001: use tolerance of vertex instead of RTol where
259 Standard_Integer i,j,k,nbvtx,nbponline;
260 Standard_Integer indicevertexonline;
261 Standard_Real indicevertex;
263 Standard_Boolean APointDeleted = Standard_False;
264 //----------------------------------------------------------
265 //-- F i l t r e s u r r e s t r i c t i o n s --
266 //----------------------------------------------------------
267 //-- deux vertex sur la meme restriction et seulement
268 //-- sur celle ci ne doivent pas avoir le meme parametre
270 Standard_Real Tol=RTol;
274 cout<<"\n----------- avant ComputeVertexParameters -------------"<<endl;
275 for(i=1;i<=nbvtx;i++) {
277 Standard_Real polr = Vertex(i).ParameterOnLine();
278 Standard_Real pol = (Standard_Integer)polr;
279 if(pol>=1 && pol<=nbvtx) {
280 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
281 <<","<<Vertex(pol).Value().Y()
282 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
285 cout<<"\n----------------------------------------------------------"<<endl;
289 //-- ----------------------------------------------------------------------
290 //-- Traitement des aretes de couture : On duplique les points situes
291 //-- sur des restrictions differentes
293 //-- Phase Creation de nouveaux points sur S1
294 Standard_Boolean encoreunefois;
297 encoreunefois=Standard_False;
298 for(i=1; i<=nbvtx && encoreunefois==Standard_False; i++) {
299 IntPatch_Point& VTXi = svtx.ChangeValue(i);
300 for(j=1; j<=nbvtx && encoreunefois==Standard_False; j++) {
302 IntPatch_Point& VTXj = svtx.ChangeValue(j);
303 if(VTXi.ParameterOnLine() != VTXj.ParameterOnLine()) {
304 Standard_Real d = VTXi.Value().Distance(VTXj.Value());
305 Standard_Real toli = VTXi.Tolerance();
306 Standard_Real tolj = VTXj.Tolerance();
307 Standard_Real maxtol = Max(toli,tolj);
308 // MSV Oct 30, 2001: compare in 2D space also;
309 // increase tolerances
311 CompareVerticesOnS1(VTXi,VTXj) || CompareVerticesOnS2(VTXi,VTXj)) {
312 //-- Creation Vtx (REF:S1(i) S2(j)) (On Garde S1(i))
313 Standard_Real newtoli = Max (toli, tolj+d*1.01);
314 Standard_Real newtolj = Max (tolj, toli+d*1.01);
315 Standard_Boolean acreer=Standard_False;
316 if(VTXi.IsOnDomS1()) {
317 if(VTXj.IsOnDomS1()) {
318 if(VTXj.ArcOnS1() != VTXi.ArcOnS1()) {
319 acreer=Standard_True;
323 acreer=Standard_True;
329 vtx.SetArc(Standard_True,
331 VTXi.ParameterOnArc1(),
332 VTXi.TransitionLineArc1(),
333 VTXi.TransitionOnS1());
334 for(k=1; encoreunefois==Standard_False && k<=nbvtx; k++) {
335 const IntPatch_Point& VTXk = svtx.Value(k);
336 if(SameVtxRst(VTXk,vtx)) {
337 encoreunefois=Standard_True;
340 if(encoreunefois==Standard_False) {
341 VTXi.SetTolerance(newtoli);
342 VTXj.SetTolerance(newtolj);
343 vtx.SetTolerance(newtolj);
345 encoreunefois=Standard_True;
348 encoreunefois=Standard_False;
351 //-- -----------------------------------------------------
352 //-- Creation Vtx (REF:S2(i) S1(j)) (On Garde S2(i))
353 acreer=Standard_False;
354 if(VTXi.IsOnDomS2()) {
355 if(VTXj.IsOnDomS2()) {
356 if(VTXj.ArcOnS2() != VTXi.ArcOnS2()) {
357 acreer=Standard_True;
361 acreer=Standard_True;
367 vtx.SetArc(Standard_False,
369 VTXi.ParameterOnArc2(),
370 VTXi.TransitionLineArc2(),
371 VTXi.TransitionOnS2());
372 for(k=1; encoreunefois==Standard_False && k<=nbvtx; k++) {
373 const IntPatch_Point& VTXk = svtx.Value(k);
374 if(SameVtxRst(VTXk,vtx)) {
375 encoreunefois=Standard_True;
378 if(encoreunefois==Standard_False) {
379 VTXi.SetTolerance(newtoli);
380 VTXj.SetTolerance(newtolj);
381 vtx.SetTolerance(newtolj);
383 encoreunefois=Standard_True;
386 encoreunefois=Standard_False;
395 while(encoreunefois);
399 //-- ----------------------------------------------------------------------
404 APointDeleted = Standard_False;
405 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
406 const IntPatch_Point& VTXi = svtx.Value(i);
407 if(VTXi.Tolerance() > Tol) Tol = VTXi.Tolerance(); //-- 9 oct 97
408 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
409 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
411 const IntPatch_Point& VTXj = svtx.Value(j);
412 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
413 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
414 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
417 if(lapt) { if(indl>=j) indl--; }
418 if(fipt) { if(indf>=j) indf--; }
419 APointDeleted = Standard_True;
428 while(APointDeleted == Standard_True);
432 APointDeleted = Standard_False;
433 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
434 const IntPatch_Point& VTXi = svtx.Value(i);
435 if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) {
436 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
438 const IntPatch_Point& VTXj = svtx.Value(j);
439 if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) {
440 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
441 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
444 if(lapt) { if(indl>=j) indl--; }
445 if(fipt) { if(indf>=j) indf--; }
446 APointDeleted = Standard_True;
455 while(APointDeleted == Standard_True);
458 nbponline = NbPnts();
460 //----------------------------------------------------
461 //-- On trie les Vertex
462 Standard_Boolean SortIsOK;
464 SortIsOK = Standard_True;
465 for(i=2; i<=nbvtx; i++) {
466 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
467 SortIsOK = Standard_False;
468 svtx.Exchange(i-1,i);
474 //----------------------------------------------------
475 //-- On detecte les points confondus dans la LineOn2S
476 Standard_Real dmini = Precision::Confusion();
478 for(i=2; i<=nbponline; i++) {
479 const IntSurf_PntOn2S& aPnt1=curv->Value(i-1);
480 const IntSurf_PntOn2S& aPnt2=curv->Value(i);
481 Standard_Real d = (aPnt1.Value()).SquareDistance((aPnt2.Value()));
483 curv->RemovePoint(i);
485 //----------------------------------------------
486 //-- On recadre les Vertex si besoin
488 for(j=1; j<=nbvtx; j++) {
489 indicevertex = svtx.Value(j).ParameterOnLine();
490 if(indicevertex >= i) {
491 svtx.ChangeValue(j).SetParameter(indicevertex-1.0);
494 //modified by NIZNHY-PKV Mon Feb 11 09:28:02 2002 f
496 //modified by NIZNHY-PKV Mon Feb 11 09:28:04 2002 t
499 //----------------------------------------------------
500 for(i=1; i<=nbvtx; i++) {
501 const gp_Pnt& P = svtx.Value(i).Value();
502 Standard_Real vTol = svtx.Value(i).Tolerance();
510 indicevertex = curv->NbPoints();
514 indicevertex = svtx.Value(i).ParameterOnLine();
519 indicevertex = svtx.Value(i).ParameterOnLine();
524 indicevertex = svtx.Value(i).ParameterOnLine();
527 indicevertexonline = (Standard_Integer)indicevertex;
528 //--------------------------------------------------
529 //-- On Compare le vertex avec les points de la ligne
530 //-- d indice indicevertexOnLine-1
531 //-- indicevertexOnLine
532 //-- indicevertexOnLine+1
533 //--------------------------------------------------
534 if(indicevertexonline<1) {
535 if(CompareVertexAndPoint(P,curv->Value(1).Value(),vTol)) {
536 //-------------------------------------------------------
537 //-- On remplace le point cheminement(1) par vertex(i)
538 //-- et vertex(i) prend pour parametre 1
539 //-------------------------------------------------------
541 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
542 RecadreMemePeriode(POn2S,curv->Value(1),U1Period(),V1Period(),U2Period(),V2Period());
543 curv->Value(1,POn2S);
545 //--curv->Value(1,svtx.Value(i).PntOn2S());
546 svtx.ChangeValue(i).SetParameter(1.0);
549 //-------------------------------------------------------
550 //-- On insere le point de cheminement Vertex(i)
551 //-- On recadre les parametres des autres vertex
552 //-------------------------------------------------------
553 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
554 RecadreMemePeriode(POn2S,curv->Value(1),U1Period(),V1Period(),U2Period(),V2Period());
555 curv->InsertBefore(1,POn2S);
557 //-- curv->InsertBefore(1,svtx.Value(i).PntOn2S());
558 svtx.ChangeValue(i).SetParameter(1.0);
560 for(j=1;j<=nbvtx;j++) {
562 Standard_Real t = svtx.Value(j).ParameterOnLine();
564 svtx.ChangeValue(j).SetParameter(t+1.0);
569 } //--- fin : if(indicevertexonline<1)
571 //---------------------------------------------------------
572 //-- vertex(i) == cheminement (indicevertexonline-1)
573 //-- vertex(i) == cheminement (indicevertexonline)
574 //-- vertex(i) == cheminement (indicevertexonline+1)
575 //---------------------------------------------------------
576 Standard_Boolean Substitution = Standard_False;
577 //-- for(k=indicevertexonline+1; !Substitution && k>=indicevertexonline-1;k--) { avant le 9 oct 97
578 for(k=indicevertexonline+1; k>=indicevertexonline-1;k--) {
579 if(k>0 && k<=nbponline) {
580 if(CompareVertexAndPoint(P,curv->Value(k).Value(),vTol)) {
581 //-------------------------------------------------------
582 //-- On remplace le point cheminement(k)
583 //-- par vertex(i) et vertex(i) prend pour parametre k
584 //-------------------------------------------------------
585 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
586 RecadreMemePeriode(POn2S,curv->Value(k),U1Period(),V1Period(),U2Period(),V2Period());
587 curv->Value(k,POn2S);
588 Standard_Real mu1,mv1,mu2,mv2;
589 POn2S.Parameters(mu1,mv1,mu2,mv2);
590 svtx.ChangeValue(i).SetParameter(k);
591 svtx.ChangeValue(i).SetParameters(mu1,mv1,mu2,mv2);
592 Substitution = Standard_True;
597 //Remove duplicating points
600 Standard_Integer ind_point;
601 for(ind_point = 2; (ind_point <= nbponline && nbponline > 2); ind_point++) {
602 Standard_Real d = (curv->Value(ind_point-1).Value()).SquareDistance((curv->Value(ind_point).Value()));
604 curv->RemovePoint(ind_point);
606 //----------------------------------------------
607 //-- On recadre les Vertex si besoin
609 for(j=1; j<=nbvtx; j++) {
610 indicevertex = svtx.Value(j).ParameterOnLine();
611 if(indicevertex >= ind_point) {
612 svtx.ChangeValue(j).SetParameter(indicevertex-1.0);
615 //modified by NIZNHY-PKV Mon Feb 11 09:28:02 2002 f
617 //modified by NIZNHY-PKV Mon Feb 11 09:28:04 2002 t
622 //--static int deb6nov98=1; Ne resout rien (a part partiellement BUC60409)
624 //--Substitution=Standard_True;
627 if(Substitution==Standard_False) {
628 //-------------------------------------------------------
629 //-- On insere le point de cheminement Vertex(i)
630 //-- On recadre les parametres des autres vertex
631 //-------------------------------------------------------
632 IntSurf_PntOn2S POn2S = svtx.Value(i).PntOn2S();
633 if(indicevertexonline >= nbponline) {
634 RecadreMemePeriode(POn2S,curv->Value(nbponline),U1Period(),V1Period(),U2Period(),V2Period());
638 RecadreMemePeriode(POn2S,curv->Value(indicevertexonline+1),U1Period(),V1Period(),U2Period(),V2Period());
639 curv->InsertBefore(indicevertexonline+1,POn2S);
641 //-- curv->InsertBefore(indicevertexonline+1,svtx.Value(i).PntOn2S());
642 svtx.ChangeValue(i).SetParameter(indicevertexonline+1);
644 for(j=1;j<=nbvtx;j++) {
646 Standard_Real t = svtx.Value(j).ParameterOnLine();
647 if(t>(Standard_Real)indicevertexonline) {
648 svtx.ChangeValue(j).SetParameter(t+1.0);
653 } //-- indicevertexonline>=1
655 } //-- boucle i sur vertex
661 APointDeleted = Standard_False;
662 for(i=1; i<=nbvtx && (APointDeleted == Standard_False); i++) {
663 const IntPatch_Point& VTX = svtx.Value(i);
664 for(j=1; j<=nbvtx && (APointDeleted == Standard_False) ; j++) {
666 const IntPatch_Point& VTXM1 = svtx.Value(j);
668 Standard_Boolean kill = Standard_False;
669 Standard_Boolean killm1 = Standard_False;
670 if(VTXM1.ParameterOnLine() == VTX.ParameterOnLine()) {
671 if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) { //-- OnS1 OnS1
672 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS1 == OnS1
673 if(VTXM1.IsOnDomS2()) { //-- OnS1 == OnS1 OnS2
674 if(VTX.IsOnDomS2()==Standard_False) { //-- OnS1 == OnS1 OnS2 PasOnS2
678 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1 OnS2 == OnS2
683 else { //-- OnS1 == OnS1 PasOnS2
684 if(VTX.IsOnDomS2()) { //-- OnS1 == OnS1 PasOnS2 OnS2
685 killm1=Standard_True;
691 if(!(kill || killm1)) {
692 if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) { //-- OnS2 OnS2
693 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS2 == OnS2
694 if(VTXM1.IsOnDomS1()) { //-- OnS2 == OnS2 OnS1
695 if(VTX.IsOnDomS1()==Standard_False) { //-- OnS2 == OnS2 OnS1 PasOnS1
699 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2 OnS1 == OnS1
704 else { //-- OnS2 == OnS2 PasOnS1
705 if(VTX.IsOnDomS1()) { //-- OnS2 == OnS2 PasOnS1 OnS1
706 killm1=Standard_True;
713 APointDeleted = Standard_True;
718 APointDeleted = Standard_True;
727 while(APointDeleted == Standard_True);
730 SortIsOK = Standard_True;
731 for(i=2; i<=nbvtx && SortIsOK; i++) {
732 const IntPatch_Point& Pim1=svtx.Value(i-1);
733 const IntPatch_Point& Pii =svtx.Value(i);
734 if(Pim1.ParameterOnLine()==Pii.ParameterOnLine()) {
735 if( (Pii.IsOnDomS1() == Standard_False)
736 && (Pii.IsOnDomS2() == Standard_False)) {
737 SortIsOK = Standard_False;
742 if( (Pim1.IsOnDomS1() == Standard_False)
743 && (Pim1.IsOnDomS2() == Standard_False)) {
744 SortIsOK = Standard_False;
753 //-- ----------------------------------------------------------------------------
754 //-- On ajoute les vertex de debut et de fin de ligne s il ne sont pas presents.
756 //-- Existe t il un vertex de debut de ligne, de fin .
758 //-- Si Besoin : il faudra dedoubler les points de debut et de fin sur les periodiques ??????
763 Standard_Boolean bFirst = Standard_False;
764 Standard_Boolean bLast = Standard_False;
765 nbponline = NbPnts();
766 for(i=1;i<=nbvtx;i++) {
767 Standard_Real pol = svtx.Value(i).ParameterOnLine();
769 bFirst = fipt = Standard_True;
773 bLast = lapt = Standard_True;
777 if(bFirst == Standard_False) {
778 Standard_Real pu1,pv1,pu2,pv2;
779 Standard_Boolean vtxfound = Standard_False;
781 curv->Value(1).Parameters(pu1,pv1,pu2,pv2);
783 (vtxfound==Standard_False) && (i<=nbvtx);i++) {
784 const IntPatch_Point& V = svtx.Value(i);
785 //jgv: to avoid loops
786 //Standard_Real vTol = V.Tolerance();
787 if(CompareVertexAndPoint(V.Value(), curv->Value(1).Value(), Precision::Confusion()/*vTol*/)) {
789 vtx.SetParameters(pu1,pv1,pu2,pv2);
790 vtxfound = Standard_True;
793 if(vtxfound == Standard_False) {
794 vtx.SetValue(curv->Value(1).Value(),Tol,Standard_False);
795 vtx.SetParameters(pu1,pv1,pu2,pv2);
798 svtx.Prepend(vtx); nbvtx++;
799 fipt = Standard_True;
802 if(bLast == Standard_False) {
803 Standard_Real pu1,pv1,pu2,pv2;
804 Standard_Boolean vtxfound = Standard_False;
806 curv->Value(nbponline).Parameters(pu1,pv1,pu2,pv2);
808 (vtxfound==Standard_False) && (i<=nbvtx);i++) {
809 const IntPatch_Point& V = svtx.Value(i);
810 //jgv: to avoid loops
811 //Standard_Real vTol = V.Tolerance();
812 if(CompareVertexAndPoint(V.Value(), curv->Value(nbponline).Value(), Precision::Confusion()/*vTol*/)) {
814 vtx.SetParameters(pu1,pv1,pu2,pv2);
815 vtxfound = Standard_True;
818 if(vtxfound == Standard_False) {
819 vtx.SetValue(curv->Value(nbponline).Value(),Tol,Standard_False);
820 vtx.SetParameters(pu1,pv1,pu2,pv2);
822 vtx.SetParameter(nbponline);
823 svtx.Append(vtx); nbvtx++;
824 lapt = Standard_True;
831 //--------------------------------------------------------------
832 //-- ** Detection de points trouves sur une meme restriction
833 //-- avec la meme transition et avec des params on line
835 //-- ** Dans ce cas (-> donnerait un baillemenmt) on supprime
836 //-- le point 'intermediaire'.
837 //-- ** (exemple Vtx(1) ..... Vtx(204) Vtx(205))
838 //-- on supprime le Vtx(204)
839 //-- ** (exemple Vtx(1) Vtx(2) ..... Vtx(205))
840 //-- on supprime le Vtx(2)
841 //-- ** (exemple Vtx(1) ... Vtx(100) Vtx(101) ... Vtx(205))
842 //-- on supprime le Vtx(100) (Vtx(100)et101 sur m restr)
844 //--------------------------------------------------------------
847 APointDeleted = Standard_False;
848 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
849 const IntPatch_Point& VTXi = svtx.Value(i);
850 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
851 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
853 const IntPatch_Point& VTXj = svtx.Value(j);
854 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
855 if( (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()+1)
856 || (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()-1)) {
857 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
858 IntSurf_Transition t1 = VTXi.TransitionLineArc1();
859 IntSurf_Transition t2 = VTXj.TransitionLineArc1();
860 if(t1.TransitionType()==t2.TransitionType()) {
861 if((VTXj.ParameterOnLine()!=1) && (VTXj.ParameterOnLine()!=NbPnts())) {
864 if(lapt) { if(indl>=j) indl--; }
865 if(fipt) { if(indf>=j) indf--; }
866 APointDeleted = Standard_True;
878 //-- meme traitement sur les restrictions du second shape
880 while(APointDeleted == Standard_True);
883 APointDeleted = Standard_False;
884 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
885 const IntPatch_Point& VTXi = svtx.Value(i);
886 if((VTXi.IsOnDomS1()==Standard_False) && (VTXi.IsOnDomS2()==Standard_True)) {
887 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
889 const IntPatch_Point& VTXj = svtx.Value(j);
890 if((VTXj.IsOnDomS1()==Standard_False) && (VTXj.IsOnDomS2()==Standard_True)) {
891 if( (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()+1)
892 || (VTXi.ParameterOnLine() == VTXj.ParameterOnLine()-1)) {
893 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
894 IntSurf_Transition t1 = VTXi.TransitionLineArc2();
895 IntSurf_Transition t2 = VTXj.TransitionLineArc2();
896 if(t1.TransitionType()==t2.TransitionType()) {
897 if((VTXj.ParameterOnLine()!=1) && (VTXj.ParameterOnLine()!=NbPnts())) {
900 if(lapt) { if(indl>=j) indl--; }
901 if(fipt) { if(indf>=j) indf--; }
902 APointDeleted = Standard_True;
913 while(APointDeleted == Standard_True);
914 //--------------------------------------------------------------
916 //--------------------------------------------------------------
917 //-- dans le cas de lignes periodiques du type :
918 //-- Un point sur restriction R1 de param p1 -> P3d1 Vtx1
919 //-- Un point sur restriction R2 de param p2 -> P3d1 Vtx2
921 //-- Un point sur restriction R1 de param p1 -> P3d1 Vtx3
922 //-- pas de point sur R2
924 //-- On doit dans ce cas creer un nouveau Vtx4 = Vtx3 sur la
927 //-- Ce cas se produit qd on a corrige un baillement avec le filtre
938 SortIsOK = Standard_True;
939 for(i=2; i<=nbvtx; i++) {
940 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
941 SortIsOK = Standard_False;
942 svtx.Exchange(i-1,i);
951 cout<<"\n----------- apres ComputeVertexParameters -------------"<<endl;
952 for(i=1;i<=nbvtx;i++) {
954 Standard_Real polr = Vertex(i).ParameterOnLine();
955 Standard_Real pol = (Standard_Integer)polr;
956 if(pol>=1 && pol<=nbvtx) {
957 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
958 <<","<<Vertex(pol).Value().Y()
959 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
962 cout<<"\n----------------------------------------------------------"<<endl;
970 Standard_Boolean IntPatch_WLine::IsOutSurf1Box(const gp_Pnt2d& P1uv) {
972 Standard_Integer n=NbPnts();
973 Standard_Real pu1,pu2,pv1,pv2;
975 for(Standard_Integer i=1;i<=n;i++) {
976 curv->Value(i).Parameters(pu1,pv1,pu2,pv2);
977 Buv1.Add(gp_Pnt2d(pu1,pv1));
979 Buv1.Get(pu1,pv1,pu2,pv2);
983 Buv1.Enlarge(pu2*0.01);
986 Buv1.Enlarge(pv2*0.01);
989 Standard_Boolean out=Buv1.IsOut(P1uv);
993 Standard_Boolean IntPatch_WLine::IsOutSurf2Box(const gp_Pnt2d& P2uv) {
995 Standard_Integer n=NbPnts();
996 Standard_Real pu1,pu2,pv1,pv2;
998 for(Standard_Integer i=1;i<=n;i++) {
999 curv->Value(i).Parameters(pu1,pv1,pu2,pv2);
1000 Buv2.Add(gp_Pnt2d(pu2,pv2));
1002 Buv2.Get(pu1,pv1,pu2,pv2);
1006 Buv2.Enlarge(pu2*0.01);
1009 Buv2.Enlarge(pv2*0.01);
1012 Standard_Boolean out=Buv2.IsOut(P2uv);
1016 Standard_Boolean IntPatch_WLine::IsOutBox(const gp_Pnt& Pxyz) {
1017 if(Bxyz.IsWhole()) {
1018 Standard_Integer n=NbPnts();
1020 for(Standard_Integer i=1;i<=n;i++) {
1021 gp_Pnt P=curv->Value(i).Value();
1024 Standard_Real x0,y0,z0,x1,y1,z1;
1025 Bxyz.Get(x0,y0,z0,x1,y1,z1);
1026 x1-=x0; y1-=y0; z1-=z0;
1029 Bxyz.Enlarge(x1*0.01);
1032 Bxyz.Enlarge(z1*0.01);
1037 Bxyz.Enlarge(y1*0.01);
1040 Bxyz.Enlarge(z1*0.01);
1044 Standard_Boolean out=Bxyz.IsOut(Pxyz);
1049 Standard_Boolean IntPatch_WLine::HasArcOnS1() const {
1053 void IntPatch_WLine::SetArcOnS1(const Handle(Adaptor2d_HCurve2d)& A) {
1054 hasArcOnS1=Standard_True;
1058 const Handle(Adaptor2d_HCurve2d)& IntPatch_WLine::GetArcOnS1() const {
1062 Standard_Boolean IntPatch_WLine::HasArcOnS2() const {
1066 void IntPatch_WLine::SetArcOnS2(const Handle(Adaptor2d_HCurve2d)& A) {
1067 hasArcOnS2=Standard_True;
1071 const Handle(Adaptor2d_HCurve2d)& IntPatch_WLine::GetArcOnS2() const {
1076 void IntPatch_WLine::Dump() const {
1078 cout<<" ----------- D u m p I n t P a t c h _ W L i n e --------------"<<endl;
1080 Standard_Integer nbp = NbPnts();
1081 printf("Num [X Y Z] [U1 V1] [U2 V2]\n");
1082 // for(Standard_Integer i=1;i<=nbp;i++) {
1083 for(i=1;i<=nbp;i++) {
1084 Standard_Real u1,v1,u2,v2;
1085 Point(i).Parameters(u1,v1,u2,v2);
1086 printf("%4d [%+10.20f %+10.20f %+10.20f] [%+10.20f %+10.20f] [%+10.20f %+10.20f]\n",
1088 Point(i).Value().X(),
1089 Point(i).Value().Y(),
1090 Point(i).Value().Z(),
1094 //cout<<"IntSurf_PntOn2S : "<<i<<" Pnt ("<<curv->Value(i).Value().X()
1095 // <<","<<curv->Value(i).Value().Y()
1096 // <<","<<curv->Value(i).Value().Z()<<")"<<endl;
1097 //cout<<" : u1("<<u1<<") v1("<<v1<<") u2("<<u2<<") v2("<<v2<<")"<<endl;
1100 for(i=1;i<=nbp;i++) {
1102 Standard_Real polr = Vertex(i).ParameterOnLine();
1103 Standard_Integer pol = (Standard_Integer)polr;
1104 if(pol>=1 && pol<=nbp) {
1105 cout<<"----> IntSurf_PntOn2S : "<<polr<<" Pnt ("<<Vertex(pol).Value().X()
1106 <<","<<Vertex(pol).Value().Y()
1107 <<","<<Vertex(pol).Value().Z()<<")"<<endl;
1110 cout<<"\n----------------------------------------------------------"<<endl;