2

I want to visualise a line plot (extracted from a plot over line filter along the 'surface' of a model) over the line from which its data was extracted. The Plot Over Line filter allows colouring of the line by a data value, and minor transformations, but I want to set the Z position to a multiplier of the data value.

Here's an image of the basics, which doesn't have Z of the line multiplied by the data value:

enter image description here

I exported the line plot data, converted the data value (let's call it magnitude) to a pseudo-elevation, and imported the result as an x,y,z points set (where x,y are horizontal coordinates, and z = magnitude expressed as an elevation coordinate).

How do I draw a curve along these points? Without any filters applied, it simply plots as a series of points in space.

Is there another way? I'm sure this is simple, but I'm unable to see it.

a different ben
  • 3,900
  • 6
  • 35
  • 45

1 Answers1

3

Modified from the question How to connect points in paraview? using the 'Transform the input' example given in the Paraview public Wiki's page on the programmable python filter, and the 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)

Alternatively, here's another script that will do a similar job, modified from a couple of the other examples on the same page as the previous example:

# 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())

Both solutions result in an image like this (after some fiddling with the Properties panel):

Plot of line data over 3d model

Community
  • 1
  • 1
a different ben
  • 3,900
  • 6
  • 35
  • 45