0032137: Coding Rules - merge redundant .lxx files into header files within Package gp
[occt.git] / src / gp / gp_Sphere.lxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 inline gp_Sphere::gp_Sphere () : radius (RealLast())
16 { }
17
18 inline gp_Sphere::gp_Sphere (const gp_Ax3& A3,
19                              const Standard_Real Radius) :
20                              pos (A3),
21                              radius (Radius)
22 {
23   Standard_ConstructionError_Raise_if (Radius < 0.0, "gp_Sphere() - radius should be >= 0");
24 }
25
26 inline void gp_Sphere::SetLocation (const gp_Pnt& Loc)
27 { pos.SetLocation (Loc); }
28
29 inline void gp_Sphere::SetPosition (const gp_Ax3& A3)
30 { pos = A3; }
31
32 inline void gp_Sphere::SetRadius (const Standard_Real R)
33 {
34   Standard_ConstructionError_Raise_if (R < 0.0, "gp_Sphere::SetRadius() - radius should be >= 0");
35   radius = R;
36 }
37
38 inline Standard_Real gp_Sphere::Area () const
39 { return 4.0 * M_PI * radius * radius; }
40
41 inline void gp_Sphere::UReverse()
42 { pos.YReverse(); }
43
44 inline void gp_Sphere::VReverse()
45 { pos.ZReverse(); }
46
47 inline Standard_Boolean gp_Sphere::Direct() const
48 { return pos.Direct(); }
49
50 inline const gp_Pnt& gp_Sphere::Location () const
51 { return pos.Location(); }
52
53 inline const gp_Ax3& gp_Sphere::Position () const
54 { return pos; }
55
56 inline Standard_Real gp_Sphere::Radius () const
57 { return radius; }
58
59 inline Standard_Real gp_Sphere::Volume () const
60 { return (4.0 * M_PI * radius * radius * radius) / 3.0; }
61
62 inline gp_Ax1 gp_Sphere::XAxis () const
63 { return gp_Ax1(pos.Location(), pos.XDirection()); }
64
65 inline gp_Ax1 gp_Sphere::YAxis () const
66 { return gp_Ax1(pos.Location(), pos.YDirection()); }
67
68 inline void gp_Sphere::Rotate (const gp_Ax1& A1,
69                                const Standard_Real Ang)
70 { pos.Rotate (A1, Ang); }
71
72 inline gp_Sphere gp_Sphere::Rotated (const gp_Ax1& A1,
73                                      const Standard_Real Ang) const
74 {
75   gp_Sphere C = *this;
76   C.pos.Rotate (A1, Ang);
77   return C;
78 }
79
80 inline void gp_Sphere::Scale (const gp_Pnt& P,
81                               const Standard_Real S)
82 {
83   pos.Scale (P, S);      
84   radius *= S;
85   if (radius < 0) radius = - radius;
86 }
87
88 inline gp_Sphere gp_Sphere::Scaled (const gp_Pnt& P,
89                                     const Standard_Real S) const
90 {
91   gp_Sphere C = *this;
92   C.pos.Scale (P, S);
93   C.radius *= S;
94   if (C.radius < 0) C.radius = - C.radius;
95   return C;
96 }
97
98 inline void gp_Sphere::Transform (const gp_Trsf& T)
99 {
100   pos.Transform (T);
101   radius *= T.ScaleFactor();
102   if (radius < 0) radius = - radius;
103 }
104
105 inline gp_Sphere gp_Sphere::Transformed (const gp_Trsf& T) const
106 {
107   gp_Sphere C = *this;
108   C.pos.Transform (T);
109   C.radius *= T.ScaleFactor();
110   if (C.radius < 0) C.radius = - C.radius;
111   return C;
112 }
113
114 inline void gp_Sphere::Translate (const gp_Vec& V)
115 { pos.Translate (V); }
116
117 inline gp_Sphere gp_Sphere::Translated (const gp_Vec& V) const
118 {
119   gp_Sphere C = *this;
120   C.pos.Translate (V);
121   return C;
122 }
123
124 inline void gp_Sphere::Translate (const gp_Pnt& P1,
125                                   const gp_Pnt& P2)
126 { pos.Translate (P1, P2); }
127
128 inline gp_Sphere gp_Sphere::Translated (const gp_Pnt& P1,
129                                         const gp_Pnt& P2) const
130 {
131   gp_Sphere C = *this;
132   C.pos.Translate (P1, P2);
133   return C;
134 }
135