Hi all,
I tried to follow the guide and create a simple filter using vtkQuadricDecimation. However, I keep getting the paraview crashing and could not figure out why (I did select an input before applying this filter). Could anyone please help?
from vtkmodules.vtkCommonDataModel import vtkDataSet
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from vtkmodules.numpy_interface import dataset_adapter as dsa
import vtkmodules
from paraview.util.vtkAlgorithm import smproxy, smproperty, smdomain
@smproxy.filter(label="Quadratic Decimation Filter")
@smproperty.input(name="PolyDataInput", port_index=0)
@smdomain.datatype(dataTypes=["vtkPolyData"])
class QuadricDecimationFilter(VTKPythonAlgorithmBase):
def __init__(self):
VTKPythonAlgorithmBase.__init__(self, nInputPorts=1)
self._realAlgorithm = vtk.vtkQuadricDecimation()
def RequestData(self, request, inInfo, outInfo):
self.Update()
from vtkmodules.vtkCommonDataModel import vtkPolyData
mesh = vtkPolyData.GetData(inInfo[0])
self._realAlgorithm.SetInputData(mesh)
self._realAlgorithm.VolumePreservationOn()
self._realAlgorithm.Update()
output = vtkPolyData.GetData(outInfo, 0)
output.ShallowCopy(self._realAlgorithm.GetOutput())
@smproperty.doublevector(name="Reduction", default_values=0.5)
@smdomain.doublerange(min=0, max=1)
def SetReductionRatio(self, reduction):
self._realAlgorithm.SetTargetReduction(reduction)
self.Modified()
Thank you,
Shawn