zoukankan      html  css  js  c++  java
  • VTK Procedural Source Object

    VTK 使用 Procedural Source Object 来展示一些固定的三维物体,比如 多边形柱体、多边球体、棱锥等等,在三维画布下添加 Prop 的示例代码如下:

    auto sphere = vtkSmartPointer<vtkSphereSource>::New();
    sphere->SetRadius(24);
    
    auto cylinder = vtkSmartPointer<vtkCylinderSource>::New();
    cylinder->SetResolution(3);
    cylinder->SetHeight(48);
    cylinder->SetRadius(48);
    
    auto mapperSphere = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapperSphere->SetInputConnection(sphere->GetOutputPort());
    
    auto actorSphere = vtkSmartPointer<vtkActor>::New();
    actorSphere->SetMapper(mapperSphere);
    actorSphere->SetPosition(0, 0, 0);
    
    auto mapperCylinder = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapperCylinder->SetInputConnection(cylinder->GetOutputPort());
    
    auto actorCylinder = vtkSmartPointer<vtkActor>::New();
    actorCylinder->SetMapper(mapperCylinder);
    actorCylinder->SetPosition(144, 0, 0);
    
    auto renderer = vtkSmartPointer<vtkRenderer>::New();
    renderer->AddActor(actorSphere);
    renderer->AddActor(actorCylinder);
    
    renderer->SetBackground(0.6, 0.6, 0.6);
    
    auto actorAxes = vtkSmartPointer<vtkAxesActor>::New();
    actorAxes->SetPosition(0, 0, 0);
    actorAxes->SetTotalLength(120, 120, 120);
    actorAxes->SetShaftType(0);
    actorAxes->SetAxisLabels(0);
    actorAxes->SetCylinderRadius(0.02);
    
    renderer->AddActor(actorAxes);
    
    auto win = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
    win->AddRenderer(renderer);
    
    ui->widgetVtk->setRenderWindow(win);
    

    需要注意的地方是,在给 Actor 调用 SetPosition 的时候,这个位置算的是三维物体的重心位置到原点的相对距离,而原点的位置默认是(0, 0, 0);
    可以通过 Source 的 SetCenter 来重置原点的位置。

  • 相关阅读:
    查看Android应用所需权限(uses-permission)
    Android Camera后台拍照
    傅里叶变换
    linux文件系统问题:wrong fs type, bad option, bad superblock
    H3 android 系统编译
    开源股票数据工具
    获取股票实时交易数据的方法
    获取历史和实时股票数据接口
    CRC在线计算工具
    硬盘自动挂载
  • 原文地址:https://www.cnblogs.com/hbrw/p/13213103.html
Copyright © 2011-2022 走看看