basic_rendering.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. r"""verify basic surface rendering"""
  2. from . import internals
  3. from ..simple import *
  4. from .. import print_info as log
  5. def Execute(opts):
  6. log("initialize pipeline")
  7. view = CreateView('RenderView')
  8. view.ViewSize = [400, 400]
  9. layout = CreateLayout()
  10. layout.AssignView(0, view)
  11. layout.SetSize(400, 400)
  12. Sphere(PhiResolution=1000, ThetaResolution=1000)
  13. Elevation(LowPoint=[-0.5, -0.5, 0.], HighPoint=[0.5, 0.5, 0])
  14. disp = Show()
  15. disp.SetRepresentationType("Surface")
  16. # setup LUT
  17. elevationLUT = GetColorTransferFunction('Elevation')
  18. elevationLUT.RescaleTransferFunction(0.0, 1.0)
  19. ColorBy(disp, ('POINTS', 'Elevation'))
  20. # reset camera
  21. view.ResetCamera(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
  22. log("begin render")
  23. Render()
  24. log("end render")
  25. if opts.interactive:
  26. Interact()
  27. if opts.output:
  28. log("save test image")
  29. SaveScreenshot(opts.output, ImageResolution=[400, 400])
  30. if opts.baseline:
  31. log("compare baseline image")
  32. internals.compare(opts.output, opts.baseline)
  33. elif opts.baseline:
  34. raise RuntimeError("baseline (-v) specified without output (-o)")
  35. def main(args=None):
  36. import argparse
  37. parser = argparse.ArgumentParser(description='Test basic surface rendering.')
  38. parser.add_argument("-i", "--interactive", help="enable interaction", action="store_true")
  39. parser.add_argument("-o", "--output", help="output image file", type=str)
  40. parser.add_argument("-v", "--baseline", help="baseline image (for comparison)", type=str)
  41. Execute(parser.parse_args(args))
  42. if __name__ == "__main__":
  43. main()