1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _gp_Torus_HeaderFile
16 #define _gp_Torus_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <TColStd_Array1OfReal.hxx>
27 class Standard_ConstructionError;
28 class Standard_DimensionError;
38 //! Describes a torus.
39 //! A torus is defined by its major and minor radii and
40 //! positioned in space with a coordinate system (a gp_Ax3
41 //! object) as follows:
42 //! - The origin of the coordinate system is the center of the torus;
43 //! - The surface is obtained by rotating a circle of radius
44 //! equal to the minor radius of the torus about the "main
45 //! Direction" of the coordinate system. This circle is
46 //! located in the plane defined by the origin, the "X
47 //! Direction" and the "main Direction" of the coordinate
48 //! system. It is centered on the "X Axis" of this coordinate
49 //! system, and located at a distance, from the origin of
50 //! this coordinate system, equal to the major radius of the torus;
51 //! - The "X Direction" and "Y Direction" define the
52 //! reference plane of the torus.
53 //! The coordinate system described above is the "local
54 //! coordinate system" of the torus.
55 //! Note: when a gp_Torus torus is converted into a
56 //! Geom_ToroidalSurface torus, some implicit properties
57 //! of its local coordinate system are used explicitly:
58 //! - its origin, "X Direction", "Y Direction" and "main
59 //! Direction" are used directly to define the parametric
60 //! directions on the torus and the origin of the parameters,
61 //! - its implicit orientation (right-handed or left-handed)
62 //! gives the orientation (direct, indirect) to the
63 //! Geom_ToroidalSurface torus.
65 //! gce_MakeTorus which provides functions for more
66 //! complex torus constructions
67 //! Geom_ToroidalSurface which provides additional
68 //! functions for constructing tori and works, in particular,
69 //! with the parametric equations of tori.
77 //! creates an indefinite Torus.
81 //! a torus centered on the origin of coordinate system
82 //! A3, with major radius MajorRadius and minor radius
83 //! MinorRadius, and with the reference plane defined
84 //! by the origin, the "X Direction" and the "Y Direction" of A3.
86 //! It is not forbidden to create a torus with
87 //! MajorRadius = MinorRadius = 0.0
88 //! Raises ConstructionError if MinorRadius < 0.0 or if MajorRadius < 0.0
89 gp_Torus(const gp_Ax3& A3, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
91 //! Modifies this torus, by redefining its local coordinate
93 //! - its origin and "main Direction" become those of the
94 //! axis A1 (the "X Direction" and "Y Direction" are then recomputed).
95 //! Raises ConstructionError if the direction of A1 is parallel to the "XDirection"
96 //! of the coordinate system of the toroidal surface.
97 void SetAxis (const gp_Ax1& A1);
99 //! Changes the location of the torus.
100 void SetLocation (const gp_Pnt& Loc);
102 //! Assigns value to the major radius of this torus.
103 //! Raises ConstructionError if MajorRadius - MinorRadius <= Resolution()
104 void SetMajorRadius (const Standard_Real MajorRadius);
106 //! Assigns value to the minor radius of this torus.
107 //! Raises ConstructionError if MinorRadius < 0.0 or if
108 //! MajorRadius - MinorRadius <= Resolution from gp.
109 void SetMinorRadius (const Standard_Real MinorRadius);
111 //! Changes the local coordinate system of the surface.
112 void SetPosition (const gp_Ax3& A3);
114 //! Computes the area of the torus.
115 Standard_Real Area() const;
117 //! Reverses the U parametrization of the torus
118 //! reversing the YAxis.
121 //! Reverses the V parametrization of the torus
122 //! reversing the ZAxis.
125 //! returns true if the Ax3, the local coordinate system of this torus, is right handed.
126 Standard_Boolean Direct() const;
128 //! returns the symmetry axis of the torus.
129 const gp_Ax1& Axis() const;
131 //! Computes the coefficients of the implicit equation of the surface
132 //! in the absolute Cartesian coordinate system:
133 //! Coef(1) * X^4 + Coef(2) * Y^4 + Coef(3) * Z^4 +
134 //! Coef(4) * X^3 * Y + Coef(5) * X^3 * Z + Coef(6) * Y^3 * X +
135 //! Coef(7) * Y^3 * Z + Coef(8) * Z^3 * X + Coef(9) * Z^3 * Y +
136 //! Coef(10) * X^2 * Y^2 + Coef(11) * X^2 * Z^2 +
137 //! Coef(12) * Y^2 * Z^2 + Coef(13) * X^2 * Y * Z +
138 //! Coef(14) * X * Y^2 * Z + Coef(15) * X * Y * Z^2 +
139 //! Coef(16) * X^3 + Coef(17) * Y^3 + Coef(18) * Z^3 +
140 //! Coef(19) * X^2 * Y + Coef(20) * X^2 * Z + Coef(21) * Y^2 * X +
141 //! Coef(22) * Y^2 * Z + Coef(23) * Z^2 * X + Coef(24) * Z^2 * Y +
142 //! Coef(25) * X * Y * Z +
143 //! Coef(26) * X^2 + Coef(27) * Y^2 + Coef(28) * Z^2 +
144 //! Coef(29) * X * Y + Coef(30) * X * Z + Coef(31) * Y * Z +
145 //! Coef(32) * X + Coef(33) * Y + Coef(34) * Z +
147 //! Raises DimensionError if the length of Coef is lower than 35.
148 Standard_EXPORT void Coefficients (TColStd_Array1OfReal& Coef) const;
150 //! Returns the Torus's location.
151 const gp_Pnt& Location() const;
153 //! Returns the local coordinates system of the torus.
154 const gp_Ax3& Position() const;
156 //! returns the major radius of the torus.
157 Standard_Real MajorRadius() const;
159 //! returns the minor radius of the torus.
160 Standard_Real MinorRadius() const;
162 //! Computes the volume of the torus.
163 Standard_Real Volume() const;
165 //! returns the axis X of the torus.
166 gp_Ax1 XAxis() const;
168 //! returns the axis Y of the torus.
169 gp_Ax1 YAxis() const;
171 Standard_EXPORT void Mirror (const gp_Pnt& P);
174 //! Performs the symmetrical transformation of a torus
175 //! with respect to the point P which is the center of the
177 Standard_NODISCARD Standard_EXPORT gp_Torus Mirrored (const gp_Pnt& P) const;
179 Standard_EXPORT void Mirror (const gp_Ax1& A1);
182 //! Performs the symmetrical transformation of a torus with
183 //! respect to an axis placement which is the axis of the
185 Standard_NODISCARD Standard_EXPORT gp_Torus Mirrored (const gp_Ax1& A1) const;
187 Standard_EXPORT void Mirror (const gp_Ax2& A2);
190 //! Performs the symmetrical transformation of a torus with respect
191 //! to a plane. The axis placement A2 locates the plane of the
192 //! of the symmetry : (Location, XDirection, YDirection).
193 Standard_NODISCARD Standard_EXPORT gp_Torus Mirrored (const gp_Ax2& A2) const;
195 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
198 //! Rotates a torus. A1 is the axis of the rotation.
199 //! Ang is the angular value of the rotation in radians.
200 Standard_NODISCARD gp_Torus Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
202 void Scale (const gp_Pnt& P, const Standard_Real S);
205 //! Scales a torus. S is the scaling value.
206 //! The absolute value of S is used to scale the torus
207 Standard_NODISCARD gp_Torus Scaled (const gp_Pnt& P, const Standard_Real S) const;
209 void Transform (const gp_Trsf& T);
212 //! Transforms a torus with the transformation T from class Trsf.
213 Standard_NODISCARD gp_Torus Transformed (const gp_Trsf& T) const;
215 void Translate (const gp_Vec& V);
218 //! Translates a torus in the direction of the vector V.
219 //! The magnitude of the translation is the vector's magnitude.
220 Standard_NODISCARD gp_Torus Translated (const gp_Vec& V) const;
222 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
225 //! Translates a torus from the point P1 to the point P2.
226 Standard_NODISCARD gp_Torus Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
242 Standard_Real majorRadius;
243 Standard_Real minorRadius;
249 #include <gp_Torus.lxx>
255 #endif // _gp_Torus_HeaderFile