Hi,
I met two issues here. My data (512x512x512 volume) is stored in .vti. My paraview version is 5.12.1, python 3.10
I tried to print the bounds by print(reader.GetDataInformation().GetBounds())
. But sometimes I got (1, -1, 1, -1, 1, -1) sometimes I got (0, 511, 0, 511, 0, 511). Is it a bug?
When I changed camera position by doing camera.SetPosition(1, 1, 1)
and camera.SetPosition(2, 2, 2),
I got the same rendering.
Thank you for your help
mwestphal
(Mathieu Westphal (Kitware))
May 6, 2025, 9:28am
2
I tried to print the bounds by print(reader.GetDataInformation().GetBounds()). But sometimes I got (1, -1, 1, -1, 1, -1) sometimes I got (0, 511, 0, 511, 0, 511). Is it a bug?
Works fine here, did you show and render your data first ?
When I changed camera position by doing camera.SetPosition(1, 1, 1)
and camera.SetPosition(2, 2, 2),
I got the same rendering.
Works fine here, did you render afert changing position ?
Hi,
Works fine here, did you show and render your data first ?
I did it by:
reader = OpenDataFile(".volume_path")
print(reader.GetDataInformation().GetBounds())
the rendering code was after it
Works fine here, did you render afert changing position ?
yes
mwestphal
(Mathieu Westphal (Kitware))
May 6, 2025, 9:40am
4
You need to at least update information before using GetDataInformation.
thanks, the first issue was solved, but the second remains there.
this is my full code:
reader = OpenDataFile("./volume_path.vti")
UpdatePipeline()
print(reader.GetDataInformation().GetBounds())
view = GetActiveViewOrCreate('RenderView')
bounds = reader.GetDataInformation().GetBounds()
center = [(bounds[0] + bounds[1]) / 2,
(bounds[2] + bounds[3]) / 2,
(bounds[4] + bounds[5]) / 2]
view.ViewSize = [800, 800]
SetViewProperties(
Background=[1.0, 1.0, 1.0],
UseColorPaletteForBackground=0,
)
view.AxesGrid.Visibility = 0
view.OrientationAxesVisibility = 0
view.CameraViewAngle = 1
display = GetDisplayProperties(reader, view=view)
display.Representation = 'Volume'
ColorBy(display, ('POINTS', 'Scalars_'))
cmap = GetColorTransferFunction('Scalars_')
cmap.ApplyPreset('Turbo', True)
cmap.RescaleTransferFunctionToDataRange(True)
opacity = GetOpacityTransferFunction('Scalars_')
gaussian_list = []
for i in range(256):
gaussian_list.append(i)
gaussian_list.append(gaussian(i, 200, 60, 0.05))
gaussian_list.append(0.5)
gaussian_list.append(0)
opacity.Points = gaussian_list
camera = view.GetActiveCamera()
camera.SetFocalPoint(center[0], center[1], center[2]) # The point the camera looks at
camera.SetViewUp(0, 1, 0) # Which direction is 'up'
camera.SetViewAngle(2)
angle_degrees = 60
angle_radians = math.radians(angle_degrees)
camera.SetPosition(center[0]+8, center[1]+8, center[2]+8)
Render()
filename = f"./ParaView/bin/render_test.png"
SaveScreenshot(filename, view, ImageResolution=view.ViewSize)
mwestphal
(Mathieu Westphal (Kitware))
May 6, 2025, 9:58am
6
Try something wildly different and see if it has an effect
No, I still got the same rendering even when I increased it to camera.SetPosition(center[0]+1000, center[1]+1000, center[2]+1000)
mwestphal
(Mathieu Westphal (Kitware))
May 6, 2025, 10:44am
8
This simple script does not reproduce the issue:
from paraview.simple import *
Wavelet()
Show()
Render()
cam=GetActiveCamera()
cam.SetPosition(1000, 1000, 1000)
SaveScreenshot("output.png")
Please try on your side.
thank you. I think I solved the problem. But I observed another problem that my volume is [512, 512, 512] but when I did camera.SetPosition(800, 800, 800)
, I only saw the zoomed-in part of the volume. here is my code:
reader = OpenDataFile("./volume_path.vti")
UpdatePipeline()
view = GetActiveViewOrCreate('RenderView')
bounds = reader.GetDataInformation().GetBounds()
SetViewProperties(
Background=[1.0, 1.0, 1.0],
UseColorPaletteForBackground=0,
)
view.AxesGrid.Visibility = 0
view.OrientationAxesVisibility = 0
#
display = GetDisplayProperties(reader, view=view)
display.Representation = 'Volume'
ColorBy(display, ('POINTS', 'Scalars_'))
cmap = GetColorTransferFunction('Scalars_')
cmap.ApplyPreset('Turbo', True)
cmap.RescaleTransferFunctionToDataRange(True)
opacity = GetOpacityTransferFunction('Scalars_')
gaussian_list = []
for i in range(256):
gaussian_list.append(i)
gaussian_list.append(gaussian(i, 200, 60, 0.05))
gaussian_list.append(0.5)
gaussian_list.append(0)
opacity.Points = gaussian_list
Show()
Render()
camera = GetActiveCamera()
camera.SetPosition(800, 800, 800)
filename = f"./ParaView/bin/render_test.png"
SaveScreenshot(filename, ImageResolution=[800, 800])
i attached rendered volume under camera.SetPosition(800, 800, 800)
and camera.SetPosition(2000, 2000, 2000)