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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Prs3d_ToolCylinder.hxx>
19 #include <Graphic3d_ArrayOfTriangles.hxx>
20 #include <Poly_Array1OfTriangle.hxx>
21 #include <Prs3d_ToolQuadric.hxx>
23 //=======================================================================
24 //function : Constructor
26 //=======================================================================
27 Prs3d_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)
32 : myBottomRadius (theBottomRad),
33 myTopRadius (theTopRad),
36 myStacksNb = theNbStacks;
37 mySlicesNb = theNbSlices;
40 //=======================================================================
43 //=======================================================================
44 gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
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,
53 //=======================================================================
56 //=======================================================================
57 gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
59 const Standard_Real aU = theU * M_PI * 2.0;
60 return gp_Dir (Cos (aU) * myHeight,
62 myBottomRadius - myTopRadius);
65 //=======================================================================
68 //=======================================================================
69 Handle(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)
76 Handle(Graphic3d_ArrayOfTriangles) anArray;
77 Prs3d_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
78 aTool.FillArray (anArray, theTrsf);