在VTK中要显示文字,可以用一下几种方法。
1 vtkTextActor
vtkTextActor是一个可以直接用于表示文字的类,可以使用其SetInput()函数设定想要显示的文字,例如:
textActor->SetDisplayPosition(10, 10);
textActor->SetInput("3D Image");
textActor->GetTextProperty()->SetFontSize(18);
textActor->GetTextProperty()->SetColor(1, 0, 0);
renderer->AddActor(textActor);
2 vtkVectorText
关于使用这个类进行文字显示的具体实现,可见参考资料[1]。
3 vtkTextMapper
用法如下:
textMapper->SetInput("Hello World");
textMapper->GetTextProperty()->SetFontSize(24);
actor2D->SetMapper(textMapper);
renderer->AddActor(actor);
参考资料
[1]vtk三维文字显示的方法