[Insight-users] SpatialObject and MTimes
Gavin Baker
gavinb+xtk at cs.mu.OZ.AU
Mon May 23 02:34:38 EDT 2005
Greetings,
I have been working on some modelling with the SpatialObject classes,
and came across some unexpected behaviour.
Basically, the MTime of the SpatialObject is determined only by its
bounds and the MTime of its children. But it also has MTimes
associated with its transforms, which are not taken into account.
So, an example of a potential problem is:
1. Create a SpatialObject
2. Initialise its parent transform
3. Connect it to a SpatialObjectToImageFilter
4. Update the filter, saving its output
5. Do some processing (eg. model-image registration)
6. Change the object's transform
7. Call Update() on the writer to render the object and save the output
What I would expect to happen is to see the newly transformed object
in the output. But the MTime, which is set in step #2 does not change
at step #6, so the output of the rendering filter is unchanged.
(I have some code to demonstrate this if it helps, it's just a hacked
up version of the ModelImageRegistration1.cxx example.)
The obvious thing seems to be to include the MTime of the transforms
in the MTime of the object itself. Especially since changing the
transform will potentially change the bounding box (upon which the
object's MTime depends).
[Later]
I've made a patch to the SpatialObject code, it seems to work with my
program, and fix the problem described above. Please find it attached
below. It includes the MTime of the two transforms, and also adds
const qualifiers to the two Get* methods (which would be good to
include, regardless of the other changes).
[Later again]
I have re-run the SpatialObject test suite against this, and they all
pass, so it hasn't caused major breakage (yet!).
Can someone familiar with the SpatialObjects framework please comment?
Thanks,
:: Gavin
--
Gavin Baker Complex Systems Group
http://www.cs.mu.oz.au/~gavinb The University of Melbourne
-------------- next part --------------
Index: itkSpatialObject.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/SpatialObject/itkSpatialObject.h,v
retrieving revision 1.59
diff -u -r1.59 itkSpatialObject.h
--- itkSpatialObject.h 4 Apr 2005 13:58:35 -0000 1.59
+++ itkSpatialObject.h 23 May 2005 06:22:08 -0000
@@ -173,10 +173,10 @@
void ComputeObjectToParentTransform(void);
/** Return the Modified time of the LocalToWorldTransform */
- unsigned long GetTransformMTime( void );
+ unsigned long GetTransformMTime( void ) const;
/** Return the Modified time of the WorldToLocalTransform */
- unsigned long GetWorldTransformMTime( void );
+ unsigned long GetWorldTransformMTime( void ) const;
/** Returns the value at a point */
virtual bool ValueAt( const PointType & point, double & value,
Index: itkSpatialObject.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/SpatialObject/itkSpatialObject.txx,v
retrieving revision 1.62
diff -u -r1.62 itkSpatialObject.txx
--- itkSpatialObject.txx 9 Mar 2005 16:46:14 -0000 1.62
+++ itkSpatialObject.txx 23 May 2005 06:22:08 -0000
@@ -487,6 +487,21 @@
{
latestTime = m_BoundsMTime;
}
+
+ unsigned long transformMTime = this->GetTransformMTime();
+
+ if( latestTime < transformMTime )
+ {
+ latestTime = transformMTime;
+ }
+
+ unsigned long worldMTime = this->GetWorldTransformMTime();
+
+ if( latestTime < worldMTime )
+ {
+ latestTime = worldMTime;
+ }
+
typedef typename TreeNodeType::ChildrenListType ChildrenListType;
if(!m_TreeNode)
@@ -633,7 +648,7 @@
template< unsigned int TDimension >
unsigned long
SpatialObject< TDimension >
-::GetTransformMTime(void)
+::GetTransformMTime(void) const
{
return m_ObjectToParentTransform->GetMTime();
}
@@ -642,7 +657,7 @@
template< unsigned int TDimension >
unsigned long
SpatialObject< TDimension >
-::GetWorldTransformMTime(void)
+::GetWorldTransformMTime(void) const
{
return m_IndexToWorldTransform->GetMTime();
}
More information about the Insight-users
mailing list