0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / Geom / Geom_ToroidalSurface.hxx
1 // Created on: 1993-03-10
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Geom_ToroidalSurface_HeaderFile
18 #define _Geom_ToroidalSurface_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
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;
31 class gp_Ax3;
32 class gp_Torus;
33 class Geom_Curve;
34 class gp_Pnt;
35 class gp_Vec;
36 class gp_Trsf;
37 class Geom_Geometry;
38
39
40 class Geom_ToroidalSurface;
41 DEFINE_STANDARD_HANDLE(Geom_ToroidalSurface, Geom_ElementarySurface)
42
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
88 {
89
90 public:
91
92   
93
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.
100   //! Warnings :
101   //! It is not forbidden to create a toroidal surface with
102   //! MajorRadius = MinorRadius = 0.0
103   //!
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);
106   
107
108   //! Creates a ToroidalSurface from a non transient Torus from
109   //! package gp.
110   Standard_EXPORT Geom_ToroidalSurface(const gp_Torus& T);
111   
112   //! Modifies this torus by changing its major radius.
113   //! Exceptions
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);
119   
120   //! Modifies this torus by changing its minor radius.
121   //! Exceptions
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);
127   
128   //! Converts the gp_Torus torus T into this torus.
129   Standard_EXPORT void SetTorus (const gp_Torus& T);
130   
131
132   //! Returns the non transient torus with the same geometric
133   //! properties as <me>.
134   Standard_EXPORT gp_Torus Torus() const;
135   
136   //! Return the  parameter on the  Ureversed surface for
137   //! the point of parameter U on <me>.
138   //! Return 2.PI - U.
139   Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
140   
141   //! Return the  parameter on the  Ureversed surface for
142   //! the point of parameter U on <me>.
143   //! Return 2.PI - U.
144   Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
145   
146   //! Computes the aera of the surface.
147   Standard_EXPORT Standard_Real Area() const;
148   
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;
152   
153
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 +
166   //! Coef(31) = 0.0
167   //! Raised if the length of Coef is lower than 31.
168   Standard_EXPORT void Coefficients (TColStd_Array1OfReal& Coef) const;
169   
170   //! Returns the major radius, or the minor radius, of this torus.
171   Standard_EXPORT Standard_Real MajorRadius() const;
172   
173   //! Returns the major radius, or the minor radius, of this torus.
174   Standard_EXPORT Standard_Real MinorRadius() const;
175   
176   //! Computes the volume.
177   Standard_EXPORT Standard_Real Volume() const;
178   
179   //! Returns True.
180   Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
181   
182   //! Returns True.
183   Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
184   
185   //! Returns True.
186   Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
187   
188   //! Returns True.
189   Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
190   
191   //! Computes the U isoparametric curve.
192   //!
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.
196   //! Warnings :
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;
200   
201   //! Computes the V isoparametric curve.
202   //!
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.
206   //! Warnings :
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;
210   
211
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;
220   
221
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;
225   
226
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;
230   
231
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;
235   
236
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;
241   
242   //! Applies the transformation T to this torus.
243   Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
244   
245   //! Creates a new object which is a copy of this torus.
246   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
247
248
249
250
251   DEFINE_STANDARD_RTTIEXT(Geom_ToroidalSurface,Geom_ElementarySurface)
252
253 protected:
254
255
256
257
258 private:
259
260
261   Standard_Real majorRadius;
262   Standard_Real minorRadius;
263
264
265 };
266
267
268
269
270
271
272
273 #endif // _Geom_ToroidalSurface_HeaderFile