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 #ifndef _Geom_ToroidalSurface_HeaderFile
18 #define _Geom_ToroidalSurface_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Real.hxx>
24 #include <Geom_ElementarySurface.hxx>
25 #include <TColStd_Array1OfReal.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 class Standard_ConstructionError;
29 class Standard_DimensionError;
30 class Standard_RangeError;
40 class Geom_ToroidalSurface;
41 DEFINE_STANDARD_HANDLE(Geom_ToroidalSurface, Geom_ElementarySurface)
43 //! Describes a torus.
44 //! A torus is defined by its major and minor radii, and
45 //! positioned in space with a coordinate system (a
46 //! gp_Ax3 object) as follows:
47 //! - The origin is the center of the torus.
48 //! - The surface is obtained by rotating a circle around
49 //! the "main Direction". This circle has a radius equal
50 //! to the minor radius, and is located in the plane
51 //! defined by the origin, "X Direction" and "main
52 //! Direction". It is centered on the "X Axis", on its
53 //! positive side, and positioned at a distance from the
54 //! origin equal to the major radius. This circle is the
55 //! "reference circle" of the torus.
56 //! - The plane defined by the origin, the "X Direction"
57 //! and the "Y Direction" is called the "reference plane" of the torus.
58 //! This coordinate system is the "local coordinate
59 //! system" of the torus. The following apply:
60 //! - Rotation around its "main Axis", in the trigonometric
61 //! sense given by "X Direction" and "Y Direction",
62 //! defines the u parametric direction.
63 //! - The "X Axis" gives the origin for the u parameter.
64 //! - Rotation around an axis parallel to the "Y Axis" and
65 //! passing through the center of the "reference circle"
66 //! gives the v parameter on the "reference circle".
67 //! - The "X Axis" gives the origin of the v parameter on
68 //! the "reference circle".
69 //! - The v parametric direction is oriented by the
70 //! inverse of the "main Direction", i.e. near 0, as v
71 //! increases, the Z coordinate decreases. (This
72 //! implies that the "Y Direction" orients the reference
73 //! circle only when the local coordinate system is direct.)
74 //! - The u isoparametric curve is a circle obtained by
75 //! rotating the "reference circle" of the torus through
76 //! an angle u about the "main Axis".
77 //! The parametric equation of the torus is :
78 //! P(u, v) = O + (R + r*cos(v)) * (cos(u)*XDir +
79 //! sin(u)*YDir ) + r*sin(v)*ZDir, where:
80 //! - O, XDir, YDir and ZDir are respectively the
81 //! origin, the "X Direction", the "Y Direction" and the "Z
82 //! Direction" of the local coordinate system,
83 //! - r and R are, respectively, the minor and major radius.
84 //! The parametric range of the two parameters is:
85 //! - [ 0, 2.*Pi ] for u
86 //! - [ 0, 2.*Pi ] for v
87 class Geom_ToroidalSurface : public Geom_ElementarySurface
94 //! A3 is the local coordinate system of the surface.
95 //! The orientation of increasing V parametric value is defined
96 //! by the rotation around the main axis (ZAxis) in the
97 //! trigonometric sense. The parametrization of the surface in the
98 //! U direction is defined such as the normal Vector (N = D1U ^ D1V)
99 //! is oriented towards the "outside region" of the surface.
101 //! It is not forbidden to create a toroidal surface with
102 //! MajorRadius = MinorRadius = 0.0
104 //! Raised if MinorRadius < 0.0 or if MajorRadius < 0.0
105 Standard_EXPORT Geom_ToroidalSurface(const gp_Ax3& A3, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
108 //! Creates a ToroidalSurface from a non transient Torus from
110 Standard_EXPORT Geom_ToroidalSurface(const gp_Torus& T);
112 //! Modifies this torus by changing its major radius.
114 //! Standard_ConstructionError if:
115 //! - MajorRadius is negative, or
116 //! - MajorRadius - r is less than or equal to
117 //! gp::Resolution(), where r is the minor radius of this torus.
118 Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
120 //! Modifies this torus by changing its minor radius.
122 //! Standard_ConstructionError if:
123 //! - MinorRadius is negative, or
124 //! - R - MinorRadius is less than or equal to
125 //! gp::Resolution(), where R is the major radius of this torus.
126 Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
128 //! Converts the gp_Torus torus T into this torus.
129 Standard_EXPORT void SetTorus (const gp_Torus& T);
132 //! Returns the non transient torus with the same geometric
133 //! properties as <me>.
134 Standard_EXPORT gp_Torus Torus() const;
136 //! Return the parameter on the Ureversed surface for
137 //! the point of parameter U on <me>.
139 Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
141 //! Return the parameter on the Ureversed surface for
142 //! the point of parameter U on <me>.
144 Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
146 //! Computes the aera of the surface.
147 Standard_EXPORT Standard_Real Area() const;
149 //! Returns the parametric bounds U1, U2, V1 and V2 of this torus.
150 //! For a torus: U1 = V1 = 0 and U2 = V2 = 2*PI .
151 Standard_EXPORT void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const Standard_OVERRIDE;
154 //! Returns the coefficients of the implicit equation of the surface
155 //! in the absolute cartesian coordinate system :
156 //! Coef(1) * X**4 + Coef(2) * Y**4 + Coef(3) * Z**4 +
157 //! Coef(4) * X**3 * Y + Coef(5) * X**3 * Z + Coef(6) * Y**3 * X +
158 //! Coef(7) * Y**3 * Z + Coef(8) * Z**3 * X + Coef(9) * Z**3 * Y +
159 //! Coef(10) * X**2 * Y**2 + Coef(11) * X**2 * Z**2 +
160 //! Coef(12) * Y**2 * Z**2 + Coef(13) * X**3 + Coef(14) * Y**3 +
161 //! Coef(15) * Z**3 + Coef(16) * X**2 * Y + Coef(17) * X**2 * Z +
162 //! Coef(18) * Y**2 * X + Coef(19) * Y**2 * Z + Coef(20) * Z**2 * X +
163 //! Coef(21) * Z**2 * Y + Coef(22) * X**2 + Coef(23) * Y**2 +
164 //! Coef(24) * Z**2 + Coef(25) * X * Y + Coef(26) * X * Z +
165 //! Coef(27) * Y * Z + Coef(28) * X + Coef(29) * Y + Coef(30) * Z +
167 //! Raised if the length of Coef is lower than 31.
168 Standard_EXPORT void Coefficients (TColStd_Array1OfReal& Coef) const;
170 //! Returns the major radius, or the minor radius, of this torus.
171 Standard_EXPORT Standard_Real MajorRadius() const;
173 //! Returns the major radius, or the minor radius, of this torus.
174 Standard_EXPORT Standard_Real MinorRadius() const;
176 //! Computes the volume.
177 Standard_EXPORT Standard_Real Volume() const;
180 Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
183 Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
186 Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
189 Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
191 //! Computes the U isoparametric curve.
193 //! For a toroidal surface the UIso curve is a circle.
194 //! The center of the Uiso circle is at the distance MajorRadius
195 //! from the location point of the toroidal surface.
197 //! The radius of the circle can be zero if for the surface
198 //! MinorRadius = 0.0
199 Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const Standard_OVERRIDE;
201 //! Computes the V isoparametric curve.
203 //! For a ToroidalSurface the VIso curve is a circle.
204 //! The axis of the circle is the main axis (ZAxis) of the
205 //! toroidal surface.
207 //! The radius of the circle can be zero if for the surface
208 //! MajorRadius = MinorRadius
209 Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V) const Standard_OVERRIDE;
212 //! Computes the point P (U, V) on the surface.
213 //! P (U, V) = Loc + MinorRadius * Sin (V) * Zdir +
214 //! (MajorRadius + MinorRadius * Cos(V)) *
215 //! (cos (U) * XDir + sin (U) * YDir)
216 //! where Loc is the origin of the placement plane (XAxis, YAxis)
217 //! XDir is the direction of the XAxis and YDir the direction of
218 //! the YAxis and ZDir the direction of the ZAxis.
219 Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE;
222 //! Computes the current point and the first derivatives in
223 //! the directions U and V.
224 Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE;
227 //! Computes the current point, the first and the second derivatives
228 //! in the directions U and V.
229 Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE;
232 //! Computes the current point, the first,the second and the
233 //! third derivatives in the directions U and V.
234 Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE;
237 //! Computes the derivative of order Nu in the direction u and
238 //! Nv in the direction v.
239 //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
240 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE;
242 //! Applies the transformation T to this torus.
243 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
245 //! Creates a new object which is a copy of this torus.
246 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
251 DEFINE_STANDARD_RTTIEXT(Geom_ToroidalSurface,Geom_ElementarySurface)
261 Standard_Real majorRadius;
262 Standard_Real minorRadius;
273 #endif // _Geom_ToroidalSurface_HeaderFile