1 // Created on: 1994-03-18
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
22 #include <GeomAPI_ExtremaSurfaceSurface.ixx>
25 #include <GeomAdaptor_Surface.hxx>
26 #include <Extrema_POnSurf.hxx>
28 #include <Precision.hxx>
32 //=======================================================================
33 //function : GeomAPI_ExtremaSurfaceSurface
35 //=======================================================================
37 GeomAPI_ExtremaSurfaceSurface::GeomAPI_ExtremaSurfaceSurface()
39 myIsDone = Standard_False;
43 //=======================================================================
44 //function : GeomAPI_ExtremaSurfaceSurface
46 //=======================================================================
48 GeomAPI_ExtremaSurfaceSurface::GeomAPI_ExtremaSurfaceSurface
49 (const Handle(Geom_Surface)& S1,
50 const Handle(Geom_Surface)& S2)
56 //=======================================================================
57 //function : GeomAPI_ExtremaSurfaceSurface
59 //=======================================================================
61 GeomAPI_ExtremaSurfaceSurface::GeomAPI_ExtremaSurfaceSurface
62 (const Handle(Geom_Surface)& S1,
63 const Handle(Geom_Surface)& S2,
64 const Standard_Real U1min,
65 const Standard_Real U1max,
66 const Standard_Real V1min,
67 const Standard_Real V1max,
68 const Standard_Real U2min,
69 const Standard_Real U2max,
70 const Standard_Real V2min,
71 const Standard_Real V2max)
73 Init(S1,S2,U1min,U1max,V1min,V1max,U2min,U2max,V2min,V2max);
77 //=======================================================================
80 //=======================================================================
82 void GeomAPI_ExtremaSurfaceSurface::Init
83 (const Handle(Geom_Surface)& S1,
84 const Handle(Geom_Surface)& S2)
86 GeomAdaptor_Surface TheSurface1 (S1);
87 GeomAdaptor_Surface TheSurface2 (S2);
89 Standard_Real Tol = Precision::PConfusion();
91 Extrema_ExtSS theExtSS(TheSurface1, TheSurface2,Tol,Tol);
94 myIsDone = myExtSS.IsDone() && ( myExtSS.NbExt() > 0);
98 // evaluate the lower distance and its index;
100 Standard_Real Dist2, Dist2Min = myExtSS.SquareDistance(1);
103 for ( Standard_Integer i = 2; i <= myExtSS.NbExt(); i++) {
104 Dist2 = myExtSS.SquareDistance(i);
105 if ( Dist2 < Dist2Min) {
114 //=======================================================================
117 //=======================================================================
119 void GeomAPI_ExtremaSurfaceSurface::Init
120 (const Handle(Geom_Surface)& S1,
121 const Handle(Geom_Surface)& S2,
122 const Standard_Real U1min,
123 const Standard_Real U1max,
124 const Standard_Real V1min,
125 const Standard_Real V1max,
126 const Standard_Real U2min,
127 const Standard_Real U2max,
128 const Standard_Real V2min,
129 const Standard_Real V2max)
131 GeomAdaptor_Surface TheSurface1 (S1,U1min,U1max,V1min,V1max);
132 GeomAdaptor_Surface TheSurface2 (S2,U2min,U2max,V2min,V2max);
134 Standard_Real Tol = Precision::PConfusion();
135 Extrema_ExtSS theExtSS(TheSurface1, TheSurface2,
136 U1min,U1max,V1min,V1max,
137 U2min,U2max,V2min,V2max,
141 myIsDone = myExtSS.IsDone() && ( myExtSS.NbExt() > 0);
145 // evaluate the lower distance and its index;
147 Standard_Real Dist2, Dist2Min = myExtSS.SquareDistance(1);
150 for ( Standard_Integer i = 2; i <= myExtSS.NbExt(); i++) {
151 Dist2 = myExtSS.SquareDistance(i);
152 if ( Dist2 < Dist2Min) {
161 //=======================================================================
162 //function : NbExtrema
164 //=======================================================================
166 Standard_Integer GeomAPI_ExtremaSurfaceSurface::NbExtrema() const
169 return myExtSS.NbExt();
175 //=======================================================================
178 //=======================================================================
180 void GeomAPI_ExtremaSurfaceSurface::Points
181 (const Standard_Integer Index,
185 Standard_OutOfRange_Raise_if( Index < 1 || Index > NbExtrema(),
186 "GeomAPI_ExtremaCurveCurve::Points");
188 Extrema_POnSurf PS1,PS2;
189 myExtSS.Points(Index,PS1,PS2);
196 //=======================================================================
197 //function : Parameters
199 //=======================================================================
201 void GeomAPI_ExtremaSurfaceSurface::Parameters
202 (const Standard_Integer Index,
206 Standard_Real& V2) const
208 Standard_OutOfRange_Raise_if( Index < 1 || Index > NbExtrema(),
209 "GeomAPI_ExtremaCurveCurve::Parameters");
211 Extrema_POnSurf PS1,PS2;
212 myExtSS.Points(Index,PS1,PS2);
214 PS1.Parameter(U1,V1);
215 PS2.Parameter(U2,V2);
219 //=======================================================================
220 //function : Distance
222 //=======================================================================
224 Standard_Real GeomAPI_ExtremaSurfaceSurface::Distance
225 (const Standard_Integer Index) const
227 Standard_OutOfRange_Raise_if( Index < 1 || Index > NbExtrema(),
228 "GeomAPI_ExtremaCurveCurve::Distance");
230 return sqrt (myExtSS.SquareDistance(Index));
234 //=======================================================================
235 //function : NearestPoints
237 //=======================================================================
239 void GeomAPI_ExtremaSurfaceSurface::NearestPoints
243 StdFail_NotDone_Raise_if
244 ( !myIsDone, "GeomAPI_ExtremaSurfaceSurface::NearestPoints");
246 Points(myIndex,P1,P2);
250 //=======================================================================
251 //function : LowerDistanceParameters
253 //=======================================================================
255 void GeomAPI_ExtremaSurfaceSurface::LowerDistanceParameters
259 Standard_Real& V2) const
261 StdFail_NotDone_Raise_if
262 ( !myIsDone, "GeomAPI_ExtremaSurfaceSurface::LowerDistanceParameters");
264 Parameters(myIndex,U1,V1,U2,V2);
268 //=======================================================================
269 //function : LowerDistance
271 //=======================================================================
273 Standard_Real GeomAPI_ExtremaSurfaceSurface::LowerDistance() const
275 StdFail_NotDone_Raise_if
276 ( !myIsDone, "GeomAPI_ExtremaSurfaceSurface::LowerDistance");
278 return sqrt (myExtSS.SquareDistance(myIndex));
282 //=======================================================================
283 //function : Standard_Real
285 //=======================================================================
287 GeomAPI_ExtremaSurfaceSurface::operator Standard_Real() const
289 return LowerDistance();
293 //=======================================================================
294 //function : Standard_Integer
296 //=======================================================================
298 GeomAPI_ExtremaSurfaceSurface::operator Standard_Integer() const