Sure, XML is attached. It expects VTKPolyData and outputs VTKImageData
Cheers,
Bruce
On Mon Feb 02 2015 at 2:46:22 PM Utkarsh Ayachit <
[email protected]> wrote:
> Mind sharing the generated XML that you're trying to load? It will be
> easier to debug.
>
> On Mon, Feb 2, 2015 at 2:36 PM, Bruce Jones <[email protected]>
> wrote:
> > Hi,
> >
> > I'm writing a paraview plugin based on a python programmable filter. To
> do
> > this I'm using the excellent plugin generator described here,
> > http://www.kitware.com/blog/home/post/534
> >
> > I am trying to add a dropdown list to the plugin XML, as in here
> > http://www.paraview.org/Wiki/ParaView/Plugin_HowTo#Drop_down_list
> >
> > However including the example code, or the code I actually need, in the
> XML
> > causes paraview to crash when the filter is selected.
> >
> > Due to the way paraview is crashing, I can see the output messages but
> not
> > select or scroll. One line seems pertinent which is
> >
> > Incorrect message received. missing xml_group and xml_name information
> >
> > Any suggestions?
> >
> > Cheers,
> > Bruce
> >
> >
> >
> > _______________________________________________
> > 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
> >
>
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<SourceProxy name="GridFromSPH" class="vtkPythonProgrammableFilter" label="Grid From SPH">
<Documentation
long_help="Interpolates SPH field data to a structured grid"
short_help="Interpolates SPH field data to a structured grid">
</Documentation>
<InputProperty
name="Input"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkPolyData"/>
</DataTypeDomain>
</InputProperty>
<IntVectorProperty
name="Mapping_Type"
command="SetParameter"
number_of_elements="1"
default_values="1">
<EnumerationDomain name="enum">
<Entry value="1" text="Volume Average"/>
<Entry value="2" text="SPH Kernel"/>
</EnumerationDomain>
<Documentation>Switch mapping type between simple volume average of particles in cell, or SPH kernel intergation from cell centers. For SPH Kernel KappaH must be appropriatley set.</Documentation>
</IntVectorProperty>
<DoubleVectorProperty
name="X_max"
label="X max"
initial_string="X_max"
command="SetParameter"
animateable="1"
default_values="1.7"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="X_min"
label="X min"
initial_string="X_min"
command="SetParameter"
animateable="1"
default_values="0.0"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Y_max"
label="Y max"
initial_string="Y_max"
command="SetParameter"
animateable="1"
default_values="0.7"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Y_min"
label="Y min"
initial_string="Y_min"
command="SetParameter"
animateable="1"
default_values="0.0"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Z_max"
label="Z max"
initial_string="Z_max"
command="SetParameter"
animateable="1"
default_values="0.4"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Z_min"
label="Z min"
initial_string="Z_min"
command="SetParameter"
animateable="1"
default_values="0.0"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="dx"
label="dx"
initial_string="dx"
command="SetParameter"
animateable="1"
default_values="0.05"
number_of_elements="1">
<Documentation></Documentation>
</DoubleVectorProperty>
<!-- Output data type: "vtkImageData" -->
<IntVectorProperty command="SetOutputDataSetType"
default_values="6"
name="OutputDataSetType"
number_of_elements="1"
panel_visibility="never">
<Documentation>The value of this property determines the dataset type
for the output of the programmable filter.</Documentation>
</IntVectorProperty>
<StringVectorProperty
name="Script"
command="SetScript"
number_of_elements="1"
default_values="
#This is intended as the script of a 'Programmable Filter'
# Uses vtkImageData
import math
from vtk import *

# Get io handles
inData = self.GetInputDataObject(0,0)
output = self.GetOutputDataObject(0)

# Get/compute Bounds
gridBounds = [X_min, X_max, Y_min, Y_max, Z_min, Z_max]
# Compute number of cells
numCells = [int(ceil((gridBounds[1]-gridBounds[0])/dx)), int(ceil((gridBounds[3]-gridBounds[2])/dx)), int(ceil((gridBounds[5]-gridBounds[4])/dx))]
totalCells = numCells[0]*numCells[1]*numCells[2]
# Recompute upperbounds for even divisions
gridBounds[1] = gridBounds[0]+dx*numCells[0]
gridBounds[3] = gridBounds[2]+dx*numCells[1]
gridBounds[5] = gridBounds[4]+dx*numCells[2]

# Get pointdata
pointData = inData.GetPointData()

# Query number of particles
noPoint = inData.GetNumberOfPoints()

# Initialise a hashtable for the grid
gridHash=[]
numPointsInCell=[]
for i in range(totalCells):
 gridHash.append([])
 numPointsInCell.append(0)

