Remove negative index access from CPoint

Callers should be responsible for index count and/or use iterators
This commit is contained in:
Seth Hillbrand 2025-08-08 10:45:58 -07:00
parent 5df10e23b9
commit b207ec8817
28 changed files with 93 additions and 92 deletions

View File

@ -1090,7 +1090,7 @@ void GERBER_PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aPoly, FILL_T aFill, int
} }
// If the polygon is not closed, close it: // If the polygon is not closed, close it:
if( aPoly.CPoint( 0 ) != aPoly.CPoint( -1 ) ) if( aPoly.CPoint( 0 ) != aPoly.CLastPoint() )
FinishTo( VECTOR2I( aPoly.CPoint( 0 ) ) ); FinishTo( VECTOR2I( aPoly.CPoint( 0 ) ) );
fmt::println( m_outputFile, "G37*" ); fmt::println( m_outputFile, "G37*" );
@ -1124,7 +1124,7 @@ void GERBER_PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aPoly, FILL_T aFill, int
// Ensure the thick outline is closed for filled polygons // Ensure the thick outline is closed for filled polygons
// (if not filled, could be only a polyline) // (if not filled, could be only a polyline)
if( ( aPoly.CPoint( 0 ) != aPoly.CPoint( -1 ) ) && ( aPoly.IsClosed() || aFill != FILL_T::NO_FILL ) ) if( ( aPoly.CPoint( 0 ) != aPoly.CLastPoint() ) && ( aPoly.IsClosed() || aFill != FILL_T::NO_FILL ) )
LineTo( VECTOR2I( aPoly.CPoint( 0 ) ) ); LineTo( VECTOR2I( aPoly.CPoint( 0 ) ) );
PenFinish(); PenFinish();

View File

