VTK学习笔记(五)vtkRotationalExtrusionFilter
作者:互联网
1. 头文件中的翻译
扫描多边形数据创建“裙子”从自由边和线,线从顶点。
vtkRotationalExtrusionFilter是一个建模过滤器。它以多边形数据作为输入,并在输出时生成多边形数据。输入数据集围绕z轴旋转以创建新的多边形原语。这些原语形成一个“裙子”或扫面。例如,扫线会得到一个圆柱体壳,扫圆会得到一个环面。
这个过滤器有许多控制参数。你可以通过“Capping”实例变量来控制2D对象(即多边形或三角形带)的扫描是否被生成的几何体所覆盖。此外,您还可以控制旋转角度,以及是否沿着z轴进行平移。(翻译对于创建“spring”很有用。)你也可以使用“DeltaRotation”实例变量来调整生成几何体的半径。
裙子是通过定位某些拓扑特征而产生的。自由边(只被一个多边形或三角形带使用的多边形或三角形带的边)生成曲面。对于直线或折线也是如此。顶点生成线。
这个过滤器可以用来建模轴对称的物体,如圆柱体、瓶子和酒杯;或平动/旋转对称物体,如弹簧或开瓶器。
如果对象扫描360度,半径不变,对象不平移,则不执行封顶。这是因为这个上限是不必要的。
一些多边形物体没有自由边(例如,球体)。当清扫时,如果盖上盖子,这将导致两个独立的表面,或如果盖上盖子,没有表面。
2. 通俗说就是画折线或者图形,然后绕Z轴旋转。 这里的扫描/清扫(sweep)就是类似绕Z轴旋转的意思,
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCellArray.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkRotationalExtrusionFilter.h>
#include <vtkStripper.h>
#include <vtkTubeFilter.h>
int main(int, char*[])
{
// Create the RenderWindow, Renderer and both Actors
//
vtkNew<vtkNamedColors> colors;
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin);
// create bottle profile
//
vtkNew<vtkPoints> points;
points->InsertPoint(0, 0.01, 0.0, 0.0);
points->InsertPoint(1, 1.5, 0.0, 0.0);
points->InsertPoint(2, 1.5, 0.0, 3.5);
points->InsertPoint(3, 1.25, 0.0, 3.75);
points->InsertPoint(4, 0.75, 0.0, 4.00);
points->InsertPoint(5, 0.6, 0.0, 4.35);
points->InsertPoint(6, 0.7, 0.0, 4.65);
points->InsertPoint(7, 1.0, 0.0, 4.75);
points->InsertPoint(8, 1.0, 0.0, 5.0);
points->InsertPoint(9, 0.2, 0.0, 5.0);
vtkNew<vtkCellArray> lines;
lines->InsertNextCell(10); // number of points
lines->InsertCellPoint(0);
lines->InsertCellPoint(1);
lines->InsertCellPoint(2);
lines->InsertCellPoint(3);
lines->InsertCellPoint(4);
lines->InsertCellPoint(5);
lines->InsertCellPoint(6);
lines->InsertCellPoint(7);
lines->InsertCellPoint(8);
lines->InsertCellPoint(9);
vtkNew<vtkPolyData> profile;
profile->SetPoints(points);
profile->SetLines(lines);
// extrude profile to make bottle
//
vtkNew<vtkRotationalExtrusionFilter> extrude;
extrude->SetInputData(profile);
extrude->SetResolution(60);
vtkNew<vtkPolyDataMapper> map;
map->SetInputConnection(extrude->GetOutputPort());
vtkNew<vtkActor> bottle;
bottle->SetMapper(map);
bottle->GetProperty()->SetColor(colors->GetColor3d("Mint").GetData());
// display the profile
vtkNew<vtkStripper> stripper;
stripper->SetInputData(profile);
vtkNew<vtkTubeFilter> tubes;
tubes->SetInputConnection(stripper->GetOutputPort());
tubes->SetNumberOfSides(11);
tubes->SetRadius(0.05);
vtkNew<vtkPolyDataMapper> profileMapper;
profileMapper->SetInputConnection(tubes->GetOutputPort());
vtkNew<vtkActor> profileActor;
profileActor->SetMapper(profileMapper);
profileActor->GetProperty()->SetColor(colors->GetColor3d("Tomato").GetData());
// Add the actors to the renderer, set the background and size
//
renderer->AddActor(bottle);
renderer->AddActor(profileActor);
renderer->SetBackground(colors->GetColor3d("Burlywood").GetData());
renWin->SetSize(640, 480);
renWin->SetWindowName("Bottle");
renWin->Render();
renderer->GetActiveCamera()->SetPosition(1, 0, 0);
renderer->GetActiveCamera()->SetFocalPoint(0, 0, 0);
renderer->GetActiveCamera()->SetViewUp(0, 0, 1);
renderer->ResetCamera();
renderer->GetActiveCamera()->Azimuth(30);
renderer->GetActiveCamera()->Elevation(30);
// render the image
//
iren->Start();
return EXIT_SUCCESS;
}
标签:vtkRotationalExtrusionFilter,0.0,VTK,lines,笔记,points,renderer,include,vtkNew 来源: https://blog.csdn.net/yxmlhc/article/details/121204415