[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>
if(m_PointsContainer->Size() < 1)<br>
{<br>
m_Bounds.Fill( NumericTraits< CoordRepType >::Zero );<br>
m_BoundsMTime.Modified();<br>
return false;<br>
}<br>
<br>
PointsContainerConstIterator ci = m_PointsContainer->Begin();<br>
Point< TCoordRep, VPointDimension> point = ci->Value();<br>
for (unsigned int i=0; i < PointDimension; i++)<br>
{<br>
m_Bounds[2*i ] = point[i];<br>
m_Bounds[2*i+1] = point[i];<br>
}<br>
++ci;<br>
<br>
//use a const iterator to grab the points and compute<br>
//the bounding box.<br>
while( ci != m_PointsContainer->End() )<br>
{<br>
...<br>
++ci;<br>
}<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> </div>
<div><font face="Arial" size="2"> if (m_PointsContainer->Size() <
1)<br>
return false;</font></div>
<div> </div>
<div><font face="Arial" size="2"> for (unsigned int i=0; i < PointDimension;
i++)<br>
{<br>
m_Bounds[2*i] = m_PointsContainer->Begin()->Value()[i];<br>
m_Bounds[2*i+1] = m_PointsContainer->Begin()->Value()[i];<br>
}<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<valueType>::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->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:</font></div>
<div> </div>
<div><font face="Arial" size="2"> if ( point[i] > m_Bounds[2*i+1]
)<br>
{<br>
m_Bounds[2*i+1] = point[i];<br>
}<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> </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--