@ -48,8 +48,8 @@ bool POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt )
// there are enough leader points - the next // there are enough leader points - the next
// locked-in point is the end of the last leader // locked-in point is the end of the last leader
// segment // segment
m_lockedPoints.Append( m_leaderPts.CPoint( -2 ) ); m_lockedPoints.Append( m_leaderPts.CPoints()[ m_leaderPts.PointCount() - 2 ] );
m_lockedPoints.Append( m_leaderPts.CPoint( -1 ) ); m_lockedPoints.Append( m_leaderPts.CLastPoint() );
} }
else else
{ {
@ -165,7 +165,7 @@ static SHAPE_LINE_CHAIN build45DegLeader( const VECTOR2I& aEndPoint, const SHAPE
if( aLastPoints.PointCount() < 1 ) if( aLastPoints.PointCount() < 1 )
return SHAPE_LINE_CHAIN(); return SHAPE_LINE_CHAIN();
const VECTOR2I lastPt = aLastPoints.CPoint( -1 ); const VECTOR2I lastPt = aLastPoints.CLastPoint();
const VECTOR2D endpointD = aEndPoint; const VECTOR2D endpointD = aEndPoint;
const VECTOR2D lineVec = endpointD - lastPt; const VECTOR2D lineVec = endpointD - lastPt;
@ -174,7 +174,7 @@ static SHAPE_LINE_CHAIN build45DegLeader( const VECTOR2I& aEndPoint, const SHAPE
std::vector<VECTOR2I>{ lastPt, lastPt + GetVectorSnapped45( lineVec ) } ); std::vector<VECTOR2I>{ lastPt, lastPt + GetVectorSnapped45( lineVec ) } );
EDA_ANGLE lineA( lineVec ); EDA_ANGLE lineA( lineVec );
EDA_ANGLE prevA( GetVectorSnapped45( lastPt - aLastPoints.CPoint( -2 ) ) ); EDA_ANGLE prevA( GetVectorSnapped45( lastPt - aLastPoints.CPoints()[ aLastPoints.PointCount() - 2 ] ) );
bool vertical = std::abs( lineVec.y ) > std::abs( lineVec.x ); bool vertical = std::abs( lineVec.y ) > std::abs( lineVec.x );
bool horizontal = std::abs( lineVec.y ) < std::abs( lineVec.x ); bool horizontal = std::abs( lineVec.y ) < std::abs( lineVec.x );

View File

@ -156,7 +156,7 @@ void RULE_AREA_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
// Simplify doesn't handle that currently. // Simplify doesn't handle that currently.
if( outline.PointCount() >= 3 ) if( outline.PointCount() >= 3 )
{ {
SEG seg( outline.CPoint( -1 ), outline.CPoint( 1 ) ); SEG seg( outline.CLastPoint(), outline.CPoint( 1 ) );
if( seg.LineDistance( outline.CPoint( 0 ) ) <= 1 ) if( seg.LineDistance( outline.CPoint( 0 ) ) <= 1 )
outline.Remove( 0 ); outline.Remove( 0 );

View File

@ -540,7 +540,7 @@ public:
if( m_points.size() == 0 ) if( m_points.size() == 0 )
m_bbox = BOX2I( aP, VECTOR2I( 0, 0 ) ); m_bbox = BOX2I( aP, VECTOR2I( 0, 0 ) );
if( m_points.size() == 0 || aAllowDuplication || CPoint( -1 ) != aP ) if( m_points.size() == 0 || aAllowDuplication || CLastPoint() != aP )
{ {
m_points.push_back( aP ); m_points.push_back( aP );
m_shapes.push_back( SHAPES_ARE_PT ); m_shapes.push_back( SHAPES_ARE_PT );

View File

@ -1562,7 +1562,7 @@ void SHAPE_LINE_CHAIN::Append( const SHAPE_LINE_CHAIN& aOtherLine )
return retval; return retval;
}; };
if( PointCount() == 0 || aOtherLine.CPoint( 0 ) != CPoint( -1 ) ) if( PointCount() == 0 || aOtherLine.CPoint( 0 ) != CLastPoint() )
{ {
const VECTOR2I p = aOtherLine.CPoint( 0 ); const VECTOR2I p = aOtherLine.CPoint( 0 );
m_points.push_back( p ); m_points.push_back( p );
@ -2485,7 +2485,7 @@ const VECTOR2I SHAPE_LINE_CHAIN::PointAlong( int aPathLength ) const
total += l; total += l;
} }
return CPoint( -1 ); return CLastPoint();
} }
@ -2824,7 +2824,7 @@ bool SHAPE_LINE_CHAIN::OffsetLine( int aAmount, CORNER_STRATEGY aCornerStrategy,
wxASSERT( outline.IsClosed() ); wxASSERT( outline.IsClosed() );
const VECTOR2I& start = CPoint( 0 ); const VECTOR2I& start = CPoint( 0 );
const VECTOR2I& end = CPoint( -1 ); const VECTOR2I& end = CLastPoint();
outline.Split( start, true ); outline.Split( start, true );
outline.Split( end, true ); outline.Split( end, true );

View File

@ -369,7 +369,7 @@ SHAPE_LINE_CHAIN KIGEOM::RectifyPolygon( const SHAPE_LINE_CHAIN& aPoly )
// Manually handle the last segment if not closed // Manually handle the last segment if not closed
if( !aPoly.IsClosed() && aPoly.PointCount() >= 2 ) if( !aPoly.IsClosed() && aPoly.PointCount() >= 2 )
{ {
handleSegment( SEG( aPoly.CPoint( -1 ), aPoly.CPoint( 0 ) ) ); handleSegment( SEG( aPoly.CLastPoint(), aPoly.CPoint( 0 ) ) );
} }
raOutline.SetClosed( true ); raOutline.SetClosed( true );

View File

@ -510,8 +510,8 @@ bool doConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aShapeList, SHAPE_POLY_
// Snap the segment endpoint // Snap the segment endpoint
currContour.SetPoint( -1, startPt ); currContour.SetPoint( -1, startPt );
shapeOwners[std::make_pair( currContour.CPoint( -2 ), shapeOwners[std::make_pair( currContour.CPoints()[currContour.PointCount() - 2 ],
currContour.CPoint( -1 ) )] = owner; currContour.CLastPoint() )] = owner;
} }
prevPt = startPt; prevPt = startPt;

View File

@ -557,7 +557,7 @@ protected:
{ {
m_baseLine->Mirror( aCentre, aFlipDirection ); m_baseLine->Mirror( aCentre, aFlipDirection );
m_origin = m_baseLine->CPoint( 0 ); m_origin = m_baseLine->CPoint( 0 );
m_end = m_baseLine->CPoint( -1 ); m_end = m_baseLine->CLastPoint();
} }
if( m_baseLineCoupled ) if( m_baseLineCoupled )
@ -858,7 +858,7 @@ void PCB_TUNING_PATTERN::EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_
&& m_baseLineCoupled->SegmentCount() > 0 ) && m_baseLineCoupled->SegmentCount() > 0 )
{ {
centerlineOffsetEnd = centerlineOffsetEnd =
( m_baseLineCoupled->CPoint( -1 ) - m_baseLine->CPoint( -1 ) ) / 2; ( m_baseLineCoupled->CLastPoint() - m_baseLine->CLastPoint() ) / 2;
} }
SEG baseEnd = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( -1 ) SEG baseEnd = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( -1 )
@ -1191,7 +1191,7 @@ bool PCB_TUNING_PATTERN::removeToBaseline( PNS::ROUTER* aRouter, int aPNSLayer,
{ {
VECTOR2I startSnapPoint, endSnapPoint; VECTOR2I startSnapPoint, endSnapPoint;
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CPoint( -1 ), std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(),
aRouter, aPNSLayer, startSnapPoint, endSnapPoint ); aRouter, aPNSLayer, startSnapPoint, endSnapPoint );
wxCHECK( pnsLine, false ); wxCHECK( pnsLine, false );
@ -1359,7 +1359,7 @@ bool PCB_TUNING_PATTERN::resetToBaseline( GENERATOR_TOOL* aTool, int aPNSLayer,
PNS::NODE* world = router->GetWorld(); PNS::NODE* world = router->GetWorld();
VECTOR2I startSnapPoint, endSnapPoint; VECTOR2I startSnapPoint, endSnapPoint;
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CPoint( -1 ), std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(),
router, aPNSLayer, startSnapPoint, endSnapPoint ); router, aPNSLayer, startSnapPoint, endSnapPoint );
if( !pnsLine ) if( !pnsLine )
@ -1483,7 +1483,7 @@ bool PCB_TUNING_PATTERN::Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COM
if( resetToBaseline( aTool, pnslayer, *m_baseLine, true ) ) if( resetToBaseline( aTool, pnslayer, *m_baseLine, true ) )
{ {
m_origin = m_baseLine->CPoint( 0 ); m_origin = m_baseLine->CPoint( 0 );
m_end = m_baseLine->CPoint( -1 ); m_end = m_baseLine->CLastPoint();
} }
else else
{ {
@ -1680,7 +1680,7 @@ bool PCB_TUNING_PATTERN::MakeEditPoints( EDIT_POINTS& aPoints ) const
if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 ) if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 )
{ {
centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2; centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2;
centerlineOffsetEnd = ( m_baseLineCoupled->CPoint( -1 ) - m_end ) / 2; centerlineOffsetEnd = ( m_baseLineCoupled->CLastPoint() - m_end ) / 2;
} }
aPoints.AddPoint( m_origin + centerlineOffset ); aPoints.AddPoint( m_origin + centerlineOffset );
@ -1723,7 +1723,7 @@ bool PCB_TUNING_PATTERN::UpdateFromEditPoints( EDIT_POINTS& aEditPoints )
if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 ) if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 )
{ {
centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2; centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2;
centerlineOffsetEnd = ( m_baseLineCoupled->CPoint( -1 ) - m_end ) / 2; centerlineOffsetEnd = ( m_baseLineCoupled->CLastPoint() - m_end ) / 2;
} }
SEG base = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( 0 ) SEG base = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( 0 )
@ -1778,7 +1778,7 @@ bool PCB_TUNING_PATTERN::UpdateEditPoints( EDIT_POINTS& aEditPoints )
if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 ) if( m_tuningMode == DIFF_PAIR && m_baseLineCoupled && m_baseLineCoupled->SegmentCount() > 0 )
{ {
centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2; centerlineOffset = ( m_baseLineCoupled->CPoint( 0 ) - m_origin ) / 2;
centerlineOffsetEnd = ( m_baseLineCoupled->CPoint( -1 ) - m_end ) / 2; centerlineOffsetEnd = ( m_baseLineCoupled->CLastPoint() - m_end ) / 2;
} }
SEG base = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( 0 ) SEG base = m_baseLine && m_baseLine->SegmentCount() > 0 ? m_baseLine->CSegment( 0 )

