0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_ToolSphere.cxx
CommitLineData
625e1958 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
62ef08df 16#include <Prs3d_ToolSphere.hxx>
625e1958 17
18#include <Graphic3d_ArrayOfTriangles.hxx>
19#include <Poly_Array1OfTriangle.hxx>
62ef08df 20#include <Prs3d_ToolQuadric.hxx>
625e1958 21
22//=======================================================================
23//function : Constructor
24//purpose :
25//=======================================================================
62ef08df 26Prs3d_ToolSphere::Prs3d_ToolSphere (const Standard_Real theRadius,
27 const Standard_Integer theNbSlices,
28 const Standard_Integer theNbStacks)
625e1958 29: myRadius (theRadius)
30{
caf231b0 31 mySlicesNb = theNbSlices;
32 myStacksNb = theNbStacks;
625e1958 33}
34
35//=======================================================================
36//function : Vertex
37//purpose :
38//=======================================================================
62ef08df 39gp_Pnt Prs3d_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
625e1958 40{
caf231b0 41 const Standard_Real aU = theU * M_PI * 2.0;
42 const Standard_Real aV = theV * M_PI;
43 return gp_Pnt (myRadius * Cos (aU) * Sin (aV),
44 -myRadius * Sin (aU) * Sin (aV),
45 myRadius * Cos (aV));
625e1958 46}
47
48//=======================================================================
49//function : Add
50//purpose :
51//=======================================================================
62ef08df 52gp_Dir Prs3d_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
625e1958 53{
caf231b0 54 const Standard_Real aU = theU * M_PI * 2.0;
55 const Standard_Real aV = theV * M_PI;
56 return gp_Dir (Cos (aU) * Sin (aV),
57 -Sin (aU) * Sin (aV),
58 Cos (aV));
59}
60
61//=======================================================================
62//function : Perform
63//purpose :
64//=======================================================================
62ef08df 65Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolSphere::Create (const Standard_Real theRadius,
66 const Standard_Integer theNbSlices,
67 const Standard_Integer theNbStacks,
68 const gp_Trsf& theTrsf)
caf231b0 69{
70 Handle(Graphic3d_ArrayOfTriangles) anArray;
62ef08df 71 Prs3d_ToolSphere aTool (theRadius, theNbSlices, theNbStacks);
caf231b0 72 aTool.FillArray (anArray, theTrsf);
73 return anArray;
625e1958 74}