<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt"><div><span>Thanks a lot David,</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>One last thing. How do I delete an VTK object? In python I can't call Delete(). And how can I be sure the object is deleted? I know of DebugOn() and the vtkDebugMacro but how can it be printed? Whenever I am trying this little example in ipython:</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px;
font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>------</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>import vtk</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">a = vtk.vtkObject()</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">a.DebugOn()</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">del a</div><div
style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">------</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">nothing can be seen. Is the object deleted or can't I see the output? How can I make te output visible?</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Cheers,</span></div><div style="color: rgb(0, 0, 0); font-size:
13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Wili</span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">Von:</span></b> David Gobbi <david.gobbi@gmail.com><br> <b><span style="font-weight: bold;">An:</span></b> Willi Huber <surfersparadise85-vtk@yahoo.com> <br><b><span style="font-weight: bold;">CC:</span></b> "vtkusers@vtk.org" <vtkusers@vtk.org> <br> <b><span style="font-weight: bold;">Gesendet:</span></b> 15:17 Dienstag, 12.Februar 2013<br> <b><span style="font-weight: bold;">Betreff:</span></b> Re: [vtkusers] How to dump images
correctly in Python<br> </font> </div> <br>Hi Willi,<br><br>An output exists for as long as its generator exists. Likewise, the<br>generator exists for as long as the output exists. As long as your<br>program is making use of one or the other, neither will be freed. So<br>what you should do is copy the output into a new data object:<br><br>o = vtkImageData()<br>o.DeepCopy(f.GetOutput())<br><br>After you do that, you can delete the original output and the entire<br>pipeline that it was connected to. The new output (i.e. the copy) can<br>be used as input to a new pipeline. You can also try ShallowCopy()<br>instead of DeepCopy(), but after ShallowCopy the original output and<br>its copy share the same data array, so after ShallowCopy you should<br>call ReleaseData on the original output.<br><br>By the way, this is not wrapper-specific. It is exactly the same for<br>VTK in C++.<br><br> - David<br><br>On Tue, Feb 12, 2013
at 5:49 AM, Willi Huber<br><<a ymailto="mailto:surfersparadise85-vtk@yahoo.com" href="mailto:surfersparadise85-vtk@yahoo.com">surfersparadise85-vtk@yahoo.com</a>> wrote:<br>> Hello all,<br>><br>> I still have the same problems.<br>><br>> What is the deal with vtk GetOutput(), GetOutputPort() etc.?<br>> How long does the generator object of this GetOutput() live? Can it be<br>> dumped right after obtaining GetOutput(). How can it be dumped?<br>> How long does the GetOutput()-object, e.g. an image, live? How can it make<br>> it be collected by the garbage collection?<br>><br>> I am generating a large amount of images which have to get dumped correctly.<br>> Please advice me what to do. I think this advices are also helpful for later<br>> generations of VTK-wrapper users.<br>><br>> I have also problems generating only a plain image with a certain value.<br>> What I am currently doing is:<br>><br>>
def generate_scalar_value_filled_3d_vtkImageData(spacing, origin, extent,<br>> scalar_type, scalar_value):<br>> import vtk<br>><br>> image = vtk.vtkImageData()<br>> image.SetExtent([0, 0, 0, 0, 0, 0])<br>> image.SetOrigin(origin)<br>> image.SetSpacing(spacing)<br>> image.SetScalarType(scalar_type)<br>> image.AllocateScalars()<br>><br>> padder = vtk.vtkImageConstantPad()<br>> padder.SetOutputWholeExtent(extent)<br>> padder.SetConstant(scalar_value)<br>> padder.SetInput(image)<br>> padder.Update()<br>><br>> out = padder.GetOutput()<br>> # image.ReleaseData()<br>><br>> return out<br>><br>> Whenever I call ReleaseData on the image my output is somewhat influenced. I<br>> cannot
explain in which way. Can somebody explain me all the underlying<br>> structure and ideas? I am getting more and more confused from minute to<br>> minute.<br>><br>> Thanks in advance.<br>><br>> Best,<br>> Willi<br>><br>><br>> ________________________________<br>> Von: Willi Huber <<a ymailto="mailto:surfersparadise85-vtk@yahoo.com" href="mailto:surfersparadise85-vtk@yahoo.com">surfersparadise85-vtk@yahoo.com</a>><br>> An: "<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" <<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>> Gesendet: 20:30 Montag, 11.Februar 2013<br>> Betreff: [vtkusers] How to dump images correctly in Python<br>><br>> Hello all,<br>><br>> I am having serious space problems. With my program I constantly generate<br>> images and I thought the internal garbage collector of python takes
care but<br>> it doesn't seem so whenever I give an image to an other filter.<br>> Now I am trying to delete all the unnecessary images by my own. Is there a<br>> common way to do this? I am using ReleaseData(). Is there a way to see what<br>> references a certain object?<br>><br>> How is a image in vtk gernerated by a filter? Is it always a new image<br>> whenever I call GetOutput() or still the same all the time?<br>><br>> Best,<br><br><br> </div> </div> </blockquote></div> </div></body></html>