Visualizing sets of boundary mesh points as lines

I have a csv file with 3 columns. The first and second columns are x,y coordinates of mesh boundary points. The third column is an integer that tells which boundary the point is a part of.
Here is an example file: boundaries.csv (2.4 KB)

I would like to visualize the boundaries as distinct lines. So far I have only gotten them to show as sets of differently colored points using the TableToPoints filter by activating the “2d” and “Keep All Data Arrays” options:

With a python script for the programmable filter from here: https://public.kitware.com/pipermail/paraview/2014-March/030781.html, I managed to add the black lines.
For completeness, the script is:

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)

I would like to have separate lines from the points for each boundary. Is that possible?

if not, is it possible to extract lines based on the boundary index?
I have tried with this script:

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

But I did not find a function to access the boundary index.

What do you mean by separate ?

Do you want to have a Cell by boundary ?

The programmable filter can simultaneously generate boundary ids as cell data with lines:

pdi = self.GetPolyDataInput()
pdo =  self.GetPolyDataOutput()
numPoints = pdi.GetNumberOfPoints()
pdo.Allocate()

pb = pdi.GetPointData().GetArray(' b')
cb = vtk.vtkIntArray()
cb.SetName('b')
cb.SetNumberOfComponents(1)
pdo.GetCellData().AddArray(cb)

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

  bid = pb.GetTuple1(i)
  cb.InsertNextTuple1(bid)

(I don’t take care of the duplicate lines.)

1 Like

Thx that was illuminating!

One thing I struggled with is finding documentation on the available python functions.
Is there a list somewhere?

Also the duplication of lines can be avoided with:

pdi = self.GetPolyDataInput()
pdo =  self.GetPolyDataOutput()
numPoints = pdi.GetNumberOfPoints()
pdo.Allocate()

pb = pdi.GetPointData().GetArray(' b')
cb = vtk.vtkIntArray()
cb.SetName('b')
cb.SetNumberOfComponents(1)
pdo.GetCellData().AddArray(cb)

for i in range(0, numPoints-1):
	bid = pb.GetTuple1(i)
	bidNext = pb.GetTuple1(i+1)
	if (bid == bidNext):
		points = [i, i+1]
		pdo.InsertNextCell(3, 2, points)
		cb.InsertNextTuple1(bid)