summaryrefslogtreecommitdiff
path: root/src/Extrema/Extrema_GenLocateExtCS.cxx
blob: 8e6957b6d5a67762ea254f25c1167aef684ec758 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// File:	Extrema_GenLocateExtCS.cxx
// Created:	Thu Jan 25 15:29:48 1996
// Author:	Laurent PAINNOT
//		<lpa@nonox>


#include <Extrema_GenLocateExtCS.ixx>

#include <Extrema_FuncExtCS.hxx>
#include <math_Vector.hxx>
#include <math_FunctionSetRoot.hxx>
#include <math_NewtonFunctionSetRoot.hxx>

//=======================================================================
//function : Extrema_GenLocateExtCS
//purpose  : 
//=======================================================================

 Extrema_GenLocateExtCS::Extrema_GenLocateExtCS()
{
}

//=======================================================================
//function : Extrema_GenLocateExtCS
//purpose  : 
//=======================================================================

 Extrema_GenLocateExtCS::Extrema_GenLocateExtCS(const Adaptor3d_Curve& C, 
						const Adaptor3d_Surface& S, 
						const Standard_Real T, 
						const Standard_Real U, 
						const Standard_Real V, 
						const Standard_Real Tol1, 
						const Standard_Real Tol2)
{
  Perform(C,S,T,U,V,Tol1,Tol2);
}

//=======================================================================
//function : Perform
//purpose  : 
//=======================================================================

void Extrema_GenLocateExtCS::Perform(const Adaptor3d_Curve& C, 
				     const Adaptor3d_Surface& S, 
				     const Standard_Real T, 
				     const Standard_Real U, 
				     const Standard_Real V, 
				     const Standard_Real Tol1, 
				     const Standard_Real Tol2)
{
  myDone = Standard_False;

  Standard_Real Tinf, Tsup;
  Tinf = C.FirstParameter();
  Tsup = C.LastParameter();

  Standard_Real Uinf, Usup, Vinf, Vsup;
  Uinf = S.FirstUParameter();
  Usup = S.LastUParameter();
  Vinf = S.FirstVParameter();
  Vsup = S.LastVParameter();

  Extrema_FuncExtCS F (C,S);
  math_Vector Tol(1, 3), Start(1, 3), BInf(1, 3), BSup(1, 3);
  Tol(1) = Tol1;
  Tol(2) = Tol2;
  Tol(3) = Tol2;

  Start(1) = T;
  Start(2) = U;
  Start(3) = V;

  BInf(1) = Tinf;
  BInf(2) = Uinf;
  BInf(3) = Vinf;

  BSup(1) = Tsup;
  BSup(2) = Usup;
  BSup(3) = Vsup;

  math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
  if (!SR.IsDone()) 
    return;

  mySqDist = F.SquareDistance(1);
  myPoint1 = F.PointOnCurve(1);
  myPoint2 = F.PointOnSurface(1);
  myDone = Standard_True;

}

//=======================================================================
//function : IsDone
//purpose  : 
//=======================================================================

Standard_Boolean Extrema_GenLocateExtCS::IsDone() const 
{
  return myDone;
}

//=======================================================================
//function : Value
//purpose  : 
//=======================================================================

Standard_Real Extrema_GenLocateExtCS::SquareDistance() const 
{
  if (!IsDone()) { StdFail_NotDone::Raise(); }
  return mySqDist;
}

//=======================================================================
//function : PointOnCurve
//purpose  : 
//=======================================================================

const Extrema_POnCurv& Extrema_GenLocateExtCS::PointOnCurve() const 
{
  if (!IsDone()) { StdFail_NotDone::Raise(); }
  return myPoint1;
}

//=======================================================================
//function : PointOnSurface
//purpose  : 
//=======================================================================

const Extrema_POnSurf& Extrema_GenLocateExtCS::PointOnSurface() const 
{
  if (!IsDone()) { StdFail_NotDone::Raise(); }
  return myPoint2;
}