1 // Created on: 1997-11-06
2 // Created by: Roman BORISOV
3 // Copyright (c) 1997-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.
18 #include <Adaptor3d_Curve.hxx>
19 #include <Adaptor3d_Surface.hxx>
21 #include <gp_Pnt2d.hxx>
23 #include <math_Matrix.hxx>
24 #include <ProjLib_PrjFunc.hxx>
25 #include <Standard_ConstructionError.hxx>
27 ProjLib_PrjFunc::ProjLib_PrjFunc(const Adaptor3d_CurvePtr & C,const Standard_Real FixVal,const Adaptor3d_SurfacePtr & S, const Standard_Integer Fix) : myCurve(C), mySurface(S), myt(0), myU(0), myV(0), myFix(Fix)
29 myNorm=Min(1.,Min(mySurface->UResolution(1.),mySurface->VResolution(1.)));
32 case 1: myt = FixVal; break;
33 case 2: myU = FixVal; break;
34 case 3: myV = FixVal; break;
35 default: throw Standard_ConstructionError();
39 Standard_Integer ProjLib_PrjFunc::NbVariables() const
44 Standard_Integer ProjLib_PrjFunc::NbEquations() const
49 Standard_Boolean ProjLib_PrjFunc::Value(const math_Vector& X,math_Vector& F)
51 math_Matrix D (1,2,1,2);
55 Standard_Boolean ProjLib_PrjFunc::Derivatives(const math_Vector& X,math_Matrix& D)
61 Standard_Boolean ProjLib_PrjFunc::Values(const math_Vector& X,math_Vector& F,math_Matrix& D)
63 Standard_Real u = 0., v = 0., t = 0.;
81 /* if(X(1) > mySup.X() || X(1) < myInf.X()) return Standard_False;
82 if(X(2) > mySup.Y() || X(2) < myInf.Y()) return Standard_False;
85 gp_Vec DS1_u, DS1_v, DS2_u, DS2_uv, DS2_v, DC1_t;
86 myCurve->D1(t, C, DC1_t);
87 mySurface->D2(u, v, S, DS1_u, DS1_v, DS2_u, DS2_v, DS2_uv);
91 F(1) = V*DS1_u*myNorm;
92 F(2) = V*DS1_v*myNorm;
96 D(1, 1) = (DS1_u.SquareMagnitude() + V*DS2_u)*myNorm; // dE1/du
97 D(1, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm; // dE1/dv
98 D(2, 1) = D(1, 2); // dE2/du
99 D(2, 2) = (DS1_v.SquareMagnitude() + V*DS2_v)*myNorm; // dE2/dv
102 D(1, 1) = (-DC1_t*DS1_u)*myNorm; // dE1/dt
103 D(1, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm; // dE1/dv
104 D(2, 1) = (-DC1_t*DS1_v)*myNorm; // dE2/dt
105 D(2, 2) = (DS1_v.SquareMagnitude() + V*DS2_v)*myNorm; // dE2/dv
108 D(1, 1) = -DC1_t*DS1_u*myNorm; // dE1/dt
109 D(1, 2) = (DS1_u.SquareMagnitude() + V*DS2_u)*myNorm; // dE1/du
110 D(2, 1) = -DC1_t*DS1_v*myNorm; // dE2/dt
111 D(2, 2) = (DS1_v*DS1_u + V*DS2_uv)*myNorm;// dE2/du
114 /* cout<<"F = ("<<F(1)<<", "<<F(2)<<")"<<endl;
115 cout<<"dE1/dt = "<<D(1,1)<<endl;
116 cout<<"dE1/dv = "<<D(1,2)<<endl;
117 cout<<"dE2/dt = "<<D(2,1)<<endl;
118 cout<<"dE2/dv = "<<D(2,2)<<endl;
126 return Standard_True;
129 gp_Pnt2d ProjLib_PrjFunc::Solution() const
132 case 1: return gp_Pnt2d(myU, myV);
133 case 2: return gp_Pnt2d(myt, myV);
134 case 3: return gp_Pnt2d(myt, myU);
136 // pout NT, meme si on n'y passe pas.
137 return gp_Pnt2d(0.,0.);