0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / Prs3d / Prs3d_ToolCylinder.cxx
CommitLineData
625e1958 1// Created on: 1995-07-27
2// Created by: Modelistation
3// Copyright (c) 1995-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
62ef08df 17#include <Prs3d_ToolCylinder.hxx>
625e1958 18
19#include <Graphic3d_ArrayOfTriangles.hxx>
20#include <Poly_Array1OfTriangle.hxx>
62ef08df 21#include <Prs3d_ToolQuadric.hxx>
625e1958 22
23//=======================================================================
24//function : Constructor
25//purpose :
26//=======================================================================
62ef08df 27Prs3d_ToolCylinder::Prs3d_ToolCylinder (const Standard_Real theBottomRad,
28 const Standard_Real theTopRad,
29 const Standard_Real theHeight,
30 const Standard_Integer theNbSlices,
31 const Standard_Integer theNbStacks)
625e1958 32: myBottomRadius (theBottomRad),
33 myTopRadius (theTopRad),
34 myHeight (theHeight)
35{
caf231b0 36 myStacksNb = theNbStacks;
37 mySlicesNb = theNbSlices;
625e1958 38}
39
40//=======================================================================
41//function : Vertex
42//purpose :
43//=======================================================================
62ef08df 44gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
625e1958 45{
caf231b0 46 const Standard_Real aU = theU * M_PI * 2.0;
47 const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
48 return gp_Pnt (Cos (aU) * aRadius,
49 Sin (aU) * aRadius,
625e1958 50 theV * myHeight);
51}
52
53//=======================================================================
54//function : Add
55//purpose :
56//=======================================================================
62ef08df 57gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
625e1958 58{
caf231b0 59 const Standard_Real aU = theU * M_PI * 2.0;
60 return gp_Dir (Cos (aU) * myHeight,
61 Sin (aU) * myHeight,
62 myBottomRadius - myTopRadius);
63}
64
65//=======================================================================
66//function : Perform
67//purpose :
68//=======================================================================
62ef08df 69Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolCylinder::Create (const Standard_Real theBottomRad,
70 const Standard_Real theTopRad,
71 const Standard_Real theHeight,
72 const Standard_Integer theNbSlices,
73 const Standard_Integer theNbStacks,
74 const gp_Trsf& theTrsf)
caf231b0 75{
76 Handle(Graphic3d_ArrayOfTriangles) anArray;
62ef08df 77 Prs3d_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
caf231b0 78 aTool.FillArray (anArray, theTrsf);
79 return anArray;
625e1958 80}