[vtkusers] vtkProbeFilter and vtkPlot

Eric E. Monson emonson at cs.duke.edu
Mon Jun 20 14:36:01 EDT 2011


Hey Marc,

I think you need to set the indices of the X and Y columns in your plot's SetInput() call: e.g. line->SetInput(mPath->toTable->GetOutput(), 0, 1);

It does look like vtkPlot has a plain SetInput(table) method which gets inherited by vtkPlotPoints and Line, but I get the same errors as you do when I try to set the input to the plot as just a table without specifying the indices. 

If you're using the index as X, then it just won't use the column you pass in as X (you can just give it the Y column index twice, if you want).

Hope this helps,
-Eric

· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Eric E Monson
Duke Visualization Technology Group


On Jun 20, 2011, at 11:09 AM, Marc Ferland wrote:

> Hi,
> 
> I'm currently trying to plot the output of a vtkProbeFilter with the new chart API using a vtkDataObjectToTable filter and I'm having difficulties getting a vtkTable that will be accepted by the plotter. I get errors like:
> 
> ERROR: In /home/marc/tmp/vtk/VTK/Filtering/vtkAlgorithm.cxx, line 460
> vtkContextMapper2D (0xd0d630): Attempt to get an input array for an index that has not been specified
> 
> ERROR: In /home/marc/tmp/vtk/VTK/Charts/vtkPlotPoints.cxx, line 600
> vtkPlotLine (0xcf9ca0): No Y column is set (index 1).
> 
> ERROR: In /home/marc/tmp/vtk/VTK/Filtering/vtkAlgorithm.cxx, line 460
> vtkContextMapper2D (0xd0d630): Attempt to get an input array for an index that has not been specified
> ....
> 
> The code looks like this: 
> // Convert the polydata to a vtkTable using points data
> mPath->toTable = vtkDataObjectToTable::New();
> mPath->toTable->SetInputConnection(mProbeFilter->GetOutputPort());
> mPath->toTable->SetFieldType(vtkDataObjectToTable::POINT_DATA);
> mPath->toTable->Update();
> 
> // Test
> vtkTable *table = mPath->toTable->GetOutput();
> qDebug() << table->GetNumberOfColumns(); // returns 2
> qDebug() << table->GetNumberOfRows();    // returns 6
> qDebug() << table->GetValue(0, 0).GetTypeAsString(); // returns: "short"
> qDebug() << table->GetValue(0, 1).GetTypeAsString(); // returns: "char" <-- weird?!
>    
> mPath->view = vtkContextView::New();
> mPath->view->GetRenderer()->SetBackground(0.5, 0.5, 0.5);
>    
> mPath->chartxy = vtkChartXY::New();
> mPath->view->GetScene()->AddItem(mPath->chartxy);
> vtkPlot* line = mPath->chartxy->AddPlot(vtkChart::LINE);
> line->SetUseIndexForXSeries(true);
> line->SetInput(mPath->toTable->GetOutput());
> line->SetColor(0.0, 255, 0.0, 255);
> line->SetWidth(1.0);
> 
> FYI: The old XYPlot actor was working correctly with the same probe filter input.
> 
> So my question is: What am I doing wrong here? Also, is there an example somewhere showing how to correctly use a vtkProbeFilter and the new charting API?
> 
> Regards,
> 
> Marc
> _______________________________________________
> 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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list