-1

I want to filter a pressure by thresholding using python-vtk

    import vtk
    filename = "a.foam"

    reader = vtk.vtkOpenFOAMReader()
    reader.SetFileName(filename)
    reader.CreateCellToPointOn()
    reader.DecomposePolyhedraOn()
    reader.EnableAllCellArrays()
    reader.Update()

    tArray = vtk_to_numpy(reader.GetTimeValues())
    reader.UpdateTimeStep(tArray[-1]) 
    reader.Update()

    filter_threshold = vtk.vtkThreshold()
    filter_threshold.SetInputConnection(reader.GetOutputPort()) 

how should I select "pressure" on filter class ?

matsubara
  • 1
  • 2

1 Answers1

1

Use SetInputArrayToProcess method.

https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#a6bea16e1329609dbccce0ff8d2367484

Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33
  • Thanks It may be resolved """ filter_threshold = vtk.vtkThreshold() filter_threshold.SetInputConnection(reader.GetOutputPort()) filter_threshold.ThresholdByLower(1.0) filter_threshold.ThresholdByUpper(100.0) FIELD_ASSOCIATION_POINTS = 0 filter_threshold.SetInputArrayToProcess(0,0,0,FIELD_ASSOCIATION_POINTS,"alpha") filter_threshold.Update() """ – matsubara Apr 24 '20 at 12:13