# Hash the points into the table
maxPointsInCell = 0;
for i in range(noPoint):
 # Get this points coords
 coord = inData.GetPoint(i)
 x, y, z = coord[:3]
 # Hash coords to a grid coords
 idx = divmod(x-gridBounds[0],dx)[0]
 idy = divmod(y-gridBounds[2],dx)[0]
 idz = divmod(z-gridBounds[4],dx)[0]
 # Compute linear index from ijk index
 gridID = int(idx + idy*numCells[0] + idz*numCells[0]*numCells[1])
 # Add this particle index to the corresponding grid element
 gridHash[gridID].append(i)
 # Track max and quantity of particles in each cell
 numPointsInCell[gridID] = numPointsInCell[gridID] + 1
 if numPointsInCell[gridID] > maxPointsInCell:
 maxPointsInCell = numPointsInCell[gridID]

# Compute cell SVF
svf=[]
for i in range(totalCells):
 svf.append(float(numPointsInCell[i]))

# Create and configure a VTK Grid
grid = vtkImageData()
grid.SetOrigin(gridBounds[0], gridBounds[2], gridBounds[4])
grid.SetSpacing(dx, dx, dx)
grid.SetDimensions(numCells[0]+1, numCells[1]+1, numCells[2]+1) # number of points in each direction

# Begin Data Mapping
# query number of arrays
numArrays = pointData.GetNumberOfArrays();

# Declare Arrays
dataArrays = []
for i in range(numArrays):
 dataArrays.append(vtkDoubleArray())

# Loop over particle arrays and map to grid arrays with simple average
for i in range(numArrays):
 # Get particle array
 currArray = pointData.GetArray(i)
 # Get number of components per array entry (vtk limits: 1,2,3,4, or 9)
 numComponents = currArray.GetNumberOfComponents()
 # Get particle array array config and set grid array config
 dataArrays[i].SetNumberOfComponents(numComponents)
 dataArrays[i].SetNumberOfTuples(totalCells)
 dataArrays[i].SetName(currArray.GetName())
 # Loop over cells
 for cell in range(totalCells):
 numParts = numPointsInCell[cell]
 # Create temporary cell data array, length = number of components (vtk limits: 1,2,3,4, or 9)
 cellData = [0]*numComponents
 if numParts > 0:
 # Loop over particles contained in this cell
 for part in range(numParts):
 # Get the particle data for this particle
 partData = currArray.GetTuple(gridHash[cell][part])
 # Add this particle data to the average in this cell (componentwise)
 for component in range(numComponents):
 cellData[component] = cellData[component]+partData[component]
 # Divide running total with number of particles to finish average 
 for component in range(numComponents):
 cellData[component] = cellData[component]/numParts
 # Add this tuple (vector) to the vtk array
 dataArrays[i].SetTuple(cell,cellData)
 # Attach this array of grid data to the vtk grid
 grid.GetCellData().AddArray(dataArrays[i])

# Finally add an array indicating the quantity of particles in each cell to the grid
array = vtkDoubleArray()
array.SetNumberOfComponents(1) # this is 3 for a vector
array.SetNumberOfTuples(grid.GetNumberOfCells())
for i in range(grid.GetNumberOfCells()):
 array.SetValue(i, svf[i])

grid.GetCellData().AddArray(array)
array.SetName("Number of Particles")

# Copy the grid we created to paraviews output object
output.ShallowCopy(grid);

#Tell paraview about the output object


print 'Number of SPH points: %d' % noPoint
"
panel_visibility="advanced">
<Hints>
<Widget type="multi_line"/>
</Hints>
<Documentation>This property contains the text of a python program that
the programmable source runs.</Documentation>
</StringVectorProperty>
<StringVectorProperty
name="InformationScript"
label="RequestInformation Script"
command="SetInformationScript"
number_of_elements="1"
default_values="# Get/compute Bounds
gridBounds = [X_min, X_max, Y_min, Y_max, Z_min, Z_max]
# Compute number of cells
numCells = [int(ceil((gridBounds[1]-gridBounds[0])/dx)), int(ceil((gridBounds[3]-gridBounds[2])/dx)), int(ceil((gridBounds[5]-gridBounds[4])/dx))]

executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)

outInfo.Set(executive.WHOLE_EXTENT(), 0, numCells[0], 0, numCells[1], 0, numCells[2])
outInfo.Set(vtk.vtkDataObject.SPACING() , dx, dx, dx)
"
panel_visibility="advanced">
<Hints>
<Widget type="multi_line" />
</Hints>
<Documentation>This property is a python script that is executed during
the RequestInformation pipeline pass. Use this to provide information
such as WHOLE_EXTENT to the pipeline downstream.</Documentation>
</StringVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
_______________________________________________
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