[Insight-users] Problem with BoundingBox

Stephen R. Aylward aylward@unc.edu
Wed, 22 Jan 2003 17:48:23 -0500


--------------070402010106060000060607
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I think you just pointed out another flaw....how about :-)

    if(m_PointsContainer->Size() < 1)
      {
      m_Bounds.Fill( NumericTraits< CoordRepType >::Zero );
      m_BoundsMTime.Modified();
      return false;
      }

    PointsContainerConstIterator ci = m_PointsContainer->Begin();
    Point< TCoordRep, VPointDimension>   point = ci->Value();
    for (unsigned int i=0; i < PointDimension; i++)
      {
      m_Bounds[2*i  ] = point[i];
      m_Bounds[2*i+1] = point[i];
      }
    ++ci;

    //use a const iterator to grab the points and compute
    //the bounding box.
    while( ci != m_PointsContainer->End() )
      {
       ...
       ++ci;
       }



Parag Chandra wrote:

> Thanks. The fix I am using currently is to copy itk::BoundingBox into 
> my own namespace and then modify ComputeBoundingBox() as follows:
>  
>     if (m_PointsContainer->Size() < 1)
>       return false;
>  
>     for (unsigned int i=0; i < PointDimension; i++)
>       {
>       m_Bounds[2*i] = m_PointsContainer->Begin()->Value()[i];
>       m_Bounds[2*i+1] = m_PointsContainer->Begin()->Value()[i];
>       }
> Seems to work so far.
>
>     ----- Original Message -----
>     *From:* Stephen R. Aylward <mailto:aylward@unc.edu>
>     *To:* Parag Chandra <mailto:pchandra@radonc.unc.edu>
>     *Cc:* ITK Mailing List <mailto:insight-users@public.kitware.com>
>     *Sent:* Wednesday, January 22, 2003 5:14 PM
>     *Subject:* Re: [Insight-users] Problem with BoundingBox
>
>
>     Thanks.
>
>     We can change the initial value to
>     NumericTraits<valueType>::NonPositiveMin() and your problem should
>     be fixed.
>
>     I will check the fix into cvs...
>
>     s
>
>     Parag Chandra wrote:
>
>>     I have a 2-D set of points that I want to compute the bounding
>>     box of. Using itk::BoundingBox->ComputeBoundingBox() gives the
>>     correct values for the first three points (xMin, xMax, yMin), but
>>     the fourth point (yMax) is always 2.225e-308, the default value
>>     as returned by NumericTraits<double>::min(). All the y-values in
>>     my point set are negative, so of course, the following block:
>>      
>>             if ( point[i] > m_Bounds[2*i+1] )
>>               {
>>               m_Bounds[2*i+1] = point[i];
>>               }
>>     will never be executed. Is this a bug that needs to be/has
>>     already been addressed?
>>      
>>     Thanks,
>>     -Parag
>
>
>-- 
>=======================================================================
>Stephen R. Aylward, Ph.D.			www.cs.unc.edu/~aylward
>Research Assistant Professor of Radiology		aylward@unc.edu
>Adjunct Assistant Professor of Computer Science		  (919)966-9695
>    
>
>


