Last active
August 29, 2015 14:20
-
-
Save nicoguaro/a12dbcd619a692712536 to your computer and use it in GitHub Desktop.
Snippets relted to Paraview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Set projection to parallel in Paraview | |
In Paraview 4.3 the default is perspective projection. | |
""" | |
camera = GetActiveCamera () | |
camera. SetParallelProjection (True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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