0022610: The algorithm GeomAPI_ProjectPointOnSurf produces wrong results
[occt.git] / src / Extrema / Extrema_ExtElSS.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
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.
8 //
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.
11 //
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.
18
19
20
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>
27
28
29 Extrema_ExtElSS::Extrema_ExtElSS()
30 {
31   myDone = Standard_False;
32   myIsPar = Standard_False;
33 }
34
35
36 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Pln& S2)
37 {
38   Perform(S1, S2);
39 }
40
41
42 void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Pln& S2)
43 {
44
45   myDone = Standard_True;
46   myIsPar = Standard_False;
47   myNbExt = 0;
48
49   if ((S1.Axis().Direction()).IsParallel(S2.Axis().Direction(),
50                                          Precision::Angular())) {
51     myIsPar = Standard_True;
52     myNbExt = 1;
53     mySqDist = new TColStd_HArray1OfReal(1, 1);
54     mySqDist->SetValue(1, S1.SquareDistance(S2));
55   }
56 }
57
58
59 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Sphere& S2)
60 {
61   Perform(S1, S2);
62 }
63
64
65 //void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Sphere& S2)
66 void Extrema_ExtElSS::Perform(const gp_Pln& , const gp_Sphere& )
67 {
68
69   myDone = Standard_True;
70   myIsPar = Standard_False;
71   myNbExt = 0;
72   Standard_NotImplemented::Raise();
73 }
74
75 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Sphere& S2)
76 {
77   Perform(S1, S2);
78 }
79
80
81 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Sphere& S2)
82 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Sphere& )
83 {
84
85   myDone = Standard_True;
86   myIsPar = Standard_False;
87   myNbExt = 0;
88   Standard_NotImplemented::Raise();
89 }
90
91
92 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cylinder& S2)
93 {
94   Perform(S1, S2);
95 }
96
97
98 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cylinder& S2)
99 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cylinder& )
100 {
101
102   myDone = Standard_True;
103   myIsPar = Standard_False;
104   myNbExt = 0;
105   Standard_NotImplemented::Raise();
106 }
107
108 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cone& S2)
109 {
110   Perform(S1, S2);
111 }
112
113
114 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cone& S2)
115 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cone& )
116 {
117
118   myDone = Standard_True;
119   myIsPar = Standard_False;
120   myNbExt = 0;
121   Standard_NotImplemented::Raise();
122 }
123
124
125 Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Torus& S2)
126 {
127   Perform(S1, S2);
128 }
129
130
131 //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Torus& S2)
132 void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Torus& )
133 {
134
135   myDone = Standard_True;
136   myIsPar = Standard_False;
137   myNbExt = 0;
138   Standard_NotImplemented::Raise();
139 }
140
141
142 Standard_Boolean Extrema_ExtElSS::IsDone() const
143 {
144   return myDone;
145 }
146
147
148 Standard_Boolean Extrema_ExtElSS::IsParallel() const
149 {
150   if(!myDone) StdFail_NotDone::Raise();
151   return myIsPar;
152 }
153
154
155 Standard_Integer Extrema_ExtElSS::NbExt() const
156 {
157   if(!myDone) StdFail_NotDone::Raise();
158   if (myIsPar) StdFail_InfiniteSolutions::Raise();
159   return myNbExt;
160 }
161
162
163 Standard_Real Extrema_ExtElSS::SquareDistance(const Standard_Integer N) const
164 {
165   if(!myDone) StdFail_NotDone::Raise();
166   if (myIsPar && N != 1) StdFail_InfiniteSolutions::Raise();
167   return mySqDist->Value(N);
168 }
169
170
171 void Extrema_ExtElSS::Points(const Standard_Integer N,
172                              Extrema_POnSurf&       P1,
173                              Extrema_POnSurf&       P2) const
174 {
175   if(!myDone) StdFail_NotDone::Raise();
176   if (myIsPar) StdFail_InfiniteSolutions::Raise();
177   P1 = myPOnS1->Value(N);
178   P2 = myPOnS2->Value(N);
179 }
180
181