Warning, /include/opencascade/IntCurveSurface_QuadricCurveExactInter.gxx is written in an unsupported language. File is not indexed.
0001 // Created on: 1993-08-18
0002 // Created by: Laurent BUCHARD
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016
0017 // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001
0018
0019 #include <TColStd_SequenceOfReal.hxx>
0020 #include <math_FunctionAllRoots.hxx>
0021 #include <math_FunctionSample.hxx>
0022 #include <IntSurf_Quadric.hxx>
0023 #include <GeomAbs_SurfaceType.hxx>
0024
0025
0026 #define EPSX 0.00000000000001
0027 #define EPSDIST 0.00000001
0028 #define EPSNUL 0.00000001
0029
0030 //================================================================================
0031 IntCurveSurface_QuadricCurveExactInter::IntCurveSurface_QuadricCurveExactInter(const TheSurface& S,
0032 const TheCurve& C)
0033 : nbpnts(-1),nbintv(-1)
0034 {
0035 GeomAbs_SurfaceType QuadricType = TheSurfaceTool::GetType(S);
0036 IntSurf_Quadric Quadric;
0037 switch(QuadricType) {
0038 case GeomAbs_Plane: { Quadric.SetValue(TheSurfaceTool::Plane(S)); break; }
0039 case GeomAbs_Cylinder: { Quadric.SetValue(TheSurfaceTool::Cylinder(S)); break; }
0040 case GeomAbs_Cone: { Quadric.SetValue(TheSurfaceTool::Cone(S)); break; }
0041 case GeomAbs_Sphere: { Quadric.SetValue(TheSurfaceTool::Sphere(S)); break; }
0042 default: {
0043 //cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform "<<endl;
0044 break;
0045 }
0046 }
0047
0048 // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 Begin
0049 Standard_Integer nbIntervals = TheCurveTool::NbIntervals(C, GeomAbs_C1);
0050 TColStd_Array1OfReal anIntervals(1, nbIntervals + 1);
0051 Standard_Integer ii;
0052
0053 TheCurveTool::Intervals(C, anIntervals, GeomAbs_C1);
0054
0055 for (ii = 1; ii <= nbIntervals; ii++) {
0056 Standard_Real U1 = anIntervals.Value(ii);
0057 Standard_Real U2 = anIntervals.Value(ii + 1);
0058
0059 math_FunctionSample Sample(U1,U2,TheCurveTool::NbSamples(C,U1,U2));
0060 IntCurveSurface_TheQuadCurvFunc Function(Quadric,C);
0061 math_FunctionAllRoots Roots(Function,Sample,EPSX,EPSDIST,EPSNUL);
0062
0063 if(Roots.IsDone()) {
0064 Standard_Integer nbp = Roots.NbPoints();
0065 Standard_Integer nbi = Roots.NbIntervals();
0066 Standard_Integer i;
0067 for( i = 1; i<=nbp; i++) {
0068 pnts.Append(Roots.GetPoint(i));
0069 //-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;
0070 }
0071
0072 Standard_Real a,b;
0073 for(i = 1; i<=nbi; i++) {
0074 Roots.GetInterval(i,a,b);
0075 //cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
0076 intv.Append(a);
0077 intv.Append(b);
0078 }
0079 } else {
0080 break;
0081 }
0082 }
0083
0084 if (ii > nbIntervals) {
0085 nbpnts = pnts.Length();
0086 nbintv = intv.Length()/2;
0087 }
0088 // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
0089 }
0090 //================================================================================
0091 Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const {
0092 return(nbpnts!=-1);
0093 }
0094 //================================================================================
0095 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const {
0096 return(nbpnts);
0097 }
0098 //================================================================================
0099 Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const {
0100 return(nbintv);
0101 }
0102 //================================================================================
0103 Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const {
0104 return(pnts(Index));
0105 }
0106 //================================================================================
0107 void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
0108 Standard_Real& a,
0109 Standard_Real& b) const
0110 {
0111 Standard_Integer Index2 = Index+Index-1;
0112 a = intv(Index2);
0113 b = intv(Index2+1);
0114 }
0115
0116
0117
0118
0119
0120
0121