0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / IntPatch / IntPatch_GLine.cxx
1 // File:        IntPatch_GLine.cxx
2 // Created:     Mon Apr  6 11:17:45 1992
3 // Author:      Jacques GOUSSARD
4 // Copyright:   OPEN CASCADE 1992
5
6 #include <IntPatch_GLine.ixx>
7
8 #define DEBUG 0
9
10 //  modified by Edward AGAPOV (eap) Wed Mar 6 2002 (bug occ212)
11 //  -- case: points with equal params == PI/2 
12   
13 //-- Precision::PConfusion()*1000.0  -> 1e-6
14 //#define PrecisionPConfusion ( Precision::PConfusion()*1000.0 )
15
16 #include <gp_Pln.hxx>
17
18 //=======================================================================
19 //function : IntPatch_GLine
20 //purpose  : Creates a Line as intersection line
21 //           when the transitions are In or Out.
22 //=======================================================================
23
24 IntPatch_GLine::IntPatch_GLine (const gp_Lin& L,
25                                 const Standard_Boolean Tang,
26                                 const IntSurf_TypeTrans Trans1,
27                                                                 const IntSurf_TypeTrans Trans2) :
28   IntPatch_Line(Tang,Trans1,Trans2),
29   par1(0.0), par2(0.0),
30   fipt(Standard_False),lapt(Standard_False),
31   indf(0), indl(0)
32 {
33   typ = IntPatch_Lin;
34   pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2();
35 }
36
37 //=======================================================================
38 //function : IntPatch_GLine
39 //purpose  : Creates a Line as intersection line
40 //           when the transitions are Touch.
41 //=======================================================================
42
43 IntPatch_GLine::IntPatch_GLine (const gp_Lin& L,
44                                 const Standard_Boolean Tang,
45                                 const IntSurf_Situation Situ1,
46                                 const IntSurf_Situation Situ2) :
47   IntPatch_Line(Tang,Situ1,Situ2),
48   par1(0.0), par2(0.0),
49   fipt(Standard_False),lapt(Standard_False),
50   indf(0), indl(0)
51 {
52   typ = IntPatch_Lin;
53   pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2();
54 }
55
56 //=======================================================================
57 //function : IntPatch_GLine
58 //purpose  : Creates a Line as intersection line
59 //           when the transitions are Undecided.
60 //=======================================================================
61
62 IntPatch_GLine::IntPatch_GLine (const gp_Lin& L,
63                                 const Standard_Boolean Tang) :
64   IntPatch_Line(Tang),
65   par1(0.0), par2(0.0),
66   fipt(Standard_False),lapt(Standard_False),
67   indf(0), indl(0)
68 {
69   typ = IntPatch_Lin;
70   pos = gp_Pln(L.Location(),L.Direction()).Position().Ax2();
71 }
72
73 //=======================================================================
74 //function : IntPatch_GLine
75 //purpose  : Creates a circle as intersection line
76 //           when the transitions are In or Out.
77 //=======================================================================
78
79 IntPatch_GLine::IntPatch_GLine (const gp_Circ& C,
80                                 const Standard_Boolean Tang,
81                                 const IntSurf_TypeTrans Trans1,
82                                 const IntSurf_TypeTrans Trans2) :
83   IntPatch_Line(Tang,Trans1,Trans2),
84   pos(C.Position()),
85   par1(C.Radius()), par2(0.0),
86   fipt(Standard_False),lapt(Standard_False),
87   indf(0), indl(0)
88 {
89   typ = IntPatch_Circle;
90 }
91
92 //=======================================================================
93 //function : IntPatch_GLine
94 //purpose  : Creates a circle as intersection line
95 //           when the transitions are Touch.
96 //=======================================================================
97
98 IntPatch_GLine::IntPatch_GLine (const gp_Circ& C,
99                                 const Standard_Boolean Tang,
100                                 const IntSurf_Situation Situ1,
101                                 const IntSurf_Situation Situ2) :
102   IntPatch_Line(Tang,Situ1,Situ2),
103   pos(C.Position()),
104   par1(C.Radius()), par2(0.0),
105   fipt(Standard_False),lapt(Standard_False),
106   indf(0), indl(0)
107 {
108   typ = IntPatch_Circle;
109 }
110
111 //=======================================================================
112 //function : IntPatch_GLine
113 //purpose  : Creates a circle as intersection line
114 //           when the transitions are Undecided.
115 //=======================================================================
116
117 IntPatch_GLine::IntPatch_GLine (const gp_Circ& C,
118                                 const Standard_Boolean Tang) :
119   IntPatch_Line(Tang),
120   pos(C.Position()),
121   par1(C.Radius()), par2(0.0),
122   fipt(Standard_False),lapt(Standard_False),
123   indf(0), indl(0)
124 {
125   typ = IntPatch_Circle;
126 }
127
128 //=======================================================================
129 //function : IntPatch_GLine
130 //purpose  : Creates an ellipse as intersection line
131 //           when the transitions are In or Out.
132 //=======================================================================
133
134 IntPatch_GLine::IntPatch_GLine (const gp_Elips& E,
135                                 const Standard_Boolean Tang,
136                                 const IntSurf_TypeTrans Trans1,
137                                 const IntSurf_TypeTrans Trans2) :
138   IntPatch_Line(Tang,Trans1,Trans2),
139   pos(E.Position()),
140   par1(E.MajorRadius()),
141   par2(E.MinorRadius()),
142   fipt(Standard_False),lapt(Standard_False),
143   indf(0), indl(0)
144 {
145   typ = IntPatch_Ellipse;
146 }
147
148 //=======================================================================
149 //function : IntPatch_GLine
150 //purpose  : Creates an ellispe as intersection line
151 //           when the transitions are Touch.
152 //=======================================================================
153
154 IntPatch_GLine::IntPatch_GLine (const gp_Elips& E,
155                                 const Standard_Boolean Tang,
156                                 const IntSurf_Situation Situ1,
157                                 const IntSurf_Situation Situ2) :
158   IntPatch_Line(Tang,Situ1,Situ2),
159   pos(E.Position()),
160   par1(E.MajorRadius()),
161   par2(E.MinorRadius()),
162   fipt(Standard_False),lapt(Standard_False),
163   indf(0), indl(0)
164 {
165   typ = IntPatch_Ellipse;
166 }
167
168 //=======================================================================
169 //function : IntPatch_GLine
170 //purpose  : Creates an ellipse as intersection line
171 //           when the transitions are Undecided.
172 //=======================================================================
173
174 IntPatch_GLine::IntPatch_GLine (const gp_Elips& E,
175                                 const Standard_Boolean Tang) :
176   IntPatch_Line(Tang),
177   pos(E.Position()),
178   par1(E.MajorRadius()),
179   par2(E.MinorRadius()),
180   fipt(Standard_False),lapt(Standard_False),
181   indf(0), indl(0)
182 {
183   typ = IntPatch_Ellipse;
184 }
185
186 //=======================================================================
187 //function : IntPatch_GLine
188 //purpose  : Creates a parabola as intersection line
189 //           when the transitions are In or Out.
190 //=======================================================================
191
192 IntPatch_GLine::IntPatch_GLine (const gp_Parab& P,
193                                 const Standard_Boolean Tang,
194                                 const IntSurf_TypeTrans Trans1,
195                                 const IntSurf_TypeTrans Trans2) :
196   IntPatch_Line(Tang,Trans1,Trans2),
197   pos(P.Position()),
198   par1(P.Focal()), par2(0.0),
199   fipt(Standard_False),lapt(Standard_False),
200   indf(0), indl(0)
201 {
202   typ = IntPatch_Parabola;
203 }
204
205 //=======================================================================
206 //function : IntPatch_GLine
207 //purpose  : Creates a parabola as intersection line
208 //           when the transitions are Touch.
209 //=======================================================================
210
211 IntPatch_GLine::IntPatch_GLine (const gp_Parab& P,
212                                 const Standard_Boolean Tang,
213                                 const IntSurf_Situation Situ1,
214                                 const IntSurf_Situation Situ2) :
215   IntPatch_Line(Tang,Situ1,Situ2),
216   pos(P.Position()),
217   par1(P.Focal()), par2(0.0),
218   fipt(Standard_False),lapt(Standard_False),
219   indf(0), indl(0)
220 {
221   typ = IntPatch_Parabola;
222 }
223
224 //=======================================================================
225 //function : IntPatch_GLine
226 //purpose  : Creates a parabola as intersection line 
227 //           when the transitions are Undecided.
228 //=======================================================================
229
230 IntPatch_GLine::IntPatch_GLine (const gp_Parab& P,
231                                 const Standard_Boolean Tang) :
232   IntPatch_Line(Tang),
233   pos(P.Position()),
234   par1(P.Focal()), par2(0.0),
235   fipt(Standard_False),lapt(Standard_False),
236   indf(0), indl(0)
237 {
238   typ = IntPatch_Parabola;
239 }
240
241 //=======================================================================
242 //function : IntPatch_GLine
243 //purpose  : Creates an hyperbola as intersection line
244 //           when the transitions are In or Out.
245 //=======================================================================
246
247 IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H,
248                                 const Standard_Boolean Tang,
249                                 const IntSurf_TypeTrans Trans1,
250                                 const IntSurf_TypeTrans Trans2) :
251   IntPatch_Line(Tang,Trans1,Trans2),
252   pos(H.Position()),
253   par1(H.MajorRadius()),
254   par2(H.MinorRadius()),
255   fipt(Standard_False),lapt(Standard_False),
256   indf(0), indl(0)
257 {
258   typ = IntPatch_Hyperbola;
259 }
260
261 //=======================================================================
262 //function : IntPatch_GLine
263 //purpose  : Creates an hyperbola as intersection line
264 //           when the transitions are Touch.
265 //=======================================================================
266
267 IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H,
268                                 const Standard_Boolean Tang,
269                                 const IntSurf_Situation Situ1,
270                                 const IntSurf_Situation Situ2) :
271   IntPatch_Line(Tang,Situ1,Situ2),
272   pos(H.Position()),
273   par1(H.MajorRadius()),
274   par2(H.MinorRadius()),
275   fipt(Standard_False),lapt(Standard_False),
276   indf(0), indl(0)
277 {
278   typ = IntPatch_Hyperbola;
279 }
280
281 //=======================================================================
282 //function : IntPatch_GLine
283 //purpose  : Creates an hyperbola as  intersection line
284 //           when the transitions are Undecided.
285 //=======================================================================
286
287 IntPatch_GLine::IntPatch_GLine (const gp_Hypr& H,
288                                 const Standard_Boolean Tang) :
289   IntPatch_Line(Tang),
290   pos(H.Position()),
291   par1(H.MajorRadius()),
292   par2(H.MinorRadius()),
293   fipt(Standard_False),lapt(Standard_False),
294   indf(0), indl(0)
295 {
296   typ = IntPatch_Hyperbola;
297 }
298
299 //=======================================================================
300 //function : Replace
301 //purpose  : To replace the element of range Index in the list
302 //           of points.
303 //=======================================================================
304
305 void IntPatch_GLine::Replace (const Standard_Integer /*Index*/,
306                               const IntPatch_Point& Pnt)
307 {
308   svtx.Append(Pnt);
309   //--   svtx(Index) = Pnt;
310 }
311
312 //=======================================================================
313 //function : AddVertex
314 //purpose  : To add a vertex in the list.
315 //=======================================================================
316
317 void IntPatch_GLine::AddVertex (const IntPatch_Point& Pnt)
318 {
319   //-- On detecte le cas de 2 points 3d identiques 
320   //-- pour les ramener au meme parametre sur la 
321   //-- GLine 
322   if (NbVertex())
323   {
324     const Standard_Real pf = (fipt? svtx.Value(indf).ParameterOnLine() : 0.0);
325     const Standard_Real pl = (lapt? svtx.Value(indl).ParameterOnLine() : 0.0);
326     Standard_Real par = Pnt.ParameterOnLine();
327     if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse)
328     {
329       if(fipt && lapt) {
330         while(par<pf) par+=M_PI+M_PI;
331         while(par>pl) par-=M_PI+M_PI;
332         if(par<pf) { 
333           const Standard_Real PrecisionPConfusion ( Precision::PConfusion()*1000.0 );
334           if((pf-par)>PrecisionPConfusion) {
335             return;
336           }
337         }
338         IntPatch_Point ParModif = Pnt;
339         ParModif.SetParameter(par);
340         svtx.Append(ParModif);
341         return; 
342       }
343     }
344     else
345     {
346       if(fipt && lapt) { 
347         if(pl<par || par<pf) 
348           return;
349       }
350     }
351   }
352   svtx.Append(Pnt);
353 }
354
355 //=======================================================================
356 //function : ComputeVertexParameters
357 //purpose  : Set the parameters of all the vertex on the line.
358 //           if a vertex is already in the line, 
359 //           its parameter is modified
360 //           else a new point in the line is inserted.
361 //=======================================================================
362
363 void IntPatch_GLine::ComputeVertexParameters(const Standard_Real /*Tol*/)
364
365   Standard_Boolean   SortIsOK,APointDeleted;
366   Standard_Boolean   SortAgain = Standard_True;
367   Standard_Integer   i,j;
368   const Standard_Real ParamMinOnLine = (fipt? Vertex(indf).ParameterOnLine() : -100000.0);
369   const Standard_Real ParamMaxOnLine = (lapt? Vertex(indl).ParameterOnLine() :  100000.0);
370
371   //----------------------------------------------------------
372   //--     F i l t r e   s u r   r e s t r i c t i o n s   --
373   //----------------------------------------------------------
374   //-- deux vertex sur la meme restriction et seulement 
375   //-- sur celle ci ne doivent pas avoir le meme parametre
376   //==========================================================
377   //-- 2 vertices on the same restriction and only
378   //-- on that one must not have the same parametres
379   
380   Standard_Integer nbvtx = NbVertex();
381
382   const Standard_Real PrecisionPConfusion ( Precision::PConfusion()*1000.0 );
383
384   do { 
385     APointDeleted = Standard_False;
386     for(i=1; (i<=nbvtx) && (!APointDeleted); i++)
387     { 
388       const IntPatch_Point& VTXi   = svtx.Value(i);
389       if(VTXi.IsOnDomS1() || VTXi.IsOnDomS2())
390       {
391         for(j=1; (j<=nbvtx) && (!APointDeleted); j++)
392         {
393           if(i!=j)
394           {
395             const IntPatch_Point& VTXj   = svtx.Value(j);
396             if((!VTXj.IsOnDomS1()) && (!VTXj.IsOnDomS2()))
397             {
398               if(Abs(VTXi.ParameterOnLine()-VTXj.ParameterOnLine())<=PrecisionPConfusion)
399               {
400                 svtx.Remove(j);
401                 nbvtx--;
402                 if(lapt) { if(indl>j) indl--; } 
403                 if(fipt) { if(indf>j) indf--; } 
404                 APointDeleted = Standard_True;
405               }
406             }
407           }
408         }
409       }
410     }
411   }
412   while(APointDeleted && nbvtx > 2);
413
414   do { 
415     APointDeleted = Standard_False;
416     for(i=1; (i<=nbvtx) && (!APointDeleted); i++)
417     {
418       const IntPatch_Point& VTXi   = svtx.Value(i);
419       if(VTXi.IsOnDomS1() && (!VTXi.IsOnDomS2()))
420       {
421         for(j=1; (j<=nbvtx) && (!APointDeleted); j++)
422         {
423           if(i!=j)
424           {
425             const IntPatch_Point& VTXj   = svtx.Value(j);
426             if(VTXj.IsOnDomS1() && (!VTXj.IsOnDomS2()))
427             {
428               if(Abs(VTXi.ParameterOnArc1()-VTXj.ParameterOnArc1())<=PrecisionPConfusion)
429               {
430                 if(VTXi.ArcOnS1() == VTXj.ArcOnS1())
431                 {
432                   if(VTXi.IsVertexOnS1())
433                   {
434                     svtx.Remove(j);
435                     nbvtx--;
436                     if(lapt) { if(indl>j) indl--; } 
437                     if(fipt) { if(indf>j) indf--; } 
438                   }
439                   else
440                   {
441                     svtx.Remove(i);
442                     nbvtx--;
443                     if(lapt) { if(indl>i) indl--; } 
444                     if(fipt) { if(indf>i) indf--; } 
445                   }
446                   APointDeleted = Standard_True;
447                 }
448               }
449             }
450           }
451         }
452       }
453     }
454   }
455   while(APointDeleted);
456
457   do { 
458     APointDeleted = Standard_False;
459     for(i=1; (i<=nbvtx) && (!APointDeleted); i++)
460     {
461       const IntPatch_Point& VTXi   = svtx.Value(i);
462       if(VTXi.IsOnDomS2() && (!VTXi.IsOnDomS1()))
463       {
464         for(j=1; (j<=nbvtx) && (!APointDeleted); j++)
465         {
466           if(i!=j)
467           {
468             const IntPatch_Point& VTXj   = svtx.Value(j);
469             if(VTXj.IsOnDomS2() && (!VTXj.IsOnDomS1()))
470             {
471               if(Abs(VTXi.ParameterOnArc2()-VTXj.ParameterOnArc2())<=PrecisionPConfusion)
472               {
473                 if(VTXi.ArcOnS2() == VTXj.ArcOnS2())
474                 {
475                   if(VTXi.IsVertexOnS1())
476                   {
477                     svtx.Remove(j);
478                     nbvtx--;
479                     if(lapt) { if(indl>j) indl--; } 
480                     if(fipt) { if(indf>j) indf--; } 
481                   }
482                   else
483                   {
484                     svtx.Remove(i);
485                     nbvtx--;
486                     if(lapt) { if(indl>i) indl--; } 
487                     if(fipt) { if(indf>i) indf--; }                 
488                   }
489                   APointDeleted = Standard_True;                  
490                 }
491               }
492             }
493           }
494         }
495       }
496     }
497   }
498   while(APointDeleted);
499         
500
501   //----------------------------------------------------------
502   //-- Tri des vertex et suppression des Vtx superflus
503   //-- 
504   //// modified by jgv, 2.11.01 for BUC61033 ////
505   Standard_Real u1min = RealLast(), u1max = RealFirst();
506   Standard_Real u2min = RealLast(), u2max = RealFirst();
507   Standard_Boolean ToBreak = Standard_False;
508   ///////////////////////////////////////////////
509   do { 
510     nbvtx     = NbVertex();
511     if(SortAgain)
512     { 
513       do
514       {
515         SortIsOK = Standard_True;
516         for(i=2; i<=nbvtx; i++)
517         {
518           if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine())
519           {
520             SortIsOK = Standard_False;
521             svtx.Exchange(i-1,i);
522             if(fipt) { if(indf==i) indf=i-1; else if(indf==i-1) indf=i; }
523             if(lapt) { if(indl==i) indl=i-1; else if(indl==i-1) indl=i; }
524           }
525         }
526       }
527       while(!SortIsOK);
528     }
529
530     //// modified by jgv, 2.11.01 for BUC61033 ////
531     if (ToBreak)
532       break;
533     ///////////////////////////////////////////////
534
535     SortAgain = Standard_False;
536     SortIsOK = Standard_True; 
537     for(i=2; i<=nbvtx && SortIsOK; i++) { 
538       IntPatch_Point& VTX   = svtx.ChangeValue(i);      
539       for(j=1; j<=nbvtx && SortIsOK; j++) {
540         if(i!=j) { 
541           IntPatch_Point& VTXM1 = svtx.ChangeValue(j);
542           Standard_Boolean kill   = Standard_False;
543           Standard_Boolean killm1 = Standard_False;
544           if(Abs(VTXM1.ParameterOnLine()-VTX.ParameterOnLine())<PrecisionPConfusion) { 
545             if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) {  //-- OnS1    OnS1
546               if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) {    //-- OnS1 == OnS1
547                 if(VTXM1.IsOnDomS2()) {                 //-- OnS1 == OnS1  OnS2  
548                   if(VTX.IsOnDomS2()==Standard_False) {   //-- OnS1 == OnS1  OnS2 PasOnS2
549                     kill=Standard_True;   
550                   }
551                   else {
552                     if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1  OnS2 == OnS2
553                       if(VTXM1.IsVertexOnS2()) {                      
554                         kill=Standard_True;
555                       }
556                       else { 
557                         killm1=Standard_True;
558                       }
559                     }
560                   }
561                 }
562                 else {                                  //-- OnS1 == OnS1  PasOnS2  
563                   if(VTX.IsOnDomS2()) {                 //-- OnS1 == OnS1  PasOnS2  OnS2
564                     killm1=Standard_True;
565                   }
566                 }
567               }
568             }
569             else { //-- Pas OnS1  et  OnS1
570               if(VTXM1.IsOnDomS2()==Standard_False && VTX.IsOnDomS2()==Standard_False) { 
571                 if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()==Standard_False) { 
572                   kill=Standard_True;
573                 }
574                 else  if(VTX.IsOnDomS1() && VTXM1.IsOnDomS1()==Standard_False) { 
575                   killm1=Standard_True;
576                 }
577               }
578             }
579             
580             if(!(kill || killm1)) {
581               if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) {  //-- OnS2    OnS2
582                 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) {    //-- OnS2 == OnS2
583                   if(VTXM1.IsOnDomS1()) {                 //-- OnS2 == OnS2  OnS1  
584                     if(VTX.IsOnDomS1()==Standard_False) {   //-- OnS2 == OnS2  OnS1 PasOnS1
585                       kill=Standard_True;   
586                     }
587                     else {
588                       if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2  OnS1 == OnS1
589                         if(VTXM1.IsVertexOnS1()) {                    
590                           kill=Standard_True;                //-- OnS2 == OnS2  OnS1 == OnS1  Vtx PasVtx
591                         }
592                         else { 
593                           killm1=Standard_True;              //-- OnS2 == OnS2  OnS1 == OnS1  PasVtx Vtx
594                         } 
595                       }
596                     }
597                   }
598                   else {                                  //-- OnS2 == OnS2  PasOnS1  
599                     if(VTX.IsOnDomS1()) {                 //-- OnS2 == OnS2  PasOnS1  OnS1
600                       killm1=Standard_True;
601                     }
602                   }
603                 }
604               }
605               else { //-- Pas OnS2  et  OnS2
606                 if(VTXM1.IsOnDomS1()==Standard_False && VTX.IsOnDomS1()==Standard_False) { 
607                   if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()==Standard_False) { 
608                     kill=Standard_True;
609                   }
610                   else  if(VTX.IsOnDomS2() && VTXM1.IsOnDomS2()==Standard_False) { 
611                     killm1=Standard_True;
612                   }
613                 }
614               }
615             }
616             //-- On a j < i 
617             if(kill) { 
618               SortIsOK = Standard_False;
619               if(lapt) { if(indl>i) indl--; else if(indl==i) indl=j; } 
620               if(fipt) { if(indf>i) indf--; else if(indf==i) indf=j; } 
621               svtx.Remove(i);
622               nbvtx--;
623             }
624             else if(killm1) { 
625               SortIsOK = Standard_False;
626               if(lapt) { if(indl>j) indl--;  else if(indl==j) indl=i-1;} 
627               if(fipt) { if(indf>j) indf--;  else if(indf==j) indf=i-1;} 
628               svtx.Remove(j);
629               nbvtx--; 
630             }
631 //          else
632             else if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse) { // eap
633               //-- deux points de meme parametre qui ne peuvent etre confondus
634               //-- On change les parametres d un des points si les points UV sont
635               //-- differents. Ceci distingue le cas des aretes de couture.
636               // ==========================================================
637               //-- 2 points with the same parameters
638               //-- Change parametres of one point if points UV are
639               //-- different. This is the case of seam edge
640               Standard_Real ponline = VTX.ParameterOnLine();
641               // eap, =>>
642               Standard_Real newParam = ponline;
643               const Standard_Real PiPi = M_PI+M_PI;
644               Standard_Boolean is2PI = ( Abs(ponline-PiPi) <= PrecisionPConfusion );
645
646               if (nbvtx > 2 && // do this check if seam edge only gives vertices 
647                   !is2PI)      // but always change 2PI -> 0
648                 continue;
649               
650               if (is2PI)
651                 newParam = 0;
652               else if (Abs(ponline) <= PrecisionPConfusion)
653                 newParam = PiPi;
654               else 
655                 newParam -= PiPi;
656 //            if(  (Abs(ponline)<=PrecisionPConfusion)
657 //                 ||(Abs(ponline-M_PI-M_PI) <=PrecisionPConfusion)) 
658               // eap, <<=
659                 Standard_Real u1a,v1a,u2a,v2a,u1b,v1b,u2b,v2b; 
660                 VTXM1.Parameters(u1a,v1a,u2a,v2a);
661                 VTX.Parameters(u1b,v1b,u2b,v2b);
662                 Standard_Integer flag  = 0;
663                 
664                 if(   (Abs(u1a-u1b)<=PrecisionPConfusion) ) flag|=1;
665                 if(   (Abs(v1a-v1b)<=PrecisionPConfusion) ) flag|=2;
666                 if(   (Abs(u2a-u2b)<=PrecisionPConfusion) ) flag|=4;
667                 if(   (Abs(v2a-v2b)<=PrecisionPConfusion) ) flag|=8;
668                 Standard_Boolean TestOn1 = Standard_False;
669                 Standard_Boolean TestOn2 = Standard_False;
670                 switch(flag) { 
671                 case 3:   //-- meme point U1 V1  
672                 case 7:  //-- meme point U1 V1   meme U2            
673                 case 12:  //--                    meme U2 V2
674                 case 13:  //-- meme point U1      meme U2 V2
675                 case 10:  //-- meme point    V1   meme    V2   Test si U1a=U1b Mod 2PI et Test si U2a=U2b Mod 2PI
676                   break;
677                 case 11:   //-- meme point U1 V1   meme    V2   Test si U2a=U2b Mod 2PI   
678                   { TestOn2 = Standard_True; break; } 
679                 case 14:  //-- meme point    V1   meme U2 V2   Test si U1a=U1b Mod 2PI
680                   { TestOn1 = Standard_True; break; } 
681                 default: break;
682                 };
683                 // eap
684                 //if(ArcType()==IntPatch_Circle || ArcType()==IntPatch_Ellipse) {}
685                   if(TestOn1) { 
686                     //// modified by jgv, 2.11.01 for BUC61033 ////
687                     Standard_Real U1A = (u1a < u1b)? u1a : u1b;
688                     Standard_Real U1B = (u1a < u1b)? u1b : u1a;
689                     if (u1min == RealLast())
690                       {
691                         u1min = U1A;
692                         u1max = U1B;
693                       }
694                     else
695                       {
696                         if (Abs(U1A-u1min) > PrecisionPConfusion)
697                           ToBreak = Standard_True;
698                         if (Abs(U1B-u1max) > PrecisionPConfusion)
699                           ToBreak = Standard_True;
700                       }
701                     ///////////////////////////////////////////////
702                     // eap, =>>
703 //                    if (Abs(ponline) <= PrecisionPConfusion) { 
704 //                    const Standard_Real PiPi = M_PI+M_PI;
705                       if(newParam >= ParamMinOnLine && newParam <= ParamMaxOnLine
706                          /*PiPi >= ParamMinOnLine && PiPi<=ParamMaxOnLine*/) { 
707                         SortAgain = Standard_True;
708                         SortIsOK = Standard_False;
709                         if (newParam > ponline)
710                           if(u1a < u1b) { VTX.SetParameter(newParam); } 
711                           else          { VTXM1.SetParameter(newParam); }
712                         else
713                           if(u1a > u1b) { VTX.SetParameter(newParam); } 
714                           else          { VTXM1.SetParameter(newParam); } 
715                       }
716 //                  }
717 //                  else { 
718 //                    if(0.0 >= ParamMinOnLine && 0.0<=ParamMaxOnLine) { 
719 //                      SortAgain = Standard_True;
720 //                      SortIsOK = Standard_False;
721 //                      if(u1a > u1b) { VTX.SetParameter(0.0); } 
722 //                      else          { VTXM1.SetParameter(0.0); } 
723 //                    }
724 //                  }
725                     // eap, <<=
726                   }
727                   if(TestOn2) { 
728                     //// modified by jgv, 2.11.01 for BUC61033 ////
729                     Standard_Real U2A = (u2a < u2b)? u2a : u2b;
730                     Standard_Real U2B = (u2a < u2b)? u2b : u2a;
731                     if (u2min == RealLast())
732                       {
733                         u2min = U2A;
734                         u2max = U2B;
735                       }
736                     else
737                       {
738                         if (Abs(U2A-u2min) > PrecisionPConfusion)
739                           ToBreak = Standard_True;
740                         if (Abs(U2B-u2max) > PrecisionPConfusion)
741                           ToBreak = Standard_True;
742                       }
743                     ///////////////////////////////////////////////
744                     // eap, =>>
745 //                  if (Abs(ponline) <= PrecisionPConfusion) { 
746 //                    const Standard_Real PiPi = M_PI+M_PI;
747                       if(newParam >= ParamMinOnLine && newParam <= ParamMaxOnLine
748                          /*PiPi >= ParamMinOnLine && PiPi<=ParamMaxOnLine*/) {
749                         SortAgain = Standard_True;
750                         SortIsOK = Standard_False;
751                         if (newParam > ponline)
752                           if(u2a < u2b) { VTX.SetParameter(newParam); } 
753                           else          { VTXM1.SetParameter(newParam); }
754                         else
755                           if(u2a > u2b) { VTX.SetParameter(newParam); } 
756                           else          { VTXM1.SetParameter(newParam); } 
757                       }
758 //                  }
759 //                  else { 
760 //                    if(0.0 >= ParamMinOnLine && 0.0<=ParamMaxOnLine) {
761 //                      SortAgain = Standard_True;
762 //                      SortIsOK = Standard_False;
763 //                      if(u2a > u2b) { VTX.SetParameter(0.0); } 
764 //                      else          { VTXM1.SetParameter(0.0); } 
765 //                    }
766 //                  }
767 //                }
768 //              }
769               // eap, <<=
770               }
771             }
772           }
773         }
774       } //-- if(i!=j)
775     }
776   }
777   while(!SortIsOK);
778
779   //-- Recalcul de fipt et lapt
780   //-- 
781   nbvtx=NbVertex();
782   if(nbvtx)
783   {
784     do { 
785       SortIsOK = Standard_True;
786       for(i=2; i<=nbvtx; i++)
787       {
788         if(svtx.Value(i-1).ParameterOnLine()  > svtx.Value(i).ParameterOnLine())
789         {
790           SortIsOK = Standard_False;
791           svtx.Exchange(i-1,i);
792         }
793       }
794     }
795     while(!SortIsOK);
796     indl=nbvtx;
797     indf=1;
798   }
799 }