0023981: Wrong section curves
[occt.git] / src / Extrema / Extrema_GenLocateExtCS.cxx
CommitLineData
b311480e 1// Created on: 1996-01-25
2// Created by: Laurent PAINNOT
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
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.
10//
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.
13//
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.
20
7fd59977 21
22
23#include <Extrema_GenLocateExtCS.ixx>
24
25#include <Extrema_FuncExtCS.hxx>
26#include <math_Vector.hxx>
27#include <math_FunctionSetRoot.hxx>
28#include <math_NewtonFunctionSetRoot.hxx>
29
30//=======================================================================
31//function : Extrema_GenLocateExtCS
32//purpose :
33//=======================================================================
34
b311480e 35Extrema_GenLocateExtCS::Extrema_GenLocateExtCS()
7fd59977 36{
37}
38
39//=======================================================================
40//function : Extrema_GenLocateExtCS
41//purpose :
42//=======================================================================
43
44 Extrema_GenLocateExtCS::Extrema_GenLocateExtCS(const Adaptor3d_Curve& C,
45 const Adaptor3d_Surface& S,
46 const Standard_Real T,
47 const Standard_Real U,
48 const Standard_Real V,
49 const Standard_Real Tol1,
50 const Standard_Real Tol2)
51{
52 Perform(C,S,T,U,V,Tol1,Tol2);
53}
54
55//=======================================================================
56//function : Perform
57//purpose :
58//=======================================================================
59
60void Extrema_GenLocateExtCS::Perform(const Adaptor3d_Curve& C,
61 const Adaptor3d_Surface& S,
62 const Standard_Real T,
63 const Standard_Real U,
64 const Standard_Real V,
65 const Standard_Real Tol1,
66 const Standard_Real Tol2)
67{
68 myDone = Standard_False;
69
70 Standard_Real Tinf, Tsup;
71 Tinf = C.FirstParameter();
72 Tsup = C.LastParameter();
73
74 Standard_Real Uinf, Usup, Vinf, Vsup;
75 Uinf = S.FirstUParameter();
76 Usup = S.LastUParameter();
77 Vinf = S.FirstVParameter();
78 Vsup = S.LastVParameter();
79
80 Extrema_FuncExtCS F (C,S);
81 math_Vector Tol(1, 3), Start(1, 3), BInf(1, 3), BSup(1, 3);
82 Tol(1) = Tol1;
83 Tol(2) = Tol2;
84 Tol(3) = Tol2;
85
86 Start(1) = T;
87 Start(2) = U;
88 Start(3) = V;
89
90 BInf(1) = Tinf;
91 BInf(2) = Uinf;
92 BInf(3) = Vinf;
93
94 BSup(1) = Tsup;
95 BSup(2) = Usup;
96 BSup(3) = Vsup;
97
98 math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
99 if (!SR.IsDone())
100 return;
101
102 mySqDist = F.SquareDistance(1);
103 myPoint1 = F.PointOnCurve(1);
104 myPoint2 = F.PointOnSurface(1);
105 myDone = Standard_True;
106
107}
108
109//=======================================================================
110//function : IsDone
111//purpose :
112//=======================================================================
113
114Standard_Boolean Extrema_GenLocateExtCS::IsDone() const
115{
116 return myDone;
117}
118
119//=======================================================================
120//function : Value
121//purpose :
122//=======================================================================
123
124Standard_Real Extrema_GenLocateExtCS::SquareDistance() const
125{
126 if (!IsDone()) { StdFail_NotDone::Raise(); }
127 return mySqDist;
128}
129
130//=======================================================================
131//function : PointOnCurve
132//purpose :
133//=======================================================================
134
135const Extrema_POnCurv& Extrema_GenLocateExtCS::PointOnCurve() const
136{
137 if (!IsDone()) { StdFail_NotDone::Raise(); }
138 return myPoint1;
139}
140
141//=======================================================================
142//function : PointOnSurface
143//purpose :
144//=======================================================================
145
146const Extrema_POnSurf& Extrema_GenLocateExtCS::PointOnSurface() const
147{
148 if (!IsDone()) { StdFail_NotDone::Raise(); }
149 return myPoint2;
150}
151