1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Extrema_ExtElSS.hxx>
17 #include <Extrema_ExtPElS.hxx>
18 #include <Extrema_POnSurf.hxx>
19 #include <gp_Cone.hxx>
20 #include <gp_Cylinder.hxx>
22 #include <gp_Sphere.hxx>
23 #include <gp_Torus.hxx>
24 #include <Precision.hxx>
25 #include <Standard_NotImplemented.hxx>
26 #include <Standard_OutOfRange.hxx>
27 #include <StdFail_InfiniteSolutions.hxx>
28 #include <StdFail_NotDone.hxx>
30 Extrema_ExtElSS::Extrema_ExtElSS()
32 myDone = Standard_False;
33 myIsPar = Standard_False;
37 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Pln& S2)
43 void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Pln& S2)
46 myDone = Standard_True;
47 myIsPar = Standard_False;
50 if ((S1.Axis().Direction()).IsParallel(S2.Axis().Direction(),
51 Precision::Angular())) {
52 myIsPar = Standard_True;
54 mySqDist = new TColStd_HArray1OfReal(1, 1);
55 mySqDist->SetValue(1, S1.SquareDistance(S2));
60 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Sphere& S2)
66 //void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Sphere& S2)
67 void Extrema_ExtElSS::Perform(const gp_Pln& , const gp_Sphere& )
70 myDone = Standard_True;
71 myIsPar = Standard_False;
73 Standard_NotImplemented::Raise();
76 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Sphere& S2)
82 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Sphere& S2)
83 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Sphere& )
86 myDone = Standard_True;
87 myIsPar = Standard_False;
89 Standard_NotImplemented::Raise();
93 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cylinder& S2)
99 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cylinder& S2)
100 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cylinder& )
103 myDone = Standard_True;
104 myIsPar = Standard_False;
106 Standard_NotImplemented::Raise();
109 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cone& S2)
115 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cone& S2)
116 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cone& )
119 myDone = Standard_True;
120 myIsPar = Standard_False;
122 Standard_NotImplemented::Raise();
126 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Torus& S2)
132 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Torus& S2)
133 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Torus& )
136 myDone = Standard_True;
137 myIsPar = Standard_False;
139 Standard_NotImplemented::Raise();
143 Standard_Boolean Extrema_ExtElSS::IsDone() const
149 Standard_Boolean Extrema_ExtElSS::IsParallel() const
151 if(!myDone) StdFail_NotDone::Raise();
156 Standard_Integer Extrema_ExtElSS::NbExt() const
158 if(!myDone) StdFail_NotDone::Raise();
159 if (myIsPar) StdFail_InfiniteSolutions::Raise();
164 Standard_Real Extrema_ExtElSS::SquareDistance(const Standard_Integer N) const
166 if(!myDone) StdFail_NotDone::Raise();
167 if (myIsPar && N != 1) StdFail_InfiniteSolutions::Raise();
168 return mySqDist->Value(N);
172 void Extrema_ExtElSS::Points(const Standard_Integer N,
174 Extrema_POnSurf& P2) const
176 if(!myDone) StdFail_NotDone::Raise();
177 if (myIsPar) StdFail_InfiniteSolutions::Raise();
178 P1 = myPOnS1->Value(N);
179 P2 = myPOnS2->Value(N);