<div dir="ltr"><div><div><div>Rick,<br><br></div>You don't have to do a deep copy for this case.  Deep copy is for when you plan to modify one and don't want the other to keep the modifications.  Shallow Copy should work fine in this case.  You could also do something like this:<br><br></div>bool myFunction(vtkSmartPointer<vtkImageData> & output)<br>{<br></div><div>  vtkSmartPointer<vtkImageData> myImage = ...;<br><br>  ...<br><br></div><div>  output = myImage; // This should change output to point to the image in myImage incrementing the reference count to myImage's image and avoid any need to copy.<br></div>  return true;<br><div>}<br><br></div><div>You would call it like this:<br></div><div>vtkSmartPointer<vtkImageData> image; // Use default ctor that doesn't allocate<br></div><div>bool result = myFunction(image);<br><br></div><div>To the best of my knowledge, the above should work.<br><br></div><div>HTH,<br></div><div>Shawn<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 16, 2016 at 1:38 PM, Richard Frank <span dir="ltr"><<a href="mailto:rickfrank@me.com" target="_blank">rickfrank@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Sorry for the blank reply previous.</div><div><br></div><div>The Tutorial is great but I don't see an example of the case I'm talking about.</div><div><br></div><div>That is, returning a pointer to the caller in such a way that the caller doesn't  have to think about whether they need to explicitly delete.</div><div><br></div><div>so, given a function  or method with a signature already returning a bool, and other code already dependent on that return type, I want to return the result of reading a file, for instance:</div><div><br></div><div>bool ReadAnImageFile(vtkSmartPointer<vtkImageData> & theImageRead)</div><div>{</div><div>   vtkSmartPointer<vtkImageFileReader> reader = <span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"> vtkSmartPointer<vtkImageFileReader>::New9);</span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">reader->SetFileName("Something.png");</span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">reader->Update();</span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">vtkImageData * image =  reader->GetOutput();  How to get image into theImageRead?</span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">// This seems to work</span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:SFNSText,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:300;letter-spacing:normal;line-height:22.5px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">theImageRead->DeepCopy(image);</span></div><div><br></div><div>// but if it's really doing a deep copy and I have a large 3D .mha file or something</div><div>// it will be slow.....is there a better way?</div><div>}</div><div><br></div><div><br></div><div>Thanks</div><div><br></div><div>Rick</div><div><br>On May 16, 2016, at 12:00 PM, <a href="mailto:vtkusers-request@vtk.org" target="_blank">vtkusers-request@vtk.org</a> wrote:<br><br></div><div><blockquote type="cite"><div><div><span>Send vtkusers mailing list submissions to<br>      <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>  <a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>or, via email, send a message with subject or body 'help' to<br>      <a href="mailto:vtkusers-request@vtk.org" target="_blank">vtkusers-request@vtk.org</a><br><br>You can reach the person managing the list at<br>  <a href="mailto:vtkusers-owner@vtk.org" target="_blank">vtkusers-owner@vtk.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of vtkusers digest..."<br><br><br>Today's Topics:<br><br> 1. why does the generated 3D model have borken part? (Liu_tj)<br> 2. Re: SmartPointer reference? (Dan Lipsa)<br> 3. Re: vtkBooleanOperationPolyDataFilter creates  non-manifold<br> edges (Andras Lasso)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Mon, 16 May 2016 21:11:33 +0800 (CST)<br>From: Liu_tj <<a href="mailto:tjlp@netease.com" target="_blank">tjlp@netease.com</a>><br>To: vtkusers <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>Subject: [vtkusers] why does the generated 3D model have borken part?<br>Message-ID: <<a href="mailto:7543d5b6.11.154b9b16f2f.Coremail.tjlp@netease.com" target="_blank">7543d5b6.11.154b9b16f2f.Coremail.tjlp@netease.com</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>Hi,<br><br>I used vtkMarchingCubes, vtkDecimatePro and vtkSmoothPolyDataFilter to generate 3D model for DICOM image. When it is firstly generated, the 3D model is fine (See the attached First.jpg). However, when I store it to STL file and use STLReader to read the STL file and display in vtkRenderWindow, it shows broken part (See loading.jpg). Why?<br><br>Thanks<br>Liu Peng<br><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0001.html%3E" target="_blank">http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0001.html></a><br>-------------- next part --------------<br>A non-text attachment was scrubbed...<br>Name: First.jpg<br>Type: image/jpeg<br>Size: 36205 bytes<br>Desc: not available<br>URL: <<a href="http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0002.jpg%3E" target="_blank">http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0002.jpg></a><br>-------------- next part --------------<br>A non-text attachment was scrubbed...<br>Name: loading.jpg<br>Type: image/jpeg<br>Size: 24157 bytes<br>Desc: not available<br>URL: <<a href="http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0003.jpg%3E" target="_blank">http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0003.jpg></a><br><br>------------------------------<br><br>Message: 2<br>Date: Mon, 16 May 2016 10:18:30 -0400<br>From: Dan Lipsa <<a href="mailto:dan.lipsa@kitware.com" target="_blank">dan.lipsa@kitware.com</a>><br>To: Richard Frank <<a href="mailto:rickfrank@me.com" target="_blank">rickfrank@me.com</a>><br>Cc: VTK Users <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>Subject: Re: [vtkusers] SmartPointer reference?<br>Message-ID:<br>  <CADwGrVq4_tna0Oph5Tqn+m=<a href="mailto:6Uk4GTn8GJuGBvdfZ8XudbjcsBA@mail.gmail.com" target="_blank">6Uk4GTn8GJuGBvdfZ8XudbjcsBA@mail.gmail.com</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>Does this help?<br><a href="http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers" target="_blank">http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers</a><br><br>What exactly is the problem you are seeing?<br>Dan<br><br><br>On Fri, May 13, 2016 at 7:22 PM, Richard Frank <<a href="mailto:rickfrank@me.com" target="_blank">rickfrank@me.com</a>> wrote:<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">Hi,</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Is it possible to return a smart pointer by reference?</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I'd like to return an image as a parameter, rather than a return type but</blockquote><blockquote type="cite">nothing seems to be happy.</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">for instance</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">bool SomeFunction(vtkSmartPointer<vtkImageData> & outImage)</blockquote><blockquote type="cite">{</blockquote><blockquote type="cite">vtkSmartPointer<vtkImageReader> r =</blockquote><blockquote type="cite">vtkSmartPointer<vtkImageReader>::New();</blockquote><blockquote type="cite">r->SetFileName("Path");</blockquote><blockquote type="cite">r->Update();</blockquote><blockquote type="cite">// What next?</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">return true;</blockquote><blockquote type="cite">}</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I though Take was a possible choice</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">outImage = vtkSmartPointer<vtkImageData>::Take(r->GetOutput());</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">but no happiness there.</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any solution?</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Rick</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________</blockquote><blockquote type="cite">Powered by <a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Visit other Kitware open-source projects at</blockquote><blockquote type="cite"><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Please keep messages on-topic and check the VTK FAQ at:</blockquote><blockquote type="cite"><a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Follow this link to subscribe/unsubscribe:</blockquote><blockquote type="cite"><a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://public.kitware.com/pipermail/vtkusers/attachments/20160516/2787da74/attachment-0001.html%3E" target="_blank">http://public.kitware.com/pipermail/vtkusers/attachments/20160516/2787da74/attachment-0001.html></a><br><br>------------------------------<br><br>Message: 3<br>Date: Mon, 16 May 2016 15:14:15 +0000<br>From: Andras Lasso <<a href="mailto:lasso@queensu.ca" target="_blank">lasso@queensu.ca</a>><br>To: normanius <<a href="mailto:juch@zhaw.ch" target="_blank">juch@zhaw.ch</a>>, "<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>" <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>Subject: Re: [vtkusers] vtkBooleanOperationPolyDataFilter creates<br>    non-manifold        edges<br>Message-ID:<br>        <<a href="mailto:DM2PR07MB350120A5448638CA86B2746D8770@DM2PR07MB350.namprd07.prod.outlook.com" target="_blank">DM2PR07MB350120A5448638CA86B2746D8770@DM2PR07MB350.namprd07.prod.outlook.com</a>><br>        <br>Content-Type: text/plain; charset="us-ascii"<br><br><blockquote type="cite">but it cannot be that one has to do that extra cleanup step after every such basic operation, right?!</blockquote><br>Performing Boolean operation on meshes may sound easy but is an extremely difficult problem. It would be nice if VTK had a solution that worked reliably, so it's great that you submit reports on specific problems you find.<br><br>However, I'm not sure if there is anybody who could work on fixing these issues in the near future. So, if you cannot fix them yourself then most likely your best bet is to work around the problem by converting all meshes to images, combining them, and regenerating a mesh.<br><br>Andras<br><br>-----Original Message-----<br>From: vtkusers [mailto:<a href="mailto:vtkusers-bounces@vtk.org" target="_blank">vtkusers-bounces@vtk.org</a>] On Behalf Of normanius<br>Sent: May 15, 2016 4:54 AM<br>To: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>Subject: [vtkusers] vtkBooleanOperationPolyDataFilter creates non-manifold edges<br><br>Hi all<br><br>This is an issue that has been raised already. But I wanted to ask whether there is a workaround or whether it actually is a bug that has been properly reported.<br><br>Find attached sample code which reproduces the problem: If I union two overlapping, watertight objects A and B, the resulting object C very likely won't be watertight (it shows border edges and non-manifold edges).<br><br>The sample code in essence does this:<br>- create cylinder A as a vtk.vtkCylinderSource<br>- create sphere B as a vtk.vtkSphereSource<br>- extract triangles from A and B<br>- create union C with vtk.vtkBooleanOperationPolyDataFilter() with<br>SetOperationToUnion()<br><br>The problem occurs also, if I use other objects than cylinders or spheres.<br>The problem occurs also, if I "clean/condition" the surfaces of A and B before calculating the union. (I tried vtkCleanPolyData(),<br>vtkFillHolesFilter() and addition of small noise on the vertices, which sometimes helps to regularise operations on objects)<br><br>In the following two screenshots. The first one indicates the two objects to union. The second one shows the result, with the non-manifold and border edges.<br><br><<a href="http://vtk.1045678.n5.nabble.com/file/n5738088/input.png%3E" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5738088/input.png></a><br><<a href="http://vtk.1045678.n5.nabble.com/file/n5738088/result.png%3E" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5738088/result.png></a> <br><br>Because I often make use of vtkBooleanOperationPolyDataFilter, the problem is really annoying for me. That's why I thought to seek help in the community. Any ideas of how to handle this?<br>Cleaning the surface (set flag cleanOutputSurface=True in my code) does improve the situation in some cases - but it cannot be that one has to do that extra cleanup step after every such basic operation, right?!<br><br>By the way: this problem has been reported already: see here <<a href="http://vtk.1045678.n5.nabble.com/Non-manifold-triangles-after-running-vtkBooleanOperationPolydataFilter-td5713964.html%3E" target="_blank">http://vtk.1045678.n5.nabble.com/Non-manifold-triangles-after-running-vtkBooleanOperationPolydataFilter-td5713964.html></a><br>and here<br><<a href="http://vtk.1045678.n5.nabble.com/Broken-surfaces-for-vtkBooleanOperationPolyDataFilter-Bug-td5735413.html%3E" target="_blank">http://vtk.1045678.n5.nabble.com/Broken-surfaces-for-vtkBooleanOperationPolyDataFilter-Bug-td5735413.html></a><br>reproduced_problem.py<br><<a href="http://vtk.1045678.n5.nabble.com/file/n5738088/reproduced_problem.py%3E" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5738088/reproduced_problem.py></a> .<br><br>Thanks for any inputs from your side.<br><br><br><br>--<br>View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkBooleanOperationPolyDataFilter-creates-non-manifold-edges-tp5738088.html" target="_blank">http://vtk.1045678.n5.nabble.com/vtkBooleanOperationPolyDataFilter-creates-non-manifold-edges-tp5738088.html</a><br>Sent from the VTK - Users mailing list archive at <a href="http://Nabble.com" target="_blank">Nabble.com</a>.<br>_______________________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">http://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>Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">http://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>Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br><br>------------------------------<br><br>End of vtkusers Digest, Vol 145, Issue 16<br>*****************************************<br></span></div></div></blockquote></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>