默认是mm
#include <vtkSmartPointer.h>
#include <vtkSTLWriter.h>
#include <vtkPolyData.h>
#include <vtkTransform.h>
void saveSTLFile(vtkPolyData* polyData, const char* fileName)
{
// 将VTK对象转换为毫米
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->Scale(0.001, 0.001, 0.001);
vtkSmartPointer<vtkTransformPolyDataFilter> filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
filter->SetInputData(polyData);
filter->SetTransform(transform);
filter->Update();
// 写入STL文件
vtkSmartPointer<vtkSTLWriter> writer = vtkSmartPointer<vtkSTLWriter>::New();
writer->SetFileName(fileName);
writer->SetInputData(filter->GetOutput());
writer->Write();
}