View File

@ -508,7 +508,7 @@ void LENGTH_DELAY_CALCULATION::OptimiseTraceInPad( SHAPE_LINE_CHAIN& aLine, cons
if( shape->Contains( aLine.CPoint( 0 ) ) ) if( shape->Contains( aLine.CPoint( 0 ) ) )
clipLineToPad( aLine, aPad, aPcbLayer, true ); clipLineToPad( aLine, aPad, aPcbLayer, true );
else if( shape->Contains( aLine.CPoint( -1 ) ) ) else if( shape->Contains( aLine.CLastPoint() ) )
clipLineToPad( aLine, aPad, aPcbLayer, false ); clipLineToPad( aLine, aPad, aPcbLayer, false );
} }

View File

@ -3465,7 +3465,7 @@ bool FABMASTER::loadZone( BOARD* aBoard, const std::unique_ptr<FABMASTER::TRACE>
} }
else else
{ {
const VECTOR2I& last = active_chain->CPoint( -1 ); const VECTOR2I& last = active_chain->CLastPoint();
// Not if this can ever happen, or what do if it does (add both points?). // Not if this can ever happen, or what do if it does (add both points?).
if( last != start ) if( last != start )

View File

@ -90,7 +90,7 @@ bool COMPONENT_DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
// Lines that go directly between two linked pads are also special-cased // Lines that go directly between two linked pads are also special-cased
const SHAPE_LINE_CHAIN& line = cn.origLine.CLine(); const SHAPE_LINE_CHAIN& line = cn.origLine.CLine();
const JOINT* jA = m_world->FindJoint( line.CPoint( 0 ), aItem->Layer(), aItem->Net() ); const JOINT* jA = m_world->FindJoint( line.CPoint( 0 ), aItem->Layer(), aItem->Net() );
const JOINT* jB = m_world->FindJoint( line.CPoint( -1 ), aItem->Layer(), aItem->Net() ); const JOINT* jB = m_world->FindJoint( line.CLastPoint(), aItem->Layer(), aItem->Net() );
wxASSERT( jA == aJoint || jB == aJoint ); wxASSERT( jA == aJoint || jB == aJoint );
const JOINT* jSearch = ( jA == aJoint ) ? jB : jA; const JOINT* jSearch = ( jA == aJoint ) ? jB : jA;

View File

@ -740,8 +740,8 @@ bool DIFF_PAIR_PLACER::routeHead( const VECTOR2I& aP )
if( m_placingVia ) if( m_placingVia )
{ {
m_currentTrace.AppendVias ( makeVia( m_currentTrace.CP().CPoint( -1 ), m_netP ), m_currentTrace.AppendVias ( makeVia( m_currentTrace.CP().CLastPoint(), m_netP ),
makeVia( m_currentTrace.CN().CPoint( -1 ), m_netN ) ); makeVia( m_currentTrace.CN().CLastPoint(), m_netN ) );
} }
else else
{ {

View File

@ -351,17 +351,17 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
{ {
ssize_t arcIndex = tunedN.ArcIndex( curIndexN ); ssize_t arcIndex = tunedN.ArcIndex( curIndexN );
m_result.AddPtAndArc( tunedP.CPoint( -1 ), tunedN.Arc( arcIndex ) ); m_result.AddPtAndArc( tunedP.CLastPoint(), tunedN.Arc( arcIndex ) );
} }
else else
{ {
m_result.AddCorner( tunedP.CPoint( -1 ), tunedN.CPoint( curIndexN ) ); m_result.AddCorner( tunedP.CLastPoint(), tunedN.CPoint( curIndexN ) );
} }
curIndexN = tunedN.NextShape( curIndexN ); curIndexN = tunedN.NextShape( curIndexN );
} }
m_result.AddCorner( tunedP.CPoint( -1 ), tunedN.CPoint( -1 ) ); m_result.AddCorner( tunedP.CLastPoint(), tunedN.CLastPoint() );
long long int dpLen = origPathLength(); long long int dpLen = origPathLength();
int64_t dpDelay = origPathDelay(); int64_t dpDelay = origPathDelay();

View File

@ -269,7 +269,7 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
// corner case for loopy tracks: insert the end loop point back into the hull // corner case for loopy tracks: insert the end loop point back into the hull
if( const std::optional<SHAPE_LINE_CHAIN::INTERSECTION> isect = pnew.SelfIntersecting() ) if( const std::optional<SHAPE_LINE_CHAIN::INTERSECTION> isect = pnew.SelfIntersecting() )
{ {
if( isect->p != pnew.CPoint( -1 ) ) if( isect->p != pnew.CLastPoint() )
pnew.Split( isect->p ); pnew.Split( isect->p );
} }
@ -385,7 +385,7 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
// In the case that the initial path ends *inside* the current obstacle (i.e. the mouse cursor // In the case that the initial path ends *inside* the current obstacle (i.e. the mouse cursor
// is somewhere inside the hull for the current obstacle) we want to end the walkaround at the // is somewhere inside the hull for the current obstacle) we want to end the walkaround at the
// point closest to the cursor // point closest to the cursor
bool inLast = aObstacle.PointInside( CPoint( -1 ) ) && !aObstacle.PointOnEdge( CPoint( -1 ) ); bool inLast = aObstacle.PointInside( CLastPoint() ) && !aObstacle.PointOnEdge( CLastPoint() );
bool appendV = true; bool appendV = true;
int lastDst = INT_MAX; int lastDst = INT_MAX;
@ -536,7 +536,7 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
// just project the normal of the endpoint onto this next segment and call it quits. // just project the normal of the endpoint onto this next segment and call it quits.
if( inLast && v_next ) if( inLast && v_next )
{ {
int d = ( v_next->pos - CPoint( -1 ) ).SquaredEuclideanNorm(); int d = ( v_next->pos - CLastPoint() ).SquaredEuclideanNorm();
if( d < lastDst ) if( d < lastDst )
{ {
@ -544,7 +544,7 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
} }
else else
{ {
VECTOR2I proj = SEG( v->pos, v_next->pos ).NearestPoint( CPoint( -1 ) ); VECTOR2I proj = SEG( v->pos, v_next->pos ).NearestPoint( CLastPoint() );
out.Append( proj ); out.Append( proj );
appendV = false; appendV = false;
break; break;
@ -718,7 +718,7 @@ SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECT
return path; return path;
} }
DIRECTION_45 dir( aOrigin.CPoint( -1 ) - aOrigin.CPoint( -2 ) ); DIRECTION_45 dir( aOrigin.CLastPoint() - aOrigin.CPoints()[ aOrigin.PointCount() - 2 ] );
return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() ); return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
} }
@ -923,7 +923,7 @@ void LINE::dragSegment45( const VECTOR2I& aP, int aIndex )
if( index == path.SegmentCount() - 1 ) if( index == path.SegmentCount() - 1 )
{ {
path.Insert( path.PointCount() - 1, path.CPoint( -1 ) ); path.Insert( path.PointCount() - 1, path.CLastPoint() );
} }
else if( path.IsPtOnArc( index + 1 ) ) else if( path.IsPtOnArc( index + 1 ) )
{ {

View File

@ -144,6 +144,7 @@ public:
///< Return the \a aIdx-th point of the line. ///< Return the \a aIdx-th point of the line.
const VECTOR2I& CPoint( int aIdx ) const { return m_line.CPoint( aIdx ); } const VECTOR2I& CPoint( int aIdx ) const { return m_line.CPoint( aIdx ); }
const VECTOR2I& CLastPoint() const { return m_line.CLastPoint(); }
const SEG CSegment( int aIdx ) const { return m_line.CSegment( aIdx ); } const SEG CSegment( int aIdx ) const { return m_line.CSegment( aIdx ); }
///< Set line width. ///< Set line width.

View File

@ -151,7 +151,7 @@ bool LINE_PLACER::handleSelfIntersections()
} }
// ignore the point where head and tail meet // ignore the point where head and tail meet
if( ipoint == head.CPoint( 0 ) || ipoint == tail.CPoint( -1 ) ) if( ipoint == head.CPoint( 0 ) || ipoint == tail.CLastPoint() )
return false; return false;
// Intersection point is on the first or the second segment: just start routing // Intersection point is on the first or the second segment: just start routing
@ -346,7 +346,7 @@ bool LINE_PLACER::mergeHead()
return false; return false;
} }
if( n_tail && head.CPoint( 0 ) != tail.CPoint( -1 ) ) if( n_tail && head.CPoint( 0 ) != tail.CLastPoint() )
{ {
PNS_DBG( Dbg(), Message, wxT( "Merge failed: head and tail discontinuous." ) ); PNS_DBG( Dbg(), Message, wxT( "Merge failed: head and tail discontinuous." ) );
return false; return false;
@ -443,7 +443,7 @@ bool LINE_PLACER::cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I&
if( aL.PointCount() == 0 ) if( aL.PointCount() == 0 )
return false; return false;
VECTOR2I lastP = aL.CPoint(-1); VECTOR2I lastP = aL.CLastPoint();
int accumulatedDist = 0; int accumulatedDist = 0;
dists.reserve( 2 * aL.PointCount() ); dists.reserve( 2 * aL.PointCount() );
@ -664,7 +664,7 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
if( bestLength < hugThresholdLengthComplete && bestLine.has_value() ) if( bestLength < hugThresholdLengthComplete && bestLine.has_value() )
{ {
walkFull.SetShape( bestLine->CLine() ); walkFull.SetShape( bestLine->CLine() );
walkP = walkFull.CLine().CPoint(-1); walkP = walkFull.CLine().CLastPoint();
PNS_DBGN( Dbg(), EndGroup ); PNS_DBGN( Dbg(), EndGroup );
continue; continue;
} }
@ -682,7 +682,7 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
validCw = cursorDistMinimum( wr.lines[WP_CW].CLine(), aP, hugThresholdLength, l_cw ); validCw = cursorDistMinimum( wr.lines[WP_CW].CLine(), aP, hugThresholdLength, l_cw );
if( validCw ) if( validCw )
distCw = ( aP - l_cw.CPoint( -1 ) ).EuclideanNorm(); distCw = ( aP - l_cw.CLastPoint() ).EuclideanNorm();
PNS_DBG( Dbg(), AddShape, &l_cw, MAGENTA, 200000, wxString::Format( "wh-result-cw %s", PNS_DBG( Dbg(), AddShape, &l_cw, MAGENTA, 200000, wxString::Format( "wh-result-cw %s",
validCw ? "non-colliding" validCw ? "non-colliding"
@ -694,7 +694,7 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
validCcw = cursorDistMinimum( wr.lines[WP_CCW].CLine(), aP, hugThresholdLength, l_ccw ); validCcw = cursorDistMinimum( wr.lines[WP_CCW].CLine(), aP, hugThresholdLength, l_ccw );
if( validCcw ) if( validCcw )
distCcw = ( aP - l_ccw.CPoint( -1 ) ).EuclideanNorm(); distCcw = ( aP - l_ccw.CLastPoint() ).EuclideanNorm();
PNS_DBG( Dbg(), AddShape, &l_ccw, MAGENTA, 200000, wxString::Format( "wh-result-ccw %s", PNS_DBG( Dbg(), AddShape, &l_ccw, MAGENTA, 200000, wxString::Format( "wh-result-ccw %s",
validCcw ? "non-colliding" validCcw ? "non-colliding"
@ -705,12 +705,12 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
if( distCw < distCcw && validCw ) if( distCw < distCcw && validCw )
{ {
walkFull.SetShape( l_cw ); walkFull.SetShape( l_cw );
walkP = l_cw.CPoint(-1); walkP = l_cw.CLastPoint();
} }
else if( validCcw ) else if( validCcw )
{ {
walkFull.SetShape( l_ccw ); walkFull.SetShape( l_ccw );
walkP = l_ccw.CPoint(-1); walkP = l_ccw.CLastPoint();
} }
else else
{ {
@ -725,7 +725,7 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
if( l1.EndsWithVia() ) if( l1.EndsWithVia() )
{ {
VIA v ( l1.Via() ); VIA v ( l1.Via() );
v.SetPos( walkFull.CPoint( -1 ) ); v.SetPos( walkFull.CLastPoint() );
walkFull.AppendVia( v ); walkFull.AppendVia( v );
} }
@ -800,9 +800,9 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail
if( m_placingVia && viaOk ) if( m_placingVia && viaOk )
{ {
PNS_DBG( Dbg(), AddPoint, aNewHead.CPoint(-1), RED, 1000000, wxString::Format( "VIA" ) ); PNS_DBG( Dbg(), AddPoint, aNewHead.CLastPoint(), RED, 1000000, wxString::Format( "VIA" ) );
aNewHead.AppendVia( makeVia( aNewHead.CPoint( -1 ) ) ); aNewHead.AppendVia( makeVia( aNewHead.CLastPoint() ) );
} }
OPTIMIZER::Optimize( &aNewHead, effort, m_currentNode ); OPTIMIZER::Optimize( &aNewHead, effort, m_currentNode );
@ -881,9 +881,9 @@ bool LINE_PLACER::splitHeadTail( const LINE& aNewLine, const LINE& aOldTail, LIN
if( n > 1 && aOldTail.PointCount() > 1 ) if( n > 1 && aOldTail.PointCount() > 1 )
{ {
if( l2.CLine().PointOnEdge( aOldTail.CPoint( -1 ) ) ) if( l2.CLine().PointOnEdge( aOldTail.CLastPoint() ) )
{ {
l2.Line().Split( aOldTail.CPoint( -1 ) ); l2.Line().Split( aOldTail.CLastPoint() );
} }
for( i = 0; i < aOldTail.PointCount(); i++ ) for( i = 0; i < aOldTail.PointCount(); i++ )
@ -953,7 +953,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTai
if( m_placingVia && viaOk ) if( m_placingVia && viaOk )
{ {
newHead.AppendVia( makeVia( newHead.CPoint( -1 ) ) ); newHead.AppendVia( makeVia( newHead.CLastPoint() ) );
PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-new-via" ); PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-new-via" );
} }
@ -1104,7 +1104,7 @@ bool LINE_PLACER::optimizeTailHeadTransition()
void LINE_PLACER::updatePStart( const LINE& tail ) void LINE_PLACER::updatePStart( const LINE& tail )
{ {
if( tail.CLine().PointCount() ) if( tail.CLine().PointCount() )
m_p_start = tail.CLine().CPoint(-1); m_p_start = tail.CLine().CLastPoint();
else else
m_p_start = m_currentStart; m_p_start = m_currentStart;
} }
@ -1228,7 +1228,7 @@ bool LINE_PLACER::route( const VECTOR2I& aP )
if( !m_head.PointCount() ) if( !m_head.PointCount() )
return false; return false;
return m_head.CPoint( -1 ) == aP; return m_head.CLastPoint() == aP;
} }
@ -1504,7 +1504,7 @@ bool LINE_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
if( !current.PointCount() ) if( !current.PointCount() )
m_currentEnd = m_p_start; m_currentEnd = m_p_start;
else else
m_currentEnd = current.CLine().CPoint( -1 ); m_currentEnd = current.CLine().CLastPoint();
NODE* latestNode = m_currentNode; NODE* latestNode = m_currentNode;
m_lastNode = latestNode->Branch(); m_lastNode = latestNode->Branch();
@ -1515,7 +1515,7 @@ bool LINE_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
&& current.SegmentCount() ) && current.SegmentCount() )
{ {
if ( aEndItem->Net() == m_currentNet ) if ( aEndItem->Net() == m_currentNet )
SplitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) ); SplitAdjacentSegments( m_lastNode, aEndItem, current.CLastPoint() );
if( Settings().RemoveLoops() ) if( Settings().RemoveLoops() )
removeLoops( m_lastNode, current ); removeLoops( m_lastNode, current );
@ -1608,11 +1608,11 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis
return true; return true;
} }
VECTOR2I p_pre_last = l.CPoint( -1 ); VECTOR2I p_pre_last = l.CLastPoint();
const VECTOR2I p_last = l.CPoint( -1 ); const VECTOR2I p_last = l.CLastPoint();
if( l.PointCount() > 2 ) if( l.PointCount() > 2 )
p_pre_last = l.CPoint( -2 ); p_pre_last = l.CPoints()[ l.PointCount() - 2 ];
if( aEndItem && m_currentNet && m_currentNet == aEndItem->Net() ) if( aEndItem && m_currentNet && m_currentNet == aEndItem->Net() )
realEnd = true; realEnd = true;
@ -1805,7 +1805,7 @@ void LINE_PLACER::removeLoops( NODE* aNode, LINE& aLatest )
if( !aLatest.SegmentCount() ) if( !aLatest.SegmentCount() )
return; return;
if( aLatest.CLine().CPoint( 0 ) == aLatest.CLine().CPoint( -1 ) ) if( aLatest.CLine().CPoint( 0 ) == aLatest.CLine().CLastPoint() )
return; return;
std::set<LINKED_ITEM *> toErase; std::set<LINKED_ITEM *> toErase;
@ -2020,7 +2020,7 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, PNS::PNS_MO
if( l.SegmentCount() > 1 && m_orthoMode ) if( l.SegmentCount() > 1 && m_orthoMode )
{ {
VECTOR2I newLast = l.CSegment( 0 ).LineProject( l.CPoint( -1 ) ); VECTOR2I newLast = l.CSegment( 0 ).LineProject( l.CLastPoint() );
l.Remove( -1, -1 ); l.Remove( -1, -1 );
l.SetPoint( 1, newLast ); l.SetPoint( 1, newLast );

View File

@ -504,7 +504,7 @@ void MEANDER_SHAPE::miter( int aRadius, bool aSide )
VECTOR2D dir = m_currentDir.Resize( (double) aRadius ); VECTOR2D dir = m_currentDir.Resize( (double) aRadius );
SHAPE_LINE_CHAIN lc = makeMiterShape( m_currentPos, dir, aSide ); SHAPE_LINE_CHAIN lc = makeMiterShape( m_currentPos, dir, aSide );
m_currentPos = lc.CPoint( -1 ); m_currentPos = lc.CLastPoint();
turn( aSide ? ANGLE_90 : -ANGLE_90 ); turn( aSide ? ANGLE_90 : -ANGLE_90 );
m_currentTarget->Append( lc ); m_currentTarget->Append( lc );
@ -900,7 +900,7 @@ void MEANDER_SHAPE::updateBaseSegment( )
if( m_dual ) if( m_dual )
{ {
VECTOR2I midpA = ( CLine( 0 ).CPoint( 0 ) + CLine( 1 ).CPoint( 0 ) ) / 2; VECTOR2I midpA = ( CLine( 0 ).CPoint( 0 ) + CLine( 1 ).CPoint( 0 ) ) / 2;
VECTOR2I midpB = ( CLine( 0 ).CPoint( -1 ) + CLine( 1 ).CPoint( -1 ) ) / 2; VECTOR2I midpB = ( CLine( 0 ).CLastPoint() + CLine( 1 ).CLastPoint() ) / 2;
m_clippedBaseSeg.A = m_baseSeg.LineProject( midpA ); m_clippedBaseSeg.A = m_baseSeg.LineProject( midpA );
m_clippedBaseSeg.B = m_baseSeg.LineProject( midpB ); m_clippedBaseSeg.B = m_baseSeg.LineProject( midpB );
@ -908,7 +908,7 @@ void MEANDER_SHAPE::updateBaseSegment( )
else else
{ {
m_clippedBaseSeg.A = m_baseSeg.LineProject( CLine( 0 ).CPoint( 0 ) ); m_clippedBaseSeg.A = m_baseSeg.LineProject( CLine( 0 ).CPoint( 0 ) );
m_clippedBaseSeg.B = m_baseSeg.LineProject( CLine( 0 ).CPoint( -1 ) ); m_clippedBaseSeg.B = m_baseSeg.LineProject( CLine( 0 ).CLastPoint() );
} }
} }

View File

@ -52,7 +52,7 @@ void MOUSE_TRAIL_TRACER::AddTrailPoint( const VECTOR2I& aP )
} }
else else
{ {
SEG s_new( m_trail.CPoint( -1 ), aP ); SEG s_new( m_trail.CLastPoint(), aP );
if( m_trail.SegmentCount() > 2 ) if( m_trail.SegmentCount() > 2 )
{ {
@ -284,7 +284,7 @@ VECTOR2I MOUSE_TRAIL_TRACER::GetTrailLeadVector() const
} }
else else
{ {
return m_trail.CPoint( -1 ) - m_trail.CPoint( 0 ); return m_trail.CLastPoint() - m_trail.CPoint( 0 );
} }
} }

View File

@ -92,7 +92,7 @@ bool MULTI_DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
const VECTOR2I& origFirst = l.originalLine.CLine().CPoint( 0 ); const VECTOR2I& origFirst = l.originalLine.CLine().CPoint( 0 );
const int distFirst = ( origFirst - aP ).EuclideanNorm(); const int distFirst = ( origFirst - aP ).EuclideanNorm();
const VECTOR2I& origLast = l.originalLine.CLine().CPoint( -1 ); const VECTOR2I& origLast = l.originalLine.CLine().CLastPoint();
const int distLast = ( origLast - aP ).EuclideanNorm(); const int distLast = ( origLast - aP ).EuclideanNorm();
l.cornerDistance = std::min( distFirst, distLast ); l.cornerDistance = std::min( distFirst, distLast );
@ -223,7 +223,7 @@ bool MULTI_DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
} }
// and if it's connected (non-trivial fanout), disregard it // and if it's connected (non-trivial fanout), disregard it
const JOINT* jt = m_world->FindJoint( l.originalLine.CPoint( -1 ), &l.originalLine ); const JOINT* jt = m_world->FindJoint( l.originalLine.CLastPoint(), &l.originalLine );
assert (jt != nullptr); assert (jt != nullptr);
@ -707,7 +707,7 @@ bool MULTI_DRAGGER::Drag( const VECTOR2I& aP )
if( m_dragMode == DM_CORNER ) if( m_dragMode == DM_CORNER )
{ {
// first, drag only the primary line // first, drag only the primary line
// PNS_DBG( Dbg(), AddPoint, primaryDragged->CPoint( -1 ), YELLOW, 600000, wxT("mdrag-sec")); // PNS_DBG( Dbg(), AddPoint, primaryDragged->CLastPoint(), YELLOW, 600000, wxT("mdrag-sec"));
lastPreDrag = primaryPreDrag->CSegment( -1 ); lastPreDrag = primaryPreDrag->CSegment( -1 );
primaryDir = DIRECTION_45( lastPreDrag ); primaryDir = DIRECTION_45( lastPreDrag );
@ -787,7 +787,7 @@ bool MULTI_DRAGGER::Drag( const VECTOR2I& aP )
{ {
// compute the distance between the primary line and the last point of // compute the distance between the primary line and the last point of
// the currently processed line // the currently processed line
int dist = lastPreDrag.LineDistance( l.preDragLine.CPoint( -1 ), true ); int dist = lastPreDrag.LineDistance( l.preDragLine.CLastPoint(), true );
// now project it on the perpendicular line we computed before // now project it on the perpendicular line we computed before
auto projected = aP + perp.Resize( dist ); auto projected = aP + perp.Resize( dist );

View File

@ -1101,7 +1101,7 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex, bool
const SHAPE_ARC* sa = static_cast<const SHAPE_ARC*>( arc->Shape( -1 ) ); const SHAPE_ARC* sa = static_cast<const SHAPE_ARC*>( arc->Shape( -1 ) );
int nSegs = line.PointCount(); int nSegs = line.PointCount();
VECTOR2I last = nSegs ? line.CPoint( -1 ) : VECTOR2I(); VECTOR2I last = nSegs ? line.CLastPoint() : VECTOR2I();
ssize_t lastShape = nSegs ? line.ArcIndex( static_cast<ssize_t>( nSegs ) - 1 ) : -1; ssize_t lastShape = nSegs ? line.ArcIndex( static_cast<ssize_t>( nSegs ) - 1 ) : -1;
line.Append( arcReversed[i] ? sa->Reversed() : *sa ); line.Append( arcReversed[i] ? sa->Reversed() : *sa );
@ -1138,7 +1138,7 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex, bool
void NODE::FindLineEnds( const LINE& aLine, JOINT& aA, JOINT& aB ) void NODE::FindLineEnds( const LINE& aLine, JOINT& aA, JOINT& aB )
{ {
aA = *FindJoint( aLine.CPoint( 0 ), &aLine ); aA = *FindJoint( aLine.CPoint( 0 ), &aLine );
aB = *FindJoint( aLine.CPoint( -1 ), &aLine ); aB = *FindJoint( aLine.CLastPoint(), &aLine );
} }

View File

@ -996,7 +996,7 @@ int OPTIMIZER::smartPadsSingle( LINE* aLine, ITEM* aPad, bool aEnd, int aEndVert
{ {
SHAPE_LINE_CHAIN v; SHAPE_LINE_CHAIN v;
SHAPE_LINE_CHAIN connect = dir.BuildInitialTrace( SHAPE_LINE_CHAIN connect = dir.BuildInitialTrace(
breakout.CPoint( -1 ), line.CPoint( p ), diag == 0 ); breakout.CLastPoint(), line.CPoint( p ), diag == 0 );
DIRECTION_45 dir_bkout( breakout.CSegment( -1 ) ); DIRECTION_45 dir_bkout( breakout.CSegment( -1 ) );
@ -1083,7 +1083,7 @@ bool OPTIMIZER::runSmartPads( LINE* aLine )
if( line.PointCount() < 3 ) if( line.PointCount() < 3 )
return false; return false;
VECTOR2I p_start = line.CPoint( 0 ), p_end = line.CPoint( -1 ); VECTOR2I p_start = line.CPoint( 0 ), p_end = line.CLastPoint();
ITEM* startPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_start ); ITEM* startPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_start );
ITEM* endPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_end ); ITEM* endPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_end );
@ -1125,7 +1125,7 @@ bool OPTIMIZER::fanoutCleanup( LINE* aLine )
DIRECTION_45::CORNER_MODE cornerMode = ROUTER::GetInstance()->Settings().GetCornerMode(); DIRECTION_45::CORNER_MODE cornerMode = ROUTER::GetInstance()->Settings().GetCornerMode();
VECTOR2I p_start = aLine->CPoint( 0 ), p_end = aLine->CPoint( -1 ); VECTOR2I p_start = aLine->CPoint( 0 ), p_end = aLine->CLastPoint();
ITEM* startPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_start ); ITEM* startPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_start );
ITEM* endPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_end ); ITEM* endPad = findPadOrVia( aLine->Layer(), aLine->Net(), p_end );

View File

@ -186,7 +186,7 @@ int SHOVE::getClearance( const ITEM* aA, const ITEM* aB ) const
void SHOVE::sanityCheck( LINE* aOld, LINE* aNew ) void SHOVE::sanityCheck( LINE* aOld, LINE* aNew )
{ {
assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) ); assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) );
assert( aOld->CPoint( -1 ) == aNew->CPoint( -1 ) ); assert( aOld->CLastPoint() == aNew->CLastPoint() );
} }
@ -288,7 +288,7 @@ bool SHOVE::shoveLineFromLoneVia( const LINE& aCurLine, const LINE& aObstacleLin
if( shortest.PointCount() < 2 ) if( shortest.PointCount() < 2 )
return false; return false;
if( aObstacleLine.CPoint( -1 ) != shortest.CPoint( -1 ) ) if( aObstacleLine.CLastPoint() != shortest.CLastPoint() )
return false; return false;
if( aObstacleLine.CPoint( 0 ) != shortest.CPoint( 0 ) ) if( aObstacleLine.CPoint( 0 ) != shortest.CPoint( 0 ) )
@ -362,7 +362,7 @@ bool SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE& aObstacleLine,
int minDist0, minDist1, minhull0, minhull1 ; int minDist0, minDist1, minhull0, minhull1 ;
VECTOR2I p0 = minDistP( l.CPoint( 0 ), minDist0, minhull0 ); VECTOR2I p0 = minDistP( l.CPoint( 0 ), minDist0, minhull0 );
VECTOR2I p1 = minDistP( l.CPoint( -1 ), minDist1, minhull1 ); VECTOR2I p1 = minDistP( l.CLastPoint(), minDist1, minhull1 );
PNS_DBG( Dbg(), Message, wxString::Format( "mindists : %d %d hulls %d %d\n", minDist0, minDist1, minhull0, minhull1 ) ); PNS_DBG( Dbg(), Message, wxString::Format( "mindists : %d %d hulls %d %d\n", minDist0, minDist1, minhull0, minhull1 ) );
@ -437,7 +437,7 @@ bool SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE& aObstacleLine,
continue; continue;
} }
if( path.CPoint( -1 ) != obs.CPoint( -1 ) || path.CPoint( 0 ) != obs.CPoint( 0 ) ) if( path.CLastPoint() != obs.CLastPoint() || path.CPoint( 0 ) != obs.CPoint( 0 ) )
{ {
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "attempt %d fail vend-start\n" ), PNS_DBG( Dbg(), Message, wxString::Format( wxT( "attempt %d fail vend-start\n" ),
attempt ) ); attempt ) );
@ -511,7 +511,7 @@ bool SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE& aObstacleLine,
if( aObstacleLine.PointCount() >= 2 ) if( aObstacleLine.PointCount() >= 2 )
{ {
jtStart = m_currentNode->FindJoint( aObstacleLine.CPoint( 0 ), &aObstacleLine ); jtStart = m_currentNode->FindJoint( aObstacleLine.CPoint( 0 ), &aObstacleLine );
jtEnd = m_currentNode->FindJoint( aObstacleLine.CPoint( -1 ), &aObstacleLine ); jtEnd = m_currentNode->FindJoint( aObstacleLine.CLastPoint(), &aObstacleLine );
} }
if( jtStart ) if( jtStart )
@ -1600,9 +1600,9 @@ bool SHOVE::patchTadpoleVia( ITEM* nearest, LINE& current )
if (current.CLine().PointCount() < 1 ) if (current.CLine().PointCount() < 1 )
return false; return false;
// PNS_DBG(Dbg(), Message, wxString::Format( "cp %d %d", current.CLine().CPoint(-1).x, current.CLine().CPoint(-1).y ) ); // PNS_DBG(Dbg(), Message, wxString::Format( "cp %d %d", current.CLine().CLastPoint().x, current.CLine().CLastPoint().y ) );
auto jtViaEnd = m_currentNode->FindJoint( current.CLine().CPoint(-1), &current ); auto jtViaEnd = m_currentNode->FindJoint( current.CLine().CLastPoint(), &current );
// PNS_DBG(Dbg(), Message, wxString::Format( "jt %p", jtViaEnd ) ); // PNS_DBG(Dbg(), Message, wxString::Format( "jt %p", jtViaEnd ) );
@ -2501,7 +2501,7 @@ SHOVE::SHOVE_STATUS SHOVE::Run()
m_currentNode->LockJoint( head.CPoint( 0 ), &head, true ); m_currentNode->LockJoint( head.CPoint( 0 ), &head, true );
if( !head.EndsWithVia() ) if( !head.EndsWithVia() )
m_currentNode->LockJoint( head.CPoint( -1 ), &head, true ); m_currentNode->LockJoint( head.CLastPoint(), &head, true );
} }
SetShovePolicy( head, headLineEntry.policy ); SetShovePolicy( head, headLineEntry.policy );

