Create a "how to create a filter" procedure
Cory created a Perlin Noise filter a few years ago. When I asked how he figured it out and the steps he used, he gave me the following steps. I think these should be added to the ParaView Reference Manual, along with other tips. At least this is a good start! From Cory:
Here's roughly how I figured it out:
- check that there is a VTK class named vtkPerlinNoise. There is! Hmm, but it's not a filter.
- check if there is a VTK class that produces Perline noise on a grid. Nope, nothing else named Perlin.
- look at vtkPerlinNoise again. Hmm, it's a vtkImplicitFunction subclass. That means it is used in a context where points in a dataset are passed to it, and something is done with the resulting value. What other filters exposed in ParaView do something similar? The Clip filter is one. So now I have a model of how to do this.
- What is a filter that takes a vtkImplicitFunction and evaluates it at all points in a VTK dataset? Anything with the name Implicit in it? Indeed! vtkSampleImplicitFunctionFilter.
- Start creating the XML needed for vtkSampleImplicitFunctionFilter. There are not many options in this class, so that is pretty simple.
- Last part - how do I create a vtkPerlinNoise object and get it to the vtkSampleImplicitFunctionFilter? Look to the "Clip" filter. It has a ProxyProperty called ClipFunction. A ProxyProperty is a property that takes another ParaView proxy - in this case, we want it to take a proxy object representing a vtkPerlinNoise object. Using the example of "Clip", we can tell the Clip proxy that its ClipFunction property can be one of the proxies in a list of proxies representing implicit functions. Now I know I have to do the same for the vtkSampleImplicitFunctionFilter proxy, but I need only provide one implicit function, the Perlin noise function.
- Before I can tell the vtkSampleImplicitFunctionFilter proxy about the Perlin noise implicit function, I have to write some XML to describe it. I look for the "Cylinder" implicit function to use as a model and find it in misc_utilities.xml. Here I see that I need to describe properties of the implicit function. In the case of Perlin noise, there are just a couple to expose. Plus, I need to make sure the XML for the Perlin noise function is in the right ProxyGroup - in this case that group is "implicit_functions". It could be anything, really - it just has to match what I put in the XML for the vtkSampleImplicitFunctionFilter proxy.
- Now I am ready to define the property in the vtkSampleImplicitFunctionFilter proxy that is the Perlin noise source. I once again use the "Clip" filter as my model and see that I need to list the Perlin noise proxy in the group of possible proxies for this property.
- Yadda yadda yadda, I've got an XML filter.
So you see, it wasn't that easy. At least, it wouldn't be very easy to write up. On the other hand, including it as an example on the plugins HOWTO isn't far-fetched. People who learn by pattern matching (like me) will be able to use it as a basis for some XML plugins.