1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 // Modified by skv - Thu Sep 30 15:21:07 2004 OCC593
25 #include <Extrema_FuncExtPS.ixx>
28 #include <Standard_TypeMismatch.hxx>
29 #include <Precision.hxx>
30 #include <GeomAbs_IsoType.hxx>
32 Extrema_FuncExtPS::Extrema_FuncExtPS ()
34 myPinit = Standard_False;
35 mySinit = Standard_False;
38 //=============================================================================
39 Extrema_FuncExtPS::Extrema_FuncExtPS (const gp_Pnt& P,
40 const Adaptor3d_Surface& S)
43 myS = (Adaptor3d_SurfacePtr)&S;
44 GeomAbs_SurfaceType aSType = S.GetType();
45 myPinit = Standard_True;
46 mySinit = Standard_True;
49 //=============================================================================
50 void Extrema_FuncExtPS::Initialize(const Adaptor3d_Surface& S)
52 myS = (Adaptor3d_SurfacePtr)&S;
53 GeomAbs_SurfaceType aSType = S.GetType();
54 mySinit = Standard_True;
59 //=============================================================================
61 void Extrema_FuncExtPS::SetPoint(const gp_Pnt& P)
64 myPinit = Standard_True;
69 //=============================================================================
71 //=============================================================================
73 Standard_Integer Extrema_FuncExtPS::NbVariables () const { return 2;}
74 //=============================================================================
76 Standard_Integer Extrema_FuncExtPS::NbEquations () const { return 2;}
77 //=============================================================================
79 Standard_Boolean Extrema_FuncExtPS::Value (const math_Vector& UV,
82 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
86 myS->D1(myU,myV,myPs,Dus,Dvs);
88 gp_Vec PPs (myP,myPs);
95 //=============================================================================
97 Standard_Boolean Extrema_FuncExtPS::Derivatives (const math_Vector& UV,
101 return Values(UV,F,Df);
103 //=============================================================================
105 Standard_Boolean Extrema_FuncExtPS::Values (const math_Vector& UV,
109 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
112 gp_Vec Dus, Dvs, Duus, Dvvs, Duvs;
113 myS->D2(myU,myV,myPs,Dus,Dvs,Duus,Dvvs,Duvs);
115 gp_Vec PPs (myP,myPs);
117 Df(1,1) = Dus.SquareMagnitude() + PPs.Dot(Duus);
118 Df(1,2) = Dvs.Dot(Dus) + PPs.Dot(Duvs);
120 Df(2,2) = Dvs.SquareMagnitude() + PPs.Dot(Dvvs);
126 return Standard_True;
128 //=============================================================================
130 Standard_Integer Extrema_FuncExtPS::GetStateNumber ()
132 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
133 mySqDist.Append(myPs.SquareDistance(myP));
134 myPoint.Append(Extrema_POnSurf(myU,myV,myPs));
137 //=============================================================================
139 Standard_Integer Extrema_FuncExtPS::NbExt () const
141 return mySqDist.Length();
143 //=============================================================================
145 Standard_Real Extrema_FuncExtPS::SquareDistance (const Standard_Integer N) const
147 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
148 return mySqDist.Value(N);
150 //=============================================================================
152 Extrema_POnSurf Extrema_FuncExtPS::Point (const Standard_Integer N) const
154 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
155 return myPoint.Value(N);