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
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001
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>
26 #define EPSX 0.00000000000001
27 #define EPSDIST 0.00000001
28 #define EPSNUL 0.00000001
30 //================================================================================
31 IntCurveSurface_QuadricCurveExactInter::IntCurveSurface_QuadricCurveExactInter(const TheSurface& S,
33 : nbpnts(-1),nbintv(-1)
35 GeomAbs_SurfaceType QuadricType = TheSurfaceTool::GetType(S);
36 IntSurf_Quadric Quadric;
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; }
43 //cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform "<<endl;
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);
53 TheCurveTool::Intervals(C, anIntervals, GeomAbs_C1);
55 for (ii = 1; ii <= nbIntervals; ii++) {
56 Standard_Real U1 = anIntervals.Value(ii);
57 Standard_Real U2 = anIntervals.Value(ii + 1);
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);
64 Standard_Integer nbp = Roots.NbPoints();
65 Standard_Integer nbi = Roots.NbIntervals();
67 for( i = 1; i<=nbp; i++) {
68 pnts.Append(Roots.GetPoint(i));
69 //-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;
73 for(i = 1; i<=nbi; i++) {
74 Roots.GetInterval(i,a,b);
75 //cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
84 if (ii > nbIntervals) {
85 nbpnts = pnts.Length();
86 nbintv = intv.Length()/2;
88 // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
90 //================================================================================
91 Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const {
94 //================================================================================
95 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const {
98 //================================================================================
99 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const {
102 //================================================================================
103 Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const {
106 //================================================================================
107 void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
109 Standard_Real& b) const
111 Standard_Integer Index2 = Index+Index-1;