[vtkusers] vtkChartXY: line looks coarser as the number of plot points increases

sdobashi dobashisuguru at gmail.com
Thu Apr 25 03:52:55 EDT 2019


Hello, VTK users

I have trouble regarding vtkChartXY.

A line becomes coarser as the number of plot points increases (for example,
from 100 to 1000000).
I attached the images to illustrate this behavior, as well as the cord
example.
I used VTK 8.2.0, build with -DVTK_RENDERING_BACKEND:STRING="OpenGL2"
option.

I want to prevent the line looks coarse even when the number of plot points
grows like 1000000.
Is there a way to achieve this?

I would appreciate any help.
Thank you in advance.

Here is the code:

#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
#include <vtkSmartPointer.h>
#include <vtkChartXY.h>
#include <vtkTable.h>
#include <vtkPlot.h>
#include <vtkFloatArray.h>
#include <vtkContextView.h>
#include <vtkContextScene.h>

int main(int, char**)
{
    auto table = vtkSmartPointer<vtkTable>::New();

    auto arrX = vtkSmartPointer<vtkFloatArray>::New();
    arrX->SetName("X Axis");
    table->AddColumn(arrX);

    auto arrC = vtkSmartPointer<vtkFloatArray>::New();
    arrC->SetName("Cosine");
    table->AddColumn(arrC);

    //const auto numPoints = 100; // OK
    const auto numPoints = 1000000; // NG (looks coarse)

    const float inc = 3.14 / numPoints;
    table->SetNumberOfRows(numPoints);
    for (auto i = 0; i < numPoints; ++i) {
        table->SetValue(i, 0, i * inc);
        table->SetValue(i, 1, cos(i * inc));
    }

    auto view = vtkSmartPointer<vtkContextView>::New();
    view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
    view->GetRenderWindow()->SetSize(800, 600);

    auto chart = vtkSmartPointer<vtkChartXY>::New();
    view->GetScene()->AddItem(chart);
    auto line = chart->AddPlot(vtkChart::LINE);
    line->SetInputData(table, 0, 1);
    line->SetColor(255, 0, 0, 255);
    line->SetWidth(10.0);

    view->GetRenderWindow()->Render();
    view->GetInteractor()->Initialize();
    view->GetInteractor()->Start();
}

<http://vtk.1045678.n5.nabble.com/file/t342304/OK_numPoints_100.png> 
<http://vtk.1045678.n5.nabble.com/file/t342304/NG_numPoints_1000000.png> 




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list