• vtk 动画入门 1 代码


    实现效果如图:

    1. #include
    2. //VTK_MODULE_INIT(vtkRenderingOpenGL2);
    3. //VTK_MODULE_INIT(vtkInteractionStyle);
    4. VTK_MODULE_INIT(vtkRenderingOpenGL2);
    5. VTK_MODULE_INIT(vtkInteractionStyle);
    6. //VTK_MODULE_INIT(vtkRenderingFreeType);
    7. #include
    8. #include
    9. #include "vtkSmartPointer.h"
    10. #include "vtkMultiBlockDataSet.h"
    11. #include "vtkTecplotReader.h"
    12. #include "vtkPointData.h"
    13. #include "vtkCellData.h"
    14. #include "vtkDataSetMapper.h"
    15. #include "vtkPolyDataMapper.h"
    16. #include "vtkActor.h"
    17. #include "vtkRenderWindow.h"
    18. #include "vtkRenderer.h"
    19. #include "vtkCellDataToPointData.h"
    20. #include "vtkAppendFilter.h"
    21. #include "vtkPolyData.h"
    22. #include "vtkUnstructuredGrid.h"
    23. #include "vtkLookupTable.h"
    24. #include "vtkScalarBarActor.h"
    25. #include "vtkRenderWindowInteractor.h"
    26. #include
    27. #include "vtkCellArray.h"
    28. #include "vtkIdList.h"
    29. #include "vtkSphereSource.h"
    30. #include "vtkPolyDataMapper.h"
    31. #include "vtkAnimationCue.h"
    32. #include "vtkAnimationScene.h"
    33. #include "vtkNew.h"
    34. class vtkCustomAnimationCue : public vtkAnimationCue
    35. {
    36. public:
    37. static vtkCustomAnimationCue* New();
    38. //vtkTypeRevisionMacro(vtkCustomAnimationCue,vtkAnimationCue);
    39. vtkRenderWindow * RenWin ;
    40. vtkSphereSource * Sphere ;
    41. protected:
    42. vtkCustomAnimationCue() {
    43. }
    44. virtual void TickInternal(double currenttime, double deltatime,double clocktime) {
    45. double new_st = currenttime * 180;
    46. this->Sphere->SetStartTheta(new_st);
    47. this->RenWin->Render();
    48. }
    49. private:
    50. };
    51. vtkStandardNewMacro(vtkCustomAnimationCue);
    52. void main() {
    53. /**/
    54. vtkNew renderer ;
    55. vtkNew renWin ;
    56. renWin->SetMultiSamples(0);
    57. //renWin->SetSize(2000,2000);
    58. renWin->AddRenderer(renderer);
    59. vtkNew sphere ;
    60. vtkNew mapper ;
    61. mapper->SetInputConnection(sphere->GetOutputPort());
    62. vtkNew actor ;
    63. actor->SetMapper(mapper);
    64. renderer->AddActor(actor);
    65. renWin->Render();
    66. /** /
    67. vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();
    68. renderWindowInteractor->SetRenderWindow(renWin);
    69. renderWindowInteractor->Start();
    70. **/
    71. vtkNew scene ;
    72. //scene->SetModeToRealTime();
    73. scene->SetModeToSequence();
    74. scene->SetFrameRate(30);
    75. scene->SetStartTime(0);
    76. scene->SetEndTime(60);
    77. vtkNew cue;
    78. cue->Sphere = sphere;
    79. cue->RenWin = renWin;
    80. cue->SetTimeModeToNormalized();
    81. cue->SetStartTime(.0);
    82. cue->SetEndTime(1.0);
    83. scene->AddCue(cue);
    84. scene->Play();
    85. scene->Stop();
    86. }

  • 相关阅读:
    Linux安全—iptables详解(概念和filter表)
    登录验证的步骤
    基于openHarmony实现本地UDP通信
    网络协议学习地图分享
    Linux系统下实现开机自动加载驱动模块
    ADS基础教程15 - 设计加密保护IP
    【Java基础】- HttpURLConnection详解
    长连接、短连接
    不同的测试技术区分
    电脑重装系统桌面图标变成白色文件怎么恢复?
  • 原文地址:https://blog.csdn.net/zhanglixin999/article/details/133525788