Creating actor copy did not copy the texture information

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating actor copy did not copy the texture information

vinmean
This post was updated on .
Following is the code I wrote to copy a group of actors (assembly) to another. Earlier, 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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Creating actor copy did not copy the texture information

vinmean
I am now able to copy the texture using the below lines



                vtkSmartPointer<vtkTexture> texture = actor->GetTexture();

                new_actor->SetTexture(texture);




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers