[Insight-developers] itkBoundingBox... surprising behavior

Miller, James V (CRD) millerjv@crd.ge.com
Mon, 4 Mar 2002 14:21:57 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C1C3B1.08903C64
Content-Type: text/plain;
	charset="iso-8859-1"

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


------_=_NextPart_001_01C1C3B1.08903C64
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>There are a 
couple of issues here:</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>1) We usually 
avoid calling Modified() on every point insertion because Modified() takes some 
time and you really don't want</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>to increment the 
modified time for such a short operation.</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>Rather, what we 
normally would do is call InsertElement() on the points container a number of 
times, then call Modified()</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>on the container 
so that it reflects a proper modified time.&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>2) itkBoundingBox 
may not be checking the ModifiedTime of its container.&nbsp; If its container 
has been modified, then</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>that should be 
reflected in the reported modified time of the bounding box.</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>In general, the 
GetMTime() method should return the latest time of the object itself or any of 
its sub -items.&nbsp; In your case,</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>GetMTime() on the 
BoundingBox should return the later of the its modified time and the modified 
time of its points container.</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>If it is not 
doing this, that is a bug.</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>Either way, you 
shouldn't have to create a new points container.&nbsp; You should be able to 
call InsertElement on the </FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002><FONT color=#0000ff size=2>current container 
and then call Modified() on the container and the BoundingBox should reflect the 
proper modified time.</FONT></SPAN></DIV>
<DIV><SPAN class=839061619-04032002></SPAN>&nbsp;</DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Jean-Philippe Guyon 
  [mailto:piloo@unc.edu]<BR><B>Sent:</B> Monday, March 04, 2002 12:12 
  PM<BR><B>To:</B> insight-developers@public.kitware.com<BR><B>Subject:</B> 
  [Insight-developers] itkBoundingBox... surprising 
behavior<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>Hello Folks,</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>I have just noticed something which seems weird 
  in the SetPoints() function of the itkBoundingBox class.</FONT></DIV>
  <DIV><FONT face=Arial size=2>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&nbsp;that is the 
  same, then the points container pointer is not updated, and the Modified flag 
  is not turned on.</FONT></DIV>
  <DIV><FONT face=Arial size=2>So, if you are using the bounding box the 
  following way:</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>PointContainerPointer p = 
  BB-&gt;GetPoints();</FONT></DIV>
  <DIV><FONT face=Arial size=2>p-&gt;InsertElement(); </FONT></DIV>
  <DIV><FONT face=Arial size=2>// ...or any other function to modify the point 
  container</FONT></DIV>
  <DIV><FONT face=Arial size=2>BB-&gt;SetPoints();</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>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&nbsp;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.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>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 :)</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Please, let me know if there is anything I'm 
  doing wrong when I'm using the bounding box class.</FONT></DIV>
  <DIV><FONT face=Arial size=2>I might do not understand the way to use it. 
  </FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial 
size=2>Jean-Philippe</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C1C3B1.08903C64--