1 // Created on: 2014-10-15
2 // Created by: Denis Bogolepov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_Cylinder.hxx>
18 // =======================================================================
19 // function : OpenGl_Cylinder
21 // =======================================================================
22 OpenGl_Cylinder::OpenGl_Cylinder()
30 // =======================================================================
33 // =======================================================================
34 Standard_Boolean OpenGl_Cylinder::Init (const Standard_ShortReal theBotRad,
35 const Standard_ShortReal theTopRad,
36 const Standard_ShortReal theHeight,
37 const Standard_Integer theNbSlices,
38 const Standard_Integer theNbStacks)
43 return OpenGl_Quadric::init (theNbSlices, theNbStacks);
46 // =======================================================================
47 // function : evalVertex
49 // =======================================================================
50 OpenGl_Vec3 OpenGl_Cylinder::evalVertex (const Standard_ShortReal theU,
51 const Standard_ShortReal theV) const
53 const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
54 const Standard_ShortReal aRadius = myBotRad + (myTopRad - myBotRad) * theV;
55 return OpenGl_Vec3 (cosf (aU) * aRadius,
60 // =======================================================================
61 // function : evalNormal
63 // =======================================================================
64 OpenGl_Vec3 OpenGl_Cylinder::evalNormal (const Standard_ShortReal theU,
65 const Standard_ShortReal /*theV*/) const
67 const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
68 return OpenGl_Vec3 (cosf (aU) * myHeight,
70 myBotRad - myTopRad).Normalized();