def test(points, springs1, springs2): app = QApplication(sys.argv) window = Viewer3D.SimpleView() polydata1 = GeneratePolydata.generateLinePolydata(points, springs1) polydata2 = GeneratePolydata.generateLinePolydata(points, springs2) mapper1 = vtk.vtkPolyDataMapper() mapper1.SetInputData(polydata1) actor1 = vtk.vtkActor() actor1.SetMapper(mapper1) mapper2 = vtk.vtkPolyDataMapper() mapper2.SetInputData(polydata2) actor2 = vtk.vtkActor() actor2.SetMapper(mapper2) actor1.GetProperty().SetColor(1,0,0) actor2.GetProperty().SetColor(0,1,0.5) window.ren.AddActor(actor1) window.ren.AddActor(actor2) window.start(app) return
def __init__(self, window, xAngle, yAngle, zAngle, parent=None, axis=None, theta=None): super(question3Visualization, self).__init__(parent) self.window = window # Add the input 'window' as an attribute of the question3Visualization class self.window.ren.SetBackground(1,1,1) self.xAngle = xAngle # Store the given angles as attributes of this class self.yAngle = yAngle self.zAngle = zAngle self.rotationAxis = axis self.theta = theta self.rect1 = makeHexahedra(xSideLength=12.0, ySideLength=5.0, zSideLength=5.0) # Get the rectangle and the points. Note, this is a list (vtkUnstructuredGrid, vtkPoints) self.actor1 = getRectangleActor(self.rect1[0], [0,1,0], opacity=0.8) self.axes1 = GeneratePolydata.generateAxes(np.identity(4), label='Gr', size=10) label1 = self._getTextActor([0, 1, 0], [20, 370], opacity=1, text='RxRyRz\n_______') # Add the text to the frame. This will be upated for the visualization self.txt1x = self._getTextActor([0,1,0], [20, 350], opacity=0.5, text='Rx = 0') # Add the text to the frame. This will be upated for the visualization self.txt1y = self._getTextActor([0,1,0], [20, 325], opacity=0.5, text='Ry = 0') self.txt1z = self._getTextActor([0,1,0], [20, 300], opacity=0.5, text='Rz = 0') self.rect2 = makeHexahedra(xSideLength=15.0, ySideLength=3.0, zSideLength=3.0) # Get the rectangle and the points. Note, this is a list (vtkUnstructuredGrid, vtkPoints) self.actor2 = getRectangleActor(self.rect2[0], [1, 0, 0], opacity=0.8) self.axes2 = GeneratePolydata.generateAxes(np.identity(4), label='Red', size=7) label2 = self._getTextActor([1, 0, 0], [100, 370], opacity=1, text='Rotate about [1,1,1]\n_______') # Add the text to the frame. This will be upated for the visualization self.txt2x = self._getTextActor([1, 0, 0], [100, 350], opacity=0.5, text='theta = 0') # Add the text to the frame. This will be upated for the visualization # self.txt2y = self._getTextActor([1, 0, 0], [100, 325], opacity=0.5, text='Ry = 0') # self.txt2z = self._getTextActor([1, 0, 0], [100, 300], opacity=0.5, text='Rz = 0') label3 = self._getTextActor([0,0,0], [20, 0], opacity=1, text='Zaylor') # Add the text to the frame. This will be upated for the visualization self.window.ren.AddActor(self.actor1) self.window.ren.AddActor(self.axes1) self.window.ren.AddActor(self.actor2) self.window.ren.AddActor(self.axes2) self.window.iren.AddObserver('KeyPressEvent', self.makeVideo) print 'Press "ctrl" to make animation.'