Warnings on vc14 were eliminated
[occt.git] / src / IntCurveSurface / IntCurveSurface_QuadricCurveExactInter.gxx
1 // Created on: 1993-08-18
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-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 //  Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001
18
19 #include <TColStd_SequenceOfReal.hxx>
20 #include <math_FunctionAllRoots.hxx>
21 #include <math_FunctionSample.hxx>
22 #include <IntSurf_Quadric.hxx>
23 #include <GeomAbs_SurfaceType.hxx>
24
25
26 #define EPSX    0.00000000000001
27 #define EPSDIST 0.00000001
28 #define EPSNUL  0.00000001
29
30 //================================================================================
31 IntCurveSurface_QuadricCurveExactInter::IntCurveSurface_QuadricCurveExactInter(const TheSurface& S,
32                                                                                const TheCurve&   C)
33      : nbpnts(-1),nbintv(-1)  
34
35   GeomAbs_SurfaceType QuadricType = TheSurfaceTool::GetType(S);
36   IntSurf_Quadric Quadric;
37   switch(QuadricType) { 
38   case GeomAbs_Plane:     { Quadric.SetValue(TheSurfaceTool::Plane(S));     break; }  
39   case GeomAbs_Cylinder:  { Quadric.SetValue(TheSurfaceTool::Cylinder(S));  break; }  
40   case GeomAbs_Cone:      { Quadric.SetValue(TheSurfaceTool::Cone(S));      break; }  
41   case GeomAbs_Sphere:    { Quadric.SetValue(TheSurfaceTool::Sphere(S));    break; }  
42   default:  {  
43     //cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform "<<endl; 
44     break;  
45   }
46   }
47
48   //  Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 Begin
49   Standard_Integer     nbIntervals = TheCurveTool::NbIntervals(C, GeomAbs_C1);
50   TColStd_Array1OfReal anIntervals(1, nbIntervals + 1);
51   Standard_Integer     ii;
52
53   TheCurveTool::Intervals(C, anIntervals, GeomAbs_C1);
54
55   for (ii = 1; ii <= nbIntervals; ii++) {
56     Standard_Real U1 = anIntervals.Value(ii);
57     Standard_Real U2 = anIntervals.Value(ii + 1);
58   
59     math_FunctionSample Sample(U1,U2,TheCurveTool::NbSamples(C,U1,U2));
60     IntCurveSurface_TheQuadCurvFunc Function(Quadric,C);
61     math_FunctionAllRoots Roots(Function,Sample,EPSX,EPSDIST,EPSNUL);
62
63     if(Roots.IsDone()) { 
64       Standard_Integer nbp = Roots.NbPoints(); 
65       Standard_Integer nbi = Roots.NbIntervals(); 
66       Standard_Integer i;
67       for( i = 1; i<=nbp; i++) { 
68         pnts.Append(Roots.GetPoint(i));
69         //-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;  
70       }
71
72       Standard_Real a,b;
73       for(i = 1; i<=nbi; i++) {
74         Roots.GetInterval(i,a,b); 
75         //cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
76         intv.Append(a);
77         intv.Append(b);
78       }
79     } else {
80       break;
81     }
82   }
83
84   if (ii > nbIntervals) {
85     nbpnts = pnts.Length();
86     nbintv = intv.Length()/2;
87   }
88 //  Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
89 }
90 //================================================================================
91 Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const { 
92   return(nbpnts!=-1); 
93 }
94 //================================================================================
95 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const { 
96   return(nbpnts); 
97 }
98 //================================================================================
99 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const { 
100   return(nbintv); 
101 }
102 //================================================================================
103 Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const { 
104   return(pnts(Index)); 
105 }
106 //================================================================================
107 void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
108                                                        Standard_Real& a,
109                                                        Standard_Real& b) const 
110
111   Standard_Integer Index2 = Index+Index-1;
112   a = intv(Index2); 
113   b = intv(Index2+1); 
114 }
115
116
117
118
119
120
121