From 0714d3f1ab7da254f91e65cbb0d7f00c1ffbd510 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 22 Aug 2023 08:30:47 -0400 Subject: [PATCH] Fix SHAPE::Distance warnings --- libs/kimath/include/geometry/shape.h | 3 +-- libs/kimath/include/geometry/shape_compound.h | 2 ++ libs/kimath/include/geometry/shape_line_chain.h | 7 +++++++ libs/kimath/src/geometry/shape.cpp | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/kimath/include/geometry/shape.h b/libs/kimath/include/geometry/shape.h index 3a18e58d0d..57c70ebf01 100644 --- a/libs/kimath/include/geometry/shape.h +++ b/libs/kimath/include/geometry/shape.h @@ -239,10 +239,9 @@ public: * Always returns zero if the point is inside a closed shape and aOutlineOnly is false. * * @param aP is the point to test - * @param aOutlineOnly can be set to true to measure the distance to the outline of the shape * @return the distance from the shape to aP */ - virtual int Distance( const VECTOR2I& aP, bool aOutlineOnly = false ) const; + virtual int Distance( const VECTOR2I& aP ) const; /** * @see SHAPE::Distance diff --git a/libs/kimath/include/geometry/shape_compound.h b/libs/kimath/include/geometry/shape_compound.h index e1b3888f2d..f6703201ad 100644 --- a/libs/kimath/include/geometry/shape_compound.h +++ b/libs/kimath/include/geometry/shape_compound.h @@ -74,6 +74,8 @@ public: const BOX2I BBox( int aClearance = 0 ) const override; + using SHAPE::Distance; + int Distance( const SEG& aSeg ) const; void Move( const VECTOR2I& aVector ) override; diff --git a/libs/kimath/include/geometry/shape_line_chain.h b/libs/kimath/include/geometry/shape_line_chain.h index 8d3e08d790..fb29d78d19 100644 --- a/libs/kimath/include/geometry/shape_line_chain.h +++ b/libs/kimath/include/geometry/shape_line_chain.h @@ -862,6 +862,13 @@ public: return ( IsSharedPt( aIndex ) || ( IsPtOnArc( aIndex ) && !IsArcSegment( aIndex ) ) ); } + using SHAPE::Distance; + + int Distance( const VECTOR2I& aP, bool aOutlineOnly ) const + { + return sqrt( SquaredDistance( aP, aOutlineOnly ) ); + } + virtual const VECTOR2I GetPoint( int aIndex ) const override { return CPoint(aIndex); } virtual const SEG GetSegment( int aIndex ) const override { return CSegment(aIndex); } virtual size_t GetPointCount() const override { return PointCount(); } diff --git a/libs/kimath/src/geometry/shape.cpp b/libs/kimath/src/geometry/shape.cpp index 81b54534db..e39c8e1bdb 100644 --- a/libs/kimath/src/geometry/shape.cpp +++ b/libs/kimath/src/geometry/shape.cpp @@ -82,9 +82,9 @@ int SHAPE::GetClearance( const SHAPE* aOther ) const } -int SHAPE::Distance( const VECTOR2I& aP, bool aOutlineOnly ) const +int SHAPE::Distance( const VECTOR2I& aP ) const { - return sqrt( SquaredDistance( aP, aOutlineOnly ) ); + return sqrt( SquaredDistance( aP, false ) ); }