Inconsistent Rendering

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

Inconsistent Rendering

meakcey
This post was updated on .
I am rendering point cloud on QVTKOpenGLWidget in Qt with the code below

void SceneWidget::renderCloud(pcl::PointCloud<pcl::PointNormal>::Ptr
p3cloud){

    vRenderer->Clear();
    vWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
    SetRenderWindow(vWindow);
    vRenderer = vtkSmartPointer<vtkRenderer>::New();
    vRenderer->SetBackground(0.1, 0.1, 0.1);
    GetRenderWindow()->AddRenderer(vRenderer);

    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkUnsignedCharArray> colors =
vtkSmartPointer<vtkUnsignedCharArray>::New();
    colors->SetNumberOfComponents(3);
    colors->SetName ("Colors");

    // Set point normals
    vtkSmartPointer<vtkDoubleArray> pointNormalsArray =
vtkSmartPointer<vtkDoubleArray>::New();
    pointNormalsArray->SetNumberOfComponents(3); //3d normals (ie x,y,z)
    pointNormalsArray->SetName("Normals");

    unsigned char tmpColor[3] = {200, 200, 100};
    for(unsigned int i=0; i<p3cloud->size(); i++){
        points->InsertNextPoint(p3cloud->points[i].x, p3cloud->points[i].y,
p3cloud->points[i].z);
        double pn[3] = {p3cloud->points[i].normal_x,
p3cloud->points[i].normal_y, p3cloud->points[i].normal_z};
        //pointNormalsArray->InsertNextTypedTuple(pn);
        colors->InsertNextTypedTuple(tmpColor);
    }

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

    vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
    vertexFilter->SetInputData(pointsPoly);
    vertexFilter->Update();

    vPointCloud = vtkSmartPointer<vtkPolyData>::New();
    vPointCloud->ShallowCopy(vertexFilter->GetOutput());
    vPointCloud->GetPointData()->SetScalars(colors);

    sceneMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    sceneMapper->SetInputData(vPointCloud);

    sceneActor = vtkSmartPointer<vtkActor>::New();
    sceneActor->SetMapper(sceneMapper);
    sceneActor->GetProperty()->SetPointSize(6);
    sceneActor->GetProperty()->EdgeVisibilityOff();

    vRenderer->AddActor(sceneActor);
    vRenderer->ResetCamera(sceneActor->GetBounds());

    glEnable( GL_POINT_SMOOTH );
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    //glPointSize( 5.0f );

    //renderVTK();
    this->GetRenderWindow()->Render();
}

I am always getting different result on the screen like attached in the
pictures

bad visualized
good visualized


Something like it does not render normals. And also, when it is visualized
bad, getting rotations very slow. I did not understand root cause of it and
so how to solve that.



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