[Insight-developers] (even more) minor consistency issues

Zachary Pincus zpincus at stanford.edu
Sun Jan 15 15:26:31 EST 2006


Hi guys, it's me again (sorry!)

Gaetan and I have uncovered yet another little consistency issue in  
ITK. This time it's in Insight/Code/SpatialObject/itkSpatialObject.h

Specifically, the code there to set/get the TreeNode object looks  
like this:
   /** Set the tree container */
   void SetTreeNode(TreeNodeType* node) {m_TreeNode = node;}

   /** Return a raw pointer to the node container */
   typename TreeNodeType::Pointer GetTreeNode() {return m_TreeNode;}
   typename TreeNodeType::ConstPointer GetTreeNode() const {return  
m_TreeNode;}

Somehow, the two get functions confuse the compiler in the nasty SWIG- 
generated code. I honestly can't figure out what precisely the  
problem in the SWIG rat's nest of code is, but it's a doozie.

Ignoring that for the time being, it seems that from an ITK  
standpoint, these setters and getters have problems too!  
Specifically, the getters don't return a raw pointer as (a) they  
claim to do, and (b) as proper object getters created with  
itkGetObjectMacro do. Moreover, the MTime information isn't updated  
by the setter, and so forth.

Unless anyone knows why these functions need to *not* use the proper  
set/get macros, I propose to change the above block to:
   /** Set the tree container */
   itkSetObjectMacro(TreeNode, TreeNodeType)

   /** Get the tree container */
   itkGetObjectMacro(TreeNode, TreeNodeType);
   itkGetConstObjectMacro(TreeNode, TreeNodeType);

This change also results in SWIG generating proper code. Generally  
SWIG doesn't generate broken wrapper code unless the original code  
has some subtle errors, so I suspect that this change is for the best.

I'll follow the usual drill -- barring any objections in the next few  
days, I'll open a bug and commit my proposed fix.

Zach


More information about the Insight-developers mailing list