[vtkusers] segfault during opening buggy OBJ file
kenichiro yoshimi
rccm.kyoshimi at gmail.com
Wed Aug 9 02:04:34 EDT 2017
Hi Mihail,
I guess one way to avoid crashes with a segmentation fault is to use
the vtkCleanPolyData.
-----
#include <vtkSmartPointer.h>
#include <vtkCleanPolyData.h>
#include <vtkOBJReader.h>
#include <vtkPolyData.h>
#include <vtkPolyDataNormals.h>
int main(int argc, char * argv[])
{
vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(argv[1]);
reader->Update();
vtkSmartPointer<vtkCleanPolyData> cleaner =
vtkSmartPointer<vtkCleanPolyData>::New();
cleaner->SetInputConnection(reader->GetOutputPort());
cleaner->Update();
vtkSmartPointer<vtkPolyDataNormals> normals =
vtkSmartPointer<vtkPolyDataNormals>::New();
normals->SetInputConnection(cleaner->GetOutputPort());
normals->Update();
return 0;
}
------
Thanks,
yoshimi
2017-08-09 0:00 GMT+09:00 Mihail Isakov via vtkusers <vtkusers at vtk.org>:
> Hello,
> how i could avoid segmentation fault during processing of buggy OBJ file?
> VTK version is 7.1.1, unfortunately VTK 8.0.0 is currently not an option for me,
> i have to support older compilers, so i have not tested VTK 8.0.0.
>
> -------------------------------------------------------------------
> #include <vtkSmartPointer.h>
> #include <vtkOBJReader.h>
> #include <vtkPolyData.h>
> #include <vtkPolyDataNormals.h>
>
> int main(int argc, char * argv[])
> {
> vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
> reader->SetFileName(argv[1]);
> reader->Update();
> vtkSmartPointer<vtkPolyDataNormals> normals =
> vtkSmartPointer<vtkPolyDataNormals>::New();
> normals->SetInputConnection(reader->GetOutputPort());
> normals->Update();
> return 0;
> }
> -------------------------------------------------------------------
>
> r at deb:~/test0/build$ ./test0 ../vhmale_1024_skel_tri_1_gf_1.obj
> Segmentation fault
>
> Crash is here: VTK-7.1.1/Common/DataModel/vtkCellLinks.h
>
> 193 inline void vtkCellLinks::InsertCellReference(vtkIdType ptId,
> 194 unsigned short pos,
> 195 vtkIdType cellId)
> 196 {
> 197 this->Array[ptId].cells[pos] = cellId; <------------------
> 198 }
>
> Min. project with OBJ file is here:
>
> https://drive.google.com/file/d/0ByBLJ2-U1t9xODZHeThSWnpkaEk/view?usp=sharing
>
>
> Important were just to avoid crash somehow...
> Thank you.
>
> Regards,
> Mihail
> _______________________________________________
> 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:
> http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list