[Paraview] Coloring isocontour by the coordinates outputted from a Transform filter and some other questions

Cory Quammen cory.quammen at kitware.com
Mon Jul 10 09:27:26 EDT 2017


Shuhao,

If you don't want to use the Programmable Filter, which is actually
pretty powerful and gives you access to just about all filters in VTK
(at least those that are compiled for ParaView), then your second-best
bet for what you want to do is to create a custom VTK filter and
include that as a ParaView plugin. The documentation for ParaView
plugins [1] should get you pretty far. Note that it is usually
necessary to compile ParaView first and then build your plugin against
that local ParaView build so that the compiler and ParaView build
options match between your ParaView executable and your plugin.

As for writing a custom VTK filter, often the best guide for writing a
VTK filter is looking at other existing VTK filters, especially those
that do things similar to what you want to do. It may take some
digging and questions on the mailing list, but that's actually a
fairly reasonable way to proceed. Kitware also offers courses on
demand if you want to get up to speed in a day or so.

Hope that helps,
Cory

[1] https://www.paraview.org/Wiki/ParaView/Plugin_HowTo

On Sun, Jul 9, 2017 at 11:40 PM, Shuhao Wu <shuhao at shuhaowu.com> wrote:
> Hello Cory,
>
> Thanks for the advice. I will give this a shot. Are there also
> documentations to create custom filters? Not just ProgrammableFilters, but
> full on filters in something like a .py file (or any other language) that
> can be easily reused?
>
> This will allow me to perform the transformation, expose the coordinates,
> and perform the clipping operations all in one step, which in theory should
> reduce the computational time and memory required as there would not be
> excessive amount copying between each stage of the pipeline.
>
> I am only asking this because my dataset consists of ~30million nodes each
> time step and paraview runs somewhat slowly on my computer, taking about
> 30-70s to process a single timestamp in order to generate an image.
>
> Thanks,
> Shuhao
>
>
> On 07/09/2017 09:11 PM, Cory Quammen wrote:
>>
>> Shuhao,
>>
>> Unfortunately, the tooltips for the clip function parameters do not
>> appear to be working (I filed bug
>> https://gitlab.kitware.com/paraview/paraview/issues/17593 describing
>> the problem).
>>
>> It turns out the properties for the Box clip type are defined in a way
>> that is a bit trickier than I thought. They are relative to the
>> bounding box of the input data:
>>
>> * Position - center of the box function relative to the center of the
>> input dataset bounding box
>> * Rotation - Eulerian angles about the X, Y, and Z axes describing the
>> rotation of the bounding box
>> * Scale - non-uniform scale factor applied in x, y, and z relative to
>> the input dataset bounding box
>>
>> Given how these items are defined, it will actually really be a pain
>> to compute the properties for an arbitrary x-, y-, and z-range.
>>
>> The way you described earlier with a cascade of Calculator and
>> Threshold filters will work. Another way would be to use a single
>> Python Calculator with the expression
>>
>> numpy.all((xmin <= inputs[0].Points[:,0], inputs[0].Points[:,0] <=
>> xmax, ymin <= inputs[0].Points[:,1], inputs[0].Points[:,1] <= ymax,
>> zmin <= inputs[0].Points[:,2], inputs[0].Points[:,2] <= zmax),
>> axis=0).astype('int')
>>
>> and then Threshold by the result, which will be 0 outside [xmin, xmax,
>> ymin, ymax, zmin, zmax] and 1 inside it.
>>
>> Thanks,
>> Cory
>>
>>
>>
>> On Fri, Jul 7, 2017 at 10:51 AM, Shuhao Wu <shuhao at shuhaowu.com> wrote:
>>>
>>> Is there documentation on how the Box clip type work? I'm not quite sure
>>> how
>>> to do the math to convert the threshold values to the position/scale
>>> values.
>>>
>>> Thanks,
>>> Shuhao
>>>
>>>
>>> On 2017-07-03 10:03 AM, Cory Quammen wrote:
>>>>
>>>>
>>>> On Tue, Jun 20, 2017 at 9:33 PM, Shuhao Wu <shuhao at shuhaowu.com> wrote:
>>>>
>>>>> Hello Cory,
>>>>>
>>>>> I've been playing around a little bit more and followed your suggestion
>>>>> with using the calculator to "expose" the transformed coordinates.
>>>>> However,
>>>>> my understanding is that this Calculator will duplicate the memory
>>>>> usage
>>>>> for that coordinate and be an additional step in the filtering process,
>>>>> slowing it down.
>>>>
>>>>
>>>>
>>>>
>>>> Yes, that's true unfortunately. By the way, if you need X, Y, and Z, you
>>>> can use one Calculator filter to produce all three with the expression
>>>>
>>>> iHat*coordsX + jHat*coordsY + kHat*coordsZ
>>>>
>>>> This produces a 3-component array - you can then color your isosurface
>>>> by
>>>> just one of the components or by the magnitude.
>>>>
>>>> I have to use the Calculator filter to expose all 3 coordinates before
>>>>>
>>>>>
>>>>> using a threshold to filter for only a subset region that I want to
>>>>> plt,
>>>>> which results in a filtering chain as follows:
>>>>>
>>>>> ExposeX (Calculator) -> ExposeY (Calculator) -> ExposeZ (Calculator) ->
>>>>> ThresholdX (Threshold) -> ThresholdY (Threshold) -> ThresholdZ
>>>>> (Threshold).
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>> This is 6 filters, which is very slow with my data set (>29M nodes in a
>>>>>
>>>>>
>>>>> rectlinear grid). Is there a way to speed this up?
>>>>>
>>>>>
>>>> You could instead use a Clip filter with Clip Type set to Box. You have
>>>> to
>>>> do a little math to convert from your threshold values to the box Scale
>>>> and
>>>> Position properties, but it shouldn't be too bad, and will make your
>>>> pipeline simpler and faster.
>>>>
>>>> Cory
>>>>
>>>>
>>>>> Thanks,
>>>>> Shuhao
>>>>>
>>>>>
>>>>> On 2017-06-07 03:29 PM, Cory Quammen wrote:
>>>>>
>>>>>> Shuhao,
>>>>>>
>>>>>> Welcome to ParaView!
>>>>>>
>>>>>> On Sun, Jun 4, 2017 at 6:33 PM, Shuhao Wu <shuhao at shuhaowu.com> wrote:
>>>>>>
>>>>>>> Hello all,
>>>>>>>
>>>>>>> Is there a way to color an isocontour via the coordinates outputted
>>>>>>> from
>>>>>>> a
>>>>>>> Transform filter? I'm using the Transform filter to "normalize" my
>>>>>>> coordinate systems and I want to display the isocontour colored by
>>>>>>> the
>>>>>>> normalized Y coordinates. Do I have to create yet another Calculator
>>>>>>> filter
>>>>>>> to recalculate the normalized Y value that is already calculated by
>>>>>>> the
>>>>>>> Transform filter?
>>>>>>>
>>>>>>
>>>>>> There is currently no direct way to color surfaces by coordinate
>>>>>> value. You can, however, add a Calculator after the Transform filter
>>>>>> and simply set the expression to coordsY - no recomputation of the
>>>>>> normalization is needed. This will copy your normalized Y coordinate
>>>>>> values to a new array named "Result", and you can then color the
>>>>>> isosurface by "Result". "Result" is just the default name - you can
>>>>>> change it however you wish.
>>>>>>
>>>>>> Also: is there a way to turn off one axis on the axis grid (so turn
>>>>>> off
>>>>>>>
>>>>>>>
>>>>>>> the
>>>>>>> Y axis display and leave only X and Z)?
>>>>>>>
>>>>>>
>>>>>> Click the Edit button next to the Axes Grid option. Click the gear
>>>>>> icon in the top right of the dialog that appears. Under Face
>>>>>> Properties, click on the "Faces to Render" combo box. Turn off the
>>>>>> sides you do not wish to see by selecting them in the combo box.
>>>>>>
>>>>>> What about changing the interval on
>>>>>>>
>>>>>>>
>>>>>>> the axis itself (instead of incrementing by 100 as it chooses,
>>>>>>> increment
>>>>>>> by
>>>>>>> 250).
>>>>>>>
>>>>>>
>>>>>> In the same dialog described above, check the "X Axis Use Custom
>>>>>> Labels", and you can specify exactly the labels you want. There is no
>>>>>> property to directly change the increment.
>>>>>>
>>>>>> Best,
>>>>>> Cory
>>>>>>
>>>>>> I'm pretty new to Paraview (coming from Tecplot). Please bear with me
>>>>>> as
>>>>>> I
>>>>>>>
>>>>>>>
>>>>>>> likely will have more question.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Shuhao
>>>>>>> _______________________________________________
>>>>>>> Powered by www.kitware.com
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at
>>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>>
>>>>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>>>>> http://paraview.org/Wiki/ParaView
>>>>>>>
>>>>>>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>> http://public.kitware.com/mailman/listinfo/paraview
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>
>>
>>
>



-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.


More information about the ParaView mailing list