Here, I will apply it on the blow.vtk dataset that you can find in ParaView Examples, or in the archive available at the top of the topic. For this, open ParaView and click on Tools / Manage Plugins. To use our freshly created plugin in ParaView, we have to import it. Simply add the following before the return. Using numpy interface, it’s easy to add tables to the output. The last thing needed to make it work is adding the logic in the RequestData method. The second parameter is the actual value we want to pass to the Python View, in this case the number of bins of an histogram. It can be useful to expose it though in order to allow quick modification in the Python View script. The first one is optional, it’s the name of the array we will create to pass our parameters to the Python View. Now, we have two parameters we can modify inside ParaView. Let’s add the necessary to make them editable from ParaView before to explain their use. But for now, they don’t appear in ParaView. You can see that I added two parameters that we will want to manipulate when applying this filter. Here we are declaring a simple filter that takes a vtkDataSet and returns the exact same input. Output = dsa.WrapDataObject(self.GetOutputData(outInfo, 0)) Input = dsa.WrapDataObject(vtkDataSet.GetData(inInfo)) Return super().RequestDataObject(request, inInfo, outInfo)ĭef RequestData(self, request, inInfo, outInfo): OutInfo.GetInformationObject(0).Set(outData.DATA_OBJECT(), outData) If outData is None or (not outData.IsA(inData.GetClassName())): Super()._init_(nInputPorts=1, nOutputPorts=1, inputType="vtkDataSet", outputType="vtkDataSet")ĭef RequestDataObject(self, request, inInfo, outInfo): from import *įrom vtkmodules.numpy_interface import dataset_adapter as dsaįrom vtkmodules.vtkCommonDataModel import composite_data_supported=False)Ĭlass PythonViewHelperFilter(VTKPythonAlgorithmBase): For this, go ahead and create a new Python file declaring a new filter Python Filter with its base structure. What you will want to do to add parameters to your Python View is to first create a Python Plugin that you will load in ParaView to get your custom Python Filter. Python_view_scripting.zip (72.8 KB) Python Plugin Creating the Python Filter You may find the full example with the data below. In this example, we will manipulate the number of bins of an histogram from our Python View. This is an example of how to customize dynamically your Python View by adding parameters in ParaView linked to your Python View through the use of a custom Python Plugin (adding a Python Filter).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |