[vtkusers] Rotation of PolyData

Lonni Besançon lonni.besancon at gmail.com
Wed Jun 17 06:58:40 EDT 2015


Turns out I am now using the Actor directly to set rotation translation and
scale. It does work fine except that I need to click on the window for the
changes to appear. Would anyone know the reason why?
Don't know if this is useful but here is my code now:

void Drawing::translate(float x, float y, float z){
	cout << "Translate: " << x << " - " << " - " << y << " - " << z << endl ;
	vtkSmartPointer<vtkTransform> transform1a =
vtkSmartPointer<vtkTransform>::New();
	//transform1a->Translate(x,y,z);
	//transformFilter->SetTransform(transform1a);
	//transformFilter->Update();
	double* position = mainActor->GetPosition();
	mainActor->SetPosition(position[0]+x,position[1]+y,position[2]+z);
}

void Drawing::read(){

	std::string filename = BUNNY;
	// Read all the data from the file
	vtkSmartPointer<vtkXMLPolyDataReader> reader
=vtkSmartPointer<vtkXMLPolyDataReader>::New();
	reader->SetFileName(filename.c_str());
	reader->Update();
	inputPolyData = reader->GetOutput();

	cout << "File Found and Loaded : " << filename << endl ;

	vtkSmartPointer<vtkTransform> translation =
vtkSmartPointer<vtkTransform>::New();
	translation->Translate(0.3, -0.05, 0);
	transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
	//transformFilter->SetInputConnection(reader->GetOutputPort());
	transformFilter->SetInputData(inputPolyData);
	transformFilter->SetTransform(translation);
	//transformFilter->Update();

	vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(transformFilter->GetOutputPort());

	mainActor = vtkSmartPointer<vtkActor>::New();
	mainActor->SetMapper(mapper);

	ren->AddActor(mainActor);

	vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(win);
	vtkInteractorStyleMultiTouchCamera *style =
	vtkInteractorStyleMultiTouchCamera::New();
	iren->SetInteractorStyle(style);
	
	//Start the event loop
	iren->Initialize();
	iren->Start();

	defineClipping();
	win->PolygonSmoothingOn();
	win->Render();
	win->Start();
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Rotation-of-PolyData-tp5732340p5732400.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list