当前位置:网站首页>VTK example -- three intersecting planes

VTK example -- three intersecting planes

2022-06-11 00:11:00 Black mountain old demon's blog

VTK note - Graphics related - Plane -vtkPlaneSource_ Heishan old demon's blog -CSDN Blog _vtkplanevtkPlaneSource Create a quadrilateral array in a plane vtkPlaneSource Create a quadrilateral m x n Array , These quadrangles are arranged as regular tiles in the plane . The plane is defined by specifying an origin , Then specify the other two points that define the two axes of the plane together with the origin . These axes need not be orthogonal - So you can create a parallelogram ( Axes cannot be parallel .) The resolution of the plane ( That is, the number of subdivisions ) from ivars X Resolution and Y Resolution control . By default , The plane is centered at the origin and perpendicular to z Axis , The length of width and height is 1, The resolution is set to 1. There are three convenient ways to move your plane easily . first SetNorhttps://blog.csdn.net/liushao1031177/article/details/117110232        In the previous example , You can draw a plane ; Now use vtkPlaneSource Draw three intersecting planes ;

vtkNew<vtkPlaneSource> planeSource_xy;
planeSource_xy->SetOrigin(-1, -1, 0.0);
planeSource_xy->SetPoint1(1, -1, 0);
planeSource_xy->SetPoint2(-1, 1, 0);
planeSource_xy->Update();

vtkNew<vtkPolyDataMapper> planeMapper_xy;
planeMapper_xy->SetInputConnection(planeSource_xy->GetOutputPort());
vtkNew<vtkActor> planeActor_xy;
planeActor_xy->SetMapper(planeMapper_xy);
planeActor_xy->GetProperty()->SetColor(0, 255, 0);

vtkNew<vtkPlaneSource> planeSource_yz;
planeSource_yz->SetOrigin(0.0, -1, -1);
planeSource_yz->SetPoint1(0, 1, -1);
planeSource_yz->SetPoint2(0, -1, 1);
planeSource_yz->Update();

vtkNew<vtkPolyDataMapper> planeMapper_yz;
planeMapper_yz->SetInputConnection(planeSource_yz->GetOutputPort());
vtkNew<vtkActor> planeActor_yz;
planeActor_yz->SetMapper(planeMapper_yz);

vtkNew<vtkPlaneSource> planeSource_xz;
planeSource_xz->SetOrigin(-1, 0, -1);
planeSource_xz->SetPoint1(1, 0, -1);
planeSource_xz->SetPoint2(-1, 0, 1);
planeSource_xz->Update();

vtkNew<vtkPolyDataMapper> planeMapper_xz;
planeMapper_xz->SetInputConnection(planeSource_xz->GetOutputPort());
vtkNew<vtkActor> planeActor_xz;
planeActor_xz->SetMapper(planeMapper_xz);
planeActor_xz->GetProperty()->SetColor(255, 0, 0);

vtkNew<vtkRenderer> renderer;
renderer->AddActor(planeActor_xy);
renderer->AddActor(planeActor_yz);
renderer->AddActor(planeActor_xz);

vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("PlaneSourceDemo");
renderWindow->SetSize(640, 480);

vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow);
renderWindow->Render();
renderer->GetActiveCamera()->SetPosition(1, 0, 0);
renderer->GetActiveCamera()->SetFocalPoint(0, 1, 0);
renderer->GetActiveCamera()->SetViewUp(0, 0, 1);
renderer->GetActiveCamera()->Azimuth(30);
renderer->GetActiveCamera()->Elevation(30);
renderer->ResetCamera();
renderWindow->Render();
interactor->Start();

 

  Rotate the red plane , Around the z Shaft rotation 45°;

planeActor_xz->RotateWXYZ(45, 0, 0, 1);

  Red plane rewind (1,1,0) Direction rotation 45° and 90°;(1,1,0) The direction is after the initial rotation , The intersection of the red plane and the green plane ; rotate 90° after , The red plane intersects the green plane ;

 

 

原网站

版权声明
本文为[Black mountain old demon's blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206102254058022.html