[vtkusers] abnormal chart using scatter points
Marcus D. Hanwell
marcus.hanwell at kitware.com
Tue Apr 5 11:50:27 EDT 2011
There was significant refactoring of the code in vtkPlotPoints in master,
and what will very soon be VTK 5.8.0. I am not aware of any current issues
that would affect a plot containing the number of points you specified, and
I have certainly plotted larger datasets in ParaView using these charts.
There will be no more VTK 5.6 releases, and I would recommend you take a
look at VTK 5.8, or the release branch (which will be 5.8 soon).
Marcus
2011/4/1 Eric E. Monson <emonson at cs.duke.edu>
> Here's a screen shot of the result of your exact code compiled against the
> VTK development head from about a week ago.
>
> -Eric
>
>
> On Apr 1, 2011, at 4:03 AM, liuxy wrote:
>
> ^_^ thank you all the same, can you show this code ¡®s correct result used
> POINTS in your computer?
>
>
>
>
> ÔÚ 2011Äê4ÔÂ1ÈÕ ÉÏÎç1:56£¬Eric E. Monson <emonson at cs.duke.edu>дµÀ£º
>
>> Hello,
>>
>> I really think this might just be a bug in VTK 5.6.1. As I said before,
>> there has been a lot of development on the Charts API between 5.6 and now.
>> Your code works fine for me with the VTK development head, and I don't have
>> a 5.6 build lying around to test it on. I'm not sure why a LINE plot
>> wouldn't have trouble with it, but POINTS does ¨C vtkPlotLine is a pretty
>> bare-bones subclass of vtkPlotPoints.
>>
>> So, I think your only options are to either pull the development version
>> and build from the git repository, or wait for a little while for 5.8 to be
>> released. (That should be very soon, but I haven't heard a fixed date.)
>>
>> Sorry I couldn't be more help,
>> -Eric
>>
>>
>> On Mar 31, 2011, at 8:23 AM, liuxy wrote:
>>
>> Thank you for your help!!
>>
>> The version of VTK I used is 5.6.1, and compile the source code with
>> Cmake2.8 and VS 2008, the code of drawing scatter points more than 40,000
>> is that :
>>
>> #include <vtkSmartPointer.h>
>> #include <vtkChartXY.h>
>> #include <vtkContextScene.h>
>> #include <vtkContextView.h>
>> #include <vtkFloatArray.h>
>> #include <vtkShortArray.h>
>> #include <vtkPlotPoints.h>
>> #include <vtkRenderWindow.h>
>> #include <vtkRenderWindowInteractor.h>
>> #include <vtkRenderer.h>
>> #include <vtkTable.h>
>> #include <vtkAxis.h>
>>
>> int main(int, char*[])
>> {
>> // Set up a 2D scene, add an XY chart to it
>> vtkSmartPointer<vtkContextView> view =
>> vtkSmartPointer<vtkContextView>::New();
>> vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
>> view->GetScene()->AddItem(chart);
>> chart->SetShowLegend(true);
>>
>> // Create a table with some points in it...
>> vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
>>
>> // float Êý×é
>> vtkSmartPointer<vtkFloatArray> arrX
>> =vtkSmartPointer<vtkFloatArray>::New();
>> arrX->SetName("X Axis");
>> table->AddColumn(arrX);
>> vtkSmartPointer<vtkFloatArray> arrC =
>> vtkSmartPointer<vtkFloatArray>::New();
>> arrC->SetName("sin");
>> table->AddColumn(arrC);
>>
>> // amount of scatter points
>> int numPoints =40000;
>>
>> float inc = 7.5 / (numPoints-1);
>> table->SetNumberOfRows(numPoints);
>> for (int i = 0; i < numPoints; ++i){
>> table->SetValue(i, 0, i * inc);
>> table->SetValue(i,1, sin(i * inc));
>> }
>>
>> // Add multiple scatter plots, setting the colors etc
>> vtkPlot *points = chart->AddPlot(vtkChart::POINTS);
>> points->SetInput(table, 0, 1);
>> points->SetColor(0, 0, 255, 255);
>> points->SetWidth(2.0);
>>
>> //Finally render the scene
>> view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
>> view->GetRenderWindow()->SetSize(1024, 600);
>> view->GetInteractor()->Initialize();
>> view->GetInteractor()->Start();
>> return EXIT_SUCCESS;
>> }
>>
>>
>> and the run effect is like 4000error.jpg, if I replace vtkChart::POINTS
>> to vtkChart::LINE ,the result is right, why ?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2011/3/28 Eric E. Monson <emonson at cs.duke.edu>
>>
>>> Hello,
>>>
>>> Which version of VTK are you using? I've definitely drawn scatter plots
>>> using the Charts API that had more than 40,000 points, and this is something
>>> the Charts are supposed to be good at, so it will be interesting to see what
>>> has gone wrong in your case. The VTK version is important because a lot of
>>> development has gone on in the Charts since 5.6, so if you're using 5.6 the
>>> bug may already have been fixed.
>>>
>>> Otherwise, if you're using the development head and this is still
>>> happening, maybe you can pass along a minimal piece of code that
>>> demonstrates the problem and we can help figure out what's going on.
>>>
>>> Talk to you later,
>>> -Eric
>>>
>>> ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤ ¡¤
>>> Eric E Monson
>>> Duke Visualization Technology Group
>>>
>>>
>>> On Mar 28, 2011, at 1:43 AM, liuxy wrote:
>>>
>>> > I used vtkChart API to draw a line: y=sin(x) using "scatter points",
>>> >
>>> > the chart is abnormal when the number of points are more than 40,000.
>>> >
>>> > just like pictrue a.jpg in enclosure.
>>> >
>>> > but if the points are less than 40,000 or using "Line" to draw
>>> y=sin(x),
>>> >
>>> > the chart is correct. Just like pictrue b.jpg.
>>> >
>>> > I want to know how to use "scatter points" in drawing charts with huge
>>> scale of points ?
>>> >
>>> > or vtkChart may be not applicable in this situation ?
>>> >
>>> >
>>> > P.S:
>>> >
>>> > By reading the source Code of vtkChart,
>>> >
>>> > I found when drawing in "scatter points",
>>> >
>>> > it used function 'DrawPointSprites'.
>>> >
>>> > if replaced it with function 'DrawPoints',the chart shows correctly,
>>> >
>>> > even number of points more than 40,000.
>>> > <a.JPG><b.JPG>_______________________________________________
>>> > 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
>>>
>>>
>> <40000error.JPG>
>>
>>
>>
>
>
> _______________________________________________
> 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/20110405/a9646d68/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 25335 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110405/a9646d68/attachment.png>
More information about the vtkusers
mailing list