流
体
数
据
的
标
量
可
视
化
、
矢
量
可
视
化
实
例
流体数据的标量可视化、矢量可视化实例
流体数据的标量可视化、矢量可视化实例
tvtk.ContourFilter() 等值面过滤器
1.标量可视化
from tvtk.api import tvtk
from tvtkfunc import ivtk_scene, event_loop
plot3d = tvtk.MultiBlockPLOT3DReader(
xyz_file_name="combxyz.bin",
q_file_name="combq.bin",
scalar_function_number=100, vector_function_number=200
)
plot3d.update()
grid = plot3d.output.get_block(0)
con = tvtk.ContourFilter()
con.set_input_data(grid)
con.generate_values(10, grid.point_data.scalars.range)
m = tvtk.PolyDataMapper(scalar_range = grid.point_data.scalars.range,
input_connection=con.output_port)
a = tvtk.Actor(mapper = m)
a.property.opacity = 0.5
win = ivtk_scene(a)
win.scene.isometric_view()
event_loop()
2.矢量可视化
tvtk.Glyph3D()符号化技术
tvtk.Glyph3D()符号化技术
from tvtk.api import tvtk
from tvtkfunc import ivtk_scene, event_loop
plot3d = tvtk.MultiBlockPLOT3DReader(
xyz_file_name="combxyz.bin",
q_file_name="combq.bin",
scalar_function_number=100, vector_function_number=200
)
plot3d.update()
grid = plot3d.output.get_block(0)
mask = tvtk.MaskPoints(random_mode=True, on_ratio=50)
mask.set_input_data(grid)
glyph_source = tvtk.ConeSource()
glyph = tvtk.Glyph3D(input_connection=mask.output_port,
scale_factor=2)
glyph.set_source_connection(glyph_source.output_port)
m = tvtk.PolyDataMapper(scalar_range=grid.point_data.scalars.range,
input_connection=glyph.output_port)
a = tvtk.Actor(mapper=m)
win = ivtk_scene(a)
win.scene.isometric_view()
event_loop()
tvtk.Glyph3D()符号化技术
tvtk.MaskPoints() 降采样