Page MenuHomePhabricator

geometry3d.patch

Authored By
ritter
Sep 1 2010, 2:38 PM
Size
1 KB
Referenced Files
None
Subscribers
None

geometry3d.patch

Index: mitk/Core/Code/DataManagement/mitkGeometry3D.h
===================================================================
--- mitk/Core/Code/DataManagement/mitkGeometry3D.h (revision 25851)
+++ mitk/Core/Code/DataManagement/mitkGeometry3D.h (working copy)
@@ -434,19 +434,35 @@
}
//##Documentation
- //## @brief Test whether the point \a p (index coordinates in units) is
+ //## @brief Test whether the point \a p ((continous!)index coordinates in units) is
//## inside the bounding box
bool IsIndexInside(const mitk::Point3D& index) const
{
- bool inside = m_BoundingBox->IsInside(index);
- if((m_ImageGeometry) && (inside))
+ bool inside = false;
+ //if it is an image geometry, we need to convert the index to discrete values
+ //this is done by applying the rounding function also used in WorldToIndex (see line 323)
+ if (m_ImageGeometry)
{
- const BoundingBox::BoundsArrayType& bounds = m_BoundingBox->GetBounds();
- if((index[0] == bounds[1]) ||
- (index[1] == bounds[3]) ||
- (index[2] == bounds[5]))
- inside = false;
+ mitk::Point3D discretIndex;
+ discretIndex[0]=itk::Math::RoundHalfIntegerUp( index[0] );
+ discretIndex[1]=itk::Math::RoundHalfIntegerUp( index[1] );
+ discretIndex[2]=itk::Math::RoundHalfIntegerUp( index[2] );
+
+ inside = m_BoundingBox->IsInside(discretIndex);
+ //we have to check if the index is at the upper border of each dimension,
+ // because the boundingbox is not centerbased
+ if (inside)
+ {
+ const BoundingBox::BoundsArrayType& bounds = m_BoundingBox->GetBounds();
+ if((discretIndex[0] == bounds[1]) ||
+ (discretIndex[1] == bounds[3]) ||
+ (discretIndex[2] == bounds[5]))
+ inside = false;
+ }
}
+ else
+ inside = m_BoundingBox->IsInside(index);
+
return inside;
}

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
539
Default Alt Text
geometry3d.patch (1 KB)

Event Timeline

patch for correcting the IsIndexInside function