KuangshiAi
merge chatvis bench and main
77dc289
raw
history blame
4.26 kB
from paraview.simple import *
# ============= Configuration =============
INPUT_FILE = '/home/dullpigeon/Desktop/SciVisAgentTask/ABC/abc.raw'
OUTPUT_IMAGE = '/home/dullpigeon/Desktop/SciVisAgentTask/ABC/abc_glyph.png'
OUTPUT_STATE = '/home/dullpigeon/Desktop/SciVisAgentTask/ABC/abc_glyph.pvsm'
IMAGE_SIZE = [1024, 1024]
# ============= Load Data =============
# ABC flow: 128x128x128, float32, 3 components (vector field)
reader = ImageReader(FileNames=[INPUT_FILE])
reader.DataScalarType = 'float'
reader.DataByteOrder = 'LittleEndian'
reader.DataExtent = [0, 127, 0, 127, 0, 127]
reader.FileDimensionality = 3
reader.NumberOfScalarComponents = 3
reader.UpdatePipeline()
# ============= Get Data Info =============
bounds = reader.GetDataInformation().GetBounds()
center = [(bounds[0]+bounds[1])/2, (bounds[2]+bounds[3])/2, (bounds[4]+bounds[5])/2]
print(f"Bounds: {bounds}")
print(f"Center: {center}")
pd = reader.PointData
array_name = pd.GetArray(0).Name
print(f"Vector array: '{array_name}', components={pd.GetArray(0).GetNumberOfComponents()}")
# ============= Streamlines =============
tracer = StreamTracer(Input=reader, SeedType='Point Cloud')
tracer.Vectors = ['POINTS', array_name]
tracer.IntegrationDirection = 'BOTH'
tracer.MaximumStreamlineLength = 150.0
tracer.SeedType.Center = [73.77097622534964, 63.246234492256846, 71.65486325831273]
tracer.SeedType.NumberOfPoints = 150
tracer.SeedType.Radius = 75.0
tracer.UpdatePipeline()
# ============= Tubes =============
tube = Tube(Input=tracer)
tube.Radius = 0.5715767492484302
tube.NumberofSides = 12
tube.Capping = 1
tube.UpdatePipeline()
# ============= Create View =============
renderView = CreateView('RenderView')
renderView.ViewSize = IMAGE_SIZE
renderView.Background = [0.1, 0.1, 0.15]
layout = CreateLayout(name='Layout')
layout.AssignView(0, renderView)
# ============= Display Reader as Outline =============
readerDisplay = Show(reader, renderView)
readerDisplay.Representation = 'Outline'
ColorBy(readerDisplay, None)
readerDisplay.DiffuseColor = [0.0, 0.0, 0.0]
readerDisplay.AmbientColor = [0.0, 0.0, 0.0]
readerDisplay.Ambient = 0.0
readerDisplay.Diffuse = 1.0
readerDisplay.Specular = 1.0
readerDisplay.SpecularPower = 100.0
readerDisplay.SpecularColor = [1.0, 1.0, 1.0]
# ============= Display Tubes (Colored by Vorticity) =============
tubeDisplay = Show(tube, renderView)
tubeDisplay.Representation = 'Surface'
# Color by Vorticity magnitude
ColorBy(tubeDisplay, ('POINTS', 'Vorticity', 'Magnitude'))
# Vorticity color transfer function - Cool to Warm
vorticityLUT = GetColorTransferFunction('Vorticity')
vorticityLUT.RGBPoints = [
0.011427014127020022, 0.231373, 0.298039, 0.752941,
0.06627861150384136, 0.865003, 0.865003, 0.865003,
0.12113020888066268, 0.705882, 0.0156863, 0.14902
]
vorticityLUT.ColorSpace = 'Diverging'
vorticityLUT.NumberOfTableValues = 256
tubeDisplay.LookupTable = vorticityLUT
# Lighting properties
tubeDisplay.AmbientColor = [0.2, 0.6, 0.9]
tubeDisplay.DiffuseColor = [0.2, 0.6, 0.9]
tubeDisplay.Ambient = 0.1
tubeDisplay.Diffuse = 0.8
tubeDisplay.Specular = 0.5
tubeDisplay.SpecularPower = 40.0
tubeDisplay.SpecularColor = [1.0, 1.0, 1.0]
# ============= Lighting Setup =============
renderView.UseLight = True
renderView.KeyLightWarmth = 0.6
renderView.KeyLightIntensity = 0.8
renderView.FillLightWarmth = 0.4
# ============= Camera Setup =============
renderView.CameraPosition = [-150.9869248398403, 391.7532864870642, 219.6428988217961]
renderView.CameraFocalPoint = [32.38121308065774, 120.40859825991274, 81.63393818503701]
renderView.CameraViewUp = [0.23256370029970702, -0.31145477116075004, 0.9213631481799741]
renderView.CameraViewAngle = 30.0
renderView.CameraParallelProjection = 0
# ============= Color Bar (Legend) =============
tubeDisplay.SetScalarBarVisibility(renderView, True)
colorBar = GetScalarBar(vorticityLUT, renderView)
colorBar.Title = ''
colorBar.ComponentTitle = ''
colorBar.LabelColor = [0.0, 0.0, 0.0]
colorBar.Visibility = 1
colorBar.ScalarBarLength = 0.3
# ============= Save =============
Render(renderView)
SaveScreenshot(OUTPUT_IMAGE, renderView, ImageResolution=IMAGE_SIZE)
print(f"Screenshot saved to: {OUTPUT_IMAGE}")
SaveState(OUTPUT_STATE)
print(f"State saved to: {OUTPUT_STATE}")