Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/IntImp_ZerImpFunc.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 #define EpsAng  1.e-8
0016 #define EpsAng2 1.e-16
0017 #define Tolpetit 1.e-16
0018 
0019 #ifndef OCCT_DEBUG
0020 #define No_Standard_RangeError
0021 #define No_Standard_OutOfRange
0022 #endif
0023 
0024 #define SURF     (*((ThePSurface *)(surf)))
0025 #define FUNC     (*((TheISurface *)(func)))
0026 
0027 
0028 IntImp_ZerImpFunc::IntImp_ZerImpFunc() :
0029        surf(NULL),
0030        func(NULL),
0031        u(0.0),
0032        v(0.0),
0033        tol(0.0),
0034        valf(0.0),
0035        computed(Standard_False),
0036        tangent(Standard_False),
0037        tgdu(0.0),
0038        tgdv(0.0),
0039        derived(Standard_False)
0040 {  
0041 }
0042 
0043 IntImp_ZerImpFunc::IntImp_ZerImpFunc(const ThePSurface& PS ,
0044                                      const TheISurface& IS) :
0045        u(0.0),
0046        v(0.0),
0047        tol(0.0),
0048        valf(0.0),
0049        computed(Standard_False),
0050        tangent(Standard_False),
0051        tgdu(0.0),
0052        tgdv(0.0),
0053        derived(Standard_False)
0054 { 
0055   surf = (Standard_Address)(&PS);
0056   func = (Standard_Address)(&IS);
0057 }
0058 
0059 IntImp_ZerImpFunc::IntImp_ZerImpFunc(const TheISurface& IS) :
0060        surf(NULL),
0061        u(0.0),
0062        v(0.0),
0063        tol(0.0),
0064        valf(0.0),
0065        computed(Standard_False),
0066        tangent(Standard_False),
0067        tgdu(0.0),
0068        tgdv(0.0),
0069        derived(Standard_False)
0070 {  
0071   func = (Standard_Address)(&IS);
0072 }
0073 
0074 Standard_Integer IntImp_ZerImpFunc::NbVariables() const
0075 { 
0076   return 2;
0077 }
0078 
0079 Standard_Integer IntImp_ZerImpFunc::NbEquations() const 
0080 {
0081   return 1;
0082 }
0083 
0084 Standard_Boolean IntImp_ZerImpFunc::Value(const math_Vector& X,
0085                                           math_Vector& F)
0086 {
0087   u = X(1);
0088   v = X(2);
0089   pntsol = ThePSurfaceTool::Value(SURF, u, v);
0090   valf = TheISurfaceTool::Value(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z());
0091   F(1) = valf;
0092   computed = Standard_False;
0093   derived = Standard_False;
0094   return Standard_True;
0095 }
0096 
0097 Standard_Boolean IntImp_ZerImpFunc::Derivatives(const math_Vector& X,
0098                                                 math_Matrix& D)
0099 {
0100   u = X(1);
0101   v = X(2);
0102   ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
0103   TheISurfaceTool::Gradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(),gradient);
0104   D(1,1) = d1u.Dot(gradient);
0105   D(1,2) = d1v.Dot(gradient);
0106   computed = Standard_False;
0107   derived = Standard_True;
0108   return Standard_True;
0109 }
0110 
0111 Standard_Boolean IntImp_ZerImpFunc::Values(const math_Vector& X,
0112                                            math_Vector& F,
0113                                            math_Matrix& D)
0114 {
0115   u = X(1);
0116   v = X(2);
0117   ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
0118   TheISurfaceTool::ValueAndGradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(), 
0119                                     valf, gradient);
0120   F(1) = valf;
0121   D(1,1) = d1u.Dot(gradient);
0122   D(1,2) = d1v.Dot(gradient);
0123   computed = Standard_False;
0124   derived = Standard_True;
0125   return Standard_True;
0126 }
0127 
0128 Standard_Boolean IntImp_ZerImpFunc::IsTangent()
0129 {
0130   if (!computed) {
0131     computed = Standard_True;
0132     if(!derived) {
0133       ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
0134       derived = Standard_True;
0135     }
0136 
0137     tgdu =  gradient.Dot(d1v);
0138     tgdv = -gradient.Dot(d1u);
0139     Standard_Real N2grad = gradient.SquareMagnitude();
0140     Standard_Real N2grad_EpsAng2 = N2grad * EpsAng2;
0141     Standard_Real N2d1u  = d1u.SquareMagnitude();
0142     Standard_Real N2d1v  = d1v.SquareMagnitude();
0143     tangent =(tgdu * tgdu <= N2grad_EpsAng2 * N2d1v) && 
0144              (tgdv * tgdv <= N2grad_EpsAng2 * N2d1u);
0145     if(!tangent) {
0146       d3d.SetLinearForm(tgdu,d1u,tgdv,d1v);
0147       d2d = gp_Dir2d(tgdu, tgdv);
0148       if (d3d.Magnitude() <= Tolpetit) {    // jag
0149         tangent = Standard_True;
0150       }
0151     }    
0152   }
0153   return tangent;
0154 }
0155 
0156 #undef EpsAng
0157 #undef EpsAng2
0158 #undef Tolpetit
0159 #undef FUNC
0160 #undef SURF