b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
973c2be1 |
6 | // This library is free software; you can redistribute it and / or modify it |
7 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
15 | #include <Extrema_ExtElSS.ixx> |
16 | #include <Extrema_ExtPElS.hxx> |
17 | #include <Standard_NotImplemented.hxx> |
18 | #include <StdFail_NotDone.hxx> |
19 | #include <StdFail_InfiniteSolutions.hxx> |
20 | #include <Precision.hxx> |
21 | |
22 | |
23 | Extrema_ExtElSS::Extrema_ExtElSS() |
24 | { |
25 | myDone = Standard_False; |
26 | myIsPar = Standard_False; |
27 | } |
28 | |
29 | |
30 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Pln& S2) |
31 | { |
32 | Perform(S1, S2); |
33 | } |
34 | |
35 | |
36 | void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Pln& S2) |
37 | { |
38 | |
39 | myDone = Standard_True; |
40 | myIsPar = Standard_False; |
41 | myNbExt = 0; |
42 | |
43 | if ((S1.Axis().Direction()).IsParallel(S2.Axis().Direction(), |
44 | Precision::Angular())) { |
45 | myIsPar = Standard_True; |
46 | myNbExt = 1; |
47 | mySqDist = new TColStd_HArray1OfReal(1, 1); |
48 | mySqDist->SetValue(1, S1.SquareDistance(S2)); |
49 | } |
50 | } |
51 | |
52 | |
53 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Pln& S1, const gp_Sphere& S2) |
54 | { |
55 | Perform(S1, S2); |
56 | } |
57 | |
58 | |
59 | //void Extrema_ExtElSS::Perform(const gp_Pln& S1, const gp_Sphere& S2) |
60 | void Extrema_ExtElSS::Perform(const gp_Pln& , const gp_Sphere& ) |
61 | { |
62 | |
63 | myDone = Standard_True; |
64 | myIsPar = Standard_False; |
65 | myNbExt = 0; |
66 | Standard_NotImplemented::Raise(); |
67 | } |
68 | |
69 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Sphere& S2) |
70 | { |
71 | Perform(S1, S2); |
72 | } |
73 | |
74 | |
75 | //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Sphere& S2) |
76 | void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Sphere& ) |
77 | { |
78 | |
79 | myDone = Standard_True; |
80 | myIsPar = Standard_False; |
81 | myNbExt = 0; |
82 | Standard_NotImplemented::Raise(); |
83 | } |
84 | |
85 | |
86 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cylinder& S2) |
87 | { |
88 | Perform(S1, S2); |
89 | } |
90 | |
91 | |
92 | //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cylinder& S2) |
93 | void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cylinder& ) |
94 | { |
95 | |
96 | myDone = Standard_True; |
97 | myIsPar = Standard_False; |
98 | myNbExt = 0; |
99 | Standard_NotImplemented::Raise(); |
100 | } |
101 | |
102 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Cone& S2) |
103 | { |
104 | Perform(S1, S2); |
105 | } |
106 | |
107 | |
108 | //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Cone& S2) |
109 | void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Cone& ) |
110 | { |
111 | |
112 | myDone = Standard_True; |
113 | myIsPar = Standard_False; |
114 | myNbExt = 0; |
115 | Standard_NotImplemented::Raise(); |
116 | } |
117 | |
118 | |
119 | Extrema_ExtElSS::Extrema_ExtElSS(const gp_Sphere& S1, const gp_Torus& S2) |
120 | { |
121 | Perform(S1, S2); |
122 | } |
123 | |
124 | |
125 | //void Extrema_ExtElSS::Perform(const gp_Sphere& S1, const gp_Torus& S2) |
126 | void Extrema_ExtElSS::Perform(const gp_Sphere& , const gp_Torus& ) |
127 | { |
128 | |
129 | myDone = Standard_True; |
130 | myIsPar = Standard_False; |
131 | myNbExt = 0; |
132 | Standard_NotImplemented::Raise(); |
133 | } |
134 | |
135 | |
136 | Standard_Boolean Extrema_ExtElSS::IsDone() const |
137 | { |
138 | return myDone; |
139 | } |
140 | |
141 | |
142 | Standard_Boolean Extrema_ExtElSS::IsParallel() const |
143 | { |
144 | if(!myDone) StdFail_NotDone::Raise(); |
145 | return myIsPar; |
146 | } |
147 | |
148 | |
149 | Standard_Integer Extrema_ExtElSS::NbExt() const |
150 | { |
151 | if(!myDone) StdFail_NotDone::Raise(); |
152 | if (myIsPar) StdFail_InfiniteSolutions::Raise(); |
153 | return myNbExt; |
154 | } |
155 | |
156 | |
157 | Standard_Real Extrema_ExtElSS::SquareDistance(const Standard_Integer N) const |
158 | { |
159 | if(!myDone) StdFail_NotDone::Raise(); |
160 | if (myIsPar && N != 1) StdFail_InfiniteSolutions::Raise(); |
161 | return mySqDist->Value(N); |
162 | } |
163 | |
164 | |
165 | void Extrema_ExtElSS::Points(const Standard_Integer N, |
166 | Extrema_POnSurf& P1, |
167 | Extrema_POnSurf& P2) const |
168 | { |
169 | if(!myDone) StdFail_NotDone::Raise(); |
170 | if (myIsPar) StdFail_InfiniteSolutions::Raise(); |
171 | P1 = myPOnS1->Value(N); |
172 | P2 = myPOnS2->Value(N); |
173 | } |
174 | |
175 | |