AW: [vtkusers] animation, vtkPoints update, pipeline update

jean-charles campagne jcpouce at yahoo.com
Mon Apr 14 05:58:49 EDT 2003


hello,

--- De Boer Ingo <I.deBoer at polytec.de> wrote:
> 
> Hi Jean,
> 
> > I am trying to make an animation ( the data is
> time
> > based) the data
> > represent point in 3D. These points would be
> moving
> > since the
> > coordinates of the points vary with time. (I'm
> using
> > C++)
> 
> I am trying the same. Could you go in a bit more
> detail? 
> In your PointsUpdate-Function... Do you create a new
> 
> vtkPolyData and vtkPolyDataMapper or do you keep 
> them as a member of your class ?
> I guess the vtkPoints is also a member, which is
> initialized
> and the filled with new data in the
> PointsUpdate-Function ?
> 
> thanks & greets
>   Ingo
>  

here is the source of the "demo" i managed to write
(hope the source won't get mangled in the email)
(i know it's ugly code and not OO, but my concern here
was just to learn vtk)

--------------------------------------------------
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkStructuredPointsReader.h"
#include "vtkGlyph3D.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkProperty.h"

int main( int argc, char *argv[] )
{
	vtkPoints *points = vtkPoints::New();
	vtkSphereSource *sphere = vtkSphereSource::New();
	vtkPolyData *data = vtkPolyData::New();
	vtkGlyph3D *verts = vtkGlyph3D::New();
	vtkPolyDataMapper *sphereMapper =
vtkPolyDataMapper::New();
	vtkActor *sphereActor = vtkActor::New();
	vtkRenderer *ren1= vtkRenderer::New();
	vtkRenderWindow *renWin = vtkRenderWindow::New();
	
	const int ni = 20;
	
	points->SetNumberOfPoints(ni);
	for (int i=0; i <ni; i++) {
		points->SetPoint(i,
				(double)(i%30)*0.1,
				(double)0,
				(double)(i/20));
	}
	
	sphere->SetRadius(0.04 );
 	sphere->SetPhiResolution( 4 );
 	sphere->SetThetaResolution( 4 );
	
	data->SetPoints(points);
  
	verts->SetSource(sphere->GetOutput());
	verts->SetInput(data);
	verts->ScalingOff();

	sphereMapper->SetInput( verts->GetOutput() );

	sphereActor->SetMapper( sphereMapper );
	sphereActor->GetProperty()->SetOpacity(0.5);
	sphereActor->RotateY(-45.0);

 	ren1->AddActor( sphereActor );
 	ren1->SetBackground( 1.0, 1.0, 1.0 );
	
 	renWin->AddRenderer( ren1 );
	renWin->SetSize( 300, 300 );
	
	double u=0.2;
	int uu=0;
	int n=0;
	while (1) {
		for (int i=0; i <ni; i++) {
			points->SetPoint(i,
					 (double)(i%20)*0.1,
					 (double)0.2*sin(u*i/10.0*u),
					 (double)(i/20));
		}
		u+=0.01;
		points->Modified();
		renWin->Render();
	}
	
// 	sphere->Delete();
// 	sphereMapper->Delete();
// 	sphereActor->Delete();
// 	ren1->Delete();
// 	renWin->Delete();

// 	vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::New();
// 	iren->SetRenderWindow(renWin);
// 	iren->Initialize();
// 	iren->Start();

	return 0;
}







__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com



More information about the vtkusers mailing list