• 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)

  • 相关阅读:
    【PDF合并】利用 Python 合并 PDF 文件
    R语言CalibrationCurves包绘制带可信区间的校准曲线
    经典SQL语句大全
    【接口自动化测试】HTTP协议详解
    在RK3588开发板使用FFMpeg 结合云服务器加SRS实现摄像头数据推流到云端拱其他设备查看
    集成websocket实现实时通信(ruoyi 使用笔记)
    redis之分片集群
    openEuler 22.03 x86架构下docker运行arm等架构的容器——筑梦之路
    golang gorm —— 事务、回滚、savepoint
    leetcode栈和队列三剑客
  • 原文地址:https://blog.csdn.net/zhanglixin999/article/details/133253009