[vtkusers] vtkProbeFilter and vtkPlot

Marc Ferland marc.ferland at gmail.com
Mon Jun 20 15:44:16 EDT 2011


Hi Eric,

I've set both X and Y axis to '0':

...
line->SetUseIndexForXSeries(true);
line->SetInput(mPath->toTable->GetOutput(), 0, 0);
...

But now it just crashes...

Here's the relevant part of the stack:

#6  0x00007ffff24c70ce in std::__throw_logic_error(char const*) () from
/usr/lib/libstdc++.so.6
#7  0x00007ffff2eeedab in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_S_construct<char const*> (__beg=0x0,
    __end=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>,
__a=...) at /usr/include/c++/4.4/bits/basic_string.tcc:134
#8  0x00007ffff2501e32 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string(char const*, std::allocator<char>
const&) () from /usr/lib/libstdc++.so.6
#9  0x00007ffff6ce24d2 in vtkStdString::vtkStdString (this=0x7fffffffdd00,
s=0x0) at /home/marc/tmp/vtk/VTK/Common/vtkStdString.h:54
#10 0x00007ffff6d17488 in vtkPlot::SetInput (this=0xd07b00, table=0xcf7370,
xColumn=0, yColumn=0)
    at /home/marc/tmp/vtk/VTK/Charts/vtkPlot.cxx:372
#11 0x0000000000411883 in AmplitudeView::buildRenderingPath
(this=0x7fffffffdf00)
    at /home/marc/g3/vtk/ut/dojo/vtk/demoview/amplitudeview.cpp:89
#12 0x000000000041266f in main (argc=3, argv=0x7fffffffe0f8) at
/home/marc/g3/vtk/ut/dojo/vtk/demoview/demo.cpp:74

The string allocator throws a logic error...?!

What I'm trying to achieve is something similar to this test:
http://vtk.org/gitweb?p=VTK.git;a=blob;f=Widgets/Testing/Cxx/TestSplineWidget.cxx

but by using the chart API which seems to be the new "preferred" way of
plotting data.

Regards,

Marc


On Mon, Jun 20, 2011 at 2:36 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110620/02a8e1b0/attachment.htm>


More information about the vtkusers mailing list