1 // Created on: 1996-01-25
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1996-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>
20 #include <Extrema_FuncExtCS.hxx>
21 #include <Extrema_GenLocateExtCS.hxx>
22 #include <Extrema_POnCurv.hxx>
23 #include <Extrema_POnSurf.hxx>
24 #include <math_FunctionSetRoot.hxx>
25 #include <math_NewtonFunctionSetRoot.hxx>
26 #include <math_Vector.hxx>
27 #include <Standard_DomainError.hxx>
28 #include <StdFail_NotDone.hxx>
30 //=======================================================================
31 //function : Extrema_GenLocateExtCS
33 //=======================================================================
34 Extrema_GenLocateExtCS::Extrema_GenLocateExtCS()
35 : myDone(Standard_False),
40 //=======================================================================
41 //function : Extrema_GenLocateExtCS
43 //=======================================================================
45 Extrema_GenLocateExtCS::Extrema_GenLocateExtCS(const Adaptor3d_Curve& C,
46 const Adaptor3d_Surface& S,
47 const Standard_Real T,
48 const Standard_Real U,
49 const Standard_Real V,
50 const Standard_Real Tol1,
51 const Standard_Real Tol2)
53 Perform(C,S,T,U,V,Tol1,Tol2);
56 //=======================================================================
59 //=======================================================================
61 void Extrema_GenLocateExtCS::Perform(const Adaptor3d_Curve& C,
62 const Adaptor3d_Surface& S,
63 const Standard_Real T,
64 const Standard_Real U,
65 const Standard_Real V,
66 const Standard_Real Tol1,
67 const Standard_Real Tol2)
69 myDone = Standard_False;
71 Standard_Real Tinf, Tsup;
72 Tinf = C.FirstParameter();
73 Tsup = C.LastParameter();
75 Standard_Real Uinf, Usup, Vinf, Vsup;
76 Uinf = S.FirstUParameter();
77 Usup = S.LastUParameter();
78 Vinf = S.FirstVParameter();
79 Vsup = S.LastVParameter();
81 Extrema_FuncExtCS F (C,S);
82 math_Vector Tol(1, 3), Start(1, 3), BInf(1, 3), BSup(1, 3);
99 math_FunctionSetRoot SR (F, Tol);
100 SR.Perform(F, Start, BInf, BSup);
104 mySqDist = F.SquareDistance(1);
105 myPoint1 = F.PointOnCurve(1);
106 myPoint2 = F.PointOnSurface(1);
107 myDone = Standard_True;
111 //=======================================================================
114 //=======================================================================
116 Standard_Boolean Extrema_GenLocateExtCS::IsDone() const
121 //=======================================================================
124 //=======================================================================
126 Standard_Real Extrema_GenLocateExtCS::SquareDistance() const
128 if (!IsDone()) { throw StdFail_NotDone(); }
132 //=======================================================================
133 //function : PointOnCurve
135 //=======================================================================
137 const Extrema_POnCurv& Extrema_GenLocateExtCS::PointOnCurve() const
139 if (!IsDone()) { throw StdFail_NotDone(); }
143 //=======================================================================
144 //function : PointOnSurface
146 //=======================================================================
148 const Extrema_POnSurf& Extrema_GenLocateExtCS::PointOnSurface() const
150 if (!IsDone()) { throw StdFail_NotDone(); }