RuledSurfaceFilter using vtkmodules

I’ve gotten stuck trying to use the RuledSurfaceFilter inside one of my python plugins.

I have been writing standalone code using import vtk based on this example:
RuledSurfaceFilter.py (2.5 KB). This works great.

Now, I’m trying to create a python plugin that does something similar. However, since I’m using vtkmodules, I don’t have access to all the same classes that come with vtk, but when I try to import vtk, paraview crashes. For example, I have an array of vtkPolyLineSource() created inside my class like this

    def compute_orbits(self):
        self.orbits = []
        y0 = self.initial_conditions()
        for i in range(self.N):
            self.orbits.append(vtkPolyLineSource())

            y, t = self.integrate(y0[i]) # integrates an ODE with initial conditions y0[i]
            n = y.shape[1]
            self.orbits[i].SetNumberOfPoints(n)

            for j in range(n):
                self.orbits[i].SetPoint(j,y[0,j],y[1,j],y[2,j])

            self.orbits[i].Update()

Later, I try to create a vtkRuledSurfaceFilter() object like this

self.surface = vtkRuledSurfaceFilter()
for i in range(len(self.orbits)):
    self.surface.SetInputData(self.orbits[i].GetOutput())

But when I try to generate an output in the RequestData function, I get nothing

output = vtkMultiBlockDataSet.GetData(outInfo, 0)
output.SetBlock(0,self.surface.GetOutput())

Any tips here for working with vtkPolyLineSource() instead of vtkPolyLine()?

I’m running Paraview 5.8.0 on Ubuntu 20.04

I got something working, although it’s a bit unwieldy.

    def compute_orbits(self):
        self.surface = vtkRuledSurfaceFilter()


        points = vtkPoints()
        lines = vtkCellArray()

        self.orbits = []
        y0 = self.initial_conditions()
        
        Ntot = 0
        for i in range(self.N):
            self.orbits.append(vtkPolyLineSource())
            line = vtkPolyLine()

            y, t = self.integrate(y0[i])
            n = y.shape[1]

            self.orbits[i].SetNumberOfPoints(n)
            line.GetPointIds().SetNumberOfIds(n)

            for j in range(n):
                self.orbits[i].SetPoint(j,y[0,j],y[1,j],y[2,j])
                points.InsertPoint(Ntot,y[0,j],y[1,j],y[2,j])

                line.GetPointIds().SetId(j,Ntot)

                Ntot += 1

            self.orbits[i].Update()

        polydata = vtkPolyData()
        polydata.SetPoints(points)
        polydata.SetLines(lines)
        self.surface.SetInputData(polydata)
        self.surface.SetResolution(n, n)
        self.surface.Update()

I compute trajectories for each initial condition and put them into two different objects: self.orbits, which is an array of vtkPolyLineSource() and self.surface, which is a `vtkRuledSurfaceFilter()’.

in the RequestData function I add the filter to the output like this.

def RequestData(self, request, inInfo, outInfo):
        from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet
        output = vtkMultiBlockDataSet.GetData(outInfo, 0)
        output.SetBlock(0,self.surface.GetOutput())