[vtkusers] How to save STL file

Chao Wang buaawangchao at gmail.com
Thu Mar 8 18:26:07 EST 2012


Hey gus,

I am new to VTK, and trying to conver a OBJ file to a STL file. I tried the
following code section, but it didn't work. It did created a STL file, but
with nothing inside, only 1KB. Any help and direction would be appreciated.

Thanks.

   vtkSmartPointer<vtkOBJReader> readerOBJ =
vtkSmartPointer<vtkOBJReader>::New();
   readerOBJ->SetFileName(filename.c_str());
   readerOBJ->Update();

  vtkSmartPointer<vtkSTLWriter> stlWriter =
vtkSmartPointer<vtkSTLWriter>::New();
  stlWriter->SetFileName("Bobcat.stl");
  stlWriter->SetInputConnection(readerOBJ->GetOutputPort());
  stlWriter->Write();

-- 
Chao Wang
Graduate Research Assistant
The Durham School of Architectural Engineering and Construction
University of Nebraska - Lincoln
The Peter Kiewit Institute
1110 S. 67th Street 118A
Omaha, NE 68182-0571
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120308/38eebe50/attachment.htm>


More information about the vtkusers mailing list