[Paraview] XY plotting via filter extending vtkRectilinearGridAlgorithm, resulting plot always empty
Christine Corbett Moran
corbett at physik.uzh.ch
Tue Oct 6 04:51:19 EDT 2009
Hi,
Thanks for your suggestion to use vtkTable/vtkTableAlgorithm instead,
it worked great. As a bonus, my new example filter is just a few lines
and it's much clearer.
The only problem I have now is that the XY plot only appears with a
bit more effort on the user's part. When I execute my vtkTable
producing filter, a 3D view appears (empty unless I add a glyph) and
an XY plot only appears after I add the "plot data" filter to the end
of the pipeline.
I would like a plot to appear in XY view to appear automatically after
the execution of my filter with my desired variables plotted, with my
desired axis labels (or, even better display multiple plots in the
comparative XY plot view automatically). Do I need to output something
other than vtkTable from my filter? Create a custom view? Or something
simpler?
Thanks,
Christine
On Mon, Oct 5, 2009 at 11:02 PM, Utkarsh Ayachit
<utkarsh.ayachit at kitware.com> wrote:
> Christine,
>
> You are referring to obsolete emails and hence the confusion :).
>
> In the current ParaView (3.6 onwards), the dataset that's used for
> plotting is vtkTable (not vtkRectilinearGrid). ParaView provides "Plot
> Data" filter which allows the user to plot any other dataset type i.e.
> plot the cell/point data arrays for any data type.
>
> "Plot Over Line" filter is a special filter that probes the cell/point
> values at the point locations along a sampling line and then plots the
> values obtained. Sorry, I misread your original email. I thought you
> were using the plot over line filter for the XY-Plot. Now I realize
> that you were just trying to show your vtkRecilinearGrid directly in
> the XY-Plot view. You didn't see anything since rectilinear grid is
> not plot-able by default, so you wouldn't have been able to turn on
> the visibility of the grid in the view as well (you have apply the
> "Plot Data" filter). There's no automatic plotting for
> vtkRectilinearGrid anymore.
>
> Hope that clears up some of the confusion.
>
> Utkarsh
>
> On Mon, Oct 5, 2009 at 4:44 PM, Christine Corbett Moran
> <corbett at physik.uzh.ch> wrote:
>> Ah, I didn't know that the automatic plotting of vtkRectilinear data
>> output from a filter was done with the "Plot over line" filter. So do
>> you know of a way to fix the problem? I had also tried a sample filter
>> with both x and y coordinate values, one with higher dimensions of the
>> dummy coordinate arrays, and neither of these things worked.
>>
>> There are a number of other messages of people trying to do this, and
>> some claiming to have succeeded with similar approaches
>> http://www.paraview.org/pipermail/paraview/2008-March/007491.html
>> http://www.paraview.org/pipermail/paraview/2008-April/007870.html
>> etc.
>>
>> Christine
>>
>> On Mon, Oct 5, 2009 at 10:28 PM, Utkarsh Ayachit
>> <utkarsh.ayachit at kitware.com> wrote:
>>> The "Plot Over Line" filter isn't working for your dataset since you
>>> are producing a data with 0 width and 0 height. So when it tries to
>>> probe with the line, it's failing since the points on the line never
>>> falls within any cells.
>>>
>>> Utkarsh
>>>
>>> On Mon, Oct 5, 2009 at 4:07 PM, Christine Corbett Moran
>>> <corbett at physik.uzh.ch> wrote:
>>>> By "plotting setup" I mean that I first want to make a filter which
>>>> plots X vs. Y for a very simple case, so that when I try to make the
>>>> filter do something more complicated I don't have to worry about basic
>>>> bugs/conceptual issues (e.g. if I have a wrong understanding about
>>>> structured extents or which algorithm to derive from to automatically
>>>> create a plot in the XY view of my desired variables after execution
>>>> of a filter).
>>>>
>>>> Thanks for the vtkTable idea, it does seem I may have the wrong idea
>>>> about which type of data to produce, I had read a number of posts on
>>>> the mailing list that said that the way to get ParaView to
>>>> automatically plot the results from a filter in the XY view was to
>>>> produce vtkRectilinearGrid. I will try vtkTable and see if it is
>>>> suitable. In the meantime if anyone can help with the
>>>> vtkRectilinearGrid simple XY plot example, it may come in handy if
>>>> vtkTable is not suitable, for others, or for the next time I work with
>>>> vtkRectilinearGrid.
>>>>
>>>> Cheers,
>>>> Christine
>>>>
>>>>
>>>> On Mon, Oct 5, 2009 at 9:53 PM, Utkarsh Ayachit
>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>> I am not sure what you mean by "plotting setup for the filter". Is
>>>>> this filter supposed to produce data that can plotted directly? In
>>>>> that case you might want to simply create a vtkTableAlgorithm
>>>>> subclassand produce vtkTable (instead of vtkRectilinearGrid) that has
>>>>> data rows/columns which can easily be plotted by ParaView. vtkTable is
>>>>> also easier to deal with since you don't have to worry about
>>>>> structured extents.
>>>>>
>>>>> Utkarsh
>>>>>
>>>>> On Mon, Oct 5, 2009 at 3:38 PM, Christine Corbett Moran
>>>>> <corbett at physik.uzh.ch> wrote:
>>>>>> 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