[Paraview] Programmable Filter Help

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon Oct 21 07:26:01 EDT 2013


Hello,

For the programmable filter, there's a property named "Output Data Set
Type" that you can set using the Properties panel. By default it;s set
to "Same as Input". Look at your script, it looks like your input
dataset is multiblock dataset, comprising of multiple blocks. If you
let the output be "Same as Input", the output will also be a
multiblock dataset. Your script iterares over blocks in the input, but
is missing the logic to locate the corresponding block in the output
and operate on it. GetNumberOfPoints/GetPoints etc are available on
the individual datasets contained in a multiblock dataset and not the
multiblock dataset itself.

Try the following instead:

def process_block(input_block, output_block):
    print input_block.GetClassName(), output_block.GetClassName()
   #  ****** DO YOUR OPERATIONS HERE *****


inputDS = inputs[0]
outputDS = output

# outputDS already has the same structure as input.
iterator = iter(inputDS)
while not iterator.IsDoneWithTraversal():
    process_block(iterator.GetCurrentDataObject(),
                         outputDS.GetDataSet(iterator.Iterator))
    iterator.GoToNextItem()
del iterator


Utkarsh

On Wed, Oct 16, 2013 at 12:50 PM,  <dconklin at neo.rr.com> wrote:
> Hello
>
> I'm trying to put together a Programmable filter that will add arrays of deformed and undeformed coordinates and undeformed angles to my PointData in 4.0.1
>
> From all the examples online, I think either of these examples should work but neither does.   Any hints
> First, I am copying arrays in the PF, so I should be able to manipulate either input or output, but neither works
> It is also a composite (Exodus dataset)
>
> First version - error is can't find output.Points
>
> import math
>
> def process_block(block):
>    displ=block.PointData['DISPL']
>    # Coords of Points are locked into individual Point structures
>    # Assume Displacements applied (Points are deformed)
>    numPts=output.GetNumberOfPoints()
> #   for i in range(numPts):
> #      #x_coords[i], y_coords[i], z_coords[i] = output.GetPoint(i)
>
>    x_coords=output.Points[:,0]
>    y_coords=output.Points[:,1]
>    z_coords=output.Points[:,2]
>    x_undef=x_coords-displ[:,0]
>    y_undef=y_coords-displ[:,1]
>    z_undef=z_coords-displ[:,2]
>    # Undeformed scalar Coordinates
>    block.PointData.append(x_undef,"X_undef")
>    block.PointData.append(y_undef,"Y_undef")
>    block.PointData.append(z_undef,"Z_undef")
>    # Deformed scalar Coordinates
>    block.PointData.append(x_coords,"X_def")
>    block.PointData.append(y_coords,"Y_def")
>    block.PointData.append(z_coords,"Z_def")
>    # Calc angles (no atan2 in vtk)
>    Angles_undef=math.atan2(z_undef,x_undef)
>    block.PointData.append(Angles_undef,"Angle_undef")
>
> for block in output:
>    process_block(block)
>
> For second version I comment out x_coords=output.Points[;0] and use
> #   for i in range(numPts):
> #      #x_coords[i], y_coords[i], z_coords[i] = output.GetPoint(i)
>
> This error is can't find output.GetPoint
>
> Both of these are used in examples online of Programmable Filter, so what am I missing?
> I have substituted input for output above and no change.
> Also, output.GetNumberOfPoints works, so why doesn't output.GetPoints work?
>
> Also, I don't understand what object I should examine to find all the member functions within Input and Output within the Programmable Filter
>
> Thanks
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview


More information about the ParaView mailing list