4110baed9e6f6c38610634cea74478c4ffe3c0ca
[occt.git] / src / gp / gp_Cone.hxx
1 // Copyright (c) 1991-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 #ifndef _gp_Cone_HeaderFile
16 #define _gp_Cone_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <gp_Ax3.hxx>
23 #include <Standard_Real.hxx>
24 #include <gp_Pnt.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <gp_Ax1.hxx>
27 class Standard_ConstructionError;
28 class gp_Ax3;
29 class gp_Ax1;
30 class gp_Pnt;
31 class gp_Ax2;
32 class gp_Trsf;
33 class gp_Vec;
34
35
36
37 //! Defines an infinite conical surface.
38 //! A cone is defined by its half-angle (can be negative) at the apex and
39 //! positioned in space with a coordinate system (a gp_Ax3
40 //! object) and a "reference radius" where:
41 //! -   the "main Axis" of the coordinate system is the axis of   revolution of the cone,
42 //! -   the plane defined by the origin, the "X Direction" and
43 //! the "Y Direction" of the coordinate system is the
44 //! reference plane of the cone; the intersection of the
45 //! cone with this reference plane is a circle of radius
46 //! equal to the reference radius,
47 //! if the half-angle is positive, the apex of the cone is on
48 //! the negative side of the "main Axis" of the coordinate
49 //! system. If the half-angle is negative, the apex is on the   positive side.
50 //! This coordinate system is the "local coordinate system" of the cone.
51 //! Note: when a gp_Cone cone is converted into a
52 //! Geom_ConicalSurface cone, some implicit properties of
53 //! its local coordinate system are used explicitly:
54 //! -   its origin, "X Direction", "Y Direction" and "main
55 //! Direction" are used directly to define the parametric
56 //! directions on the cone and the origin of the parameters,
57 //! -   its implicit orientation (right-handed or left-handed)
58 //! gives the orientation (direct or indirect) of the
59 //! Geom_ConicalSurface cone.
60 //! See Also
61 //! gce_MakeCone which provides functions for more
62 //! complex cone constructions
63 //! Geom_ConicalSurface which provides additional
64 //! functions for constructing cones and works, in particular,
65 //! with the parametric equations of cones gp_Ax3
66 class gp_Cone 
67 {
68 public:
69
70   DEFINE_STANDARD_ALLOC
71
72   
73   //! Creates an indefinite Cone.
74     gp_Cone();
75   
76
77   //! Creates an infinite conical surface. A3 locates the cone
78   //! in the space and defines the reference plane of the surface.
79   //! Ang is the conical surface semi-angle. Its absolute value is in range
80   //! ]0, PI/2[.
81   //! Radius is the radius of the circle in the reference plane of
82   //! the cone.
83   //! Raises ConstructionError
84   //! * if Radius is lower than 0.0
85   //! * Abs(Ang) < Resolution from gp  or Abs(Ang) >= (PI/2) - Resolution.
86     gp_Cone(const gp_Ax3& A3, const Standard_Real Ang, const Standard_Real Radius);
87   
88   //! Changes the symmetry axis of the cone.  Raises ConstructionError
89   //! the direction of A1 is parallel to the "XDirection"
90   //! of the coordinate system of the cone.
91     void SetAxis (const gp_Ax1& A1);
92   
93   //! Changes the location of the cone.
94     void SetLocation (const gp_Pnt& Loc);
95   
96
97   //! Changes the local coordinate system of the cone.
98   //! This coordinate system defines the reference plane of the cone.
99     void SetPosition (const gp_Ax3& A3);
100   
101
102   //! Changes the radius of the cone in the reference plane of
103   //! the cone.
104   //! Raised if R < 0.0
105     void SetRadius (const Standard_Real R);
106   
107
108   //! Changes the semi-angle of the cone.
109   //! Semi-angle can be negative. Its absolute value
110   //! Abs(Ang) is in range ]0,PI/2[.
111   //! Raises ConstructionError if Abs(Ang) < Resolution from gp or Abs(Ang) >= PI/2 - Resolution
112     void SetSemiAngle (const Standard_Real Ang);
113   
114
115   //! Computes the cone's top. The Apex of the cone is on the
116   //! negative side of the symmetry axis of the cone.
117     gp_Pnt Apex() const;
118   
119   //! Reverses the   U   parametrization of   the  cone
120   //! reversing the YAxis.
121     void UReverse();
122   
123   //! Reverses the   V   parametrization of   the  cone  reversing the ZAxis.
124     void VReverse();
125   
126   //! Returns true if the local coordinate system of this cone is right-handed.
127     Standard_Boolean Direct() const;
128   
129   //! returns the symmetry axis of the cone.
130     const gp_Ax1& Axis() const;
131   
132
133   //! Computes the coefficients of the implicit equation of the quadric
134   //! in the absolute cartesian coordinates system :
135   //! A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
136   //! 2.(C1.X + C2.Y + C3.Z) + D = 0.0
137   Standard_EXPORT void Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3, Standard_Real& B1, Standard_Real& B2, Standard_Real& B3, Standard_Real& C1, Standard_Real& C2, Standard_Real& C3, Standard_Real& D) const;
138   
139   //! returns the "Location" point of the cone.
140     const gp_Pnt& Location() const;
141   
142
143   //! Returns the local coordinates system of the cone.
144     const gp_Ax3& Position() const;
145   
146
147   //! Returns the radius of the cone in the reference plane.
148     Standard_Real RefRadius() const;
149   
150   //! Returns the half-angle at the apex of this cone.
151   //! Attention! Semi-angle can be negative.
152     Standard_Real SemiAngle() const;
153   
154   //! Returns the XAxis of the reference plane.
155     gp_Ax1 XAxis() const;
156   
157   //! Returns the YAxis of the reference plane.
158     gp_Ax1 YAxis() const;
159   
160   Standard_EXPORT void Mirror (const gp_Pnt& P);
161   
162
163   //! Performs the symmetrical transformation of a cone
164   //! with respect to the point P which is the center of the
165   //! symmetry.
166   Standard_NODISCARD Standard_EXPORT gp_Cone Mirrored (const gp_Pnt& P) const;
167   
168   Standard_EXPORT void Mirror (const gp_Ax1& A1);
169   
170
171   //! Performs the symmetrical transformation of a cone with
172   //! respect to an axis placement which is the axis of the
173   //! symmetry.
174   Standard_NODISCARD Standard_EXPORT gp_Cone Mirrored (const gp_Ax1& A1) const;
175   
176   Standard_EXPORT void Mirror (const gp_Ax2& A2);
177   
178
179   //! Performs the symmetrical transformation of a cone with respect
180   //! to a plane. The axis placement A2 locates the plane of the
181   //! of the symmetry : (Location, XDirection, YDirection).
182   Standard_NODISCARD Standard_EXPORT gp_Cone Mirrored (const gp_Ax2& A2) const;
183   
184     void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
185   
186
187   //! Rotates a cone. A1 is the axis of the rotation.
188   //! Ang is the angular value of the rotation in radians.
189     Standard_NODISCARD gp_Cone Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
190   
191     void Scale (const gp_Pnt& P, const Standard_Real S);
192   
193
194   //! Scales a cone. S is the scaling value.
195   //! The absolute value of S is used to scale the cone
196     Standard_NODISCARD gp_Cone Scaled (const gp_Pnt& P, const Standard_Real S) const;
197   
198     void Transform (const gp_Trsf& T);
199   
200
201   //! Transforms a cone with the transformation T from class Trsf.
202     Standard_NODISCARD gp_Cone Transformed (const gp_Trsf& T) const;
203   
204     void Translate (const gp_Vec& V);
205   
206
207   //! Translates a cone in the direction of the vector V.
208   //! The magnitude of the translation is the vector's magnitude.
209     Standard_NODISCARD gp_Cone Translated (const gp_Vec& V) const;
210   
211     void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
212   
213
214   //! Translates a cone from the point P1 to the point P2.
215     Standard_NODISCARD gp_Cone Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
216
217
218
219
220 protected:
221
222
223
224
225
226 private:
227
228
229
230   gp_Ax3 pos;
231   Standard_Real radius;
232   Standard_Real semiAngle;
233
234
235 };
236
237
238 #include <gp_Cone.lxx>
239
240
241
242
243
244 #endif // _gp_Cone_HeaderFile