0024291: Visualization - move Z-buffer trihedron presentation from TKOpenGl to TKV3d
[occt.git] / src / StdPrs / StdPrs_ToolDisk.cxx
1 // Created on: 2016-02-04
2 // Created by: Anastasia BORISOVA
3 // Copyright (c) 2016 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 <StdPrs_ToolDisk.hxx>
17
18 #include <Graphic3d_ArrayOfTriangles.hxx>
19 #include <Poly_Array1OfTriangle.hxx>
20 #include <StdPrs_ToolQuadric.hxx>
21
22 //=======================================================================
23 //function : Constructor
24 //purpose  :
25 //=======================================================================
26 StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_Real    theInnerRadius,
27                                   const Standard_Real    theOuterRadius,
28                                   const Standard_Integer theNbSlices,
29                                   const Standard_Integer theNbStacks)
30 : myInnerRadius (theInnerRadius),
31   myOuterRadius (theOuterRadius)
32 {
33   mySlicesNb = theNbSlices;
34   myStacksNb = theNbStacks;
35 }
36
37 //=======================================================================
38 //function : Vertex
39 //purpose  :
40 //=======================================================================
41 gp_Pnt StdPrs_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
42 {
43   const Standard_Real aU      = theU * M_PI * 2.0;
44   const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
45   return gp_Pnt (Cos (aU) * aRadius,
46                  Sin (aU) * aRadius,
47                  0.0);
48 }
49
50 //=======================================================================
51 //function : Add
52 //purpose  :
53 //=======================================================================
54 gp_Dir StdPrs_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
55 {
56   return gp_Dir (0.0, 0.0, -1.0);
57 }
58
59 //=======================================================================
60 //function : Perform
61 //purpose  :
62 //=======================================================================
63 Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolDisk::Create (const Standard_Real    theInnerRadius,
64                                                             const Standard_Real    theOuterRadius,
65                                                             const Standard_Integer theNbSlices,
66                                                             const Standard_Integer theNbStacks,
67                                                             const gp_Trsf&         theTrsf)
68 {
69   Handle(Graphic3d_ArrayOfTriangles) anArray;
70   StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theNbSlices, theNbStacks);
71   aTool.FillArray (anArray, theTrsf);
72   return anArray;
73 }