[vtkusers] vtkusers Digest, Vol 145, Issue 16

Shawn Waldon shawn.waldon at kitware.com
Mon May 16 13:46:40 EDT 2016


Rick,

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:

bool myFunction(vtkSmartPointer<vtkImageData> & output)
{
  vtkSmartPointer<vtkImageData> myImage = ...;

  ...

  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.
  return true;
}

You would call it like this:
vtkSmartPointer<vtkImageData> image; // Use default ctor that doesn't
allocate
bool result = myFunction(image);

To the best of my knowledge, the above should work.

HTH,
Shawn


On Mon, May 16, 2016 at 1:38 PM, Richard Frank <rickfrank at me.com> wrote:

> Sorry for the blank reply previous.
>
> The Tutorial is great but I don't see an example of the case I'm talking
> about.
>
> 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.
>
> 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:
>
> bool ReadAnImageFile(vtkSmartPointer<vtkImageData> & theImageRead)
> {
>    vtkSmartPointer<vtkImageFileReader> reader =
>  vtkSmartPointer<vtkImageFileReader>::New9);
>
> reader->SetFileName("Something.png");
> reader->Update();
>
> vtkImageData * image =  reader->GetOutput();  How to get image into
> theImageRead?
>
> // This seems to work
>
> theImageRead->DeepCopy(image);
>
> // but if it's really doing a deep copy and I have a large 3D .mha file or
> something
> // it will be slow.....is there a better way?
> }
>
>
> Thanks
>
> Rick
>
> On May 16, 2016, at 12:00 PM, vtkusers-request at vtk.org wrote:
>
> Send vtkusers mailing list submissions to
>      vtkusers at vtk.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>  http://public.kitware.com/mailman/listinfo/vtkusers
> or, via email, send a message with subject or body 'help' to
>      vtkusers-request at vtk.org
>
> You can reach the person managing the list at
>  vtkusers-owner at vtk.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of vtkusers digest..."
>
>
> Today's Topics:
>
> 1. why does the generated 3D model have borken part? (Liu_tj)
> 2. Re: SmartPointer reference? (Dan Lipsa)
> 3. Re: vtkBooleanOperationPolyDataFilter creates  non-manifold
> edges (Andras Lasso)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 16 May 2016 21:11:33 +0800 (CST)
> From: Liu_tj <tjlp at netease.com>
> To: vtkusers <vtkusers at vtk.org>
> Subject: [vtkusers] why does the generated 3D model have borken part?
> Message-ID: <7543d5b6.11.154b9b16f2f.Coremail.tjlp at netease.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
>
> 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?
>
> Thanks
> Liu Peng
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0001.html>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: First.jpg
> Type: image/jpeg
> Size: 36205 bytes
> Desc: not available
> URL: <
> http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0002.jpg>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: loading.jpg
> Type: image/jpeg
> Size: 24157 bytes
> Desc: not available
> URL: <
> http://public.kitware.com/pipermail/vtkusers/attachments/20160516/b1f7bc02/attachment-0003.jpg>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 16 May 2016 10:18:30 -0400
> From: Dan Lipsa <dan.lipsa at kitware.com>
> To: Richard Frank <rickfrank at me.com>
> Cc: VTK Users <vtkusers at vtk.org>
> Subject: Re: [vtkusers] SmartPointer reference?
> Message-ID:
>  <CADwGrVq4_tna0Oph5Tqn+m=6Uk4GTn8GJuGBvdfZ8XudbjcsBA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Does this help?
> http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers
>
> What exactly is the problem you are seeing?
> Dan
>
>
> On Fri, May 13, 2016 at 7:22 PM, Richard Frank <rickfrank at me.com> wrote:
>
>
> Hi,
>
>
> Is it possible to return a smart pointer by reference?
>
>
> I'd like to return an image as a parameter, rather than a return type but
>
> nothing seems to be happy.
>
>
> for instance
>
>
> bool SomeFunction(vtkSmartPointer<vtkImageData> & outImage)
>
> {
>
> vtkSmartPointer<vtkImageReader> r =
>
> vtkSmartPointer<vtkImageReader>::New();
>
> r->SetFileName("Path");
>
> r->Update();
>
> // What next?
>
>
> return true;
>
> }
>
>
> I though Take was a possible choice
>
>
> outImage = vtkSmartPointer<vtkImageData>::Take(r->GetOutput());
>
>
> but no happiness there.
>
>
> Any solution?
>
>
> Thanks
>
>
> Rick
>
>
>
>
> _______________________________________________
>
> Powered by http://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
>
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
>
> Follow this link to subscribe/unsubscribe:
>
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://public.kitware.com/pipermail/vtkusers/attachments/20160516/2787da74/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 16 May 2016 15:14:15 +0000
> From: Andras Lasso <lasso at queensu.ca>
> To: normanius <juch at zhaw.ch>, "vtkusers at vtk.org" <vtkusers at vtk.org>
> Subject: Re: [vtkusers] vtkBooleanOperationPolyDataFilter creates
>    non-manifold        edges
> Message-ID:
>        <
> DM2PR07MB350120A5448638CA86B2746D8770 at DM2PR07MB350.namprd07.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> but it cannot be that one has to do that extra cleanup step after every
> such basic operation, right?!
>
>
> 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.
>
> 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.
>
> Andras
>
> -----Original Message-----
> From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of normanius
> Sent: May 15, 2016 4:54 AM
> To: vtkusers at vtk.org
> Subject: [vtkusers] vtkBooleanOperationPolyDataFilter creates non-manifold
> edges
>
> Hi all
>
> 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.
>
> 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).
>
> The sample code in essence does this:
> - create cylinder A as a vtk.vtkCylinderSource
> - create sphere B as a vtk.vtkSphereSource
> - extract triangles from A and B
> - create union C with vtk.vtkBooleanOperationPolyDataFilter() with
> SetOperationToUnion()
>
> The problem occurs also, if I use other objects than cylinders or spheres.
> The problem occurs also, if I "clean/condition" the surfaces of A and B
> before calculating the union. (I tried vtkCleanPolyData(),
> vtkFillHolesFilter() and addition of small noise on the vertices, which
> sometimes helps to regularise operations on objects)
>
> 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.
>
> <http://vtk.1045678.n5.nabble.com/file/n5738088/input.png>
> <http://vtk.1045678.n5.nabble.com/file/n5738088/result.png>
>
> 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?
> 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?!
>
> By the way: this problem has been reported already: see here <
> http://vtk.1045678.n5.nabble.com/Non-manifold-triangles-after-running-vtkBooleanOperationPolydataFilter-td5713964.html>
> and here
> <
> http://vtk.1045678.n5.nabble.com/Broken-surfaces-for-vtkBooleanOperationPolyDataFilter-Bug-td5735413.html>
> reproduced_problem.py
> <http://vtk.1045678.n5.nabble.com/file/n5738088/reproduced_problem.py> .
>
> Thanks for any inputs from your side.
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/vtkBooleanOperationPolyDataFilter-creates-non-manifold-edges-tp5738088.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by http://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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Powered by http://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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
> ------------------------------
>
> End of vtkusers Digest, Vol 145, Issue 16
> *****************************************
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160516/ed5dd7ae/attachment.html>


More information about the vtkusers mailing list