Source code for volcapy.synthetic.test_voxel

import vtk


[docs]def MakeVoxel(): ''' A voxel is a representation of a regular grid in 3-D space. ''' numberOfVertices = 8 points = vtk.vtkPoints() points.InsertNextPoint(0, 0, 0) points.InsertNextPoint(1, 0, 0) points.InsertNextPoint(0, 1, 0) points.InsertNextPoint(1, 1, 0) points.InsertNextPoint(0, 0, 1) points.InsertNextPoint(1, 0, 1) points.InsertNextPoint(0, 1, 1) points.InsertNextPoint(1, 1, 1) voxel = vtk.vtkVoxel() for i in range(0, numberOfVertices): voxel.GetPointIds().SetId(i, i) ug = vtk.vtkUnstructuredGrid() ug.SetPoints(points) ug.InsertNextCell(voxel.GetCellType(), voxel.GetPointIds()) # Create another voxel. voxel2 = vtk.vtkVoxel() aVoxelMapper = vtk.vtkDataSetMapper() aVoxelMapper.SetInputData(ug) aVoxelActor = vtk.vtkActor() aVoxelActor.SetMapper(aVoxelMapper) aVoxelActor.GetProperty().SetDiffuseColor(1, 0, 0) ren = vtk.vtkRenderer()