[Insight-users] Get-methods in itk::BoundingBox

Luis Ibanez luis.ibanez at kitware.com
Tue, 03 Feb 2004 15:27:49 -0500


Hi Ivo,


Thanks for pointing this out.


1)  GetBounds() was fixed by replacing

    itkGetConstMacro() with itkGetConstReferenceMacro()



2)  Documentation was fixed.
     It will not show up online until tomorrow
     since Doxygen html pages are regenerated
     overnight.

     The only concern with invoking ComputeBoundingBox()
     inside GetBounds() is that GetBounds() may be a
     frequently called method.  There may be a performance
     penalty if add an internall invokation to Compute
     BoundingBox().

     In the documentation is not stated that GetBounds()
     should only be called after ComputeBoundingBox().


Regards,


    Luis


-------------------
Ivo Wolf wrote:

> Hi Luis,
> 
> Thank you very much for the changes!
> 
> I just recognized two additional issues, which may be useful to be changed.
> 
> 1.) The return type of GetBounds() is BoundsArrayType. BoundsArrayType 
> is a FixedArray.
> Thus, every time GetBounds is called, a FixedArray is constructed and 
> m_Bounds is copied
> into it. My suggestion would be to return a const reference to m_Bounds.
> 
> Furthermore, the documentation of GetBounds does not match the 
> implementation anymore
> (NULL is never returned):
> 
> /** Get the bounding box. NULL is returned if the bounding box cannot be
> * computed. (This may happen if the user never specifies something to
> * compute the bounding box from.) */
> 
> ------------------------
> 
> 2.) It seems that most access methods call ComputeBoundingBox() before 
> returning except GetBounds and IsInside. Maybe it would be more consistent
> when they would also call ComputeBoundingBox().
> 
> 
> Best regards,
> 
> Ivo
> 
> Luis Ibanez wrote:
> 
>>
>> Hi Ivo,
>>
>> Thanks for pointing this out.
>>
>> This was entered as Bug # 559
>> http://www.itk.org/Bug/bug.php?op=show&bugid=559&pos=0
>> and has now been fixed in CVS.
>>
>>
>> The following methods where changed
>>
>> >   bool ComputeBoundingBox(void) const;
>> >   PointType GetCenter(void) const;
>> >   PointType GetMinimum(void) const;
>> >   PointType GetMaximum(void) const;
>> >   AccumulateType GetDiagonalLength2(void) const;
>> >   bool IsInside( const PointType & ) const;
>>
>> and the ivars were made mutable:
>>
>>
>> >   mutable  BoundsArrayType    m_Bounds;
>> >   mutable  TimeStamp          m_BoundsMTime;
>>
>>
>> Please let us know if you find any further
>> problems,
>>
>>
>>    Thanks
>>
>>
>>       Luis
>>
>>
>>
>> -----------------------
>> Ivo Wolf wrote:
>>
>>> Hello,
>>>
>>> most of the Get-methods of itk::BoundingBox are not const.
>>>
>>> The reason is probably that they are calling ComputeBoundingBox(),
>>> which changes m_Bounds and therefore cannot be const
>>> (as long as m_Bounds is not defined mutable).
>>>
>>> Two methods do not call ComputeBoundingBox():
>>> GetBounds (which is const and generated by a macro) and IsInside.
>>>
>>> Is this deliberately so?
>>>
>>> It would be nice to some const Get-methods (or at least keep GetBounds
>>> const), because otherwise the bounding-box can not be used in
>>> other const-methods.
>>>
>>> Regards,
>>>
>>> Ivo
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
> 
>