summaryrefslogtreecommitdiff
path: root/src/Extrema/Extrema_GenLocateExtSS.cxx
blob: 1ce4d4717b9aaefa51258c5b5dffbb71a8009ebe (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
136
137
138
139
140
141
142
// File:	Extrema_GenExtSS.cxx
// Created:	Tue Jul 18 08:21:34 1995
// Author:	Modelistation
//		<model@metrox>

#include <Extrema_GenLocateExtSS.ixx>

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

//=======================================================================
//function : Extrema_GenLocateExtSS
//purpose  : 
//=======================================================================

 Extrema_GenLocateExtSS::Extrema_GenLocateExtSS()
{
}

//=======================================================================
//function : Extrema_GenLocateExtSS
//purpose  : 
//=======================================================================

 Extrema_GenLocateExtSS::Extrema_GenLocateExtSS(const Adaptor3d_Surface& S1, 
						const Adaptor3d_Surface& S2, 
						const Standard_Real U1, 
						const Standard_Real V1, 
						const Standard_Real U2, 
						const Standard_Real V2, 
						const Standard_Real Tol1, 
						const Standard_Real Tol2)
{
  Perform(S1,S2,U1,V1,U2,V2,Tol1,Tol2);
}

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

void Extrema_GenLocateExtSS::Perform(const Adaptor3d_Surface& S1, 
				     const Adaptor3d_Surface& S2, 
				     const Standard_Real U1, 
				     const Standard_Real V1, 
				     const Standard_Real U2, 
				     const Standard_Real V2, 
				     const Standard_Real Tol1, 
				     const Standard_Real Tol2)
{
  myDone = Standard_False;

  Standard_Real Uinf1, Usup1, Vinf1, Vsup1;
  Uinf1 = S1.FirstUParameter();
  Usup1 = S1.LastUParameter();
  Vinf1 = S1.FirstVParameter();
  Vsup1 = S1.LastVParameter();

  Standard_Real Uinf2, Usup2, Vinf2, Vsup2;
  Uinf2 = S2.FirstUParameter();
  Usup2 = S2.LastUParameter();
  Vinf2 = S2.FirstVParameter();
  Vsup2 = S2.LastVParameter();

  Extrema_FuncExtSS F (S1,S2);
  math_Vector Tol(1, 4), Start(1, 4), BInf(1, 4), BSup(1, 4);

  Tol(1) = Tol1;
  Tol(2) = Tol1;
  Tol(3) = Tol2;
  Tol(4) = Tol2;

  Start(1) = U1;
  Start(2) = V1;
  Start(3) = U2;
  Start(4) = V2;

  BInf(1) = Uinf1;
  BInf(2) = Vinf1;
  BInf(3) = Uinf2;
  BInf(4) = Vinf2;
  BSup(1) = Usup1;
  BSup(2) = Vsup1;
  BSup(3) = Usup2;
  BSup(4) = Vsup2;

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

  mySqDist = F.SquareDistance(1);
  myPoint1 = F.PointOnS1(1);
  myPoint2 = F.PointOnS2(1);
  myDone = Standard_True;

}

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

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

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

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

//=======================================================================
//function : PointOnS1
//purpose  : 
//=======================================================================

const Extrema_POnSurf& Extrema_GenLocateExtSS::PointOnS1() const 
{
  if (!IsDone()) { StdFail_NotDone::Raise(); }
  return myPoint1;
}

//=======================================================================
//function : PointOnS2
//purpose  : 
//=======================================================================

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