0027038: Visualization - add new presentation for object manipulation
[occt.git] / src / StdPrs / StdPrs_ToolSphere.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_ToolSphere.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_ToolSphere::StdPrs_ToolSphere (const Standard_ShortReal theRadius,
27                                       const Standard_Integer theSlicesNb,
28                                       const Standard_Integer theStacksNb)
29 : myRadius (theRadius)
30 {
31   mySlicesNb = theSlicesNb;
32   myStacksNb = theStacksNb;
33 }
34
35 //=======================================================================
36 //function : Vertex
37 //purpose  :
38 //=======================================================================
39 gp_Pnt StdPrs_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
40 {
41   const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
42   const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
43   return gp_Pnt (myRadius * cosf(aU) * sinf(aV),
44                 -myRadius * sinf(aU) * sinf(aV),
45                  myRadius * cosf(aV));
46 }
47
48 //=======================================================================
49 //function : Add
50 //purpose  :
51 //=======================================================================
52 gp_Dir StdPrs_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
53 {
54   const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
55   const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
56   return gp_Dir (cosf(aU) * sinf(aV),
57                 -sinf(aU) * sinf(aV),
58                  cosf(aV));
59 }