[vtkusers] deepcopy and shallowcopy
David E DeMarle
dave.demarle at kitware.com
Fri Aug 23 13:46:05 EDT 2013
To put it another way, ShallowCopy just creates new pointers to existing
contents. DeepCopy creates pointers to entirely new contents.
If I DeepCopy a vtkDataArray containing 1MB of floats, I consume a little
more than 2MB of memory (the little more coming from the size of the
container).
If I ShallowCopy I end up with 1MB plus a little instead. VTK's reference
counting makes sure that I won't accidentally delete the 1MB buffer of
floats data until both vtkDataArrays are Deleted.
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Fri, Aug 23, 2013 at 12:37 PM, alethea <alethea at anatomage.com> wrote:
> First, DeepCopy will copy all layers of data, whereas ShallowCopy will copy
> less data.
>
> Here's a simple example of using DeepCopy in C++, where triangleFilter at
> the end of some data pipeline.
>
> vtkPolyData* UseDeepCopy(vtkTriangleFilter* triangleFilter)
> {
> triangleFilter->Update(); // this needs to be called to actually build
> the
> data structure returned in GetOutput()
>
> vtkPolyData* polyData = vtkPolyData::New(); // You must create this
> object, or it can't be used in DeepCopy
>
> polyData->DeepCopy(triangleFilter->GetOutput()); // Copy the triangulated
> data over to polyData
>
> // Note, you could delete triangleFilter now, because the data's been
> copied, though that should really be done outside of this function.
>
> return polyData;
> }
>
>
> david
>
> david bahn wrote
> > Hi All,
> > i have a question about the application of deepcopy and
> > shallowcopy functions in polydata, how does these two functions works,
> > anybody can give me an example to understand the applications of these
> two
> > functions in an example?
> >
> >
> > david
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/deepcopy-and-shallowcopy-tp5722999p5723000.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130823/34cdb95a/attachment.htm>
More information about the vtkusers
mailing list