[vtkusers] How to move the Point Cloud Data to vtkRenderWindow?

kgg124 kgg124 at naver.com
Tue Apr 23 23:47:32 EDT 2019


Hi all!

I have a 3D Scanner product and can get Point Cloud data by using it.

And I have succeeded in moving the Point Cloud data to OpenCV Viz3d.

Now, I'm trying to test with vtkRenderWindow.

My code is as below :

vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

int column;
for (int row = 0; row < h; ++row)
{
    //The stPCD is my structure that includes x,y,z points data.
    //imageRawData is buffer address.
    pcd = reinterpret_cast<stPCD*>(imageRawData); 
    for (column = 0; column < w; ++column)
    {
        if (!isnan((*pcd).z))
        {
            points->InsertNextPoint(pcd->x, pcd->y, pcd->z);
        }

        ++pcd;
    }
    imageRawData += line;
}

vtkSmartPointer<vtkPolyData> pPolyData =
vtkSmartPointer<vtkPolyData>::New();
pPolyData->SetPoints(points);

vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(pPolyData);
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(.1, .2, .3);
renderer->ResetCamera();

m_vtkWindow->AddRenderer(renderer);
m_vtkWindow->Render();


But it doesn't work.

Could you please give me an advise or link, sample code?

Thank you :)




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


More information about the vtkusers mailing list