View File

@ -109,7 +109,7 @@ bool TOPOLOGY::NearestUnconnectedAnchorPoint( const LINE* aTrack, VECTOR2I& aPoi
track.ClearLinks(); track.ClearLinks();
tmpNode->Add( track ); tmpNode->Add( track );
const JOINT* jt = tmpNode->FindJoint( track.CPoint( -1 ), &track ); const JOINT* jt = tmpNode->FindJoint( track.CLastPoint(), &track );
if( !jt || m_world->GetRuleResolver()->NetCode( jt->Net() ) <= 0 ) if( !jt || m_world->GetRuleResolver()->NetCode( jt->Net() ) <= 0 )
return false; return false;
@ -152,7 +152,7 @@ bool TOPOLOGY::LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine )
return false; return false;
aRatLine.Clear(); aRatLine.Clear();
aRatLine.Append( aTrack->CPoint( -1 ) ); aRatLine.Append( aTrack->CLastPoint() );
aRatLine.Append( end ); aRatLine.Append( end );
return true; return true;
} }
@ -210,7 +210,7 @@ bool TOPOLOGY::followTrivialPath( LINE* aLine2, bool aLeft, ITEM_SET& aSet,
while( true ) while( true )
{ {
VECTOR2I anchor = aLeft ? curr_line->CPoint( 0 ) : curr_line->CPoint( -1 ); VECTOR2I anchor = aLeft ? curr_line->CPoint( 0 ) : curr_line->CLastPoint();
LINKED_ITEM* last = aLeft ? curr_line->Links().front() : curr_line->Links().back(); LINKED_ITEM* last = aLeft ? curr_line->Links().front() : curr_line->Links().back();
const JOINT* jt = m_world->FindJoint( anchor, curr_line ); const JOINT* jt = m_world->FindJoint( anchor, curr_line );
@ -247,7 +247,7 @@ bool TOPOLOGY::followTrivialPath( LINE* aLine2, bool aLeft, ITEM_SET& aSet,
} }
LINE l = m_world->AssembleLine( next_seg, nullptr, false, aFollowLockedSegments ); LINE l = m_world->AssembleLine( next_seg, nullptr, false, aFollowLockedSegments );
VECTOR2I nextAnchor = ( aLeft ? l.CLine().CPoint( -1 ) : l.CLine().CPoint( 0 ) ); VECTOR2I nextAnchor = ( aLeft ? l.CLine().CLastPoint() : l.CLine().CPoint( 0 ) );
if( nextAnchor != anchor ) if( nextAnchor != anchor )
{ {

View File

@ -375,7 +375,7 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath )
st = ST_STUCK; st = ST_STUCK;
} }
if( ln.PointCount() > 0 && ln.CPoint( -1 ) != aInitialPath.CPoint( -1 ) ) if( ln.PointCount() > 0 && ln.CLastPoint() != aInitialPath.CLastPoint() )
{ {
st = ST_ALMOST_DONE; st = ST_ALMOST_DONE;

View File

@ -350,7 +350,7 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
// Simplify doesn't handle that currently. // Simplify doesn't handle that currently.
if( chain.PointCount() >= 3 ) if( chain.PointCount() >= 3 )
{ {
SEG seg( chain.CPoint( -1 ), chain.CPoint( 1 ) ); SEG seg( chain.CLastPoint(), chain.CPoint( 1 ) );
if( seg.LineDistance( chain.CPoint( 0 ) ) <= 1 ) if( seg.LineDistance( chain.CPoint( 0 ) ) <= 1 )
chain.Remove( 0 ); chain.Remove( 0 );

View File

@ -281,7 +281,7 @@ inline bool IsOutlineValid( const SHAPE_LINE_CHAIN& aChain )
} }
else else
{ {
if( aChain.Arc( prevArcIdx ).GetP1() != aChain.CPoint( -1 ) ) if( aChain.Arc( prevArcIdx ).GetP1() != aChain.CLastPoint() )
return false; return false;
} }
} }

View File

@ -1172,7 +1172,7 @@ BOOST_DATA_TEST_CASE( ArcToPolyline, boost::unit_test::data::make( ArcToPolyline
BOOST_CHECK_EQUAL( chain.CPoint( 0 ), c.m_geom.m_start_point ); BOOST_CHECK_EQUAL( chain.CPoint( 0 ), c.m_geom.m_start_point );
// End point (exactly) where expected // End point (exactly) where expected
BOOST_CHECK_EQUAL( chain.CPoint( -1 ), this_arc.GetP1() ); BOOST_CHECK_EQUAL( chain.CLastPoint(), this_arc.GetP1() );
int radius = ( c.m_geom.m_center_point - c.m_geom.m_start_point ).EuclideanNorm(); int radius = ( c.m_geom.m_center_point - c.m_geom.m_start_point ).EuclideanNorm();

View File

@ -87,7 +87,7 @@ void PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std:
Polyline( aL ); Polyline( aL );
if( name.length() > 0 && aL.PointCount() > 0 ) if( name.length() > 0 && aL.PointCount() > 0 )
m_labelMgr->Add( aL.CPoint( -1 ), name, GetStrokeColor() ); m_labelMgr->Add( aL.CLastPoint(), name, GetStrokeColor() );
if( aShowVertexNumbers ) if( aShowVertexNumbers )
{ {