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="&#xA;#This is intended as the script of a 'Programmable Filter'&#xA;# Uses vtkImageData&#xA;import math&#xA;from vtk import *&#xA;&#xA;# Get io handles&#xA;inData = self.GetInputDataObject(0,0)&#xA;output = self.GetOutputDataObject(0)&#xA;&#xA;# Get/compute Bounds&#xA;gridBounds = [X_min, X_max, Y_min, Y_max, Z_min, Z_max]&#xA;# Compute number of cells&#xA;numCells = [int(ceil((gridBounds[1]-gridBounds[0])/dx)), int(ceil((gridBounds[3]-gridBounds[2])/dx)), int(ceil((gridBounds[5]-gridBounds[4])/dx))]&#xA;totalCells = numCells[0]*numCells[1]*numCells[2]&#xA;# Recompute upperbounds for even divisions&#xA;gridBounds[1] = gridBounds[0]+dx*numCells[0]&#xA;gridBounds[3] = gridBounds[2]+dx*numCells[1]&#xA;gridBounds[5] = gridBounds[4]+dx*numCells[2]&#xA;&#xA;# Get pointdata&#xA;pointData = inData.GetPointData()&#xA;&#xA;# Query number of particles&#xA;noPoint = inData.GetNumberOfPoints()&#xA;&#xA;# Initialise a hashtable for the grid&#xA;gridHash=[]&#xA;numPointsInCell=[]&#xA;for i in range(totalCells):&#xA;    gridHash.append([])&#xA;    numPointsInCell.append(0)&#xA;&#xA;# Hash the points into the table&#xA;maxPointsInCell = 0;&#xA;for i in range(noPoint):&#xA;    # Get this points coords&#xA;    coord = inData.GetPoint(i)&#xA;    x, y, z = coord[:3]&#xA;    # Hash coords to a grid coords&#xA;    idx = divmod(x-gridBounds[0],dx)[0]&#xA;    idy = divmod(y-gridBounds[2],dx)[0]&#xA;    idz = divmod(z-gridBounds[4],dx)[0]&#xA;    # Compute linear index from ijk index&#xA;    gridID = int(idx + idy*numCells[0] + idz*numCells[0]*numCells[1])&#xA;    # Add this particle index to the corresponding grid element&#xA;    gridHash[gridID].append(i)&#xA;    # Track max and quantity of particles in each cell&#xA;    numPointsInCell[gridID] = numPointsInCell[gridID] + 1&#xA;    if numPointsInCell[gridID] &gt; maxPointsInCell:&#xA;        maxPointsInCell = numPointsInCell[gridID]&#xA;&#xA;# Compute cell SVF&#xA;svf=[]&#xA;for i in range(totalCells):&#xA;    svf.append(float(numPointsInCell[i]))&#xA;&#xA;# Create and configure a VTK Grid&#xA;grid = vtkImageData()&#xA;grid.SetOrigin(gridBounds[0], gridBounds[2], gridBounds[4])&#xA;grid.SetSpacing(dx, dx, dx)&#xA;grid.SetDimensions(numCells[0]+1, numCells[1]+1, numCells[2]+1) # number of points in each direction&#xA;&#xA;# Begin Data Mapping&#xA;# query number of arrays&#xA;numArrays = pointData.GetNumberOfArrays();&#xA;&#xA;# Declare Arrays&#xA;dataArrays = []&#xA;for i in range(numArrays):&#xA;    dataArrays.append(vtkDoubleArray())&#xA;&#xA;# Loop over particle arrays and map to grid arrays with simple average&#xA;for i in range(numArrays):&#xA;    # Get particle array&#xA;    currArray = pointData.GetArray(i)&#xA;    # Get number of components per array entry (vtk limits: 1,2,3,4, or 9)&#xA;    numComponents = currArray.GetNumberOfComponents()&#xA;    # Get particle array array config and set grid array config&#xA;    dataArrays[i].SetNumberOfComponents(numComponents)&#xA;    dataArrays[i].SetNumberOfTuples(totalCells)&#xA;    dataArrays[i].SetName(currArray.GetName())&#xA;    # Loop over cells&#xA;    for cell in range(totalCells):&#xA;        numParts = numPointsInCell[cell]&#xA;        # Create temporary cell data array, length = number of components (vtk limits: 1,2,3,4, or 9)&#xA;        cellData = [0]*numComponents&#xA;        if numParts &gt; 0:&#xA;            # Loop over particles contained in this cell&#xA;            for part in range(numParts):&#xA;                # Get the particle data for this particle&#xA;                partData = currArray.GetTuple(gridHash[cell][part])&#xA;                # Add this particle data to the average in this cell (componentwise)&#xA;                for component in range(numComponents):&#xA;                    cellData[component] = cellData[component]+partData[component]&#xA;            # Divide running total with number of particles to finish average        &#xA;            for component in range(numComponents):&#xA;                cellData[component] = cellData[component]/numParts&#xA;        # Add this tuple (vector) to the vtk array&#xA;        dataArrays[i].SetTuple(cell,cellData)&#xA;    # Attach this array of grid data to the vtk grid&#xA;    grid.GetCellData().AddArray(dataArrays[i])&#xA;&#xA;# Finally add an array indicating the quantity of particles in each cell to the grid&#xA;array = vtkDoubleArray()&#xA;array.SetNumberOfComponents(1) # this is 3 for a vector&#xA;array.SetNumberOfTuples(grid.GetNumberOfCells())&#xA;for i in range(grid.GetNumberOfCells()):&#xA;        array.SetValue(i, svf[i])&#xA;&#xA;grid.GetCellData().AddArray(array)&#xA;array.SetName(&quot;Number of Particles&quot;)&#xA;&#xA;# Copy the grid we created to paraviews output object&#xA;output.ShallowCopy(grid);&#xA;&#xA;#Tell paraview about the output object&#xA;&#xA;&#xA;print 'Number of SPH points: %d' % noPoint&#xA;"
        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&#xA;gridBounds = [X_min, X_max, Y_min, Y_max, Z_min, Z_max]&#xA;# Compute number of cells&#xA;numCells = [int(ceil((gridBounds[1]-gridBounds[0])/dx)), int(ceil((gridBounds[3]-gridBounds[2])/dx)), int(ceil((gridBounds[5]-gridBounds[4])/dx))]&#xA;&#xA;executive = self.GetExecutive()&#xA;outInfo = executive.GetOutputInformation(0)&#xA;&#xA;outInfo.Set(executive.WHOLE_EXTENT(), 0, numCells[0], 0, numCells[1], 0, numCells[2])&#xA;outInfo.Set(vtk.vtkDataObject.SPACING() , dx, dx, dx)&#xA;"
        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

Reply via email to