Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:20:06

0001 // Created on: 2020-09-17
0002 // Created by: Marina ZERNOVA
0003 // Copyright (c) 2020 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Prs3d_ToolTorus_HeaderFile
0017 #define _Prs3d_ToolTorus_HeaderFile
0018 
0019 #include <Prs3d_ToolQuadric.hxx>
0020 
0021 //! Standard presentation algorithm that outputs graphical primitives for torus surface.
0022 class Prs3d_ToolTorus : public Prs3d_ToolQuadric
0023 {
0024 public:
0025   //! Generate primitives for 3D quadric surface (complete torus).
0026   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0027   //! @param[in] theMinorRad  radius of the pipe
0028   //! @param[in] theNbSlices  number of slices within U parameter
0029   //! @param[in] theNbStacks  number of stacks within V parameter
0030   //! @param[in] theTrsf      optional transformation to apply
0031   //! @return generated triangulation
0032   static occ::handle<Graphic3d_ArrayOfTriangles> Create(const double   theMajorRad,
0033                                                         const double   theMinorRad,
0034                                                         const int      theNbSlices,
0035                                                         const int      theNbStacks,
0036                                                         const gp_Trsf& theTrsf)
0037   {
0038     return Create(theMajorRad,
0039                   theMinorRad,
0040                   0.0,
0041                   M_PI * 2.0,
0042                   M_PI * 2.0,
0043                   theNbSlices,
0044                   theNbStacks,
0045                   theTrsf);
0046   }
0047 
0048   //! Generate primitives for 3D quadric surface (torus segment).
0049   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0050   //! @param[in] theMinorRad  radius of the pipe
0051   //! @param[in] theAngle     angle to create a torus pipe segment
0052   //! @param[in] theNbSlices  number of slices within U parameter
0053   //! @param[in] theNbStacks  number of stacks within V parameter
0054   //! @param[in] theTrsf      optional transformation to apply
0055   //! @return generated triangulation
0056   static occ::handle<Graphic3d_ArrayOfTriangles> Create(const double   theMajorRad,
0057                                                         const double   theMinorRad,
0058                                                         const double   theAngle,
0059                                                         const int      theNbSlices,
0060                                                         const int      theNbStacks,
0061                                                         const gp_Trsf& theTrsf)
0062   {
0063     return Create(theMajorRad,
0064                   theMinorRad,
0065                   0.0,
0066                   M_PI * 2.0,
0067                   theAngle,
0068                   theNbSlices,
0069                   theNbStacks,
0070                   theTrsf);
0071   }
0072 
0073   //! Generate primitives for 3D quadric surface (torus ring segment).
0074   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0075   //! @param[in] theMinorRad  radius of the pipe
0076   //! @param[in] theAngle1    first  angle to create a torus ring segment
0077   //! @param[in] theAngle2    second angle to create a torus ring segment
0078   //! @param[in] theNbSlices  number of slices within U parameter
0079   //! @param[in] theNbStacks  number of stacks within V parameter
0080   //! @param[in] theTrsf      optional transformation to apply
0081   //! @return generated triangulation
0082   static occ::handle<Graphic3d_ArrayOfTriangles> Create(const double   theMajorRad,
0083                                                         const double   theMinorRad,
0084                                                         const double   theAngle1,
0085                                                         const double   theAngle2,
0086                                                         const int      theNbSlices,
0087                                                         const int      theNbStacks,
0088                                                         const gp_Trsf& theTrsf)
0089   {
0090     return Create(theMajorRad,
0091                   theMinorRad,
0092                   theAngle1,
0093                   theAngle2,
0094                   M_PI * 2.0,
0095                   theNbSlices,
0096                   theNbStacks,
0097                   theTrsf);
0098   }
0099 
0100   //! Generate primitives for 3D quadric surface (segment of the torus ring segment).
0101   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0102   //! @param[in] theMinorRad  radius of the pipe
0103   //! @param[in] theAngle1    first  angle to create a torus ring segment
0104   //! @param[in] theAngle2    second angle to create a torus ring segment
0105   //! @param[in] theAngle     angle to create a torus pipe segment
0106   //! @param[in] theNbSlices  number of slices within U parameter
0107   //! @param[in] theNbStacks  number of stacks within V parameter
0108   //! @param[in] theTrsf      optional transformation to apply
0109   //! @return generated triangulation
0110   Standard_EXPORT static occ::handle<Graphic3d_ArrayOfTriangles> Create(const double   theMajorRad,
0111                                                                         const double   theMinorRad,
0112                                                                         const double   theAngle1,
0113                                                                         const double   theAngle2,
0114                                                                         const double   theAngle,
0115                                                                         const int      theNbSlices,
0116                                                                         const int      theNbStacks,
0117                                                                         const gp_Trsf& theTrsf);
0118 
0119 public:
0120   //! Initializes the algorithm creating a complete torus.
0121   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0122   //! @param[in] theMinorRad  radius of the pipe
0123   //! @param[in] theNbSlices  number of slices within U parameter
0124   //! @param[in] theNbStacks  number of stacks within V parameter
0125   Prs3d_ToolTorus(const double theMajorRad,
0126                   const double theMinorRad,
0127                   const int    theNbSlices,
0128                   const int    theNbStacks)
0129   {
0130     init(theMajorRad, theMinorRad, 0.0, M_PI * 2.0, M_PI * 2.0, theNbSlices, theNbStacks);
0131   }
0132 
0133   //! Initializes the algorithm creating a torus pipe segment.
0134   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0135   //! @param[in] theMinorRad  radius of the pipe
0136   //! @param[in] theAngle     angle to create a torus pipe segment
0137   //! @param[in] theNbSlices  number of slices within U parameter
0138   //! @param[in] theNbStacks  number of stacks within V parameter
0139   Prs3d_ToolTorus(const double theMajorRad,
0140                   const double theMinorRad,
0141                   const double theAngle,
0142                   const int    theNbSlices,
0143                   const int    theNbStacks)
0144   {
0145     init(theMajorRad, theMinorRad, 0.0, M_PI * 2.0, theAngle, theNbSlices, theNbStacks);
0146   }
0147 
0148   //! Initializes the algorithm creating a torus ring segment.
0149   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0150   //! @param[in] theMinorRad  radius of the pipe
0151   //! @param[in] theAngle1    first  angle to create a torus ring segment
0152   //! @param[in] theAngle2    second angle to create a torus ring segment
0153   //! @param[in] theNbSlices  number of slices within U parameter
0154   //! @param[in] theNbStacks  number of stacks within V parameter
0155   Prs3d_ToolTorus(const double theMajorRad,
0156                   const double theMinorRad,
0157                   const double theAngle1,
0158                   const double theAngle2,
0159                   const int    theNbSlices,
0160                   const int    theNbStacks)
0161   {
0162     init(theMajorRad, theMinorRad, theAngle1, theAngle2, M_PI * 2.0, theNbSlices, theNbStacks);
0163   }
0164 
0165   //! Initializes the algorithm creating a torus ring segment.
0166   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0167   //! @param[in] theMinorRad  radius of the pipe
0168   //! @param[in] theAngle1    first  angle to create a torus ring segment
0169   //! @param[in] theAngle2    second angle to create a torus ring segment
0170   //! @param[in] theAngle     angle to create a torus pipe segment
0171   //! @param[in] theNbSlices  number of slices within U parameter
0172   //! @param[in] theNbStacks  number of stacks within V parameter
0173   Prs3d_ToolTorus(const double theMajorRad,
0174                   const double theMinorRad,
0175                   const double theAngle1,
0176                   const double theAngle2,
0177                   const double theAngle,
0178                   const int    theNbSlices,
0179                   const int    theNbStacks)
0180   {
0181     init(theMajorRad, theMinorRad, theAngle1, theAngle2, theAngle, theNbSlices, theNbStacks);
0182   }
0183 
0184 private:
0185   //! Initialisation
0186   //! @param[in] theMajorRad  distance from the center of the pipe to the center of the torus
0187   //! @param[in] theMinorRad  radius of the pipe
0188   //! @param[in] theAngle1    first  angle to create a torus ring segment
0189   //! @param[in] theAngle2    second angle to create a torus ring segment
0190   //! @param[in] theAngle     angle to create a torus pipe segment
0191   //! @param[in] theNbSlices  number of slices within U parameter
0192   //! @param[in] theNbStacks  number of stacks within V parameter
0193   Standard_EXPORT void init(const double theMajorRad,
0194                             const double theMinorRad,
0195                             const double theAngle1,
0196                             const double theAngle2,
0197                             const double theAngle,
0198                             const int    theNbSlices,
0199                             const int    theNbStacks);
0200 
0201 protected:
0202   //! Computes vertex at given parameter location of the surface.
0203   Standard_EXPORT gp_Pnt Vertex(const double theU, const double theV) const override;
0204 
0205   //! Computes normal at given parameter location of the surface.
0206   Standard_EXPORT gp_Dir Normal(const double theU, const double theV) const override;
0207 
0208 protected:
0209   // clang-format off
0210   double myMajorRadius; //!< distance from the center of the pipe to the center of the torus
0211   // clang-format on
0212   double myMinorRadius; //!< radius of the pipe
0213   double myAngle;       //!< angle to create a torus pipe segment
0214   double myVMin;        //!< first angle to create a torus ring segment
0215   double myVMax;        //!< second angle to create a torus ring segment
0216 };
0217 
0218 #endif // _Prs3d_ToolTorus_HeaderFile