1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Geom_SphericalSurface.ixx>
19 #include <gp_Circ.hxx>
22 #include <Geom_Circle.hxx>
23 #include <Geom_TrimmedCurve.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_RangeError.hxx>
27 typedef Geom_Circle Circle;
28 typedef Geom_SphericalSurface SphericalSurface;
38 //=======================================================================
41 //=======================================================================
43 Handle(Geom_Geometry) Geom_SphericalSurface::Copy () const {
45 Handle(Geom_SphericalSurface) Cs;
46 Cs = new SphericalSurface (pos, radius);
52 //=======================================================================
53 //function : Geom_SphericalSurface
55 //=======================================================================
57 Geom_SphericalSurface::Geom_SphericalSurface (const Ax3& A, const Standard_Real R)
60 if (R < 0.0) Standard_ConstructionError::Raise();
65 //=======================================================================
66 //function : Geom_SphericalSurface
68 //=======================================================================
70 Geom_SphericalSurface::Geom_SphericalSurface (const gp_Sphere& S)
71 :radius (S.Radius()) {
78 //=======================================================================
79 //function : UReversedParameter
81 //=======================================================================
83 Standard_Real Geom_SphericalSurface::UReversedParameter( const Standard_Real U) const
88 //=======================================================================
89 //function : VReversedParameter
91 //=======================================================================
93 Standard_Real Geom_SphericalSurface::VReversedParameter( const Standard_Real V) const
99 //=======================================================================
102 //=======================================================================
104 Standard_Real Geom_SphericalSurface::Area () const
105 {return 4.0 * M_PI * radius * radius;}
107 //=======================================================================
110 //=======================================================================
112 Standard_Real Geom_SphericalSurface::Radius () const
115 //=======================================================================
116 //function : IsUClosed
118 //=======================================================================
120 Standard_Boolean Geom_SphericalSurface::IsUClosed () const
121 { return Standard_True; }
123 //=======================================================================
124 //function : IsVClosed
126 //=======================================================================
128 Standard_Boolean Geom_SphericalSurface::IsVClosed () const
129 { return Standard_False; }
131 //=======================================================================
132 //function : IsUPeriodic
134 //=======================================================================
136 Standard_Boolean Geom_SphericalSurface::IsUPeriodic () const
137 { return Standard_True; }
139 //=======================================================================
140 //function : IsVPeriodic
142 //=======================================================================
144 Standard_Boolean Geom_SphericalSurface::IsVPeriodic () const
145 { return Standard_False; }
147 //=======================================================================
148 //function : SetRadius
150 //=======================================================================
152 void Geom_SphericalSurface::SetRadius (const Standard_Real R) {
154 if (R < 0.0) { Standard_ConstructionError::Raise(); }
159 //=======================================================================
160 //function : SetSphere
162 //=======================================================================
164 void Geom_SphericalSurface::SetSphere (const gp_Sphere& S) {
171 //=======================================================================
174 //=======================================================================
176 void Geom_SphericalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
177 Standard_Real& V1, Standard_Real& V2) const {
186 //=======================================================================
187 //function : Coefficients
189 //=======================================================================
191 void Geom_SphericalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
192 Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
193 Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
194 Standard_Real& D ) const {
196 // Dans le repere local de la sphere :
197 // X*X + Y*Y + Z*Z - radius * radius = 0
200 T.SetTransformation (pos);
201 Standard_Real T11 = T.Value (1, 1);
202 Standard_Real T12 = T.Value (1, 2);
203 Standard_Real T13 = T.Value (1, 3);
204 Standard_Real T14 = T.Value (1, 4);
205 Standard_Real T21 = T.Value (2, 1);
206 Standard_Real T22 = T.Value (2, 2);
207 Standard_Real T23 = T.Value (2, 3);
208 Standard_Real T24 = T.Value (2, 4);
209 Standard_Real T31 = T.Value (3, 1);
210 Standard_Real T32 = T.Value (3, 2);
211 Standard_Real T33 = T.Value (3, 3);
212 Standard_Real T34 = T.Value (3, 4);
213 A1 = T11 * T11 + T21 * T21 + T31 * T31;
214 A2 = T12 * T12 + T22 * T22 + T32 * T32;
215 A3 = T13 * T13 + T23 * T23 + T33 * T33;
216 B1 = T11 * T12 + T21 * T22 + T31 * T32;
217 B2 = T11 * T13 + T21 * T23 + T31 * T33;
218 B3 = T12 * T13 + T22 * T23 + T32 * T33;
219 C1 = T11 * T14 + T21 * T24 + T31 * T34;
220 C2 = T12 * T14 + T22 * T24 + T32 * T34;
221 C3 = T13 * T14 + T23 * T24 + T33 * T34;
222 D = T14 * T14 + T24 * T24 + T34 * T34 - radius * radius;
226 //=======================================================================
229 //=======================================================================
231 void Geom_SphericalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const
233 ElSLib::SphereD0(U,V,pos,radius,P);
237 //=======================================================================
240 //=======================================================================
242 void Geom_SphericalSurface::D1 (const Standard_Real U, const Standard_Real V ,
243 Pnt& P, Vec& D1U, Vec& D1V
246 ElSLib::SphereD1 (U, V, pos, radius, P ,D1U, D1V);
250 //=======================================================================
253 //=======================================================================
255 void Geom_SphericalSurface::D2 (const Standard_Real U, const Standard_Real V,
258 Vec& D2U, Vec& D2V, Vec& D2UV ) const
260 ElSLib::SphereD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
264 //=======================================================================
267 //=======================================================================
269 void Geom_SphericalSurface::D3 (const Standard_Real U, const Standard_Real V,
272 Vec& D2U, Vec& D2V, Vec& D2UV,
273 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV
276 ElSLib::SphereD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
277 D2UV, D3U, D3V, D3UUV, D3UVV);
281 //=======================================================================
284 //=======================================================================
286 Vec Geom_SphericalSurface::DN (const Standard_Real U, const Standard_Real V,
287 const Standard_Integer Nu, const Standard_Integer Nv) const {
289 Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
290 return ElSLib::SphereDN (U, V, pos, radius, Nu, Nv);
294 //=======================================================================
297 //=======================================================================
299 gp_Sphere Geom_SphericalSurface::Sphere () const {
301 return gp_Sphere (pos, radius);
305 //=======================================================================
308 //=======================================================================
310 Handle(Geom_Curve) Geom_SphericalSurface::UIso (const Standard_Real U) const
312 Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::SphereUIso(pos,radius,U));
313 Handle(Geom_TrimmedCurve) iso = new Geom_TrimmedCurve(GC,-M_PI/2.,M_PI/2);
318 //=======================================================================
321 //=======================================================================
323 Handle(Geom_Curve) Geom_SphericalSurface::VIso (const Standard_Real V) const
326 GC = new Geom_Circle(ElSLib::SphereVIso(pos,radius,V));
331 //=======================================================================
334 //=======================================================================
336 Standard_Real Geom_SphericalSurface::Volume () const {
338 return (4.0 * M_PI * radius * radius * radius)/3.0;
343 //=======================================================================
344 //function : Transform
346 //=======================================================================
348 void Geom_SphericalSurface::Transform (const Trsf& T) {
350 radius = radius * Abs(T.ScaleFactor());