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