gpt4 book ai didi

python - 在 Paraview 中的 3D 体积上叠加线图

转载 作者:太空宇宙 更新时间:2023-11-04 03:34:26 30 4
gpt4 key购买 nike

我想在提取数据的线上可视化线图(从沿着模型“表面”的线过滤器上的图提取)。 Plot Over Line 过滤器允许通过数据值对线进行着色,并进行较小的转换,但我想将 Z 位置设置为数据值的乘数。

这是基本图像,没有用数据值乘以直线的 Z:

enter image description here

我导出了线图数据,将数据值(让我们称之为幅度)转换为伪高程,并将结果导入为 x、y、z 点集(其中 x、y 是水平坐标,z = 表示为高程坐标的幅度)。

如何沿着这些点绘制曲线?在不应用任何过滤器的情况下,它只是绘制为空间中的一系列点。

还有别的办法吗?我敢肯定这很简单,但我看不到。

最佳答案

修改自问题How to connect points in paraview?使用 ' Transform the input ' Paraview 公共(public) Wiki 页面中关于可编程 python 过滤器的示例,以及 vtk docs :

pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()
numPoints = pdi.GetNumberOfPoints()
pdo.Allocate()
for i in range(0, numPoints-1):
points = [i, i+1]
# VTK_LINE is 3
pdo.InsertNextCell(3, 2, points)

或者,这里有另一个脚本可以完成类似的工作,它是根据与上一个示例相同页面上的几个其他示例修改而来的:

# Get a vtk.PolyData object for the input
pdi = self.GetPolyDataInput()
# Get a vtk.PolyData object for the output
pdo = self.GetPolyDataOutput()

numPoints = pdi.GetNumberOfPoints()

# Points for the line:
newPoints = vtk.vtkPoints()
for i in range(0, numPoints):
# Generate the new points from the input
coord = pdi.GetPoint(i)
x, y, z = coord[:3]
newPoints.InsertPoint(i, x, y, z)

# Add the new points to the PolyData object:
pdo.SetPoints(newPoints)

# Make a line from the new points:
aPolyLine = vtk.vtkPolyLine()

#Indicate the number of points along the line
aPolyLine.GetPointIds().SetNumberOfIds(numPoints)
for i in range(0,numPoints):
#Add the points to the line. The first value indicates
#the order of the point on the line. The second value
#is a reference to a point in a vtkPoints object. Depends
#on the order that Points were added to vtkPoints object.
#Note that this will not be associated with actual points
#until it is added to a vtkPolyData object which holds a
#vtkPoints object.
aPolyLine.GetPointIds().SetId(i, i)

#Allocate the number of 'cells' that will be added. We are just
#adding one vtkPolyLine 'cell' to the vtkPolyData object.
pdo.Allocate(1, 1)

#Add the poly line 'cell' to the vtkPolyData object.
pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())

两种解决方案都会产生这样的图像(在对“属性”面板进行一些调整之后):

Plot of line data over 3d model

关于python - 在 Paraview 中的 3D 体积上叠加线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29788695/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com