我加载了一个网格(带颜色)并希望将其写入 .ply 文件并存储 rgb 信息。我目前有下面的代码,它使用vtkPLYWriter
类,但这只是保存顶点而不是 RGB 信息。有没有内置的方法来做到这一点?
代码
vtkSmartPointer<vtkTransformPolyDataFilter> rotate_and_save_mesh(vtkSmartPointer<vtkPLYReader> mesh_reader, double rotation_angle, double x, double y, double z,
std::string& out_name, bool should_write = true){
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->RotateWXYZ(rotation_angle, x, y, z);
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter->SetTransform(transform);
transformFilter->SetInputConnection(mesh_reader->GetOutputPort());
transformFilter->Update();
if(should_write){
vtkSmartPointer<vtkPLYWriter> writer = vtkSmartPointer<vtkPLYWriter>::New();
writer->SetInputConnection(transformFilter->GetOutputPort());
writer->SetFileName(out_name.c_str());
writer->Write();
}
return transformFilter;
}