<div dir="ltr">To put it another way, ShallowCopy just creates new pointers to existing contents. DeepCopy creates pointers to entirely new contents.<div><br></div><div style>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).</div>
<div style>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.</div><div style>
<br></div></div><div class="gmail_extra"><br clear="all"><div>David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4909</div>
<br><br><div class="gmail_quote">On Fri, Aug 23, 2013 at 12:37 PM, alethea <span dir="ltr"><<a href="mailto:alethea@anatomage.com" target="_blank">alethea@anatomage.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
First, DeepCopy will copy all layers of data, whereas ShallowCopy will copy<br>
less data.<br>
<br>
Here's a simple example of using DeepCopy in C++, where triangleFilter at<br>
the end of some data pipeline.<br>
<br>
vtkPolyData* UseDeepCopy(vtkTriangleFilter* triangleFilter)<br>
{<br>
triangleFilter->Update(); // this needs to be called to actually build the<br>
data structure returned in GetOutput()<br>
<br>
vtkPolyData* polyData = vtkPolyData::New(); // You must create this<br>
object, or it can't be used in DeepCopy<br>
<br>
polyData->DeepCopy(triangleFilter->GetOutput()); // Copy the triangulated<br>
data over to polyData<br>
<br>
// Note, you could delete triangleFilter now, because the data's been<br>
copied, though that should really be done outside of this function.<br>
<br>
return polyData;<br>
}<br>
<br>
<br>
david<br>
<br>
david bahn wrote<br>
<div class="im">> Hi All,<br>
> i have a question about the application of deepcopy and<br>
> shallowcopy functions in polydata, how does these two functions works,<br>
> anybody can give me an example to understand the applications of these two<br>
> functions in an example?<br>
><br>
><br>
> david<br>
<br>
<br>
<br>
<br>
<br>
</div>--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/deepcopy-and-shallowcopy-tp5722999p5723000.html" target="_blank">http://vtk.1045678.n5.nabble.com/deepcopy-and-shallowcopy-tp5722999p5723000.html</a><br>
<div class="im HOEnZb">Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
</div><div class="HOEnZb"><div class="h5">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br></div>