[vtkusers] Copy VtkPolyData

Sebastien Jourdain sebastien.jourdain at kitware.com
Tue Aug 17 08:31:01 EDT 2010


Normally the cast should work.

Did you try that ?

vtkPolyData* tmp =
vtkPolyData::SafeDownCast(firstActor->GetMapper()->GetInput());
// is tmp == 0 ?
tmp->GetLines();

On Tue, Aug 17, 2010 at 8:04 AM, Bertrand De Boisdeffre
<bertranddeboisdeffre at yahoo.fr> wrote:
> 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.
>
>
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list