[vtkusers] Segmentation fault when trying to export a vtk mesh

Cory Quammen cory.quammen at kitware.com
Thu May 21 09:26:37 EDT 2015


Luc,

Sorry, I didn't see that. I don't see anything else that is obvious. I
suggest compiling in debug mode and running it through a debugger to
see where it is crashing.

Cory

On Thu, May 21, 2015 at 8:09 AM, Luc Valade <lucj.valade at gmail.com> wrote:
> Hi Cory
>
> I already calls writer->SetFileName("test.vtp"). I also prints
> "writer->GetFileName()" into console to check, and there is no problem here.
>
> Luc
>
>
> 2015-05-21 13:48 GMT+02:00 Cory Quammen <cory.quammen at kitware.com>:
>>
>> You haven't called writer->SetFileName() to specify where the file
>> should be saved. That is necessary and may fix your crash - though
>> there should be a more graceful approach to handling an empty file
>> name than crashing, so that may not be it.
>>
>> HTH,
>> Cory
>>
>> On Thu, May 21, 2015 at 3:34 AM, Luc Valade <lucj.valade at gmail.com> wrote:
>> > Hi,
>> >
>> >
>> >
>> > I have a problem with the export of vtk meshes using vtkXMLWriter class.
>> > Indeed, my project builds without any problem, but during the run, the
>> > call
>> > of the vtkXMLWriter method Write() generates a segmentation fault.
>> >
>> >
>> >
>> > I works on Windows and uses qtcreator and qmake. I uses the version 6.2
>> > of
>> > vtk. I've already build tutorial vtk projects using qmake to learn how
>> > to
>> > well linked projects to vtk dlls, and it worked well.
>> >
>> >
>> >
>> > Here is the projet I tried to run without success (.pro and main.cpp
>> > file)
>> >
>> >
>> >
>> > TEMPLATE = app
>> >
>> >
>> >
>> > CONFIG += console
>> >
>> > CONFIG -= app_bundle
>> >
>> > CONFIG -= qt
>> >
>> >
>> >
>> > SOURCES += main.cpp
>> >
>> >
>> >
>> > INCLUDEPATH += "C:\Program Files (x86)\VTK\include\vtk-6.2"
>> >
>> > LIBS += "-LC:\Program Files (x86)\VTK\lib"
>> >
>> > LIBS += -lvtkCommonDataModel-6.2.dll \
>> >
>> >         -lvtkCommonCore-6.2.dll \
>> >
>> >         -lvtkIOXML-6.2.dll
>> >
>> >
>> >
>> >
>> >
>> > #include <vtkVersion.h>
>> >
>> > #include <vtkCellArray.h>
>> >
>> > #include <vtkPoints.h>
>> >
>> > #include <vtkXMLPolyDataWriter.h>
>> >
>> > #include <vtkPolyData.h>
>> >
>> > #include <vtkSmartPointer.h>
>> >
>> >
>> >
>> > int main ( int, char *[] )
>> >
>> > {
>> >
>> >   // Create 10 points.
>> >
>> >   vtkSmartPointer<vtkPoints> points =
>> >
>> >     vtkSmartPointer<vtkPoints>::New();
>> >
>> >
>> >
>> >   for ( unsigned int i = 0; i < 10; ++i )
>> >
>> >     {
>> >
>> >     points->InsertNextPoint ( i, i, i );
>> >
>> >     }
>> >
>> >
>> >
>> >   // Create a polydata object and add the points to it.
>> >
>> >   vtkSmartPointer<vtkPolyData> polydata =
>> >
>> >     vtkSmartPointer<vtkPolyData>::New();
>> >
>> >   polydata->SetPoints(points);
>> >
>> >
>> >
>> >   // Write the file
>> >
>> >   vtkSmartPointer<vtkXMLPolyDataWriter> writer =
>> >
>> >     vtkSmartPointer<vtkXMLPolyDataWriter>::New();
>> >
>> >   writer->SetFileName("test.vtp");
>> >
>> > #if VTK_MAJOR_VERSION <= 5
>> >
>> >   writer->SetInput(polydata);
>> >
>> > #else
>> >
>> >   writer->SetInputData(polydata);
>> >
>> > #endif
>> >
>> >
>> >
>> >   // Optional - set the mode. The default is binary.
>> >
>> >   //writer->SetDataModeToBinary();
>> >
>> >   //writer->SetDataModeToAscii();
>> >
>> >
>> >
>> >   writer->Write();
>> >
>> >
>> >
>> >   return EXIT_SUCCESS;
>> >
>> > }
>> >
>> >
>> > Thanks in advance for any help.
>> >
>> >
>> > _______________________________________________
>> > 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
>> >
>>
>>
>>
>> --
>> Cory Quammen
>> R&D Engineer
>> Kitware, Inc.
>
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.


More information about the vtkusers mailing list