我希望可视化一条线图(从线条过滤器沿着模型的“表面”的图表中提取)在其提取数据的线上。 Plot Over Line过滤器允许通过数据值和次要变换对线进行着色,但我想将Z位置设置为数据值的乘数。
这是基础知识的图像,它没有线的Z乘以数据值:
我导出了线图数据,将数据值(让它称之为幅度)转换为伪高程,并将结果导入为x,y,z点集(其中x,y为水平坐标,z =表示为高程坐标的幅度。
如何沿这些点绘制曲线?如果没有应用任何过滤器,它只是在空间中绘制为一系列点。
还有其他方法吗?我确信这很简单,但我无法看到它。
答案 0 :(得分:1)
使用可编程python过滤器上的Paraview公共Wiki页面中提供的“How to connect points in paraview?”示例和问题Transform the input修改了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())
两种解决方案都会生成这样的图像(在使用“属性”面板进行一些调整之后):