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 myPinit = Standard_True;
45 mySinit = Standard_True;
48 //=============================================================================
49 void Extrema_FuncExtPS::Initialize(const Adaptor3d_Surface& S)
51 myS = (Adaptor3d_SurfacePtr)&S;
52 mySinit = Standard_True;
57 //=============================================================================
59 void Extrema_FuncExtPS::SetPoint(const gp_Pnt& P)
62 myPinit = Standard_True;
67 //=============================================================================
69 //=============================================================================
71 Standard_Integer Extrema_FuncExtPS::NbVariables () const { return 2;}
72 //=============================================================================
74 Standard_Integer Extrema_FuncExtPS::NbEquations () const { return 2;}
75 //=============================================================================
77 Standard_Boolean Extrema_FuncExtPS::Value (const math_Vector& UV,
80 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
84 myS->D1(myU,myV,myPs,Dus,Dvs);
86 gp_Vec PPs (myP,myPs);
93 //=============================================================================
95 Standard_Boolean Extrema_FuncExtPS::Derivatives (const math_Vector& UV,
99 return Values(UV,F,Df);
101 //=============================================================================
103 Standard_Boolean Extrema_FuncExtPS::Values (const math_Vector& UV,
107 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
110 gp_Vec Dus, Dvs, Duus, Dvvs, Duvs;
111 myS->D2(myU,myV,myPs,Dus,Dvs,Duus,Dvvs,Duvs);
113 gp_Vec PPs (myP,myPs);
115 Df(1,1) = Dus.SquareMagnitude() + PPs.Dot(Duus);
116 Df(1,2) = Dvs.Dot(Dus) + PPs.Dot(Duvs);
118 Df(2,2) = Dvs.SquareMagnitude() + PPs.Dot(Dvvs);
124 return Standard_True;
126 //=============================================================================
128 Standard_Integer Extrema_FuncExtPS::GetStateNumber ()
130 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
131 //comparison of solution with previous solutions
132 Standard_Integer i = 1, nbSol = mySqDist.Length();
133 Standard_Real tol2d = Precision::PConfusion() * Precision::PConfusion();
135 for( ; i <= nbSol; i++)
137 Standard_Real aU, aV;
138 myPoint(i).Parameter(aU, aV);
139 if( ((myU - aU ) * (myU - aU ) + (myV - aV ) * (myV - aV )) <= tol2d )
144 mySqDist.Append(myPs.SquareDistance(myP));
145 myPoint.Append(Extrema_POnSurf(myU,myV,myPs));
148 //=============================================================================
150 Standard_Integer Extrema_FuncExtPS::NbExt () const
152 return mySqDist.Length();
154 //=============================================================================
156 Standard_Real Extrema_FuncExtPS::SquareDistance (const Standard_Integer N) const
158 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
159 return mySqDist.Value(N);
161 //=============================================================================
163 Extrema_POnSurf Extrema_FuncExtPS::Point (const Standard_Integer N) const
165 if (!myPinit || !mySinit) Standard_TypeMismatch::Raise();
166 return myPoint.Value(N);