Seg fault while using VTK Smoother

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Seg fault while using VTK Smoother

chytu
Hi,

I am trying to use the VTK Smoother in trunk (#2612) to smooth a polygon mesh (generated using gp3 algorithm from tutorials). I use the following code to do so:

    pcl::surface::VTKSmoother *vtkSmoother = new pcl::surface::VTKSmoother();
    vtkSmoother->convertToVTK(mesh);
    vtkSmoother->smoothMeshWindowedSinc();
    vtkSmoother->convertToPCL(mesh);
    delete vtkSmoother;

I get a segmentation fault while running this code just after the "delete" line. Since there are no example usages in the "test" directory or in the documentation, I was wondering if the error was due to my wrong usage of VTKSmoother. Can you please tell me the right usage or any insights into what the problem could be?

Thanks,
Chytu.
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault while using VTK Smoother

Radu B. Rusu
Administrator
Chytu,

Is there a reason why you create a regular pointer and then try to delete it? Does this code work for you?


pcl::surface::VTKSmoother vtkSmoother;
vtkSmoother.convertToVTK(mesh);
vtkSmoother.smoothMeshWindowedSinc();
vtkSmoother.convertToPCL(mesh);

Cheers,
Radu.
--
Point Cloud Library (PCL) - http://pointclouds.org

On 09/29/2011 11:24 AM, chytu wrote:

> Hi,
>
> I am trying to use the VTK Smoother in trunk (#2612) to smooth a polygon
> mesh (generated using gp3 algorithm from tutorials). I use the following
> code to do so:
>
>      pcl::surface::VTKSmoother *vtkSmoother = new
> pcl::surface::VTKSmoother();
>      vtkSmoother->convertToVTK(mesh);
>      vtkSmoother->smoothMeshWindowedSinc();
>      vtkSmoother->convertToPCL(mesh);
>      delete vtkSmoother;
>
> I get a segmentation fault while running this code just after the "delete"
> line. Since there are no example usages in the "test" directory or in the
> documentation, I was wondering if the error was due to my wrong usage of
> VTKSmoother. Can you please tell me the right usage or any insights into
> what the problem could be?
>
> Thanks,
> Chytu.
>
> --
> View this message in context: http://www.pcl-users.org/Seg-fault-while-using-VTK-Smoother-tp3380114p3380114.html
> Sent from the Point Cloud Library (PCL) Users mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault while using VTK Smoother

chytu
Hi Radu,

I tried using both the regular pointer and the normal declaration. Both of them give seg fault in the destructor of VTK Smoother (which gets called when I call "delete" or when moving out of scope).

Actually, both the codes works as expected. I tried saving the mesh after the line
          vtkSmoother.convertToPCL(mesh);
and it works perfectly (I get a smoothed mesh saved into a .vtk file). But the problem of segmentation fault when moving out of scope is still there. I tried putting some random (harmless) code after the VTKSmoother part and observed that seg fault occurs everytime when moving out of the scope of the function in which VTK Smoother is called.

Is there any test code to check the working/usage for VTK smoother?

Thanks,
Chytu.

Reply | Threaded
Open this post in threaded view
|

Re: Seg fault while using VTK Smoother

chytu
Hi,

I think I figured out what the problem is. I read in VTK Tutorial that Delete() should not be called explicitly for VTK smart pointers. So, I commented out the vtk_polygons_->Delete () call in the VTK smoother's destructor and the seg fault is gone.

The fix is removing the explicit Delete() call in the ~VTKSmoother() function in vtk_smoother.cpp

Thanks for the help...

-Chytu.