Const fixes.

This commit is contained in:
Jeff Young 2020-06-21 15:58:44 +01:00
parent 158f6ad526
commit d89f8407e0
3 changed files with 19 additions and 12 deletions

View File

@ -1176,7 +1176,7 @@ class SHAPE_POLY_SET : public SHAPE
* @return int - The minimum distance between aPoint and all the segments of the aIndex-th
* polygon. If the point is contained in the polygon, the distance is zero.
*/
SEG::ecoord SquaredDistanceToPolygon( VECTOR2I aPoint, int aIndex );
SEG::ecoord SquaredDistanceToPolygon( VECTOR2I aPoint, int aIndex ) const;
/**
* Function DistanceToPolygon
@ -1190,7 +1190,7 @@ class SHAPE_POLY_SET : public SHAPE
* aIndex-th polygon. If the point is contained in the polygon, the
* distance is zero.
*/
SEG::ecoord SquaredDistanceToPolygon( const SEG& aSegment, int aIndex );
SEG::ecoord SquaredDistanceToPolygon( const SEG& aSegment, int aIndex ) const;
/**
* Function SquaredDistance
@ -1200,7 +1200,7 @@ class SHAPE_POLY_SET : public SHAPE
* @return The minimum distance squared between aPoint and all the polygons in the set.
* If the point is contained in any of the polygons, the distance is zero.
*/
SEG::ecoord SquaredDistance( VECTOR2I aPoint );
SEG::ecoord SquaredDistance( VECTOR2I aPoint ) const;
/**
* Function SquaredDistance
@ -1211,7 +1211,7 @@ class SHAPE_POLY_SET : public SHAPE
* @return The minimum distance squared between aSegment and all the polygons in the set.
* If the point is contained in the polygon, the distance is zero.
*/
SEG::ecoord SquaredDistance( const SEG& aSegment );
SEG::ecoord SquaredDistance( const SEG& aSegment ) const;
/**
* Function IsVertexInHole.

View File

@ -52,6 +52,13 @@ public:
m_points.SetClosed( true );
}
SHAPE_SIMPLE( const SHAPE_LINE_CHAIN& aPoly ) :
SHAPE( SH_SIMPLE ),
m_points( aPoly )
{
m_points.SetClosed( true );
}
SHAPE_SIMPLE( const SHAPE_SIMPLE& aOther ) :
SHAPE( SH_SIMPLE ), m_points( aOther.m_points )
{}

View File

@ -1584,7 +1584,7 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::FilletPolygon( unsigned int aRadius, int
}
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( VECTOR2I aPoint, int aPolygonIndex )
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( VECTOR2I aPoint, int aPolygonIndex ) const
{
// We calculate the min dist between the segment and each outline segment. However, if the
// segment to test is inside the outline, and does not cross any edge, it can be seen outside
@ -1593,7 +1593,7 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( VECTOR2I aPoint, int aPoly
if( containsSingle( aPoint, aPolygonIndex, 1 ) )
return 0;
SEGMENT_ITERATOR iterator = IterateSegmentsWithHoles( aPolygonIndex );
CONST_SEGMENT_ITERATOR iterator = CIterateSegmentsWithHoles( aPolygonIndex );
SEG polygonEdge = *iterator;
SEG::ecoord minDistance = polygonEdge.SquaredDistance( aPoint );
@ -1612,7 +1612,7 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( VECTOR2I aPoint, int aPoly
}
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( const SEG& aSegment, int aPolygonIndex )
SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( const SEG& aSegment, int aPolygonIndex ) const
{
// We calculate the min dist between the segment and each outline segment. However, if the
// segment to test is inside the outline, and does not cross any edge, it can be seen outside
@ -1621,9 +1621,9 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( const SEG& aSegment, int a
if( containsSingle( aSegment.A, aPolygonIndex, 1 ) )
return 0;
SEGMENT_ITERATOR iterator = IterateSegmentsWithHoles( aPolygonIndex );
SEG polygonEdge = *iterator;
SEG::ecoord minDistance = polygonEdge.SquaredDistance( aSegment );
CONST_SEGMENT_ITERATOR iterator = CIterateSegmentsWithHoles( aPolygonIndex );
SEG polygonEdge = *iterator;
SEG::ecoord minDistance = polygonEdge.SquaredDistance( aSegment );
for( iterator++; iterator && minDistance > 0; iterator++ )
{
@ -1640,7 +1640,7 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( const SEG& aSegment, int a
}
SEG::ecoord SHAPE_POLY_SET::SquaredDistance( VECTOR2I aPoint )
SEG::ecoord SHAPE_POLY_SET::SquaredDistance( VECTOR2I aPoint ) const
{
SEG::ecoord currentDistance;
SEG::ecoord minDistance = SquaredDistanceToPolygon( aPoint, 0 );
@ -1658,7 +1658,7 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistance( VECTOR2I aPoint )
}
SEG::ecoord SHAPE_POLY_SET::SquaredDistance( const SEG& aSegment )
SEG::ecoord SHAPE_POLY_SET::SquaredDistance( const SEG& aSegment ) const
{
SEG::ecoord currentDistance;
SEG::ecoord minDistance = SquaredDistanceToPolygon( aSegment, 0 );