How to move the Point Cloud Data to vtkRenderWindow?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to move the Point Cloud Data to vtkRenderWindow?

kgg124
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
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers