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

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


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
>