我想在提取数据的线上可视化线图(从沿着模型“表面”的线过滤器上的图提取)。 Plot Over Line 过滤器允许通过数据值对线进行着色,并进行较小的转换,但我想将 Z 位置设置为数据值的乘数。
这是基本图像,没有用数据值乘以直线的 Z:
我导出了线图数据,将数据值(让我们称之为幅度)转换为伪高程,并将结果导入为 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())
两种解决方案都会产生这样的图像(在对“属性”面板进行一些调整之后):
