Mike - Yes it does, thanks! <br><br>Quoting David G. - <br>&quot;The &quot;ShallowCopy&quot; method does not mean quite the same thing for<br>
vtkDataSet as it does for vtkCell.  What I mean to say in C++ speak<br>
is: vtkCell and vtkDataSet do not share a common base class that<br>
defines a &quot;ShallowCopy&quot; method.  Each has its own particular<br>
definition of ShallowCopy.&quot;<br><br>You point exactly what I was surprised about: Because I thought <br>that Copy are important things, I looked for a virtual function in<br>vtkObject - possibly pure -, the one that is shared by every object.<br>
(I voluntary omit vtkObjectBase). It means that it is possible to <br>create VTK objects that don&#39;t implement a Copy mechanism. <br><br>This is the case for vtkDataObject: There is no Copy functions. <br>However, a vtkExecutive is associated to a vtkDataObject. It<br>
means that generic filters working on vtkDataObject cannot <br>perform Shallow/DeepCopy. I don&#39;t know if I am clear enough...<br><br>Is there a reason to forbid &#39;abstract&#39; copy (ie without knowing<br>the exact implementation)?<br>
<br>Jerome<br><br><br><div class="gmail_quote">2009/12/15 Michael Jackson <span dir="ltr">&lt;<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
// Produce a &#39;Read Only&#39; copy to be used as Input<br>
inputCopy-&gt;ShallowCopy(input);<br>
// Add the Input to the &#39;internal&#39; pipeline<br>
blend-&gt;AddInput(inputCopy);<br>
// Update the &#39;internal&#39; pipeline<br>
blend-&gt;Update();<br>
<br>
/* Now, blend produced an entirely brand new &#39;output&#39; object after the<br>
* update method was called. The &#39;input&#39; to the blend filter should have<br>
* never been modified by the blend filter. Because the output is a brand<br>
* new object you do not need to deep copy it.<br>
*/<br>
output-&gt;DeepCopy(blend-&gt;GetOutput());<br>
/* If you want to &#39;save&#39; the output for use later you might want to<br>
* call &#39;output-&gt;Register(NULL);&#39; which will increase the reference<br>
* count of the object so when the &#39;blend&#39; filter goes out of scope<br>
* and is destroyed the pointer that represents &#39;output&#39; will NOT be<br>
* deleted. Another way to accomplish the same goal would be to again<br>
* shallow copy the output into another variable.<br>
*/<br>
<br>
Basically the difference between a shallow copy and a deep copy is this.<br>
The Shallow copy only makes a copy of the pointer to each of the internal<br>
data structures and increases the reference count on each of those objects.<br>
So on a 32 bit system you are copying a single 32 bit value (which happens<br>
to be a pointer) into a new location. Thus you may have 2 objects (input and<br>
inputcopy) BUT they share the same exact data structures internally. So changing<br>
the data in one will effect the other.<br>
  A deep copy will make a copy of the actual DATA that the pointer points to. Thus you<br>
end up with 2 versions of the data. One in &quot;input&quot; and one in &quot;inputcopy&quot;. Changing<br>
the data in one of those will NOT effect the other object.<br>
<br>
  To use an abstract example. If you have a vtk object that wraps 1 GigaByte of data and perform<br>
a shallow copy then your memory requirements only go up maybe 100 bytes (all the<br>
overhead of the vtk object) or so. If you do a DEEP copy then your memory requirements<br>
jumps from 1 GigaByte to 2 Gigabytes because all the actual data is copied.<br>
<br>
 Does that help?<div class="im"><br>
_________________________________________________________<br>
Mike Jackson                  <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
<br></div><div><div></div><div class="h5">
On Dec 15, 2009, at 12:13 PM, Jérôme wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Oops... it seems that I understand now some weird &quot;bad extent&quot; happening... I will keep this thread bookmarked, since it teaches a lot about VTK pipelining!<br>
<br>
This made me look at the documentation of ShallowCopy/DeepCopy. Finally, I found this class:<br>
<a href="http://www.vtk.org/doc/nightly/html/classvtkCell.html#a573202e8c9c3b5367b35fe7ad3fdfb43" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkCell.html#a573202e8c9c3b5367b35fe7ad3fdfb43</a><br>
<br>
where it is said that ShallowCopy is for read-only copy... Is the code snippet right? ShallowCopying the output of the internal filter should then produce a read-only output for the main filter!<br>
<br>
Do I mistake if I rather propose:<br>
inputCopy-&gt;ShallowCopy(input);<br>
blend-&gt;AddInput(inputCopy);<br>
blend-&gt;Update();<br>
output-&gt;DeepCopy(blend-&gt;GetOutput());<br>
<br>
Jerome<br>
<br>
2009/12/15 Michael Jackson &lt;<a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a>&gt;<br>
<br>
<br>
On Dec 15, 2009, at 11:53 AM, Bill Lorensen wrote:<br>
<br>
After seeing Berk&#39;s reply it looks as though his<br>
vtkImageData* inputCopy = input-&gt;NewInstance();<br>
inputCopy-&gt;ShallowCopy(input);<br>
blend-&gt;AddInput(inputCopy);<br>
blend-&gt;Update();<br>
output-&gt;ShallowCopy(blend-&gt;GetOutput());<br>
<br>
would be:<br>
<br>
blend-&gt;AddInput(input);<br>
blend-&gt;Update()<br>
this-&gt;GraftOutput(blend-&gt;GetOutput());<br>
<br>
Bill,<br>
 As, Berk explained, you _really_ need to have a shallow copy to decouple the internal and external pipelines. If this is not done the all sorts of &quot;Bad&quot; will happen.<br>
<br>
 Maybe what is needed is this:<br>
<br>
/* Get a Shallow copy from the input */<br>
vtkImageData* inputCopy = input-&gt;NewShallowCopyInstance();<br>
<br>
blend-&gt;AddInput(inputCopy);<br>
blend-&gt;Update();<br>
output-&gt;ShallowCopy(blend-&gt;GetOutput());<br>
/* Don&#39;t Forget to memory clean up somewhere.*/<br>
<br>
_________________________________________________________<br>
Mike Jackson                  <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
BlueQuartz Software                    <a href="http://www.bluequartz.net" target="_blank">www.bluequartz.net</a><br>
Principal Software Engineer                  Dayton, Ohio<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
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>
<br>
</blockquote>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
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>