[vtkusers] Get actual position of actor from an assembly after applying transforms

Jay jayavardhanravi at outlook.com
Thu Mar 29 12:54:44 EDT 2018


I am trying to obtain  the position of  the actor after the adding to
assembly and making transforms.

After each transformation I try to print the position and center but I
always get the initial values or the values don't update as the transforms
updates.

Do I miss something ? 

The pseudo code:

vtkSmartPointer<vtkCylinderSource> cyl =
vtkSmartPointer<vtkCylinderSource>::New();
	cyl->SetRadius(10);
	cyl->SetHeight(50);
	cyl->Update();
	vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(cyl->GetOutputPort());
	vtkSmartPointer<vtkActor> act1 = vtkSmartPointer<vtkActor>::New();
	act1->SetMapper(mapper);
	vtkSmartPointer<vtkTransform> trans1 =
vtkSmartPointer<vtkTransform>::New();
	act1->SetUserTransform(trans1);

	vtkSmartPointer<vtkCylinderSource> cyl1 =
vtkSmartPointer<vtkCylinderSource>::New();
	cyl1->SetRadius(10);
	cyl1->SetHeight(50);
	cyl1->Update();
	vtkSmartPointer<vtkPolyDataMapper> mapper1 =
vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper1->SetInputConnection(cyl1->GetOutputPort());
	vtkSmartPointer<vtkActor> act2 = vtkSmartPointer<vtkActor>::New();
	act2->SetMapper(mapper1);
	vtkSmartPointer<vtkTransform> trans2 =
vtkSmartPointer<vtkTransform>::New();
	act2->SetUserTransform(trans2);

	vtkSmartPointer<vtkAssembly> assembly =
vtkSmartPointer<vtkAssembly>::New();
	assembly->AddPart(act1);
	assembly->AddPart(act2);
	int count = 0;
	while(count < 100)
	{
		trans2->Identity();
		trans2->RotateX(30);
		trans2->RotateY(90);
		trans2->RotateZ(10);
		trans2->Update();
		renderer->AddActor(assembly);
		renderer->Render();
		count++;
		std::cout << "Center : " << act2->GetCenter()[0] << " & " <<
act2->GetCenter()[1] << " & " << act2->GetCenter()[2];
		std::cout << "Position : " << act2->GetPosition()[0] << " & " <<
act2->GetPosition()[1] << " & " << act2->GetPosition()[2];
	}

Any help or suggestions would be appreciated

Regards,
Jay



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list