--------------070402010106060000060607
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
I think you just pointed out another flaw....how about :-)<br>
<br>
&nbsp;&nbsp;&nbsp; if(m_PointsContainer-&gt;Size() &lt; 1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bounds.Fill( NumericTraits&lt; CoordRepType &gt;::Zero );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_BoundsMTime.Modified();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; PointsContainerConstIterator ci = m_PointsContainer-&gt;Begin();<br>
&nbsp;&nbsp;&nbsp; Point&lt; TCoordRep, VPointDimension&gt;&nbsp;&nbsp; point = ci-&gt;Value();<br>
&nbsp;&nbsp;&nbsp; for (unsigned int i=0; i &lt; PointDimension; i++)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bounds[2*i&nbsp; ] = point[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bounds[2*i+1] = point[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp; &nbsp; ++ci;<br>
<br>
&nbsp;&nbsp;&nbsp; //use a const iterator to grab the points and compute<br>
&nbsp;&nbsp;&nbsp; //the bounding box.<br>
&nbsp;&nbsp;&nbsp; while( ci != m_PointsContainer-&gt;End() )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp; &nbsp; &nbsp; &nbsp;...<br>
&nbsp; &nbsp; &nbsp; &nbsp;++ci;<br>
&nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
<br>
<br>
Parag Chandra wrote:<br>
<blockquote type="cite"
 cite="mid003201c2c265$0b1116f0$99221398@radonc.radonc.unc.edu">
  <title></title>
  
  <meta http-equiv="Content-Type" content="text/html; ">
 
  <meta content="MSHTML 6.00.2800.1126" name="GENERATOR">
 
  <div><font face="Arial" size="2">Thanks. The fix I am using currently is
to copy  itk::BoundingBox into my own namespace and then modify ComputeBoundingBox()
as  follows:</font></div>
 
  <div>&nbsp;</div>
 
  <div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp; if (m_PointsContainer-&gt;Size()  &lt;
1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;</font></div>
 
  <div>&nbsp;</div>
 
  <div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp; for (unsigned int i=0; i &lt;  PointDimension;
i++)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bounds[2*i] =  m_PointsContainer-&gt;Begin()-&gt;Value()[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  m_Bounds[2*i+1] =  m_PointsContainer-&gt;Begin()-&gt;Value()[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br>
  </font></div>
 
  <div><font face="Arial" size="2">Seems to work so far.</font></div>
 
  <blockquote
 style="border-left: 2px solid rgb(0,0,0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"> 
  
    <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;">-----
Original Message ----- </div>
   
    <div
 style="background: rgb(228,228,228) none repeat scroll 0%; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>From:</b>
   <a title="aylward@unc.edu" href="mailto:aylward@unc.edu">Stephen R. Aylward</a>
   </div>
   
    <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>To:</b>
    <a title="pchandra@radonc.unc.edu"
 href="mailto:pchandra@radonc.unc.edu">Parag Chandra</a> </div>
   
    <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>Cc:</b>
    <a title="insight-users@public.kitware.com"
 href="mailto:insight-users@public.kitware.com">ITK Mailing List</a> </div>
   
    <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>Sent:</b>
Wednesday, January 22, 2003 5:14    PM</div>
   
    <div
 style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>Subject:</b>
Re: [Insight-users] Problem with    BoundingBox</div>
   
    <div><br>
    </div>
    <br>
Thanks.<br>
    <br>
We can change the initial value to    NumericTraits&lt;valueType&gt;::NonPositiveMin()
and your problem should be    fixed.<br>
    <br>
I will check the fix into cvs...<br>
    <br>
s<br>
    <br>
Parag Chandra    wrote:<br>
   
    <blockquote
 cite="mid001e01c2c260$e5260bc0$99221398@radonc.radonc.unc.edu"
 type="cite">     
      <meta content="MSHTML 6.00.2800.1126" name="GENERATOR">
     
      <style></style>      
      <div><font face="Arial" size="2">I have a 2-D set of points that I
want to      compute the bounding box of. Using itk::BoundingBox-&gt;ComputeBoundingBox()
     gives the correct values for the first three points (xMin, xMax, yMin),
but      the fourth point (yMax) is always 2.225e-308, the default value
as returned      by NumericTraits&lt;double&gt;::min(). All the y-values
in my point set are      negative, so of course, the following block:</font></div>
     
      <div>&nbsp;</div>
     
      <div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (      point[i] &gt; m_Bounds[2*i+1]
     )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bounds[2*i+1]      = point[i];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      }<br>
      </font></div>
     
      <div><font face="Arial" size="2">will never be executed. Is this a
bug that      needs to be/has already been addressed?</font></div>
     
      <div>&nbsp;</div>
     
      <div><font face="Arial" size="2">Thanks,</font></div>
     
      <div><font face="Arial" size="2">-Parag</font></div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="$mailwrapcol">-- 
=======================================================================
Stephen R. Aylward, Ph.D.			<a class="moz-txt-link-abbreviated"
 href="http://www.cs.unc.edu/%7Eaylward">www.cs.unc.edu/~aylward</a>
Research Assistant Professor of Radiology		<a
 class="moz-txt-link-abbreviated" href="mailto:aylward@unc.edu">aylward@unc.edu</a>
Adjunct Assistant Professor of Computer Science		  (919)966-9695
    </pre>
    <br>
  </blockquote>
</blockquote>
<br>
</body>
</html>

--------------070402010106060000060607--