0028550: Foundation Classes - fix empty message passed to thrown exception
[occt.git] / src / gp / gp_Torus.lxx
CommitLineData
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//
d5f74e42 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
973c2be1 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
15inline gp_Torus::gp_Torus () :
16majorRadius (RealLast()),
17minorRadius (RealSmall())
18{ }
19
20inline gp_Torus::gp_Torus (const gp_Ax3& A3,
21 const Standard_Real MajorRadius,
22 const Standard_Real MinorRadius) :
23 pos(A3),
24 majorRadius (MajorRadius),
25 minorRadius (MinorRadius)
26{
2d2b3d53 27 Standard_ConstructionError_Raise_if (MinorRadius < 0.0 || MajorRadius < 0.0,
28 "gp_Torus() - invalid construction parameters");
7fd59977 29}
30
31inline void gp_Torus::SetAxis (const gp_Ax1& A1)
32{ pos.SetAxis (A1); }
33
34inline void gp_Torus::SetLocation (const gp_Pnt& Loc)
35{ pos.SetLocation (Loc); }
36
37inline void gp_Torus::SetMajorRadius (const Standard_Real MajorRadius)
38{
2d2b3d53 39 Standard_ConstructionError_Raise_if (MajorRadius - minorRadius <= gp::Resolution(),
40 "gp_Torus::SetMajorRadius() - invalid input parameters");
7fd59977 41 majorRadius = MajorRadius;
42}
43
44inline void gp_Torus::SetMinorRadius (const Standard_Real MinorRadius)
45{
2d2b3d53 46 Standard_ConstructionError_Raise_if (MinorRadius < 0.0 || majorRadius - MinorRadius <= gp::Resolution(),
47 "gp_Torus::SetMinorRadius() - invalid input parameters");
7fd59977 48 minorRadius = MinorRadius;
49}
50
51inline void gp_Torus::SetPosition (const gp_Ax3& A3)
52{ pos = A3; }
53
54inline Standard_Real gp_Torus::Area () const
c6541a0c 55{ return 4.0 * M_PI * M_PI * minorRadius * majorRadius; }
7fd59977 56
57inline void gp_Torus::UReverse()
58{ pos.YReverse(); }
59
60inline void gp_Torus::VReverse()
61{ pos.ZReverse(); }
62
63inline Standard_Boolean gp_Torus::Direct() const
64{ return pos.Direct(); }
65
66inline const gp_Ax1& gp_Torus::Axis () const
67{ return pos.Axis(); }
68
69inline const gp_Pnt& gp_Torus::Location () const
70{ return pos.Location(); }
71
72inline const gp_Ax3& gp_Torus::Position () const
73{ return pos; }
74
75inline Standard_Real gp_Torus::MajorRadius () const
76{ return majorRadius; }
77
78inline Standard_Real gp_Torus::MinorRadius () const
79{ return minorRadius; }
80
81inline Standard_Real gp_Torus::Volume () const
c6541a0c 82{ return (M_PI * minorRadius * minorRadius) * (2.0 * M_PI * majorRadius); }
7fd59977 83
84inline gp_Ax1 gp_Torus::XAxis () const
85{ return gp_Ax1(pos.Location(), pos.XDirection()); }
86
87inline gp_Ax1 gp_Torus::YAxis () const
88{ return gp_Ax1(pos.Location(), pos.YDirection()); }
89
90inline void gp_Torus::Rotate (const gp_Ax1& A1,
91 const Standard_Real Ang)
92{ pos.Rotate (A1, Ang); }
93
94inline gp_Torus gp_Torus::Rotated (const gp_Ax1& A1,
95 const Standard_Real Ang) const
96{
97 gp_Torus C = *this;
98 C.pos.Rotate (A1, Ang);
99 return C;
100}
101
102inline void gp_Torus::Scale (const gp_Pnt& P,
103 const Standard_Real S)
104{
105 pos.Scale (P, S);
106 Standard_Real s = S;
107 if (s < 0) s = - s;
108 majorRadius *= s;
109 minorRadius *= s;
110}
111
112inline gp_Torus gp_Torus::Scaled (const gp_Pnt& P,
113 const Standard_Real S) const
114{
115 gp_Torus C = *this;
116 C.pos.Scale (P, S);
117 C.majorRadius *= S;
118 if (C.majorRadius < 0) C.majorRadius = - C.majorRadius;
119 C.minorRadius *= S;
120 if (C.minorRadius < 0) C.minorRadius = - C.minorRadius;
121 return C;
122}
123
124inline void gp_Torus::Transform (const gp_Trsf& T)
125{
126 pos.Transform (T);
127 Standard_Real t = T.ScaleFactor();
128 if(t < 0 ) t = - t;
129 minorRadius *= t;
130 majorRadius *= t;
131}
132
133inline gp_Torus gp_Torus::Transformed (const gp_Trsf& T) const
134{
135 gp_Torus C = *this;
136 C.pos.Transform (T);
137 C.majorRadius *= T.ScaleFactor();
138 if (C.majorRadius < 0) C.majorRadius = - C.majorRadius;
139 C.minorRadius *= T.ScaleFactor();
140 if (C.minorRadius < 0) C.minorRadius = - C.minorRadius;
141 return C;
142}
143
144inline void gp_Torus::Translate (const gp_Vec& V)
145{ pos.Translate (V); }
146
147inline gp_Torus gp_Torus::Translated (const gp_Vec& V) const
148{
149 gp_Torus C = *this;
150 C.pos.Translate (V);
151 return C;
152}
153
154inline void gp_Torus::Translate (const gp_Pnt& P1,
155 const gp_Pnt& P2)
156{ pos.Translate (P1, P2); }
157
158inline gp_Torus gp_Torus::Translated (const gp_Pnt& P1,
159 const gp_Pnt& P2) const
160{
161 gp_Torus C = *this;
162 C.pos.Translate (P1, P2);
163 return C;
164}
165