Segmentation fault when clearing the pcl visualizer using RemoveAllViewProps

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

Segmentation fault when clearing the pcl visualizer using RemoveAllViewProps

In my application I use vtkObjImporter class to import textured obj files into pcl visualizer. I need to clear the visualizer screen at different times.
vtk API RemoveAllViewProps causes a segmentation fault if I use a renderer created by pcl visualizer. But if I delete the default renderer created by pcl and create my own, there is no segmentation fault. But then, when I add new pcl polygons, they cannot be visualized. Why is that ?

My goal is to clear all the vtk actors in the render window and still be able to add new actors to it. Please help me do this.  

Sample Code to recreate segmentation fault  when using RemoveAllViewProps on pcl's default renderer

#include <pcl/common/common.h>
#include <pcl/io/obj_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <vtkRenderWindow.h>
#include <vtkNew.h>

int main(int argc, char** argv)

        boost::shared_ptr<pcl::visualization::PCLVisualizer> result_view(new pcl::visualization::PCLVisualizer("Viewer"));

        vtkSmartPointer<vtkRenderer> renderer= result_view->getRenderWindow()->GetRenderers()->GetFirstRenderer();


        return 0;

When I add this piece of code to delete the renderer and add my own, I am able to clear the screen but cannot add new pcl shapes like sphere

        vtkSmartPointer<vtkRendererCollection> rends =result_view->getRenderWindow()->GetRenderers();
        vtkSmartPointer<vtkRenderer> renderer =  vtkSmartPointer<vtkRenderer>::New();
        vtkSmartPointer<vtkRenderWindow> renderWindow = result_view->getRenderWindow();