c827ea3a |
1 | // Created on: 2014-10-15 |
2 | // Created by: Denis Bogolepov |
3 | // Copyright (c) 2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #include <OpenGl_Disk.hxx> |
17 | |
18 | // ======================================================================= |
19 | // function : OpenGl_Disk |
20 | // purpose : |
21 | // ======================================================================= |
22 | OpenGl_Disk::OpenGl_Disk() |
23 | : myInnerRadius (1.0f), |
24 | myOuterRadius (1.0f) |
25 | { |
26 | // |
27 | } |
28 | |
29 | // ======================================================================= |
30 | // function : Init |
31 | // purpose : |
32 | // ======================================================================= |
33 | Standard_Boolean OpenGl_Disk::Init (const Standard_ShortReal theInnerRadius, |
34 | const Standard_ShortReal theOuterRadius, |
35 | const Standard_Integer theNbSlices, |
36 | const Standard_Integer theNbStacks) |
37 | { |
38 | myInnerRadius = theInnerRadius; |
39 | myOuterRadius = theOuterRadius; |
40 | return OpenGl_Quadric::init (theNbSlices, theNbStacks); |
41 | } |
42 | |
43 | // ======================================================================= |
44 | // function : evalVertex |
45 | // purpose : |
46 | // ======================================================================= |
47 | OpenGl_Vec3 OpenGl_Disk::evalVertex (const Standard_ShortReal theU, |
48 | const Standard_ShortReal theV) const |
49 | { |
50 | const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0); |
51 | const Standard_ShortReal aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV; |
52 | return OpenGl_Vec3 (cosf (aU) * aRadius, sinf (aU) * aRadius, 0.0f); |
53 | } |
54 | |
55 | // ======================================================================= |
56 | // function : evalNormal |
57 | // purpose : |
58 | // ======================================================================= |
59 | OpenGl_Vec3 OpenGl_Disk::evalNormal (const Standard_ShortReal /*theU*/, |
60 | const Standard_ShortReal /*theV*/) const |
61 | { |
62 | return OpenGl_Vec3 (0.0f, 0.0f, -1.0f); |
63 | } |