0024001: Stereographic rendering support
[occt.git] / src / Extrema / Extrema_GenLocateExtPS.cxx
CommitLineData
b311480e 1// Created on: 1995-07-18
2// Created by: Modelistation
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <Extrema_GenLocateExtPS.ixx>
18#include <Extrema_FuncExtPS.hxx>
19#include <StdFail_NotDone.hxx>
20#include <gp.hxx>
21#include <math_FunctionSetRoot.hxx>
22#include <math_NewtonFunctionSetRoot.hxx>
23#include <math_Vector.hxx>
24
25//=============================================================================
26
27Extrema_GenLocateExtPS::Extrema_GenLocateExtPS () { myDone = Standard_False; }
28//=============================================================================
29
30Extrema_GenLocateExtPS::Extrema_GenLocateExtPS (const gp_Pnt& P,
31 const Adaptor3d_Surface& S,
32 const Standard_Real U0,
33 const Standard_Real V0,
34 const Standard_Real TolU,
35 const Standard_Real TolV)
36/*-----------------------------------------------------------------------------
0d969553
Y
37Function:
38 Find (U,V) close to (U0,V0) so that dist(S(U,V),P) was extreme.
7fd59977 39
0d969553
Y
40Method:
41 If (u,v) is a solution, it is possible to write:
7fd59977 42 { F1(u,v) = (S(u,v)-P).dS/du(u,v) = 0.
43 { F2(u,v) = (S(u,v)-P).dS/dv(u,v) = 0.
0d969553
Y
44 The problem consists in finding, in the interval of surface definition,
45 the root of the system closest to (U0,V0).
46 Use class math_FunctionSetRoot with the following construction arguments:
47 - F: Extrema_FuncExtPS created from P and S,
7fd59977 48 - U0V0: math_Vector (U0,V0),
49 - Tol: Min(TolU,TolV),
50
51 - math_Vector (Uinf,Usup),
52 - math_Vector (Vinf,Vsup),
53 - 100. .
54---------------------------------------------------------------------------*/
55{
56 myDone = Standard_False;
57
58 Standard_Real Uinf, Usup, Vinf, Vsup;
59 Uinf = S.FirstUParameter();
60 Usup = S.LastUParameter();
61 Vinf = S.FirstVParameter();
62 Vsup = S.LastVParameter();
63
64 Extrema_FuncExtPS F (P,S);
65 math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2);
66
67 Tol(1) = TolU;
68 Tol(2) = TolV;
69
70 Start(1) = U0;
71 Start(2) = V0;
72
73 BInf(1) = Uinf;
74 BInf(2) = Vinf;
75 BSup(1) = Usup;
76 BSup(2) = Vsup;
77
78 math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
79 if (!SR.IsDone())
80 return;
81
82 mySqDist = F.SquareDistance(1);
83 myPoint = F.Point(1);
84 myDone = Standard_True;
85}
86//=============================================================================
87
88Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; }
89//=============================================================================
90
91Standard_Real Extrema_GenLocateExtPS::SquareDistance () const
92{
93 if (!IsDone()) { StdFail_NotDone::Raise(); }
94 return mySqDist;
95}
96//=============================================================================
97
5d99f2c8 98const Extrema_POnSurf& Extrema_GenLocateExtPS::Point () const
7fd59977 99{
100 if (!IsDone()) { StdFail_NotDone::Raise(); }
101 return myPoint;
102}
103//=============================================================================