(self)
| 28 | class TestVolume(vtkTesting.vtkTest): |
| 29 | |
| 30 | def test(self): |
| 31 | |
| 32 | parser = argparse.ArgumentParser( |
| 33 | "TestVolume", description="Exercise volume mapper (de)serialization.") |
| 34 | parser.add_argument('mapper', choices=MAPPERS.keys()) |
| 35 | args, _ = parser.parse_known_args() |
| 36 | self.mapper_type = args.mapper |
| 37 | |
| 38 | ser_om = vtkObjectManager() |
| 39 | ser_om.Initialize() |
| 40 | |
| 41 | deser_om = vtkObjectManager() |
| 42 | deser_om.Initialize() |
| 43 | |
| 44 | ren = vtkRenderer() |
| 45 | renWin = vtkRenderWindow() |
| 46 | renWin.AddRenderer(ren) |
| 47 | interactor = vtkRenderWindowInteractor() |
| 48 | interactor.SetRenderWindow(renWin) |
| 49 | interactor.GetInteractorStyle().SetCurrentStyleToTrackballCamera() |
| 50 | |
| 51 | source = vtkRTAnalyticSource() |
| 52 | source.Update() |
| 53 | mapper = MAPPERS[self.mapper_type] |
| 54 | mapper.SetInputConnection(source.GetOutputPort()) |
| 55 | actor = vtkVolume() |
| 56 | actor.SetMapper(mapper) |
| 57 | actor.GetProperty().SetScalarOpacityUnitDistance(10) |
| 58 | ren.AddActor(actor) |
| 59 | |
| 60 | colorTransferFunction = vtkColorTransferFunction() |
| 61 | colorTransferFunction.AddRGBPoint(0.0, 0.0, 0.0, 0.0) |
| 62 | colorTransferFunction.AddRGBPoint(64.0, 1.0, 0.0, 0.0) |
| 63 | colorTransferFunction.AddRGBPoint(128.0, 0.0, 0.0, 1.0) |
| 64 | colorTransferFunction.AddRGBPoint(192.0, 0.0, 1.0, 0.0) |
| 65 | colorTransferFunction.AddRGBPoint(255.0, 0.0, 0.2, 0.0) |
| 66 | |
| 67 | opacityTransferFunction = vtkPiecewiseFunction() |
| 68 | opacityTransferFunction.AddPoint(20, 0.0) |
| 69 | opacityTransferFunction.AddPoint(255, 0.2) |
| 70 | |
| 71 | volumeProperty = vtkVolumeProperty() |
| 72 | volumeProperty.SetColor(colorTransferFunction) |
| 73 | volumeProperty.SetScalarOpacity(opacityTransferFunction) |
| 74 | volumeProperty.ShadeOn() |
| 75 | volumeProperty.SetInterpolationTypeToLinear() |
| 76 | |
| 77 | actor.SetProperty(volumeProperty) |
| 78 | |
| 79 | cube = vtkCubeAxesActor() |
| 80 | cube.SetCamera(ren.GetActiveCamera()) |
| 81 | cube.SetBounds(source.GetOutput().GetBounds()) |
| 82 | ren.AddActor(cube) |
| 83 | |
| 84 | ren.ResetCamera() |
| 85 | ren.SetBackground(0.7, 0.7, 0.7) |
| 86 | renWin.Render() |
| 87 |
nothing calls this directly
no test coverage detected