slice along polyline

Hi,
I am new to paraview and trying to figure things out.
A have a VTK file that represents volumentirc data. I want to slice the volume, alony y-axis, given some points (xyz) that are on z=0 plane.

I loaded a txt file and convert it to TabletoPoints. Now on the surface of this volume, I can see the points.
I am not sure how to proceed from this point. I tried to convert the points to polyline, but don’t know how.
Then on the volume data, I clicked on the option slizeAlongPolyline, but paraview crashes without any message.

What can I do?

The only way I know of to create a poly line from the collection of points that you get from Table To Points is to use the Programmable Filter. If you add the Programmable Filter to your points and use the following script, that should connect the points together in a polyline.

output.Points = inputs[0].Points
numPoints = len(output.Points)

pointIds = vtk.vtkIdList()
pointIds.SetNumberOfIds(numPoints)
for i in range(numPoints):
    pointIds.SetId(i, i)

output.Allocate(1, 1)
output.InsertNextCell(vtk.VTK_POLY_LINE, pointIds)

Now you can create the Slice Along PolyLine filter. Set the Dataset input to your volume and the Poly Line input to the previously created output from the Programmable Filter.

Great. That worked perfectly!!!

Hi,

I have a follow-up question related to this topic.

I am trying to find average values (e.g. Mach number or pressure) at given parallel slices along the longitudinal direction of a combustion chamber. I imported a csv file describing the point distribution along the longitudinal direction of the chamber, converted the csv table to points (via TableToPoints), and used the ProgrammableFilter mentioned by @Kenneth_Moreland to make the points into a polyline. Then, I used SliceAlongPolyLine with the intent of creating planar slices (i.e. at the cross-section of the chamber) at each point described by the TableToPoints filter along the line defined by the ProgrammableFilter. Instead, the SliceAlongPolyLine took one single slice containing the whole polyline (i.e. the slice lies within the longitudinal direction of the chamber).

Does anyone know how I can take cross-sectional slices of the chamber along the polyline? Doing it by hand is practically unfeasible given the large number of slices that I would have to take.

I’m relatively new to Paraview. I tried to wrap my head around how to fix this issue, but with no success. Your help would therefore be very much appreciated!!

I can’t think of how to do this with the SliceAlongPolyLine filter. Another way to do what you want is to just do all of your steps with one slice. Then make a trace of this procedure. Edit the python to slice and find average values in a loop. Run this with pvbatch

This sounds similar to what I am doing here: Create ImageData - ParaView Support - ParaView

In my case, I converted the dataset to ImageData (using Resample to Image filter), and then I used a Programmable Filter to integrate the data longitudinally. It would be simple to do an average instead, and doing it over slices would just mean integrating twice. The biggest challenge is creating the VTK object afterward.

I also developed a (more computationally expensive) technique for computing averages in curvilinear coordinates, which may be of interest: Evaluating Symmetry in 3-dimensional Simulation Data (Technical Report) | OSTI.GOV. Perhaps you can give us more details on what you’re trying to do?

@wascott ,

I’ve tried to modify the Python trace to loop over the slicing process to create slices with the desired offset prescribed by the TableToPoint filter. Unfortunately, I get the following Type Error when loading the trace into Paraview:

TypeError: SetElement argument 2:

This is the first time I’m touching Paraview’s Python trace, so I’m not sure what exactly is going wrong? For reference, attached you can find the Python trace that I modified (Combustor_Slicing). I looped over the slicing by defining a dictionary containing all the slices, not sure whether that’s the problem. Any feedback is highly welcome.

@woodscn ,

In short, I’m trying to slice the cross-section of a cylindrical combustion chamber (post injectors) at prescribed x-locations (where the x-axis runs longitudinal to the chamber). And then extract area-averaged parameters, such as Mach number, from each slice, so to then interpolate this averaged flow field longitudinally and use it as input for a CAA simulation.

Combustor_Slicing.py (8.9 KB)

Luca,
I have no idea. However, let me make a suggestion that should make it easier. Create your script in steps, rather than one big hit. Do one slice. Then modify the python to allow an offset to the slice. Run this. Then, call this python as many times as you like. An example is in the tutorials, in ParaView, at Help/ Classroom Tutorials/ PvPython and PvBatch. Basically, call your “pvbatch yourPython.py” lots of times from a script.

That’s very similar to what I was doing in my discourse link above. In your case, you are averaging over planar slices, in my case I am summing over linear traces. It’s almost the exact same sort of operation. I’ve attached a state file that gets you part of the way there. You should view the Programmable Filter as Point Gaussian (or just Spreadsheet view). I also can’t make any guarantees about its accuracy; you should look over the algorithm and convince yourself of that, before you trust it.
Planar averaging.pvsm (444.7 KB)