1 """ The cylinder class for Pyllar."""
2
3
4
5 from Plottable import Plottable
6 import vtk
7 from numpy import *
8
10 """ The Cylinder class represents a cylinder in 3D space.
11 """
12
13 - def __init__(self, x=0, y=0, z=0, r=1, h=1, res=32):
14 """ Create an instance of the Cylinder class.
15
16 x, y, and z are the coordinates of the center of the cylinder.
17 r and h are the radius and height of the cylinder, respectively.
18 res is the number of polynomials in the angular dimansion.
19 """
20
21
22 self.object = vtk.vtkCylinderSource()
23 self.object.SetCenter(x, y, z)
24 self.pos = array([x,y,z])
25 self.direction = array([0.0,1.0,0.0])
26 self.object.SetRadius(r)
27 self.object.SetHeight(h)
28 self.object.SetResolution(res)
29
30
31 self.mapper = vtk.vtkPolyDataMapper()
32 self.mapper.SetInput(self.object.GetOutput())
33
34
35 self.actor = vtk.vtkActor()
36 self.actor.SetMapper(self.mapper)
37
38
39 self.AddToAxes()
40