Created
February 9, 2015 20:26
-
-
Save hrobeers/110db0a7d4e1a1c907c7 to your computer and use it in GitHub Desktop.
WriteStlToString
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the polyData object to write | |
vtkSmartPointer<vtkPolyData> polydata = polyData(); | |
vtkSmartPointer<vtkSTLWriter> stlWriter = | |
vtkSmartPointer<vtkSTLWriter>::New(); | |
#if VTK_MAJOR_VERSION <= 5 | |
stlWriter->SetInput(polydata); | |
#else | |
stlWriter->SetInputData(polydata); | |
#endif | |
// Set writer options | |
stlWriter->SetFileTypeToBinary(); | |
stlWriter->WriteToOutputStringOn(); | |
// Write the file | |
stlWriter->Write(); | |
char* output = stlWriter->GetOutputString(); | |
int outLen = stlWriter->GetOutputStringLength(); | |
return QByteArray(output, outLen); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't understand that output==nullptr and outLen==0
while writing the same polydata object to a file works like a charm.