Warning, /include/opencascade/IntImp_IntCS.gxx is written in an unsupported language. File is not indexed.
0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014
0015 #ifndef OCCT_DEBUG
0016 #define No_Standard_RangeError
0017 #define No_Standard_OutOfRange
0018 #endif
0019
0020
0021 #include <StdFail_NotDone.hxx>
0022 #include <Standard_DomainError.hxx>
0023 #include <IntImp_ComputeTangence.hxx>
0024 #include <math_FunctionSetRoot.hxx>
0025 #include <Precision.hxx>
0026
0027 IntImp_IntCS::IntImp_IntCS(const Standard_Real U,
0028 const Standard_Real V,
0029 const Standard_Real W,
0030 const TheFunction& F,
0031 const Standard_Real TolTangency,
0032 const Standard_Real MarginCoef) :
0033 done(Standard_True),
0034 empty(Standard_True),
0035 myFunction(F),
0036 w(0.0),
0037 u(0.0),
0038 v(0.0),
0039 tol(TolTangency*TolTangency)
0040 {
0041 if(tol<1e-13) { tol=1e-13; }
0042 math_FunctionSetRoot Rsnld(myFunction);
0043 Standard_Real u0,u1,v0,v1,w0,w1;
0044 const ThePSurface& S = myFunction.AuxillarSurface();
0045 const TheCurve& C = myFunction.AuxillarCurve();
0046
0047 w0 = TheCurveTool::FirstParameter(C);
0048 w1 = TheCurveTool::LastParameter(C);
0049
0050 u0 = ThePSurfaceTool::FirstUParameter(S);
0051 v0 = ThePSurfaceTool::FirstVParameter(S);
0052 u1 = ThePSurfaceTool::LastUParameter(S);
0053 v1 = ThePSurfaceTool::LastVParameter(S);
0054
0055 if (MarginCoef > 0.) {
0056 if (!Precision::IsInfinite(u0) && !Precision::IsInfinite(u1)) {
0057 Standard_Real marg = (u1-u0)*MarginCoef;
0058 if (u0 > u1) marg = -marg;
0059 u0 -= marg; u1 += marg;
0060 }
0061 if (!Precision::IsInfinite(v0) && !Precision::IsInfinite(v1)) {
0062 Standard_Real marg = (v1-v0)*MarginCoef;
0063 if (v0 > v1) marg = -marg;
0064 v0 -= marg; v1 += marg;
0065 }
0066 }
0067
0068 Perform(U,V,W,Rsnld,u0,u1,v0,v1,w0,w1);
0069 }
0070
0071 IntImp_IntCS::IntImp_IntCS(const TheFunction& F,
0072 const Standard_Real TolTangency) :
0073 done(Standard_True),
0074 empty(Standard_True),
0075 myFunction(F),
0076 tol(TolTangency*TolTangency)
0077 {
0078 }
0079
0080 void IntImp_IntCS::Perform(const Standard_Real U,
0081 const Standard_Real V,
0082 const Standard_Real W,
0083 math_FunctionSetRoot& Rsnld,
0084 const Standard_Real u0,
0085 const Standard_Real u1,
0086 const Standard_Real v0,
0087 const Standard_Real v1,
0088 const Standard_Real w0,
0089 const Standard_Real w1) {
0090 done = Standard_True;
0091 Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3];
0092 math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3), Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3);
0093 UVap(1) = U;
0094 UVap(2) = V;
0095 UVap(3) = W;
0096 const ThePSurface& S = myFunction.AuxillarSurface();
0097 const TheCurve& C = myFunction.AuxillarCurve();
0098
0099 BornInf(1) = u0; BornInf(2) = v0;
0100 BornSup(1) = u1; BornSup(2) = v1;
0101
0102 BornInf(3) = w0; BornSup(3) = w1;
0103
0104 Tolerance(1) = ThePSurfaceTool::UResolution(S,Precision::Confusion());
0105 Tolerance(2) = ThePSurfaceTool::VResolution(S,Precision::Confusion());
0106 Tolerance(3) = TheCurveTool::Resolution(C,Precision::Confusion());
0107 Rsnld.SetTolerance(Tolerance);
0108 Standard_Integer autretentative=0;
0109 done=Standard_False;
0110 do {
0111 if(autretentative==1) {
0112 UVap(3)=w0;
0113 }
0114 else if(autretentative==2) {
0115 UVap(3)=w1;
0116 }
0117 autretentative++;
0118 Rsnld.Perform(myFunction,UVap,BornInf,BornSup);
0119 if (Rsnld.IsDone()) {
0120 Standard_Real AbsmyFunctionRoot = Abs(myFunction.Root());
0121 if (AbsmyFunctionRoot <= tol) {
0122 Rsnld.Root(UVap);
0123 u = UVap(1);
0124 v = UVap(2);
0125 w = UVap(3);
0126 empty = Standard_False;
0127 done=Standard_True;
0128 }
0129 }
0130 }
0131 while(done==Standard_False && autretentative<3);
0132 }
0133
0134 Standard_Boolean IntImp_IntCS::IsDone() const { return done;}
0135
0136 Standard_Boolean IntImp_IntCS::IsEmpty()const {
0137 if (!done) throw StdFail_NotDone();
0138 return empty;
0139 }
0140
0141 const gp_Pnt& IntImp_IntCS::Point() const
0142 {
0143 if (!done) throw StdFail_NotDone();
0144 if (empty) throw Standard_DomainError();
0145 return myFunction.Point();
0146 }
0147
0148 void IntImp_IntCS::ParameterOnSurface(Standard_Real& U,
0149 Standard_Real& V) const
0150 {
0151 if (!done) throw StdFail_NotDone();
0152 if (empty) throw Standard_DomainError();
0153 U=u;
0154 V=v;
0155 }
0156 Standard_Real IntImp_IntCS::ParameterOnCurve() const
0157 {
0158 if (!done) throw StdFail_NotDone();
0159 if (empty) throw Standard_DomainError();
0160 return w;
0161 }
0162
0163 TheFunction& IntImp_IntCS::Function() {return myFunction;}