[Insight-developers] itkBoundingBox... and GetMTime()

Luis Ibanez luis.ibanez@kitware.com
Wed, 06 Mar 2002 18:35:23 -0500


Ok,

I just added the overloaded GetMTime() to the Bounding Box
and checked in the test that Jean-Phillipe wrote (and which is now
working fine).

We may want to talk about this GetMTime() at the Tcon.

It may be a lot of ITK objects that should be overloading this
method and are not doing so.


Luis


=============================================

Miller, James V (CRD) wrote:

>Luis,
>
>That is correct. Whenever GetMTime needs to include times from subobjects
>then it needs to override GetMTime().
>
>-----Original Message-----
>From: Luis Ibanez
>To: Miller, James V (CRD)
>Cc: 'Jean-Philippe Guyon'; insight-developers@public.kitware.com
>Sent: 3/6/2002 11:35 AM
>Subject: Re: [Insight-developers] itkBoundingBox... and GetMTime()
>
>
>Jim, Jean-Philippe,
>
>I just double checked a test program that Jean-Philippe wrote
>for the BoundingBox and it is not producing the expected result.
>
>
>Jim,
>if I understand correctly, when you said that the BoundingBox
>in its GetMTime() method should return:
>
> "the latest time of the object itself or any of its sub-items"  
>
>you mean that : the author of the BondingBox class has to overload
>the virtual GetMTime() method and add something like:
>
>
>
>unsingned long GetMTime(void) const
>{
>  unsigned long latestTime = Object::GetMTime(); // start with Object
>itself
>  if( latestTime <  m_PointsContainer->GetMTime() )
>     {
>     latestTime = m_PointsContainer->GetMTime();
>     }
>  return latestTime;
>}
>
>
>
>
>Is that correct ?
>
>Right now the BoundingBox class is not overloading the GetMTime()
>method,
>so the itk::Object::GetMTime() method is called by default and of course
>it
>cannot be aware of the changes made to the PointContainer.
>
>I'm affraid that there are a lot of classes in the toolkit with the same
>
>problem.
>(e.g. for sure all the registration methods. )
>
>If this is the case, we may need something like the PrintSelfTest macro 
>to verify
>that all the classes with ivar members overload GetMTime() and compare
>the
>times of their component with their own time in order to return the 
>latest one.
>
>What would you say is the right way to manage GetMTime()   ?
>
>
>Thanks
>
>   Luis
>
>
>
>====================================================
>
>Miller, James V (CRD) wrote:
>
>>There are a couple of issues here:
>>
>> 
>>
>>1) We usually avoid calling Modified() on every point insertion 
>>because Modified() takes some time and you really don't want
>>
>>to increment the modified time for such a short operation.
>>
>> 
>>
>>Rather, what we normally would do is call InsertElement() on the 
>>points container a number of times, then call Modified()
>>
>>on the container so that it reflects a proper modified time. 
>>
>> 
>>
>>2) itkBoundingBox may not be checking the ModifiedTime of its 
>>container.  If its container has been modified, then
>>
>>that should be reflected in the reported modified time of the bounding
>>
>
>>box.
>>
>> 
>>
>>In general, the GetMTime() method should return the latest time of the
>>
>
>>object itself or any of its sub -items.  In your case,
>>
>>GetMTime() on the BoundingBox should return the later of the its 
>>modified time and the modified time of its points container.
>>
>> 
>>
>>If it is not doing this, that is a bug.
>>
>> 
>>
>>Either way, you shouldn't have to create a new points container.  You 
>>should be able to call InsertElement on the
>>
>>current container and then call Modified() on the container and the 
>>BoundingBox should reflect the proper modified time.
>>
>> 
>>
>>    -----Original Message-----
>>    *From:* Jean-Philippe Guyon [mailto:piloo@unc.edu]
>>    *Sent:* Monday, March 04, 2002 12:12 PM
>>    *To:* insight-developers@public.kitware.com
>>    *Subject:* [Insight-developers] itkBoundingBox... surprising
>>
>behavior
>
>>    Hello Folks,
>>
>>     
>>
>>    I have just noticed something which seems weird in the SetPoints()
>>    function of the itkBoundingBox class.
>>
>>    When you call the SetPoints() function, it is first checking if
>>    the pointer passed as argument is the same as the one currently
>>    stored in the member variable m_PointsContainer. If that is the
>>    same, then the points container pointer is not updated, and the
>>    Modified flag is not turned on.
>>
>>    So, if you are using the bounding box the following way:
>>
>>     
>>
>>    PointContainerPointer p = BB->GetPoints();
>>
>>    p->InsertElement();
>>
>>    // ...or any other function to modify the point container
>>
>>    BB->SetPoints();
>>
>>     
>>
>>    the pointer won't be updated, and that make sense. But, the
>>    modified flag won't be turned on as well, and then the next call
>>    to the ComputeBoundingBox() function will not take into
>>    consideration the fact that the point container has been modified,
>>    since it is only checking for the Modified flag of the BoundingBox
>>    class, and it doesn't keep track of the last time the point
>>    container has been updated.
>>
>>     
>>
>>    So, to curb that problem, I need to create a new point container
>>    every time I want to update the BoundingBox, and then to call the
>>    SetPoints() function... that doesn't seem to be the best way to go
>>    in my opinion :)
>>
>>     
>>
>>    Please, let me know if there is anything I'm doing wrong when I'm
>>    using the bounding box class.
>>
>>    I might do not understand the way to use it.
>>
>>     
>>
>>    Jean-Philippe
>>
>
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers@public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-developers
>