[vtkusers] Copy VtkPolyData

Bertrand De Boisdeffre bertranddeboisdeffre at yahoo.fr
Tue Aug 17 08:04:00 EDT 2010


Hi,

I would like to copy a vtkPolyData into an other. 
My goal is to copy the lines of the first vtkPolydata and to set the lines of 
the second. I know the "GetLines" method, but in my code i want to copy this 
lines from an vtkActor :

Example : 

vtkCellArray lines = vtkCellArray.New();
/*
lines is build
*/

vtkPolyData firstPoly = new vtkPolyData();
poly.SetLines(lines);

vtkPolyDataMapper firstMapper = vtkPolyDataMapper.New();
firstMapper.SetInput(firstPoly);

vtkActor firstActor = new vtkActor();
firstActor.SetMapper(firstMapper);

/* Now i would  "catch"  the lines, but ...

Actor.GetMapper().GetInput() returns a vtkDataSet (not a vtkPolyData) so the 
method "GetLines" doesn't exist in this context. I tried a cast like this:
 
*/
(vtkPolyData)(Actor.GetMapper().GetInput()). GetLines()) 

 //but it doesn't work.

Then, I thought : make a copy! But, i don't know how ! 
I tried this code

vtkPolyData copy = vtkPolyData.new();
Actor.GetMapper().GetInput().DeepCopy(); // doesn't work

or

Actor.GetMapper().GetInput().CopyStructure(); // doesn't work

So your help would be appreciated.


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100817/703a568c/attachment.htm>


More information about the vtkusers mailing list