【VTK】绘制Bounding Box

网友投稿 686 2022-08-27

【VTK】绘制Bounding Box

【VTK】绘制Bounding Box

参考文章​​【vtk】some-press-key-operations-for-default-renderwindowiterator​​ ,我们可以通过按下w切换到wireframe mode,按下s键切换到surfaces mode.

但是这并不是我们要求的bounding box,要画出bounding box,可以这样:

#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;int main(){ vtkSmartPointer cone = vtkSmartPointer::New(); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInputConnection( cone->GetOutputPort() ); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper( mapper ); // --------------------- start to draw bounding box ------------------------ vtkSmartPointer normals = vtkSmartPointer::New(); normals->SetInputConnection( cone->GetOutputPort() ); vtkSmartPointer outlineFilter = vtkSmartPointer::New(); outlineFilter->SetInputConnection( normals->GetOutputPort() ); vtkSmartPointer outLinemapper = vtkSmartPointer::New(); outLinemapper->SetInputConnection( outlineFilter->GetOutputPort() ); vtkSmartPointer outlineActor = vtkSmartPointer::New(); outlineActor->SetMapper( outLinemapper ); outlineActor->GetProperty()->SetColor( 1,1,1 ); // --------------------- Drawing bounding box end------------------------ vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->AddActor( actor ); renderer->AddActor( outlineActor ); renderer->SetBackground( 0, 0, 0 ); vtkSmartPointer renderWindow = vtkSmartPointer::New(); renderWindow->AddRenderer( renderer ); vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New(); renderWindowInteractor->SetRenderWindow( renderWindow ); renderer->ResetCamera(); renderWindow->Render(); renderWindowInteractor->Start(); return 0;}

获取bounds的(x, y, z)数据

double *vtkActor::GetBounds();

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:learn vtk by Python script on mac
下一篇:【VTK】vtkTextActor位置设置问题
相关文章

 发表评论

暂时没有评论,来抢沙发吧~