Add assert to SHAPE_LINE_CHAIN::Segment + Deduplicate code
CSegment should have the exact same logic as Segment Also, moving definition to .cpp file to reduce need to rebuild every time
This commit is contained in:
parent
70f14277d1
commit
e950475bc3
|
@ -330,16 +330,7 @@ public:
|
|||
* from the end (i.e. -1 means the last segment in the line chain).
|
||||
* @return a segment at the \a aIndex in the line chain.
|
||||
*/
|
||||
SEG Segment( int aIndex )
|
||||
{
|
||||
if( aIndex < 0 )
|
||||
aIndex += SegmentCount();
|
||||
|
||||
if( aIndex == (int)( m_points.size() - 1 ) && m_closed )
|
||||
return SEG( m_points[aIndex], m_points[0], aIndex );
|
||||
else
|
||||
return SEG( m_points[aIndex], m_points[aIndex + 1], aIndex );
|
||||
}
|
||||
SEG Segment( int aIndex ) const;
|
||||
|
||||
/**
|
||||
* Return a constant copy of the \a aIndex segment in the line chain.
|
||||
|
@ -348,16 +339,7 @@ public:
|
|||
* from the end (i.e. -1 means the last segment in the line chain).
|
||||
* @return a segment at \a aIndex in the line chain.
|
||||
*/
|
||||
const SEG CSegment( int aIndex ) const
|
||||
{
|
||||
if( aIndex < 0 )
|
||||
aIndex += SegmentCount();
|
||||
|
||||
if( aIndex == (int)( m_points.size() - 1 ) && m_closed )
|
||||
return SEG( m_points[aIndex], m_points[0], aIndex );
|
||||
else
|
||||
return SEG( m_points[aIndex], m_points[aIndex + 1], aIndex );
|
||||
}
|
||||
const SEG CSegment( int aIndex ) const { return Segment( aIndex ); }
|
||||
|
||||
/**
|
||||
* Return the vertex index of the next shape in the chain, or -1 if \a aPointIndex is the
|
||||
|
|
|
@ -1027,6 +1027,21 @@ int SHAPE_LINE_CHAIN::ShapeCount() const
|
|||
}
|
||||
|
||||
|
||||
SEG SHAPE_LINE_CHAIN::Segment( int aIndex ) const
|
||||
{
|
||||
if( aIndex < 0 )
|
||||
aIndex += SegmentCount();
|
||||
|
||||
wxCHECK( aIndex < SegmentCount() && aIndex >= 0,
|
||||
m_points.size() > 0 ? SEG( m_points.back(), m_points.back() ) : SEG( 0, 0, 0, 0 ) );
|
||||
|
||||
if( aIndex == (int) ( m_points.size() - 1 ) && m_closed )
|
||||
return SEG( m_points[aIndex], m_points[0], aIndex );
|
||||
else
|
||||
return SEG( m_points[aIndex], m_points[aIndex + 1], aIndex );
|
||||
}
|
||||
|
||||
|
||||
int SHAPE_LINE_CHAIN::NextShape( int aPointIndex ) const
|
||||
{
|
||||
if( aPointIndex < 0 )
|
||||
|
|
Loading…
Reference in New Issue