0024510: Remove unused local variables
[occt.git] / src / Extrema / Extrema_ExtSS.cxx
CommitLineData
b311480e 1// Created on: 1995-07-19
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_ExtSS.ixx>
18
19#include <StdFail_NotDone.hxx>
20#include <Standard_NotImplemented.hxx>
21#include <StdFail_InfiniteSolutions.hxx>
22#include <Precision.hxx>
23#include <GeomAbs_SurfaceType.hxx>
24#include <gp_Pnt.hxx>
25#include <gp_Pln.hxx>
26
27#include <Extrema_GenExtSS.hxx>
28#include <ElCLib.hxx>
29
30Extrema_ExtSS::Extrema_ExtSS()
31{
32 myDone = Standard_False;
33}
34
35Extrema_ExtSS::Extrema_ExtSS(const Adaptor3d_Surface& S1,
36 const Adaptor3d_Surface& S2,
37 const Standard_Real TolS1,
38 const Standard_Real TolS2)
39
40{
41 Initialize(S2, S2.FirstUParameter(),
42 S2.LastUParameter(),
43 S2.FirstVParameter(),
44 S2.LastVParameter(), TolS2);
45
46 Perform(S1, S1.FirstUParameter(),
47 S1.LastUParameter(),
48 S1.FirstVParameter(),
49 S1.LastVParameter(), TolS1);
50}
51
52Extrema_ExtSS::Extrema_ExtSS(const Adaptor3d_Surface& S1,
53 const Adaptor3d_Surface& S2,
54 const Standard_Real Uinf1,
55 const Standard_Real Usup1,
56 const Standard_Real Vinf1,
57 const Standard_Real Vsup1,
58 const Standard_Real Uinf2,
59 const Standard_Real Usup2,
60 const Standard_Real Vinf2,
61 const Standard_Real Vsup2,
62 const Standard_Real TolS1,
63 const Standard_Real TolS2)
64
65{
66 Initialize(S2, Uinf2, Usup2, Vinf2, Vsup2, TolS2);
67 Perform(S1, Uinf1, Usup1, Vinf1, Vsup1, TolS1);
68}
69
70
71void Extrema_ExtSS::Initialize(const Adaptor3d_Surface& S2,
72 const Standard_Real Uinf2,
73 const Standard_Real Usup2,
74 const Standard_Real Vinf2,
75 const Standard_Real Vsup2,
76 const Standard_Real TolS2)
77{
78 myS2 = (Adaptor3d_SurfacePtr)&S2;
79 myIsPar = Standard_False;
80 myuinf2 = Uinf2;
81 myusup2 = Usup2;
82 myvinf2 = Vinf2;
83 myvsup2 = Vsup2;
84 mytolS2 = TolS2;
85 myStype = S2.GetType();
86}
87
88
89void Extrema_ExtSS::Perform(const Adaptor3d_Surface& S1,
90 const Standard_Real Uinf1,
91 const Standard_Real Usup1,
92 const Standard_Real Vinf1,
93 const Standard_Real Vsup1,
94 const Standard_Real TolS1)
95{
96 myuinf1 = Uinf1;
97 myusup1 = Usup1;
98 myvinf1 = Vinf1;
99 myvsup1 = Vsup1;
100 mytolS1 = TolS1;
101 myPOnS1.Clear();
102 myPOnS2.Clear();
103 mySqDist.Clear();
104 Standard_Integer i;
105 GeomAbs_SurfaceType myS1type = S1.GetType();
106 Standard_Integer NbU = 10, NbV = 10;
107
108 switch(myS1type) {
109
110 case GeomAbs_Plane:
111 {
112
113 switch(myStype) {
114 case GeomAbs_Plane:
115 {
116 myExtElSS.Perform(S1.Plane(),myS2->Plane());
117 }
118 break;
119 default:
120 {
121 Extrema_GenExtSS Ext(S1, *myS2, NbU, NbV, mytolS1, mytolS2);
122 myDone = Ext.IsDone();
123 if (myDone) {
124 Standard_Integer NbExt = Ext.NbExt();
125 Standard_Real U1, V1,U2,V2;
126 Extrema_POnSurf PS1;
127 Extrema_POnSurf PS2;
128 for (i = 1; i <= NbExt; i++) {
129 PS1 = Ext.PointOnS1(i);
130 PS2 = Ext.PointOnS2(i);
131 PS1.Parameter(U1, V1);
132 PS2.Parameter(U2, V2);
133 if (S1.IsUPeriodic())
134 U1 = ElCLib::InPeriod(U1, myuinf1, myuinf1+S1.UPeriod());
135 if (S1.IsVPeriodic())
136 V1 = ElCLib::InPeriod(V1, myvinf1, myvinf1+S1.VPeriod());
137 if (myS2->IsUPeriodic())
138 U2 = ElCLib::InPeriod(U2, myuinf2, myuinf2+myS2->UPeriod());
139 if (myS2->IsVPeriodic())
140 V2 = ElCLib::InPeriod(V2, myvinf2, myvinf2+myS2->VPeriod());
141
142 if ((myuinf1-U1) <= mytolS1 && (U1-myusup1) <= mytolS1 &&
143 (myvinf1-V1) <= mytolS1 && (V1-myvsup1) <= mytolS1 &&
144 (myuinf2-U2) <= mytolS2 && (U2-myusup2) <= mytolS2 &&
145 (myvinf2-V2) <= mytolS2 && (V2-myvsup2) <= mytolS2) {
146 mySqDist.Append(Ext.SquareDistance(i));
147 myPOnS1.Append(Extrema_POnSurf(U1, V1, PS1.Value()));
148 myPOnS2.Append(Extrema_POnSurf(U2, V2, PS2.Value()));
149 }
150 }
151 }
152 return;
153
154 }
155 break;
156 }
157 break;
158 }
159 default:
160 {
161 Extrema_GenExtSS Ext(S1, *myS2, NbU, NbV, mytolS1, mytolS2);
162 myDone = Ext.IsDone();
163 if (myDone) {
164 Standard_Integer NbExt = Ext.NbExt();
165 Standard_Real U1, V1,U2,V2;
166 Extrema_POnSurf PS1;
167 Extrema_POnSurf PS2;
168 for (i = 1; i <= NbExt; i++) {
169 PS1 = Ext.PointOnS1(i);
170 PS2 = Ext.PointOnS2(i);
171 PS1.Parameter(U1, V1);
172 PS2.Parameter(U2, V2);
173 if (S1.IsUPeriodic())
174 U1 = ElCLib::InPeriod(U1, myuinf1, myuinf1+S1.UPeriod());
175 if (S1.IsVPeriodic())
176 V1 = ElCLib::InPeriod(V1, myvinf1, myvinf1+S1.VPeriod());
177 if (myS2->IsUPeriodic())
178 U2 = ElCLib::InPeriod(U2, myuinf2, myuinf2+myS2->UPeriod());
179 if (myS2->IsVPeriodic())
180 V2 = ElCLib::InPeriod(V2, myvinf2, myvinf2+myS2->VPeriod());
181
182 if ((myuinf1-U1) <= mytolS1 && (U1-myusup1) <= mytolS1 &&
183 (myvinf1-V1) <= mytolS1 && (V1-myvsup1) <= mytolS1 &&
184 (myuinf2-U2) <= mytolS2 && (U2-myusup2) <= mytolS2 &&
185 (myvinf2-V2) <= mytolS2 && (V2-myvsup2) <= mytolS2) {
186 mySqDist.Append(Ext.SquareDistance(i));
187 myPOnS1.Append(Extrema_POnSurf(U1, V1, PS1.Value()));
188 myPOnS2.Append(Extrema_POnSurf(U2, V2, PS2.Value()));
189 }
190 }
191 }
192 return;
193
194 }
195 break;
196 }
197
198 myDone = myExtElSS.IsDone();
199 if (myDone) {
200 myIsPar = myExtElSS.IsParallel();
201 if (myIsPar) {
202 mySqDist.Append(myExtElSS.SquareDistance(1));
203 }
204 else {
205 Standard_Integer NbExt = myExtElSS.NbExt();
206 Standard_Real U1, V1, U2, V2;
207 Extrema_POnSurf PS1;
208 Extrema_POnSurf PS2;
209 for (i = 1; i <= NbExt; i++) {
210 myExtElSS.Points(i, PS1, PS2);
211 PS1.Parameter(U1, V1);
212 PS2.Parameter(U2, V2);
213 if ((myuinf1-U1) <= mytolS1 && (U1-myusup1) <= mytolS1 &&
214 (myvinf1-V1) <= mytolS1 && (V1-myvsup1) <= mytolS1 &&
215 (myuinf2-U2) <= mytolS2 && (U2-myusup2) <= mytolS2 &&
216 (myvinf2-V2) <= mytolS2 && (V2-myvsup2) <= mytolS2) {
217 mySqDist.Append(myExtElSS.SquareDistance(i));
218 myPOnS1.Append(PS1);
219 myPOnS2.Append(PS2);
220 }
221 }
222 }
223 }
224
225}
226
227
228Standard_Boolean Extrema_ExtSS::IsDone() const
229{
230 return myDone;
231}
232
233Standard_Boolean Extrema_ExtSS::IsParallel() const
234{
235 return myIsPar;
236}
237
238
239Standard_Real Extrema_ExtSS::SquareDistance(const Standard_Integer N) const
240{
241 if(!myDone) StdFail_NotDone::Raise();
242 if (myIsPar && N != 1) StdFail_InfiniteSolutions::Raise();
243 if ((N < 1) || (N > mySqDist.Length())) Standard_OutOfRange::Raise();
244 return mySqDist.Value(N);
245}
246
247
248Standard_Integer Extrema_ExtSS::NbExt() const
249{
250 if(!myDone) StdFail_NotDone::Raise();
251 return mySqDist.Length();
252}
253
254
255
256void Extrema_ExtSS::Points(const Standard_Integer N,
257 Extrema_POnSurf& P1,
258 Extrema_POnSurf& P2) const
259{
260 if(!myDone) StdFail_NotDone::Raise();
261 P1 = myPOnS1.Value(N);
262 P2 = myPOnS2.Value(N);
263}