4940c49a0bf6f2c07f68d6e23ee0f8f7a45305fb
[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 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 between 0 and PI/2 radians.
80   //! Radius is the radius of the circle in the reference plane of
81   //! the cone.
82   //! Raises ConstructionError
83   //! . if Radius is lower than 0.0
84   //! . Ang < Resolution from gp  or Ang >= (PI/2) - Resolution.
85     gp_Cone(const gp_Ax3& A3, const Standard_Real Ang, const Standard_Real Radius);
86   
87   //! Changes the symmetry axis of the cone.  Raises ConstructionError
88   //! the direction of A1 is parallel to the "XDirection"
89   //! of the coordinate system of the cone.
90     void SetAxis (const gp_Ax1& A1);
91   
92   //! Changes the location of the cone.
93     void SetLocation (const gp_Pnt& Loc);
94   
95
96   //! Changes the local coordinate system of the cone.
97   //! This coordinate system defines the reference plane of the cone.
98     void SetPosition (const gp_Ax3& A3);
99   
100
101   //! Changes the radius of the cone in the reference plane of
102   //! the cone.
103   //! Raised if R < 0.0
104     void SetRadius (const Standard_Real R);
105   
106
107   //! Changes the semi-angle of the cone.
108   //! Ang is the conical surface semi-angle  ]0,PI/2[.
109   //! Raises ConstructionError if Ang < Resolution from gp or Ang >= PI/2 - Resolution
110     void SetSemiAngle (const Standard_Real Ang);
111   
112
113   //! Computes the cone's top. The Apex of the cone is on the
114   //! negative side of the symmetry axis of the cone.
115     gp_Pnt Apex() const;
116   
117   //! Reverses the   U   parametrization of   the  cone
118   //! reversing the YAxis.
119     void UReverse();
120   
121   //! Reverses the   V   parametrization of   the  cone  reversing the ZAxis.
122     void VReverse();
123   
124   //! Returns true if the local coordinate system of this cone is right-handed.
125     Standard_Boolean Direct() const;
126   
127   //! returns the symmetry axis of the cone.
128     const gp_Ax1& Axis() const;
129   
130
131   //! Computes the coefficients of the implicit equation of the quadric
132   //! in the absolute cartesian coordinates system :
133   //! A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
134   //! 2.(C1.X + C2.Y + C3.Z) + D = 0.0
135   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;
136   
137   //! returns the "Location" point of the cone.
138     const gp_Pnt& Location() const;
139   
140
141   //! Returns the local coordinates system of the cone.
142     const gp_Ax3& Position() const;
143   
144
145   //! Returns the radius of the cone in the reference plane.
146     Standard_Real RefRadius() const;
147   
148   //! Returns the half-angle at the apex of this cone.
149     Standard_Real SemiAngle() const;
150   
151   //! Returns the XAxis of the reference plane.
152     gp_Ax1 XAxis() const;
153   
154   //! Returns the YAxis of the reference plane.
155     gp_Ax1 YAxis() const;
156   
157   Standard_EXPORT void Mirror (const gp_Pnt& P);
158   
159
160   //! Performs the symmetrical transformation of a cone
161   //! with respect to the point P which is the center of the
162   //! symmetry.
163   Standard_EXPORT gp_Cone Mirrored (const gp_Pnt& P) const;
164   
165   Standard_EXPORT void Mirror (const gp_Ax1& A1);
166   
167
168   //! Performs the symmetrical transformation of a cone with
169   //! respect to an axis placement which is the axis of the
170   //! symmetry.
171   Standard_EXPORT gp_Cone Mirrored (const gp_Ax1& A1) const;
172   
173   Standard_EXPORT void Mirror (const gp_Ax2& A2);
174   
175
176   //! Performs the symmetrical transformation of a cone with respect
177   //! to a plane. The axis placement A2 locates the plane of the
178   //! of the symmetry : (Location, XDirection, YDirection).
179   Standard_EXPORT gp_Cone Mirrored (const gp_Ax2& A2) const;
180   
181     void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
182   
183
184   //! Rotates a cone. A1 is the axis of the rotation.
185   //! Ang is the angular value of the rotation in radians.
186     gp_Cone Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
187   
188     void Scale (const gp_Pnt& P, const Standard_Real S);
189   
190
191   //! Scales a cone. S is the scaling value.
192   //! The absolute value of S is used to scale the cone
193     gp_Cone Scaled (const gp_Pnt& P, const Standard_Real S) const;
194   
195     void Transform (const gp_Trsf& T);
196   
197
198   //! Transforms a cone with the transformation T from class Trsf.
199     gp_Cone Transformed (const gp_Trsf& T) const;
200   
201     void Translate (const gp_Vec& V);
202   
203
204   //! Translates a cone in the direction of the vector V.
205   //! The magnitude of the translation is the vector's magnitude.
206     gp_Cone Translated (const gp_Vec& V) const;
207   
208     void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
209   
210
211   //! Translates a cone from the point P1 to the point P2.
212     gp_Cone Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
213
214
215
216
217 protected:
218
219
220
221
222
223 private:
224
225
226
227   gp_Ax3 pos;
228   Standard_Real radius;
229   Standard_Real semiAngle;
230
231
232 };
233
234
235 #include <gp_Cone.lxx>
236
237
238
239
240
241 #endif // _gp_Cone_HeaderFile