I have a custom filter and I have been trying to add logging, but can’t make it work, Paraview GUI keeps crashing and I have no idea why.
I have tried something like
import vtk
import math
import numpy as np
import numpy.linalg as la
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from vtkmodules.vtkCommonDataModel import vtkDataSet
from paraview.util.vtkAlgorithm import smproxy, smproperty
from vtk.numpy_interface import algorithms as algs
from vtk.numpy_interface import dataset_adapter as dsa
import logging
logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.warning('This will get logged to a file')
@smproxy.filter(label="Custom Markers Filter")
@smproperty.input(name="Input")
class CustomMarkersFilter(VTKPythonAlgorithmBase):
def __init__(self):
VTKPythonAlgorithmBase.__init__(self)
def RequestData(self, request, inInfo, outInfo):
logging.info('Requesting Data')
inp = vtkDataSet.GetData(inInfo[0])
dsaInp = dsa.WrapDataObject(inp)
points = dsaInp.GetPoints()
centers = identify_markers(points)
M1_, M2_, M3_ = centers
print("M1': " + str(M1_))
print("M2': " + str(M2_))
print("M3': " + str(M3_))
# Create vtkPoints from markers centers
pts = vtk.vtkPoints()
for p in centers:
pts.InsertNextPoint(p)
opt = vtkDataSet.GetData(outInfo)
dsaOpt = dsa.WrapDataObject(opt)
opt.SetPoints(pts)
numPts = pts.GetNumberOfPoints()
ptIds = vtk.vtkIdList()
ptIds.SetNumberOfIds(numPts)
for a in range(numPts):
ptIds.SetId(a, a)
dsaOpt.Allocate(1)
dsaOpt.InsertNextCell(vtk.VTK_POLY_VERTEX, ptIds)
return 1
I have also tried to initialize inside the class without success either.
Is there any way to get feedback even when the app crash?