• vtk- 数据类型(一) 三角链实例代码


     三角链实例代码

    1. #include
    2. #include
    3. #include
    4. #include "tuex.h"
    5. #include "vtkCylinderSource.h"
    6. #include "vtkPolyDataMapper.h"
    7. #include "vtkActor.h"
    8. #include "vtkRenderer.h"
    9. #include "vtkRenderWindow.h"
    10. #include "vtkRenderWindowInteractor.h"
    11. #include "vtkProperty.h"
    12. #include "vtkCamera.h"
    13. #include
    14. #include
    15. #include
    16. #include
    17. #include
    18. #include
    19. #include
    20. #include
    21. #include "vtkLine.h"
    22. #include "vtkTriangle.h"
    23. #include "vtkPolyLine.h"
    24. //VTK_MODULE_INIT(vtkRenderingOpenGL);
    25. VTK_MODULE_INIT(vtkRenderingOpenGL2);
    26. VTK_MODULE_INIT(vtkInteractionStyle);
    27. VTK_MODULE_INIT(vtkRenderingFreeType)
    28. using namespace std;
    29. #include
    30. int main(int agrv, char * agrc) {
    31. vtkNew points;
    32. points->InsertPoint(0, 0.0, 0.0, 0.0);
    33. points->InsertPoint(1, 0.0, 1.0, 0.0);
    34. points->InsertPoint(2, 1.0, 0.0, 0.0);
    35. points->InsertPoint(3, 1.0, 1.0, 0.0);
    36. points->InsertPoint(4, 2.0, 0.0, 0.0);
    37. points->InsertPoint(5, 2.0, 1.0, 0.0);
    38. points->InsertPoint(6, 3.0, 0.0, 0.0);
    39. points->InsertPoint(7, 3.0, 1.0, 0.0);
    40. vtkNew strips;
    41. strips->InsertNextCell(8);
    42. strips->InsertCellPoint(0);
    43. strips->InsertCellPoint(1);
    44. strips->InsertCellPoint(2);
    45. strips->InsertCellPoint(3);
    46. strips->InsertCellPoint(4);
    47. strips->InsertCellPoint(5);
    48. strips->InsertCellPoint(6);
    49. strips->InsertCellPoint(7);
    50. vtkNew poly;
    51. poly->SetPoints(points);
    52. poly->SetStrips(strips);
    53. vtkNew mapper;
    54. mapper->SetInputData(poly);
    55. vtkNew actor; //演员
    56. actor->SetMapper(mapper);
    57. vtkNew render; //设置舞台
    58. render->AddActor(actor); //演员上舞台
    59. render->SetBackground(0.0, 0.0, 0.0);//设置舞台背景
    60. vtkNew renWin; //
    61. renWin->AddRenderer(render);//舞台搬进戏院
    62. renWin->SetSize(640, 480);//戏院大小
    63. renWin->Render(); //戏院渲染
    64. renWin->SetWindowName("vtkPipelineDemo");//戏院起名
    65. vtkNew interactor; //与看客交互
    66. interactor->SetRenderWindow(renWin);
    67. interactor->Initialize();
    68. interactor->Start();
    69. }

    单元数据分成两个写,如下,结果一样。 

    1. vtkNew strips;
    2. strips->InsertNextCell(5);
    3. strips->InsertCellPoint(0);
    4. strips->InsertCellPoint(1);
    5. strips->InsertCellPoint(2);
    6. strips->InsertCellPoint(3);
    7. strips->InsertCellPoint(4);
    8. strips->InsertNextCell(5);
    9. strips->InsertCellPoint(3);
    10. strips->InsertCellPoint(4);
    11. strips->InsertCellPoint(5);
    12. strips->InsertCellPoint(6);
    13. strips->InsertCellPoint(7);
    14. vtkNew poly;

    运行结果:

    按w键,查看线结构:

     在线性结构里面,属于下图;f) Triangle strip(n triangles)

  • 相关阅读:
    【面试题精讲】Object类的常见方法有哪些?
    RS编码译码误码率性能matlab仿真
    【机器人学-雅可比矩阵】
    QT获取USB相机具体属性信息
    webapi开发框架实践
    MySQL 8.0 Clone 备份恢复演练
    如何学习BCGControlBar?
    数据结构:AVL树
    Redis-概念、安装、基本配置
    面试阿里技术专家岗,对答如流,这些面试题你能答出多少
  • 原文地址:https://blog.csdn.net/zhanglixin999/article/details/133253009