Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoguaro/a12dbcd619a692712536 to your computer and use it in GitHub Desktop.
Save nicoguaro/a12dbcd619a692712536 to your computer and use it in GitHub Desktop.
Snippets relted to Paraview
"""
Set projection to parallel in Paraview
In Paraview 4.3 the default is perspective projection.
"""
camera = GetActiveCamera ()
camera. SetParallelProjection (True)
"""
Example of programmable source in Paraview for an image in 3D
"""
## This part needs to go in the first box
nptsx = 100
nptsy = 100
nptsz = 100
dx = 1.0
dy = 1.0
dz = 1.0
ido = self.GetOutput()
ido.SetDimensions(nptsx + 1, nptsy + 1, nptsz + 1)
ido.SetOrigin(-nptsx/2, -nptsy/2, -nptsz/2)
ido.SetSpacing(dx, dy, dz)
ido.SetExtent(0, nptsx, 0, nptsy, 0, nptsz)
## To include a dataset associated with the image
# ido.AllocateScalars(vtk.VTK_FLOAT,1)
# ca = vtk.vtkFloatArray()
# ca.SetName("Data_set")
# ca.SetNumberOfComponents(1)
# ca.SetNumberOfTuples(nptsx*nptsy*nptsz)
# for i in range(0, nptsx*nptsy*nptsz):
# ca.SetValue(i, i)
# #add the new array to the output
# ido.GetCellData().SetScalars(ca)
## This part needs to go in the second box
from paraview import util
nptsx = 100
nptsy = 100
nptsz = 100
dx = 1.0
dy = 1.0
dz = 1.0
util.SetOutputWholeExtent(self, [0, nptsx, 0, nptsy, 0, nptsz])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment