[Paraview] XY plotting via filter extending vtkRectilinearGridAlgorithm, resulting plot always empty

Christine Corbett Moran corbett at physik.uzh.ch
Mon Oct 5 15:38:50 EDT 2009


Hi Utkarsh,

Yes that works but I actually want to do more complicated things than
just plot the data values, so first am doing something simple to make
sure I have the plotting setup for the filter correct.

Cheers,
Christine

On Mon, Oct 5, 2009 at 9:34 PM, Utkarsh Ayachit
<utkarsh.ayachit at kitware.com> wrote:
> Since you simply want to plot the data_values from your rectilinear
> grid, try applying the "Plot Data" filter instead. Does that work?
>
> Utkarsh
>
> On Mon, Oct 5, 2009 at 3:30 PM, Christine Corbett Moran
> <corbett at physik.uzh.ch> wrote:
>> Hi,
>>
>> I want to begin adding some non-trivial 2d plotting capabilities to my
>> ParaView plugin; in that interest I've implemented a filter which is
>> derived from vtkRectilinearGridAlgorithm. For now, I am trying only a
>> simple example, where my X coordinates are the particle ids, my Y and
>> Z coordinates are dummy arrays with one element, and my data is the id
>> to the power 2. When I act my filter, the XY plot view and a new 3D
>> view appear. However the XY plot is empty, as is the 3D view. I can
>> get something to appear in the 3D view by adding a glyph to the
>> pipeline (and the result makes sense), but nothing I do seems to get
>> it the XY plot view to actually plot.
>>
>> I have included the RequestData portion of my filter at the end of the
>> message as well as the information tab of the object inspector of the
>> filter. Everything looks normal to me (except I am not sure why the
>> number of cells is less than the number of points?). Can anyone see
>> the problem? Is there something more I need to do? I've already done a
>> lot of searching of the archives, playing around with the parameters,
>> and reading the vtk documentation but haven't found the bug or the
>> missing call.
>>
>> The information tab of the object inspector displays:
>> Type: Rectilinear Grid
>> Number of Cells: 1000
>> Number of Points: 1001
>> Data Arrays:
>> Name  | Data Type | Data Ranges
>> data values | int | [0,1e+06]
>> Extents
>> X Extent: 0 to 1000 (dimension: 1001)
>> Y Extent: 0 to 0 (dimension: 1)
>> Z Extent: 0 to 0 (dimension: 1)
>> Bounds
>> X range: 0 to 1e+03
>> Y range: 0 to 0
>> Z range 0 to 0
>>
>> And my request data method is:
>> //----------------------------------------------------------------------------
>> int vtkMassFunctionFilter::RequestData(vtkInformation*,
>>                                vtkInformationVector** inputVector,
>>                                vtkInformationVector* outputVector)
>>  {
>>  // Get input and output data.
>>  vtkPointSet* input = vtkPointSet::GetData(inputVector[0]);
>>  vtkRectilinearGrid* output = vtkRectilinearGrid::GetData(outputVector);
>>  // Setting the dimensions of this to be equal to our number of points,
>>  // in X, and equal to 1 in the Y and Z directions,
>>  // as these are dummy arrays.
>>  output->SetDimensions(input->GetPoints()->GetNumberOfPoints(),1,1);
>>   output->SetWholeExtent(0,input->GetPoints()->GetNumberOfPoints(),\
>>                                           0,0,\
>>                                           0,0);
>>  // Allocate the arrays for the X,Y, and Z coordinates, and inserts a
>>  // single value for the dummy arrays, as well as allocate the array
>>  // for the scalar data
>>  vtkSmartPointer<vtkDoubleArray> XArray=vtkSmartPointer<vtkDoubleArray>::New();
>>   XArray->SetNumberOfComponents(1);
>>   XArray->SetNumberOfTuples(input->GetPoints()->GetNumberOfPoints());
>>  vtkSmartPointer<vtkDoubleArray>
>> DummyYArray=vtkSmartPointer<vtkDoubleArray>::New();
>>   DummyYArray->SetNumberOfComponents(1);
>>   DummyYArray->SetNumberOfTuples(1);
>>   DummyYArray->InsertValue(0,0);
>>  vtkSmartPointer<vtkDoubleArray>
>> DummyZArray=vtkSmartPointer<vtkDoubleArray>::New();
>>   DummyZArray->SetNumberOfComponents(1);
>>   DummyZArray->SetNumberOfTuples(1);
>>   DummyZArray->InsertValue(0,0);
>>  vtkSmartPointer<vtkIntArray> dataValues=vtkSmartPointer<vtkIntArray>::New();
>>   dataValues->SetNumberOfComponents(1);
>>   dataValues->SetNumberOfTuples(input->GetPoints()->GetNumberOfPoints());
>>   dataValues->SetName("data values");
>>  for(int nextPointId = 0;\
>>      nextPointId < input->GetPoints()->GetNumberOfPoints();\
>>       ++nextPointId)
>>   {
>>   XArray->InsertValue(nextPointId,nextPointId);
>>   dataValues->InsertValue(nextPointId,pow(nextPointId,2));
>>   }
>>  // Updating the output
>>  output->SetXCoordinates(XArray);
>>  output->SetYCoordinates(DummyYArray);
>>  output->SetZCoordinates(DummyZArray);
>>  output->GetPointData()->SetScalars(dataValues);
>>  return 1;
>>  }
>> _______________________________________________
>> 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