当前位置:网站首页>VTK vtkplane and vtkcutter use
VTK vtkplane and vtkcutter use
2022-06-11 06:47:00 【mrbone11】
vtkPlane Inherited from vtkImplicitFunction abstract class , For face cutting ;vtkCutter Inherited from vtkPolyDataAlgorithm, Use specified implicit function cutting vtkDataSet
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkPlane.h"
#include "vtkCutter.h"
#include "vtkPointData.h"
#include "vtkProperty.h"
int main(int argc, char* argv[])
{
//
vtkSmartPointer<vtkRenderer> renderer = vtkRenderer::New();
vtkSmartPointer<vtkRenderWindow> renWind = vtkRenderWindow::New();
renWind->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWind);
/* A cone */
vtkSmartPointer<vtkConeSource> cone = vtkConeSource::New();
cone->SetHeight(3.0);
cone->SetRadius(1.0);
cone->SetResolution(10);
//mapper
vtkSmartPointer<vtkPolyDataMapper> coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection(cone->GetOutputPort());
//actor Set transparency for easy viewing cut effect
vtkSmartPointer<vtkActor> coneActor = vtkActor::New();
coneActor->SetMapper(coneMapper);
coneActor->GetProperty()->SetOpacity(0.5);
//
renderer->AddActor(coneActor);
/* vtkPlane cutting */
//vtkPlane Inherited from vtkImplicitFunction abstract class , For face cutting
vtkSmartPointer<vtkPlane> plane = vtkPlane::New();
plane->SetOrigin(cone->GetOutput()->GetCenter());
plane->SetNormal(1, -1, 1);// Just set a normal vector value
//vtkCutter Inherited from vtkPolyDataAlgorithm, Use specified implicit function cutting vtkDataSet
vtkSmartPointer<vtkCutter> planeCut = vtkCutter::New();
planeCut->SetInputConnection(cone->GetOutputPort());
planeCut->SetCutFunction(plane);
//mapper
vtkSmartPointer<vtkPolyDataMapper> cutMapper = vtkPolyDataMapper::New();
cutMapper->SetInputConnection(planeCut->GetOutputPort());
auto x = cone->GetOutput()->GetPointData();
//actor
vtkSmartPointer<vtkActor> planeActor = vtkActor::New();
planeActor->SetMapper(cutMapper);
double color[3] = {
1, 1, 0};
planeActor->GetProperty()->SetColor(color);
//
renderer->AddActor(planeActor);
// Show
renderer->SetBackground(0.2, 0.4, 0.6);
renWind->SetSize(400, 400);
renWind->Render();
iren->Start();
}
According to the effect :
边栏推荐
- SQL language - query statement
- AppClips&Tips(持续更新)
- Redux learning (I) -- the process of using Redux
- Handwriting promise [02] - asynchronous logic implementation
- Aircraft battle from scratch (III) flight between player aircraft and enemy aircraft
- []==![]
- Sentinel annotation support - @sentinelresource usage details
- Zabbix 监控主机是否在线
- client-go gin的简单整合六-list-watch二(关于Rs与Pod以及Deployment的完善)
- 节流和防抖
猜你喜欢

关于SIoU的原理和代码实现(回顾IoU、GIoU、DIoU、CIoU)

563. slope of binary tree

UEFI查找PCI设备

The realization of online Fox game server room configuration battle engagement customization function

Handwritten a message queue in two ways

Do you use typescript or anyscript

Why is it that the live video of the devices connected to easygbs suddenly cannot be played? Insufficient database read / write

【Matlab WSN通信】A_Star改进LEACH多跳传输协议【含源码 487期】

Warning: Each child in a list should have a unique “key“ prop.

Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)
随机推荐
Do you use typescript or anyscript
021-MongoDB数据库从入门到放弃
关于组织开展2022年宁波市重点首版次软件申报工作的通知
Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation
Starting from scratch (IV) enemy aircraft flying out of the border disappear automatically
Illustration of JS implementation from insertion sort to binary insertion sort [with source code]
Differences between FindIndex and indexof
QT socket setting connection timeout
Biweekly investment and financial report: capital rush yuan universe game
Learn a trick to use MySQL functions to realize data desensitization
修复鼠标右键没有vscode快捷入口的问题
必读1:格局越大的人,越懂得说话
Appclips & tips (continuous update)
Use of qscriptengine class
搜狐员工遭遇工资补助诈骗 黑产与灰产有何区别 又要如何溯源?
Who is stronger, zip or 7-Zip, and how to choose?
Illustrate the principle of one-way linked list and the method of JS to realize linked list [with source code]
Check whether the filing information of the medical representative is correct
Pytest automated test - easy tutorial (01)
Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand