Make sure RTree bounding box is at least as big as hole.

Fixes https://gitlab.com/kicad/code/kicad/issues/9526
This commit is contained in:
Jeff Young 2021-11-05 14:28:49 +00:00
parent b73793f9ef
commit d66487c383
1 changed files with 21 additions and 1 deletions

View File

@ -49,6 +49,21 @@ static const SHAPE* shapeFunctor( T aItem )
return aItem->Shape();
}
/**
* Used by #SHAPE_INDEX to get a SHAPE* for a hole from another type.
*
* By default relies on T::GetHole() method, should be specialized if the T object
* doesn't allow that method.
*
* @param aItem generic T object.
* @return a SHAPE* object equivalent to object.
*/
template <class T>
static const SHAPE* holeFunctor( T aItem )
{
return aItem->Hole();
}
/**
* Used by #SHAPE_INDEX to get the bounding box of a generic T object.
*
@ -61,7 +76,12 @@ static const SHAPE* shapeFunctor( T aItem )
template <class T>
BOX2I boundingBox( T aObject )
{
return shapeFunctor( aObject )->BBox();
BOX2I bbox = shapeFunctor( aObject )->BBox();
if( holeFunctor( aObject ) )
bbox.Merge( holeFunctor( aObject )->BBox() );
return bbox;
}
/**