[vtkusers] Segmentation fault when trying to export a vtk mesh
Luc Valade
lucj.valade at gmail.com
Thu May 21 03:34:31 EDT 2015
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150521/89aa4c03/attachment.html>
More information about the vtkusers
mailing list