[vtkusers] Simple questions?

Dubois, John R (MED) John.Dubois at med.ge.com
Thu Aug 21 16:16:36 EDT 2003


Sorry to bother you all, but I am new to vtk and I have a few questions
that I can't find answers to in the FAQs and I haven't had much luck
searching the archives. Well here are my questions:

1.	What is the deal with this New() and Delete() functions and
hiding the constructors? Why not simply overload the standard new and
delete (and new[] and delete[]) for the class? Doesn't this New() and
Delete() break the normal C++ allocation and free mechanisim? Consider
this vtkActor* actors = new vtkActor[100];. This is not an unreasonable
thing to do, I suspect, but can't be done with the current design. Is
there a compelling reason why custom method "New()" whas chosen over the
standard native "operator new()"?
2.	There appears to be a few bugs in the smart pointer
architecture, or am I missing something? Why does the reference count
start at 1? This causes the smart pointer clean up to fail; consider the
trivial case of: {vtkSmartPointer<vtkConeSource> cone =
vtkConeSource::New();}. The operator =() increments the reference count
to 2 so than when cone goes out of scope at } the reference count is
only decremented to 1 and the object is leaked. 
3.	The assignment operator for smart pointers calls Swap on a const
reference. Swap() is not a const member. Is it not poor style to modify
your const arguments?
4.	There is no vtkSmartPointer& operator=(const  vtkSmartPointer&
r) defined so assignments between vtkSmartPointers will not reference
count properly (Register is not called on the RHS and the LHS is not
UnRegister()ed).
5.	Why isn't the type bool used in the library? I've seen a few
functions that appear to be "yes/no" kinds of functions but they return
int. This makes it impossible to overload or specialize for bool types.
Is there a good reason for not using bool?
6.	Is there a bug in SetNthOutput? I seems to cause a Register()
call to "this" (itself) - the object effectively references itself so it
can never be deleted. In the tests I did the object was in fact leaked
(with a reference count of 2 - one for the reference count
initialization and one for the self-reference).

Any help with this would be appreciated.

GE logoGE Medical Systems 
_______________________________________________ 


John Dubois




Software Programmer

Functional and Molecular Imaging 
Phone: 519-858-5009 
E-mail: John.Dubois at med.ge.com
<mailto:John.Dubois at med.ge.com?subject=e-mail reply>  

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030821/306def81/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: John R Dubois (MED) (E-mail).vcf
Type: application/octet-stream
Size: 359 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030821/306def81/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GE48.gif
Type: image/gif
Size: 1151 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030821/306def81/attachment.gif>


More information about the vtkusers mailing list