1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
21 #include <Extrema_ExtElSS.ixx>
22 #include <Extrema_ExtPElS.hxx>
23 #include <Standard_NotImplemented.hxx>
24 #include <StdFail_NotDone.hxx>
25 #include <StdFail_InfiniteSolutions.hxx>
26 #include <Precision.hxx>
29 Extrema_ExtElSS::Extrema_ExtElSS()
31 myDone = Standard_False;
32 myIsPar = Standard_False;
36 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Pln& S2)
42 void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Pln& S2)
45 myDone = Standard_True;
46 myIsPar = Standard_False;
49 if ((S1.Axis().Direction()).IsParallel(S2.Axis().Direction(),
50 Precision::Angular())) {
51 myIsPar = Standard_True;
53 mySqDist = new TColStd_HArray1OfReal(1, 1);
54 mySqDist->SetValue(1, S1.SquareDistance(S2));
59 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Sphere& S2)
65 //void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Sphere& S2)
66 void Extrema_ExtElSS::Perform(const gp_Pln& , const gp_Sphere& )
69 myDone = Standard_True;
70 myIsPar = Standard_False;
72 Standard_NotImplemented::Raise();
75 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Sphere& S2)
81 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Sphere& S2)
82 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Sphere& )
85 myDone = Standard_True;
86 myIsPar = Standard_False;
88 Standard_NotImplemented::Raise();
92 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cylinder& S2)
98 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cylinder& S2)
99 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cylinder& )
102 myDone = Standard_True;
103 myIsPar = Standard_False;
105 Standard_NotImplemented::Raise();
108 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cone& S2)
114 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cone& S2)
115 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cone& )
118 myDone = Standard_True;
119 myIsPar = Standard_False;
121 Standard_NotImplemented::Raise();
125 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Torus& S2)
131 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Torus& S2)
132 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Torus& )
135 myDone = Standard_True;
136 myIsPar = Standard_False;
138 Standard_NotImplemented::Raise();
142 Standard_Boolean Extrema_ExtElSS::IsDone() const
148 Standard_Boolean Extrema_ExtElSS::IsParallel() const
150 if(!myDone) StdFail_NotDone::Raise();
155 Standard_Integer Extrema_ExtElSS::NbExt() const
157 if(!myDone) StdFail_NotDone::Raise();
158 if (myIsPar) StdFail_InfiniteSolutions::Raise();
163 Standard_Real Extrema_ExtElSS::SquareDistance(const Standard_Integer N) const
165 if(!myDone) StdFail_NotDone::Raise();
166 if (myIsPar && N != 1) StdFail_InfiniteSolutions::Raise();
167 return mySqDist->Value(N);
171 void Extrema_ExtElSS::Points(const Standard_Integer N,
173 Extrema_POnSurf& P2) const
175 if(!myDone) StdFail_NotDone::Raise();
176 if (myIsPar) StdFail_InfiniteSolutions::Raise();
177 P1 = myPOnS1->Value(N);
178 P2 = myPOnS2->Value(N);