From b618da1fac26800963c3e6e99fe10143e85319be Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 19 Apr 2018 13:20:25 -0700 Subject: [PATCH] Fixing bounding box calc for arcs --- common/geometry/shape_arc.cpp | 20 ++++++++++++++++++++ include/geometry/shape_arc.h | 6 +----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/common/geometry/shape_arc.cpp b/common/geometry/shape_arc.cpp index b954d1701c..5ea3a56237 100644 --- a/common/geometry/shape_arc.cpp +++ b/common/geometry/shape_arc.cpp @@ -22,6 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include + #include #include @@ -146,6 +148,24 @@ const VECTOR2I SHAPE_ARC::GetP1() const return p1; } + +const BOX2I SHAPE_ARC::BBox( int aClearance ) const +{ + BOX2I bbox; + std::vector points; + points.push_back( m_pc ); + points.push_back( m_p0 ); + points.push_back( GetP1() ); + + bbox.Compute( points ); + + if( aClearance != 0 ) + bbox.Inflate( aClearance ); + + return bbox; +} + + bool SHAPE_ARC::Collide( const VECTOR2I& aP, int aClearance ) const { assert( false ); diff --git a/include/geometry/shape_arc.h b/include/geometry/shape_arc.h index b906cd1fee..8cf3482438 100644 --- a/include/geometry/shape_arc.h +++ b/include/geometry/shape_arc.h @@ -63,11 +63,7 @@ public: const VECTOR2I GetP1() const; const VECTOR2I& GetCenter() const { return m_pc; } - const BOX2I BBox( int aClearance = 0 ) const override - { - assert( false ); - return BOX2I(); // fixme - } + const BOX2I BBox( int aClearance = 0 ) const override; bool Collide( const SEG& aSeg, int aClearance = 0 ) const override; bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const override;