Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:40

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 
0026   //! Generate primitives for 3D quadric surface (complete torus).
0027   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0028   //! @param theMinorRad [in] radius of the pipe
0029   //! @param theNbSlices [in] number of slices within U parameter
0030   //! @param theNbStacks [in] number of stacks within V parameter
0031   //! @param theTrsf     [in] optional transformation to apply
0032   //! @return generated triangulation
0033   static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theMajorRad,
0034                                                     const Standard_Real    theMinorRad,
0035                                                     const Standard_Integer theNbSlices,
0036                                                     const Standard_Integer theNbStacks,
0037                                                     const gp_Trsf&         theTrsf)
0038   {
0039     return Create (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, M_PI * 2.0, theNbSlices, theNbStacks, theTrsf);
0040   }
0041 
0042   //! Generate primitives for 3D quadric surface (torus segment).
0043   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0044   //! @param theMinorRad [in] radius of the pipe
0045   //! @param theAngle    [in] angle to create a torus pipe segment
0046   //! @param theNbSlices [in] number of slices within U parameter
0047   //! @param theNbStacks [in] number of stacks within V parameter
0048   //! @param theTrsf     [in] optional transformation to apply
0049   //! @return generated triangulation
0050   static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theMajorRad,
0051                                                     const Standard_Real    theMinorRad,
0052                                                     const Standard_Real    theAngle,
0053                                                     const Standard_Integer theNbSlices,
0054                                                     const Standard_Integer theNbStacks,
0055                                                     const gp_Trsf&         theTrsf)
0056   {
0057     return Create (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, theAngle, theNbSlices, theNbStacks, theTrsf);
0058   }
0059 
0060   //! Generate primitives for 3D quadric surface (torus ring segment).
0061   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0062   //! @param theMinorRad [in] radius of the pipe
0063   //! @param theAngle1   [in] first  angle to create a torus ring segment
0064   //! @param theAngle2   [in] second angle to create a torus ring segment
0065   //! @param theNbSlices [in] number of slices within U parameter
0066   //! @param theNbStacks [in] number of stacks within V parameter
0067   //! @param theTrsf     [in] optional transformation to apply
0068   //! @return generated triangulation
0069   static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theMajorRad,
0070                                                     const Standard_Real    theMinorRad,
0071                                                     const Standard_Real    theAngle1,
0072                                                     const Standard_Real    theAngle2,
0073                                                     const Standard_Integer theNbSlices,
0074                                                     const Standard_Integer theNbStacks,
0075                                                     const gp_Trsf&         theTrsf)
0076   {
0077     return Create (theMajorRad, theMinorRad, theAngle1, theAngle2, M_PI * 2.0, theNbSlices, theNbStacks, theTrsf);
0078   }
0079 
0080   //! Generate primitives for 3D quadric surface (segment of the torus ring segment).
0081   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0082   //! @param theMinorRad [in] radius of the pipe
0083   //! @param theAngle1   [in] first  angle to create a torus ring segment
0084   //! @param theAngle2   [in] second angle to create a torus ring segment
0085   //! @param theAngle    [in] angle to create a torus pipe segment
0086   //! @param theNbSlices [in] number of slices within U parameter
0087   //! @param theNbStacks [in] number of stacks within V parameter
0088   //! @param theTrsf     [in] optional transformation to apply
0089   //! @return generated triangulation
0090   Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theMajorRad,
0091                                                                     const Standard_Real    theMinorRad,
0092                                                                     const Standard_Real    theAngle1,
0093                                                                     const Standard_Real    theAngle2,
0094                                                                     const Standard_Real    theAngle,
0095                                                                     const Standard_Integer theNbSlices,
0096                                                                     const Standard_Integer theNbStacks,
0097                                                                     const gp_Trsf&         theTrsf);
0098 
0099 public:
0100 
0101   //! Initializes the algorithm creating a complete torus.
0102   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0103   //! @param theMinorRad [in] radius of the pipe
0104   //! @param theNbSlices [in] number of slices within U parameter
0105   //! @param theNbStacks [in] number of stacks within V parameter
0106   Prs3d_ToolTorus (const Standard_Real    theMajorRad,
0107                    const Standard_Real    theMinorRad,
0108                    const Standard_Integer theNbSlices,
0109                    const Standard_Integer theNbStacks)
0110   {
0111     init (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, M_PI * 2.0, theNbSlices, theNbStacks);
0112   }
0113 
0114   //! Initializes the algorithm creating a torus pipe segment.
0115   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0116   //! @param theMinorRad [in] radius of the pipe
0117   //! @param theAngle    [in] angle to create a torus pipe segment
0118   //! @param theNbSlices [in] number of slices within U parameter
0119   //! @param theNbStacks [in] number of stacks within V parameter
0120   Prs3d_ToolTorus (const Standard_Real    theMajorRad,
0121                    const Standard_Real    theMinorRad,
0122                    const Standard_Real    theAngle,
0123                    const Standard_Integer theNbSlices,
0124                    const Standard_Integer theNbStacks)
0125   {
0126     init (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, theAngle, theNbSlices, theNbStacks);
0127   }
0128 
0129   //! Initializes the algorithm creating a torus ring segment.
0130   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0131   //! @param theMinorRad [in] radius of the pipe
0132   //! @param theAngle1   [in] first  angle to create a torus ring segment
0133   //! @param theAngle2   [in] second angle to create a torus ring segment
0134   //! @param theNbSlices [in] number of slices within U parameter
0135   //! @param theNbStacks [in] number of stacks within V parameter
0136   Prs3d_ToolTorus (const Standard_Real    theMajorRad,
0137                    const Standard_Real    theMinorRad,
0138                    const Standard_Real    theAngle1,
0139                    const Standard_Real    theAngle2,
0140                    const Standard_Integer theNbSlices,
0141                    const Standard_Integer theNbStacks)
0142   {
0143     init (theMajorRad, theMinorRad, theAngle1, theAngle2, M_PI * 2.0, theNbSlices, theNbStacks);
0144   }
0145 
0146   //! Initializes the algorithm creating a torus ring segment.
0147   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0148   //! @param theMinorRad [in] radius of the pipe
0149   //! @param theAngle1   [in] first  angle to create a torus ring segment
0150   //! @param theAngle2   [in] second angle to create a torus ring segment
0151   //! @param theAngle    [in] angle to create a torus pipe segment
0152   //! @param theNbSlices [in] number of slices within U parameter
0153   //! @param theNbStacks [in] number of stacks within V parameter
0154   Prs3d_ToolTorus (const Standard_Real    theMajorRad,
0155                    const Standard_Real    theMinorRad,
0156                    const Standard_Real    theAngle1,
0157                    const Standard_Real    theAngle2,
0158                    const Standard_Real    theAngle,
0159                    const Standard_Integer theNbSlices,
0160                    const Standard_Integer theNbStacks)
0161   {
0162     init (theMajorRad, theMinorRad, theAngle1, theAngle2, theAngle, theNbSlices, theNbStacks);
0163   }
0164 
0165 private:
0166 
0167   //! Initialisation
0168   //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus
0169   //! @param theMinorRad [in] radius of the pipe
0170   //! @param theAngle1   [in] first  angle to create a torus ring segment
0171   //! @param theAngle2   [in] second angle to create a torus ring segment
0172   //! @param theAngle    [in] angle to create a torus pipe segment
0173   //! @param theNbSlices [in] number of slices within U parameter
0174   //! @param theNbStacks [in] number of stacks within V parameter
0175   Standard_EXPORT void init (const Standard_Real    theMajorRad,
0176                              const Standard_Real    theMinorRad,
0177                              const Standard_Real    theAngle1,
0178                              const Standard_Real    theAngle2,
0179                              const Standard_Real    theAngle,
0180                              const Standard_Integer theNbSlices,
0181                              const Standard_Integer theNbStacks);
0182 
0183 protected:
0184 
0185   //! Computes vertex at given parameter location of the surface.
0186   Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
0187 
0188   //! Computes normal at given parameter location of the surface.
0189   Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
0190 
0191 protected:
0192 
0193   Standard_Real myMajorRadius; //!< distance from the center of the pipe to the center of the torus
0194   Standard_Real myMinorRadius; //!< radius of the pipe
0195   Standard_Real myAngle;       //!< angle to create a torus pipe segment
0196   Standard_Real myVMin;        //!< first angle to create a torus ring segment
0197   Standard_Real myVMax;        //!< second angle to create a torus ring segment
0198 
0199 };
0200 
0201 #endif // _Prs3d_ToolTorus_HeaderFile