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_Torus_HeaderFile 16 #define _gp_Torus_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 <Standard_Boolean.hxx> 25 #include <TColStd_Array1OfReal.hxx> 26 #include <gp_Ax1.hxx> 27 class Standard_ConstructionError; 28 class Standard_DimensionError; 29 class gp_Ax3; 30 class gp_Ax1; 31 class gp_Pnt; 32 class gp_Ax2; 33 class gp_Trsf; 34 class gp_Vec; 35 36 37 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. 64 //! See Also 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. 70 class gp_Torus 71 { 72 public: 73 74 DEFINE_STANDARD_ALLOC 75 76 77 //! creates an indefinite Torus. 78 gp_Torus(); 79 80 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. 85 //! Warnings : 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); 90 91 //! Modifies this torus, by redefining its local coordinate 92 //! system so that: 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); 98 99 //! Changes the location of the torus. 100 void SetLocation (const gp_Pnt& Loc); 101 102 //! Assigns value to the major radius of this torus. 103 //! Raises ConstructionError if MajorRadius - MinorRadius <= Resolution() 104 void SetMajorRadius (const Standard_Real MajorRadius); 105 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); 110 111 //! Changes the local coordinate system of the surface. 112 void SetPosition (const gp_Ax3& A3); 113 114 //! Computes the area of the torus. 115 Standard_Real Area() const; 116 117 //! Reverses the U parametrization of the torus 118 //! reversing the YAxis. 119 void UReverse(); 120 121 //! Reverses the V parametrization of the torus 122 //! reversing the ZAxis. 123 void VReverse(); 124 125 //! returns true if the Ax3, the local coordinate system of this torus, is right handed. 126 Standard_Boolean Direct() const; 127 128 //! returns the symmetry axis of the torus. 129 const gp_Ax1& Axis() const; 130 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 + 146 //! Coef(35) = 0.0 147 //! Raises DimensionError if the length of Coef is lower than 35. 148 Standard_EXPORT void Coefficients (TColStd_Array1OfReal& Coef) const; 149 150 //! Returns the Torus's location. 151 const gp_Pnt& Location() const; 152 153 //! Returns the local coordinates system of the torus. 154 const gp_Ax3& Position() const; 155 156 //! returns the major radius of the torus. 157 Standard_Real MajorRadius() const; 158 159 //! returns the minor radius of the torus. 160 Standard_Real MinorRadius() const; 161 162 //! Computes the volume of the torus. 163 Standard_Real Volume() const; 164 165 //! returns the axis X of the torus. 166 gp_Ax1 XAxis() const; 167 168 //! returns the axis Y of the torus. 169 gp_Ax1 YAxis() const; 170 171 Standard_EXPORT void Mirror (const gp_Pnt& P); 172 173 174 //! Performs the symmetrical transformation of a torus 175 //! with respect to the point P which is the center of the 176 //! symmetry. 177 Standard_EXPORT Standard_NODISCARD gp_Torus Mirrored (const gp_Pnt& P) const; 178 179 Standard_EXPORT void Mirror (const gp_Ax1& A1); 180 181 182 //! Performs the symmetrical transformation of a torus with 183 //! respect to an axis placement which is the axis of the 184 //! symmetry. 185 Standard_EXPORT Standard_NODISCARD gp_Torus Mirrored (const gp_Ax1& A1) const; 186 187 Standard_EXPORT void Mirror (const gp_Ax2& A2); 188 189 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_EXPORT Standard_NODISCARD gp_Torus Mirrored (const gp_Ax2& A2) const; 194 195 void Rotate (const gp_Ax1& A1, const Standard_Real Ang); 196 197 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; 201 202 void Scale (const gp_Pnt& P, const Standard_Real S); 203 204 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; 208 209 void Transform (const gp_Trsf& T); 210 211 212 //! Transforms a torus with the transformation T from class Trsf. 213 Standard_NODISCARD gp_Torus Transformed (const gp_Trsf& T) const; 214 215 void Translate (const gp_Vec& V); 216 217 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; 221 222 void Translate (const gp_Pnt& P1, const gp_Pnt& P2); 223 224 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; 227 228 229 230 231 protected: 232 233 234 235 236 237 private: 238 239 240 241 gp_Ax3 pos; 242 Standard_Real majorRadius; 243 Standard_Real minorRadius; 244 245 246 }; 247 248 249 #include <gp_Torus.lxx> 250 251 252 253 254 255 #endif // _gp_Torus_HeaderFile 256