vtk 动画入门 1 代码

实现效果如图:

vtk 动画入门 1 代码_第1张图片


#include 
//VTK_MODULE_INIT(vtkRenderingOpenGL2);
//VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
//VTK_MODULE_INIT(vtkRenderingFreeType);
#include 
#include 
#include "vtkSmartPointer.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkTecplotReader.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
#include "vtkDataSetMapper.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkCellDataToPointData.h"
#include "vtkAppendFilter.h" 
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h" 
#include "vtkLookupTable.h"
#include "vtkScalarBarActor.h"
#include "vtkRenderWindowInteractor.h"
#include 
#include "vtkCellArray.h"
#include "vtkIdList.h" 
#include "vtkSphereSource.h" 
#include "vtkPolyDataMapper.h" 
#include "vtkAnimationCue.h" 
#include "vtkAnimationScene.h" 
#include "vtkNew.h" 


class  vtkCustomAnimationCue : public vtkAnimationCue
{
public:
	static vtkCustomAnimationCue* New();
	//vtkTypeRevisionMacro(vtkCustomAnimationCue,vtkAnimationCue);
	 vtkRenderWindow *  RenWin ;
	 vtkSphereSource *  Sphere  ;

protected:
	vtkCustomAnimationCue() {

	}
	virtual void TickInternal(double currenttime, double deltatime,double clocktime) {
		double new_st = currenttime * 180;
		this->Sphere->SetStartTheta(new_st);
		this->RenWin->Render();
	}

private:

};

vtkStandardNewMacro(vtkCustomAnimationCue);
 

void main() {

	/**/
	vtkNew renderer ;
	vtkNew renWin  ;
	renWin->SetMultiSamples(0);
	//renWin->SetSize(2000,2000);
	renWin->AddRenderer(renderer);

	vtkNew sphere ;

	vtkNew mapper  ;
	mapper->SetInputConnection(sphere->GetOutputPort());
	vtkNew actor ;
	actor->SetMapper(mapper);
	renderer->AddActor(actor);
	renWin->Render();

	/** /
	vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();
	renderWindowInteractor->SetRenderWindow(renWin);
	renderWindowInteractor->Start();
	**/

	vtkNew scene  ;
	//scene->SetModeToRealTime();
	scene->SetModeToSequence();
	scene->SetFrameRate(30);
	scene->SetStartTime(0);
	scene->SetEndTime(60);

	vtkNew cue;
	cue->Sphere = sphere;
	cue->RenWin = renWin;
	cue->SetTimeModeToNormalized();
	cue->SetStartTime(.0);
	cue->SetEndTime(1.0);

	scene->AddCue(cue);
	scene->Play();
	scene->Stop();
	 
}
  

你可能感兴趣的:(VTK,&,ITK,信息可视化,图像处理)