[vtkusers] object existence

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Wed Jul 7 12:27:08 EDT 2010


Hi,

I had a similar issue. I simply checked whether there was any interaction
with the vtkContourWidget. I did this by checking whether the contour
widget's representation has a valid data pointer. This allowed me to verify
the widget's existence.

Hope this helps,

Prathamesh

------------------------------

Message: 6
Date: Wed, 7 Jul 2010 09:50:24 +0200
From: "Barth, Sebastian" <sebastian.barth at iosb.fraunhofer.de>
Subject: Re: [vtkusers] object existence
To: Haider Syed <hsyed88 at yahoo.com>, "vtkusers at vtk.org"
       <vtkusers at vtk.org>
Message-ID:
       <
350EDD93E99EC240BD736766AD0E9008021C5DA604 at MS3EXCHANGE.ms3.corp>
Content-Type: text/plain; charset="us-ascii"

Hello,

I don't know if it is possible. You can call GetReferenceCount() but this
will cause an application crash if the objects does not exist.
Anyway, you normally should not come into the situation where you have to
check, if a reference you hold is still existing.

I'm also still confused by the garbage collection of VTK.

vtkObjectBase::New() will create and return a new instance of vtkObject with
a reference count of 1 (vtk assumes that you are holding a reference to this
object in the current scope).

If you now assign this object to another vtkObjectBase, its reference count
will be increased by 1 to 2.

If you now call Delete() or Unregister(int) (I still don't know for what the
parameter is used for) the reference count is decreased by 1 but the object
is NOT deleted since its reference count is still higher than 0 (it's 1).

I could not find a difference between Delete() and Unregister(int) apart of
the parameter that seems not to be used (or I am too stupid to read the
code).

Register() increases the reference count of an object.
Normally, all set, add, append, and remove methods in VTK should use these
functions by default.

Hope this helps.
Correct me if I am wrong.

Sebastian Barth

Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag
von Haider Syed
Gesendet: Dienstag, 6. Juli 2010 16:52
An: vtkusers at vtk.org
Betreff: [vtkusers] object existence

Hi,

I have an instance of vtkContourWidget declared, call it cwidget.  I have a
delete button for this instance and I need to check if the instance exists
or not.  How can I check if cwidget exists or not.  This may have something
to do with reference counting but I don't understand this concept fully....



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
http://www.vtk.org/pipermail/vtkusers/attachments/20100707/85755d7b/attachment-0001.htm
>

------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100707/f1dae82a/attachment.htm>


More information about the vtkusers mailing list