[vtkusers] Creating actor copy did not copy the texture information

vinmean iamdpak at gmail.com
Mon Sep 4 01:03:15 EDT 2017


Following is the code I wrote to copy a group of actors (assembly) to
another. Earler, I had imported the actors using the vtkObjImporter class.
So these actors have textures. But while copying only the polyData is being
copied. Can some one tell me how to copy the texture information too?

void deep_copy_assembly(vtkSmartPointer<vtkAssembly> src_asm,
vtkSmartPointer<vtkAssembly> dst_asm)
{
	vtkSmartPointer<vtkActorCollection> actors =
vtkSmartPointer<vtkActorCollection>::New();
	src_asm->GetActors(actors);
	actors->InitTraversal();

	for(vtkIdType i = 0; i < actors->GetNumberOfItems(); i++)
	{
		vtkSmartPointer<vtkActor> actor = actors->GetNextActor();
		vtkSmartPointer<vtkActor> new_actor = vtkSmartPointer<vtkActor>::New();
		vtkPolyData* pd =
vtkPolyData::SafeDownCast(actor->GetMapper()->GetInput());
		vtkSmartPointer<vtkPolyData> new_pd = vtkSmartPointer<vtkPolyData>::New();
		new_pd->DeepCopy(pd);
		vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
		mapper->SetInputData(new_pd);
		new_actor->SetMapper(mapper);
		dst_asm->AddPart(new_actor);
	}
}



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


More information about the vtkusers mailing list