0027341: Incorrect exact HLR results
[occt.git] / src / IntCurve / IntCurve_IntCurveCurveGen.gxx
1 // Created on: 1992-10-12
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <GeomAbs_CurveType.hxx>
18
19
20 #include <IntCurve_IntConicConic.hxx>
21 #include <gp_Lin2d.hxx>
22 #include <gp_Circ2d.hxx>
23 #include <gp_Elips2d.hxx>
24 #include <gp_Parab2d.hxx>
25 #include <gp_Hypr2d.hxx>
26 #include <Precision.hxx>
27
28 #include <TColStd_Array1OfReal.hxx>
29
30
31 void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
32                                         const Standard_Real TolConf,
33                                         const Standard_Real Tol) { 
34   IntRes2d_Domain D1;
35   Standard_Real TolDomain = Tol;
36   if(Tol<TolConf) TolDomain = TolConf;
37   GeomAbs_CurveType typ = TheCurveTool::GetType(C);
38   switch(typ) {         
39   case GeomAbs_Ellipse: 
40   case GeomAbs_Circle:
41   case GeomAbs_Parabola:
42   case GeomAbs_Hyperbola:
43   case GeomAbs_Line:
44     ResetFields(); 
45     done = Standard_True;
46     return;
47   
48   default:
49     {
50       Standard_Real paraminf = TheCurveTool::FirstParameter(C);
51       Standard_Real paramsup = TheCurveTool::LastParameter(C);
52       if(paraminf>-Precision::Infinite()) { 
53         if(paramsup<Precision::Infinite()) { 
54           //--         paraminf-----------paramsup
55           D1.SetValues(TheCurveTool::Value(C,paraminf),
56                        paraminf,
57                        TolDomain,
58                        TheCurveTool::Value(C,paramsup),
59                        paramsup,
60                        TolDomain);
61         }
62         else { 
63           //--        paraminf------------...
64           D1.SetValues(TheCurveTool::Value(C,paraminf),
65                        paraminf,
66                        TolDomain,
67                        Standard_True);
68         }
69       }
70       else { 
71         if(paramsup<Precision::Infinite()) { 
72           //--    ...-----------------paramsup
73           D1.SetValues(TheCurveTool::Value(C,paramsup),
74                        paramsup,
75                        TolDomain,
76                        Standard_False);
77         }
78       }
79       this->ResetFields();
80       intcurvcurv.SetReversedParameters(Standard_False);    
81       intcurvcurv.Perform(C,D1,TolConf,Tol);
82       this->SetValues(intcurvcurv);
83       done = Standard_True;
84     }
85   }
86 }
87
88
89 void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
90                                         const IntRes2d_Domain& D,
91                                         const Standard_Real TolConf,
92                                         const Standard_Real Tol) { 
93   GeomAbs_CurveType typ = TheCurveTool::GetType(C);
94   switch(typ) {         
95   case GeomAbs_Ellipse: 
96   case GeomAbs_Circle:
97   case GeomAbs_Parabola:
98   case GeomAbs_Hyperbola:
99   case GeomAbs_Line:
100     ResetFields(); 
101     done = Standard_True;
102     return;
103   
104   default:
105     {
106       this->ResetFields();
107       intcurvcurv.SetReversedParameters(Standard_False);    
108       intcurvcurv.Perform(C,D,TolConf,Tol);
109       this->SetValues(intcurvcurv);
110       done = Standard_True;
111     }
112   }
113 }
114
115
116
117
118 //----------------------------------------------------------------------
119 IntRes2d_Domain IntCurve_IntCurveCurveGen::ComputeDomain(const TheCurve& C1,
120                                                          const Standard_Real TolDomain) const { 
121   IntRes2d_Domain D1;
122
123   GeomAbs_CurveType typ = TheCurveTool::GetType(C1);
124   switch(typ) { 
125     
126   case GeomAbs_Ellipse: 
127   case GeomAbs_Circle: {
128     //---------------------------------------------------------------
129     //-- if the curve is a trimmed curve, first and last parameters
130     //-- will be the parameters used to buid the domain
131     //--
132     Standard_Real firstparameter = TheCurveTool::FirstParameter(C1);
133     Standard_Real lastparameter  = TheCurveTool::LastParameter(C1);  
134
135     gp_Pnt2d P1(TheCurveTool::Value(C1,firstparameter));
136     gp_Pnt2d P2(TheCurveTool::Value(C1,lastparameter));
137     D1.SetValues(P1,firstparameter  ,TolDomain,
138                  P2,lastparameter   ,TolDomain);
139     D1.SetEquivalentParameters(firstparameter,firstparameter+M_PI+M_PI);
140     break; 
141   }
142   default: { 
143     Standard_Real paraminf = TheCurveTool::FirstParameter(C1);
144     Standard_Real paramsup = TheCurveTool::LastParameter(C1);
145     if(paraminf>-Precision::Infinite()) { 
146       if(paramsup<Precision::Infinite()) { 
147         //--         paraminf-----------paramsup
148         D1.SetValues(TheCurveTool::Value(C1,paraminf),
149                      paraminf,
150                      TolDomain,
151                      TheCurveTool::Value(C1,paramsup),
152                      paramsup,
153                      TolDomain);
154       }
155       else { 
156         //--        paraminf------------...
157         D1.SetValues(TheCurveTool::Value(C1,paraminf),
158                      paraminf,
159                      TolDomain,
160                      Standard_True);
161       }
162     }
163     else { 
164       if(paramsup<Precision::Infinite()) { 
165         //--    ...-----------------paramsup
166         D1.SetValues(TheCurveTool::Value(C1,paramsup),
167                      paramsup,
168                      TolDomain,
169                      Standard_False);
170       }
171     }
172     break;
173   }
174   }
175   return(D1);
176 }
177 //----------------------------------------------------------------------
178 //-- Perform : Si Une des courbes est Composite Alors decompose les appels
179 //----------------------------------------------------------------------
180 void IntCurve_IntCurveCurveGen::Perform (const TheCurve& C1,
181                                          const IntRes2d_Domain& D1,
182                                          const TheCurve& C2,
183                                          const IntRes2d_Domain& D2,
184                                          const Standard_Real TolConf,
185                                          const Standard_Real Tol) {
186   this->ResetFields();
187   Standard_Integer nbi1 = TheCurveTool::NbIntervals(C1);
188   if(nbi1 > 1) { 
189     param1inf = TheCurveTool::FirstParameter(C1);
190     param1sup = TheCurveTool::LastParameter(C1);
191   }
192   else {
193     param1inf = (D1.HasFirstPoint())? (D1.FirstParameter()) : -Precision::Infinite();
194     param1sup = (D1.HasLastPoint()) ? (D1.LastParameter())  : Precision::Infinite();
195   }
196   Standard_Integer nbi2 = TheCurveTool::NbIntervals(C2);
197   if(nbi2 > 1) { 
198     param2inf = TheCurveTool::FirstParameter(C2);
199     param2sup = TheCurveTool::LastParameter(C2);
200   }
201   else {
202     param2inf = (D2.HasFirstPoint())? (D2.FirstParameter()) : -Precision::Infinite();
203     param2sup = (D2.HasLastPoint()) ? (D2.LastParameter())  : Precision::Infinite();
204   }
205   if(nbi1>1 || nbi2>1) { 
206     TColStd_Array1OfReal Tab1(1,nbi1+1);
207     TColStd_Array1OfReal Tab2(1,nbi2+1);
208     TheCurveTool::Intervals(C1,Tab1);
209     TheCurveTool::Intervals(C2,Tab2);
210     InternalCompositePerform(C1,D1,1,nbi1,Tab1,
211                              C2,D2,1,nbi2,Tab2,
212                              TolConf,Tol,Standard_True);
213     return;
214   }
215   else {
216     InternalPerform(C1,D1,C2,D2,TolConf,Tol,Standard_False);
217   }
218 }
219
220 //----------------------------------------------------------------------
221 //-- InternalPerform 
222 //-- Suppose des Courbes Lin...Other 
223 //-- Si Composite == True 
224 //--     Les Resultats sont Ajoutes 
225 //-- Sinon
226 //--     Les Resultats sont Copies
227 //----------------------------------------------------------------------
228 void IntCurve_IntCurveCurveGen::InternalPerform (const TheCurve& C1,
229                                                  const IntRes2d_Domain& D1,
230                                                  const TheCurve& C2,
231                                                  const IntRes2d_Domain& D2,
232                                                  const Standard_Real TolConf,
233                                                  const Standard_Real Tol,
234                                                  const Standard_Boolean Composite)
235 {
236
237   GeomAbs_CurveType typ1 = TheCurveTool::GetType(C1);
238   GeomAbs_CurveType typ2 = TheCurveTool::GetType(C2);
239
240
241   switch (typ1)
242   {
243   case GeomAbs_Line:
244     switch (typ2)
245     {
246     case GeomAbs_Line:
247       {
248         intconiconi.SetReversedParameters(Standard_False);
249         intconiconi.Perform(TheCurveTool::Line(C1),D1,
250           TheCurveTool::Line(C2),D2,TolConf,Tol);
251         if(Composite)
252         {
253           this->Append(intconiconi,
254             param1inf,
255             param1sup,
256             param2inf,
257             param2sup);
258         }
259         else
260         {
261           this->SetValues(intconiconi);
262         }
263       }
264       break;
265
266     case GeomAbs_Circle:
267       {
268         intconiconi.SetReversedParameters(Standard_False);
269         intconiconi.Perform(TheCurveTool::Line(C1),D1,
270           TheCurveTool::Circle(C2),D2,TolConf,Tol);
271         if(Composite)
272         {
273           this->Append(intconiconi,
274             param1inf,
275             param1sup,
276             param2inf,
277             param2sup);
278         }
279         else
280         {
281           this->SetValues(intconiconi);
282         }
283       }
284       break;
285
286     case GeomAbs_Ellipse:
287       {
288         intconiconi.SetReversedParameters(Standard_False);
289         intconiconi.Perform(TheCurveTool::Line(C1),D1,
290           TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
291         if(Composite)
292         {
293           this->Append(intconiconi,
294             param1inf,
295             param1sup,
296             param2inf,
297             param2sup);
298         }
299         else
300         {
301           this->SetValues(intconiconi);
302         }
303       }
304       break;
305
306     case GeomAbs_Parabola:
307       {
308         intconiconi.SetReversedParameters(Standard_False);
309         intconiconi.Perform(TheCurveTool::Line(C1),D1,
310           TheCurveTool::Parabola(C2),D2,TolConf,Tol);
311         if(Composite)
312         {
313           this->Append(intconiconi,
314             param1inf,
315             param1sup,
316             param2inf,
317             param2sup);
318         }
319         else
320         {
321           this->SetValues(intconiconi);
322         }
323       }
324       break;
325
326     case GeomAbs_Hyperbola:
327       {
328         intconiconi.SetReversedParameters(Standard_False);
329         intconiconi.Perform(TheCurveTool::Line(C1),D1,
330           TheCurveTool::Hyperbola(C2),D2,TolConf,Tol);
331         if(Composite)
332         {
333           this->Append(intconiconi,
334             param1inf,
335             param1sup,
336             param2inf,
337             param2sup);
338         }
339         else
340         {
341           this->SetValues(intconiconi);
342         }
343       }
344
345       break;
346
347     default: 
348       {
349         intconicurv.SetReversedParameters(Standard_False);
350         intconicurv.Perform(TheCurveTool::Line(C1),D1,
351           C2,D2,TolConf,Tol);
352         if(Composite)
353         {
354           this->Append(intconicurv,
355             param1inf,
356             param1sup,
357             param2inf,
358             param2sup);
359         }
360         else
361         {
362           this->SetValues(intconicurv);
363         }
364       }
365       break;
366     }
367     break;  
368
369   case GeomAbs_Circle:
370     switch (typ2)
371     {
372     case GeomAbs_Line:
373       {
374         intconiconi.SetReversedParameters(Standard_True);
375         intconiconi.Perform(TheCurveTool::Line(C2),D2,
376           TheCurveTool::Circle(C1),D1,TolConf,Tol);
377         if(Composite)
378         {
379           this->Append(intconiconi,
380             param1inf,
381             param1sup,
382             param2inf,
383             param2sup);
384         }
385         else
386         {
387           this->SetValues(intconiconi);
388         }
389       }
390       break;
391
392     case GeomAbs_Circle:
393       {
394         intconiconi.SetReversedParameters(Standard_False);
395         intconiconi.Perform(TheCurveTool::Circle(C1),D1,
396           TheCurveTool::Circle(C2),D2,TolConf,Tol);
397         if(Composite)
398         {
399           this->Append(intconiconi,
400           param1inf,
401           param1sup,
402           param2inf,
403           param2sup);
404         }
405         else
406         {
407           this->SetValues(intconiconi);
408         }
409       }
410       break;
411
412     case GeomAbs_Ellipse:
413       {
414         intconiconi.SetReversedParameters(Standard_False);
415         intconiconi.Perform(TheCurveTool::Circle(C1),D1,
416           TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
417         if(Composite)
418         {
419           this->Append(intconiconi,
420             param1inf,
421             param1sup,
422             param2inf,
423             param2sup);
424         }
425         else
426         {
427           this->SetValues(intconiconi);
428         }
429       }
430       break;
431
432     case GeomAbs_Parabola:
433       {
434         intconiconi.SetReversedParameters(Standard_False);
435         intconiconi.Perform(TheCurveTool::Circle(C1),D1,
436           TheCurveTool::Parabola(C2),D2,TolConf,Tol);
437         if(Composite)
438         {
439           this->Append(intconiconi,
440             param1inf,
441             param1sup,
442             param2inf,
443             param2sup);
444         }
445         else
446         {
447           this->SetValues(intconiconi);
448         }
449       }
450       break;
451
452     case GeomAbs_Hyperbola:
453       {
454         intconiconi.SetReversedParameters(Standard_False);
455         intconiconi.Perform(TheCurveTool::Circle(C1),D1,
456           TheCurveTool::Hyperbola(C2),D2,TolConf,Tol);
457         if(Composite)
458         {
459           this->Append(intconiconi,
460             param1inf,
461             param1sup,
462             param2inf,
463             param2sup);
464         }
465         else
466         {
467           this->SetValues(intconiconi);
468         }
469       }
470       break;
471
472     default:
473       {
474         intconicurv.SetReversedParameters(Standard_False);
475         intconicurv.Perform(TheCurveTool::Circle(C1),D1,
476           C2,D2,TolConf,Tol);
477         if(Composite)
478         {
479           this->Append(intconicurv,
480             param1inf,
481             param1sup,
482             param2inf,
483             param2sup);  }
484         else
485         {
486           this->SetValues(intconicurv);
487         }
488       }
489
490       break;
491     }
492     break;
493
494   case GeomAbs_Ellipse:
495     switch (typ2)
496     {
497       case GeomAbs_Line:
498         {
499           intconiconi.SetReversedParameters(Standard_True);
500           intconiconi.Perform(TheCurveTool::Line(C2),D2,
501                               TheCurveTool::Ellipse(C1),D1,
502                               TolConf,Tol);
503
504           if(Composite)
505           {
506             this->Append(intconiconi,
507               param1inf,
508               param1sup,
509               param2inf,
510               param2sup);
511           }
512           else
513           {
514             this->SetValues(intconiconi);
515           }
516         }
517         break;
518
519       case GeomAbs_Circle:
520         {
521           intconiconi.SetReversedParameters(Standard_True);
522
523           intconiconi.Perform(TheCurveTool::Circle(C2),D2,
524             TheCurveTool::Ellipse(C1),D1,TolConf,Tol);
525           if(Composite)
526           {
527             this->Append(intconiconi,
528               param1inf,
529               param1sup,
530               param2inf,
531               param2sup);
532           }
533           else
534           {
535             this->SetValues(intconiconi);
536           }
537         }
538         break;
539
540       case GeomAbs_Ellipse:
541         {
542           intconiconi.SetReversedParameters(Standard_False);
543           intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
544             TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
545           if(Composite)
546           {
547             this->Append(intconiconi,
548               param1inf,
549               param1sup,
550               param2inf,
551               param2sup);
552           }
553           else
554           {
555             this->SetValues(intconiconi);
556           }
557         }
558         break;
559
560       case GeomAbs_Parabola:
561         {
562           intconiconi.SetReversedParameters(Standard_False);
563           intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
564             TheCurveTool::Parabola(C2),D2,TolConf,Tol);
565           if(Composite)
566           {
567             this->Append(intconiconi,
568               param1inf,
569               param1sup,
570               param2inf,
571               param2sup);
572           }
573           else
574           {
575             this->SetValues(intconiconi);
576           }
577         }
578         break;
579
580       case GeomAbs_Hyperbola:
581         {
582           intconiconi.SetReversedParameters(Standard_False);
583           intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
584             TheCurveTool::Hyperbola(C2),D2,
585             TolConf,Tol);
586           if(Composite)
587           {
588             this->Append(intconiconi,
589               param1inf,
590               param1sup,
591               param2inf,
592               param2sup);
593           }
594           else
595           {
596             this->SetValues(intconiconi);
597           }
598         }
599         break;
600
601       default:
602         {
603           intconicurv.SetReversedParameters(Standard_False);
604           intconicurv.Perform(TheCurveTool::Ellipse(C1),D1,
605             C2,D2,TolConf,Tol);
606           if(Composite)
607           {
608             this->Append(intconicurv,
609               param1inf,
610               param1sup,
611               param2inf,
612               param2sup);
613           }
614           else
615           {
616             this->SetValues(intconicurv);
617           }
618         }
619         break;
620     }
621     break;
622
623   case GeomAbs_Parabola:
624     switch (typ2)
625     {
626     case GeomAbs_Line:
627       {
628         intconiconi.SetReversedParameters(Standard_True);
629         intconiconi.Perform(TheCurveTool::Line(C2),D2,
630           TheCurveTool::Parabola(C1),D1,TolConf,Tol);
631         if(Composite)
632         {
633           this->Append(intconiconi,
634             param1inf,
635             param1sup,
636             param2inf,
637             param2sup);
638         }
639         else
640         {
641           this->SetValues(intconiconi);
642         }
643       }
644       break;
645
646     case GeomAbs_Circle:
647       {
648         intconiconi.SetReversedParameters(Standard_True);
649         intconiconi.Perform(TheCurveTool::Circle(C2),D2,
650           TheCurveTool::Parabola(C1),D1,TolConf,Tol);
651         if(Composite)
652         { this->Append(intconiconi,
653         param1inf,
654         param1sup,
655         param2inf,
656         param2sup);
657         }
658         else
659         {
660           this->SetValues(intconiconi);
661         }
662       }
663       break;
664
665     case GeomAbs_Ellipse:
666       {
667         intconiconi.SetReversedParameters(Standard_True);
668         intconiconi.Perform(TheCurveTool::Ellipse(C2),D2,
669           TheCurveTool::Parabola(C1),D1,TolConf,Tol);
670         if(Composite)
671         {
672           this->Append(intconiconi,
673             param1inf,
674             param1sup,
675             param2inf,
676             param2sup);
677         }
678         else
679         {
680           this->SetValues(intconiconi);
681         }
682       }
683       break;
684
685     case GeomAbs_Parabola:
686       {
687         intconiconi.SetReversedParameters(Standard_False);
688         intconiconi.Perform(TheCurveTool::Parabola(C1),D1,
689           TheCurveTool::Parabola(C2),D2,TolConf,Tol);
690         if(Composite)
691         {
692           this->Append(intconiconi,
693             param1inf,
694             param1sup,
695             param2inf,
696             param2sup);
697         }
698         else
699         {
700           this->SetValues(intconiconi);
701         }
702       }
703       break;
704
705     case GeomAbs_Hyperbola:
706       {
707         intconiconi.SetReversedParameters(Standard_False);
708         intconiconi.Perform(TheCurveTool::Parabola(C1),D1,
709           TheCurveTool::Hyperbola(C2),D2,
710           TolConf,Tol);
711         if(Composite)
712         {
713           this->Append(intconiconi,
714             param1inf,
715             param1sup,
716             param2inf,
717             param2sup);
718         }
719         else
720         {
721           this->SetValues(intconiconi);
722         }
723       }
724       break;
725
726     default:
727       {
728         intconicurv.SetReversedParameters(Standard_False);
729         intconicurv.Perform(TheCurveTool::Parabola(C1),D1,
730           C2,D2,TolConf,Tol);
731         if(Composite)
732         {
733           this->Append(intconicurv,
734             param1inf,
735             param1sup,
736             param2inf,
737             param2sup);
738         }
739         else
740         {
741           this->SetValues(intconicurv);
742         }
743       }
744       break;
745     }
746     break;
747
748   case GeomAbs_Hyperbola:
749     switch (typ2)
750     {
751     case GeomAbs_Line:
752       {
753         intconiconi.SetReversedParameters(Standard_True);
754         intconiconi.Perform(TheCurveTool::Line(C2),D2,
755           TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
756         if(Composite)
757         {
758           this->Append(intconiconi,
759             param1inf,
760             param1sup,
761             param2inf,
762             param2sup);
763         }
764         else
765         {
766           this->SetValues(intconiconi);
767         }
768       }
769       break;
770
771     case GeomAbs_Circle:
772       {
773         intconiconi.SetReversedParameters(Standard_True);
774         intconiconi.Perform(TheCurveTool::Circle(C2),D2,
775           TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
776         if(Composite)    { this->Append(intconiconi,
777           param1inf,
778           param1sup,
779           param2inf,
780           param2sup);  }
781         else             { this->SetValues(intconiconi); }
782       }
783       break;
784
785     case GeomAbs_Ellipse:
786       {
787         intconiconi.SetReversedParameters(Standard_True);
788         intconiconi.Perform(TheCurveTool::Ellipse(C2),D2,
789           TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
790         if(Composite)    { this->Append(intconiconi,
791           param1inf,
792           param1sup,
793           param2inf,
794           param2sup);  }
795         else             { this->SetValues(intconiconi); }
796       }
797       break;
798
799     case GeomAbs_Parabola:
800       {
801         intconiconi.SetReversedParameters(Standard_True);
802         intconiconi.Perform(TheCurveTool::Parabola(C2),D2,
803           TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
804         if(Composite)    { this->Append(intconiconi,
805           param1inf,
806           param1sup,
807           param2inf,
808           param2sup);  }
809         else             { this->SetValues(intconiconi); }
810       }
811       break;
812
813     case GeomAbs_Hyperbola:
814       {
815         intconiconi.SetReversedParameters(Standard_False);
816         intconiconi.Perform(TheCurveTool::Hyperbola(C1),D1,
817           TheCurveTool::Hyperbola(C2),D2,
818           TolConf,Tol);
819         if(Composite)    { this->Append(intconiconi,
820           param1inf,
821           param1sup,
822           param2inf,
823           param2sup);  }
824         else             { this->SetValues(intconiconi); }
825       }
826       break;
827
828     default:
829       {
830         intconicurv.SetReversedParameters(Standard_False);
831         intconicurv.Perform(TheCurveTool::Hyperbola(C1),D1,
832           C2,D2,TolConf,Tol);
833         if(Composite)    { this->Append(intconicurv,
834           param1inf,
835           param1sup,
836           param2inf,
837           param2sup);  }
838         else             { this->SetValues(intconicurv); }
839       }
840       break;
841     }
842     break;
843
844   default:
845     switch (typ2)
846     {
847     case GeomAbs_Line:
848       {
849         intconicurv.SetReversedParameters(Standard_True);
850         intconicurv.Perform(TheCurveTool::Line(C2),D2,  C1,D1,TolConf,Tol);
851         if(Composite)
852         {
853           this->Append(intconicurv,
854             param1inf,
855             param1sup,
856             param2inf,
857             param2sup);
858         }
859         else
860         {
861           this->SetValues(intconicurv);
862         }
863       }
864       break;
865
866     case GeomAbs_Circle:
867       {
868         intconicurv.SetReversedParameters(Standard_True);
869         intconicurv.Perform(TheCurveTool::Circle(C2),D2, C1,D1,TolConf,Tol);
870         if(Composite)
871         {
872           this->Append(intconicurv,
873             param1inf,
874             param1sup,
875             param2inf,
876             param2sup);
877         }
878         else
879         {
880           this->SetValues(intconicurv);
881         }
882       }
883       break;
884
885     case GeomAbs_Ellipse:
886       {
887         intconicurv.SetReversedParameters(Standard_True);
888         intconicurv.Perform(TheCurveTool::Ellipse(C2),D2, C1,D1,TolConf,Tol);
889         if(Composite)
890         {
891           this->Append(intconicurv,
892             param1inf,
893             param1sup,
894             param2inf,
895             param2sup);
896         }
897         else
898         {
899           this->SetValues(intconicurv);
900         }
901       }
902       break;
903
904     case GeomAbs_Parabola:
905       {
906         intconicurv.SetReversedParameters(Standard_True);
907         intconicurv.Perform(TheCurveTool::Parabola(C2),D2,C1,D1,TolConf,Tol);
908         if(Composite)
909         {
910           this->Append(intconicurv,
911             param1inf,
912             param1sup,
913             param2inf,
914             param2sup);
915         }
916         else
917         {
918           this->SetValues(intconicurv);
919         }
920       }
921       break;
922
923     case GeomAbs_Hyperbola:
924       {
925         intconicurv.SetReversedParameters(Standard_True);
926         intconicurv.Perform(TheCurveTool::Hyperbola(C2),D2,C1,D1,
927           TolConf,Tol); 
928         if(Composite)
929         {
930           this->Append(intconicurv,
931             param1inf,
932             param1sup,
933             param2inf,
934             param2sup);
935         }
936         else
937         {
938           this->SetValues(intconicurv);
939         }
940       }
941       break;
942
943     default:
944       {
945         intcurvcurv.SetReversedParameters(Standard_False);    
946         intcurvcurv.Perform(C1,D1, C2,D2,TolConf,Tol);
947         if(Composite)
948         {
949           this->Append(intcurvcurv,
950             param1inf,
951             param1sup,
952             param2inf,
953             param2sup);  }
954         else
955         {
956           this->SetValues(intcurvcurv);
957         }
958         done = Standard_True;
959       }
960       break;
961     }
962     break;
963   }
964 }
965
966 void IntCurve_IntCurveCurveGen::InternalCompositePerform_noRecurs(
967                                       const Standard_Integer NbInterC1,
968                                       const TheCurve& C1,
969                                       const Standard_Integer NumInterC1,
970                                       const TColStd_Array1OfReal& Tab1,
971                                       const IntRes2d_Domain& D1,
972                                       const Standard_Integer NbInterC2,
973                                       const TheCurve& C2,
974                                       const Standard_Integer NumInterC2,
975                                       const TColStd_Array1OfReal& Tab2,
976                                       const IntRes2d_Domain& D2,
977                                       const Standard_Real TolConf,
978                                       const Standard_Real Tol)
979 {
980     
981     
982         if(NumInterC2>NbInterC2)
983     return;
984
985   
986   IntRes2d_Domain DomainC1NumInter;
987   IntRes2d_Domain DomainC2NumInter;
988
989   //----------------------------------------------------------------------
990   //-- Creation du domaine associe a la portion de C1
991   //----------------------------------------------------------------------
992   Standard_Boolean DomainIsOK = Standard_True;
993   Standard_Real ParamInf,ParamSup;
994   
995   if(NbInterC1>1) {
996     TheCurveTool::GetInterval(C1,NumInterC1,Tab1,ParamInf,ParamSup);
997     //--------------------------------------------------------------
998     //-- Verification : Domaine Inclu dans Intervalle de Definition
999     //--------------------------------------------------------------
1000
1001     Standard_Real u;
1002
1003     u = D1.FirstParameter();
1004     if(ParamInf < u) { ParamInf = u; }
1005
1006     u = D1.LastParameter();
1007     if(ParamSup > u) { ParamSup = u; }
1008
1009     if((ParamSup - ParamInf) > 1e-10) {
1010       DomainC1NumInter.SetValues(TheCurveTool::Value(C1,ParamInf),
1011                                  ParamInf,
1012                                  D1.FirstTolerance(),
1013                                  TheCurveTool::Value(C1,ParamSup),
1014                                  ParamSup,
1015                                  D1.LastTolerance());
1016     } else {
1017       DomainIsOK = Standard_False;
1018     }
1019   } else {
1020     DomainC1NumInter = D1;
1021   }
1022   
1023   //----------------------------------------------------------------------
1024   //-- Creation du domaine associe a la portion de C2
1025   //----------------------------------------------------------------------
1026   if(NbInterC2 > 1) {
1027     TheCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
1028     //--------------------------------------------------------------
1029     //-- Verification : Domaine Inclu dans Intervalle de Definition
1030     //--------------------------------------------------------------
1031
1032     Standard_Real u;
1033
1034     u = D2.FirstParameter();
1035     if(ParamInf < u) { ParamInf = u; }
1036     u = D2.LastParameter();
1037
1038     if(ParamSup > u) { ParamSup = u; }
1039
1040     if((ParamSup - ParamInf) > 1e-10) { 
1041       DomainC2NumInter.SetValues(TheCurveTool::Value(C2,ParamInf),
1042                                  ParamInf,
1043                                  D2.FirstTolerance(),
1044                                  TheCurveTool::Value(C2,ParamSup),
1045                                  ParamSup,
1046                                  D2.LastTolerance());
1047     } else {
1048       DomainIsOK = Standard_False;
1049     }
1050   } else {
1051     DomainC2NumInter = D2;
1052   }
1053
1054   if(DomainIsOK) { 
1055     InternalPerform(C2,DomainC2NumInter,
1056                     C1,DomainC1NumInter,
1057                     TolConf,Tol,
1058                     Standard_True);
1059   }
1060 }
1061
1062
1063
1064
1065 //-- C1 ou C2 sont des courbes composites 
1066 //-- 
1067
1068 void 
1069 IntCurve_IntCurveCurveGen::InternalCompositePerform(const TheCurve& C1,
1070                                                     const IntRes2d_Domain& D1,
1071                                                     const Standard_Integer XXXNumInterC1,
1072                                                     const Standard_Integer NbInterC1,
1073                                                     const TColStd_Array1OfReal& Tab1,
1074                                                     const TheCurve& C2,
1075                                                     const IntRes2d_Domain& D2,
1076                                                     const Standard_Integer XXXNumInterC2,
1077                                                     const Standard_Integer NbInterC2,
1078                                                     const TColStd_Array1OfReal& Tab2,
1079                                                     const Standard_Real TolConf,
1080                                                     const Standard_Real Tol,
1081                                                     const Standard_Boolean RecursOnC2) {
1082   
1083   Standard_Integer NumInterC2=XXXNumInterC2;    
1084   Standard_Integer NumInterC1=XXXNumInterC1;
1085
1086
1087 //  Standard_Boolean Arret=Standard_False;
1088
1089   if(NumInterC2>NbInterC2)
1090     return;
1091
1092   if(!RecursOnC2){
1093     InternalCompositePerform_noRecurs(NbInterC1, C1, NumInterC1, Tab1, D1, NbInterC2, C2, NumInterC2, Tab2, D2, TolConf, Tol);
1094     return;
1095   }
1096
1097   for(Standard_Integer i=NumInterC1 ; i<=NbInterC1; i++) {
1098     NumInterC1=i;
1099     /*
1100       InternalCompositePerform(C2,D2,NumInterC2,NbInterC2,Tab2,
1101                         C1,D1,NumInterC1,NbInterC1,Tab1,
1102                         TolConf,Tol,Standard_False);
1103     */
1104
1105     InternalCompositePerform_noRecurs(NbInterC2,C2,NumInterC2,Tab2,D2,NbInterC1,C1,NumInterC1,Tab1,D1,TolConf,Tol);
1106   }
1107
1108   if(NumInterC2<NbInterC2) {
1109     NumInterC2++;
1110     NumInterC1=1;
1111
1112     InternalCompositePerform(C1,D1,NumInterC1,NbInterC1,Tab1,
1113                              C2,D2,NumInterC2,NbInterC2,Tab2,
1114                              TolConf,Tol,
1115                              Standard_True);
1116   }
1117 }
1118
1119 //=======================================================================
1120 //function : SetMinNbSamples
1121 //purpose  : 
1122 //=======================================================================
1123 void IntCurve_IntCurveCurveGen::SetMinNbSamples(const Standard_Integer theMinNbSamples)
1124 {
1125   intcurvcurv.SetMinNbSamples(theMinNbSamples);
1126 }
1127
1128 //=======================================================================
1129 //function : GetMinNbSamples
1130 //purpose  : 
1131 //=======================================================================
1132 Standard_Integer IntCurve_IntCurveCurveGen::GetMinNbSamples() const
1133 {
1134   return intcurvcurv.GetMinNbSamples();
1135 }