Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.1 kB
2
Indexable
Never
import argparse

import numpy as np

import vtk

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Assignment1 Task 1')
    # ...
    
    ireader = vtk.vtkXMLImageReader()
    ireader.SetFileName(args.geometry)

    output = ireader.GetOutput()
    print(output)
    scalars = output.GetPointData().GetScalars()
    print(scalars)

    warp = vtk.vtkWarpScalar()
    warp.SetInputConnection(ireader.GetOuputPort())
    warp.SetScaleFactor(100)
    warp.Update()

    imapper = vtk.vtkDataSetMapper()
    imapper.SetInputConnection(warp.GetOutputPort())
    # shut down the color of the scaler
    imapper.ScalarVisibilityOff()

    iactor = vtk.vtkActor()
    iactor.SetMapper(imapper)
    iactor.GetProperty().SetColor(1,.5, 0)

    renderer = vtk.vtkRenderer()
    renderer.AddActor(iactor)

    window = vtk.vtkRenderWindow()
    window.AddRenderer(renderer)
    window.SetSize(1000, 1000)

    interactor = vtk.vtkRenderWindowInteractor()
    interactor.SetRenderWindow(window)
    interactor.Initialize()

    window.Render()

    interactor.Start()