1 // File: BlendFunc_Corde.cxx
2 // Created: Tue Jun 4 18:12:59 1996
3 // Author: Stagiaire Xuan Trang PHAMPHU
4 // Copyright: OPEN CASCADE 1996
6 #include <BlendFunc_Corde.ixx>
8 #include <math_Gauss.hxx>
12 #include <BlendFunc.hxx>
13 #include <Standard_DomainError.hxx>
14 #include <Standard_NotImplemented.hxx>
17 //=======================================================================
18 //function : BlendFunc_Corde
20 //=======================================================================
22 BlendFunc_Corde::BlendFunc_Corde(const Handle(Adaptor3d_HSurface)& S,
23 const Handle(Adaptor3d_HCurve)& CG) :
28 //=======================================================================
31 //=======================================================================
33 void BlendFunc_Corde::SetDist(const Standard_Real Dist)
38 //=======================================================================
41 //=======================================================================
43 void BlendFunc_Corde::SetParam(const Standard_Real Param)
45 guide->D2(Param,ptgui,d1gui,d2gui);
46 normtg = d1gui.Magnitude();
47 nplan = d1gui.Normalized();
48 theD = - (nplan.XYZ().Dot(ptgui.XYZ()));
51 //=======================================================================
53 //purpose : returns F(U,V)
54 //=======================================================================
56 Standard_Boolean BlendFunc_Corde::Value(const math_Vector& X, math_Vector& F)
59 surf->D1(X(1),X(2),pts,d1u,d1v);
61 F(1) = nplan.XYZ().Dot(pts.XYZ()) + theD;
62 const gp_Vec vref(ptgui,pts);
63 F(2) = vref.SquareMagnitude() - dis*dis;
68 //=======================================================================
69 //function : Derivatives
70 //purpose : D = grad F(U,V)
71 //=======================================================================
73 Standard_Boolean BlendFunc_Corde::Derivatives(const math_Vector& X, math_Matrix& D)
76 surf->D1(X(1),X(2),pts,d1u,d1v);
78 D(1,1) = nplan.Dot(d1u);
79 D(1,2) = nplan.Dot(d1v);
80 D(2,1) = 2.*gp_Vec(ptgui,pts).Dot(d1u);
81 D(2,2) = 2.*gp_Vec(ptgui,pts).Dot(d1v);
86 //=======================================================================
89 //=======================================================================
91 const gp_Pnt& BlendFunc_Corde::PointOnS () const
97 //=======================================================================
98 //function : PointOnGuide
100 //=======================================================================
102 const gp_Pnt& BlendFunc_Corde::PointOnGuide () const
108 //=======================================================================
111 //=======================================================================
113 const gp_Vec& BlendFunc_Corde::NPlan () const
119 //=======================================================================
120 //function : IsTangencyPoint
122 //=======================================================================
124 Standard_Boolean BlendFunc_Corde::IsTangencyPoint () const
130 //=======================================================================
131 //function : TangentOnS
133 //=======================================================================
135 const gp_Vec& BlendFunc_Corde::TangentOnS () const
138 Standard_DomainError::Raise("BlendFunc_Corde::TangentOnS");
143 //=======================================================================
144 //function : Tangent2dOnS
146 //=======================================================================
148 const gp_Vec2d& BlendFunc_Corde::Tangent2dOnS () const
151 Standard_DomainError::Raise("BlendFunc_Corde::Tangent2dOnS");
156 //=======================================================================
157 //function : DerFguide
159 //=======================================================================
161 void BlendFunc_Corde::DerFguide (const math_Vector& Sol, gp_Vec2d& DerF)
164 surf->D1(Sol(1),Sol(2),pts,d1u,d1v);
167 dnplan.SetLinearForm(1./normtg,d2gui,-1./normtg*(nplan.Dot(d2gui)),nplan);
169 const gp_Vec temp(pts.XYZ()-ptgui.XYZ());
171 DerF.SetX( dnplan.Dot(temp)-nplan.Dot(d1gui) );
172 DerF.SetY( -2.*d1gui.Dot(temp) );
175 //=======================================================================
176 //function : IsSolution
178 //=======================================================================
180 Standard_Boolean BlendFunc_Corde::IsSolution(const math_Vector& Sol, const Standard_Real Tol)
182 math_Vector secmember(1,2),valsol(1,2);
183 math_Matrix gradsol(1,2,1,2);
185 gp_Vec dnplan,temp,d1u,d1v;
188 Derivatives(Sol,gradsol);
189 if (Abs(valsol(1)) <= Tol &&
190 Abs(valsol(2)) <= Tol*Tol) {
192 surf->D1(Sol(1),Sol(2),pts,d1u,d1v);
193 dnplan.SetLinearForm(1./normtg,d2gui,
194 -1./normtg*(nplan.Dot(d2gui)),nplan);
196 temp.SetXYZ(pts.XYZ()-ptgui.XYZ());
198 secmember(1) = nplan.Dot(d1gui) - dnplan.Dot(temp);
199 secmember(2) = 2.*d1gui.Dot(temp);
201 // gradsol*der = secmember
202 // avec der(1) = dU/dW, der(2) = dU/dW, W est le parametre de guide
204 math_Gauss Resol(gradsol);
205 if (Resol.IsDone()) {
206 Resol.Solve(secmember);
207 tgs.SetLinearForm(secmember(1),d1u,secmember(2),d1v);
208 tg2d.SetCoord(secmember(1),secmember(2));
209 istangent = Standard_False;
212 istangent = Standard_True;
214 return Standard_True;
217 return Standard_False;