Comments.
This commit is contained in:
parent
60503652a1
commit
04c8d0e9d8
|
@ -84,7 +84,7 @@ inline bool close_enough( const wxPoint& aLeft, const wxPoint& aRight, unsigned
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function close_st
|
* Function close_st
|
||||||
* is a local method of qualifying if either the start of end point of a segment is closest to a point.
|
* Local method which qualifies whether the start or end point of a segment is closest to a point.
|
||||||
*
|
*
|
||||||
* @param aReference is the reference point
|
* @param aReference is the reference point
|
||||||
* @param aFirst is the first point
|
* @param aFirst is the first point
|
||||||
|
@ -180,9 +180,9 @@ static PCB_SHAPE* findNext( PCB_SHAPE* aShape, const wxPoint& aPoint,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ConvertOutlineToPolygon
|
* Function ConvertOutlineToPolygon
|
||||||
* build a polygon (with holes) from a PCB_SHAPE list, which is expected to be
|
* Build a polygon (with holes) from a PCB_SHAPE list, which is expected to be a closed main
|
||||||
* a outline, therefore a closed main outline with perhaps closed inner outlines.
|
* outline with perhaps closed inner outlines. These closed inner outlines are considered as
|
||||||
* These closed inner outlines are considered as holes in the main outline
|
* holes in the main outline.
|
||||||
* @param aSegList the initial list of drawsegments (only lines, circles and arcs).
|
* @param aSegList the initial list of drawsegments (only lines, circles and arcs).
|
||||||
* @param aPolygons will contain the complex polygon.
|
* @param aPolygons will contain the complex polygon.
|
||||||
* @param aErrorMax is the max error distance when polygonizing a curve (internal units)
|
* @param aErrorMax is the max error distance when polygonizing a curve (internal units)
|
||||||
|
@ -323,6 +323,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep a list of where the various segments came from so after doing our combined-polygon
|
||||||
|
// tests we can still report errors against the individual graphic items.
|
||||||
std::map<std::pair<VECTOR2I, VECTOR2I>, PCB_SHAPE*> segOwners;
|
std::map<std::pair<VECTOR2I, VECTOR2I>, PCB_SHAPE*> segOwners;
|
||||||
|
|
||||||
auto fetchOwner =
|
auto fetchOwner =
|
||||||
|
@ -332,9 +334,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
||||||
return it == segOwners.end() ? nullptr : it->second;
|
return it == segOwners.end() ? nullptr : it->second;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Grab the left most point, assume its on the board's perimeter, and see if we
|
// Grab the left most point, assume its on the board's perimeter, and see if we can put
|
||||||
// can put enough graphics together by matching endpoints to formulate a cohesive
|
// enough graphics together by matching endpoints to formulate a cohesive polygon.
|
||||||
// polygon.
|
|
||||||
|
|
||||||
graphic = (PCB_SHAPE*) aSegList[xmini];
|
graphic = (PCB_SHAPE*) aSegList[xmini];
|
||||||
|
|
||||||
|
@ -651,8 +652,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Polygon start point. Arbitrarily chosen end of the
|
// Polygon start point. Arbitrarily chosen end of the segment and build the poly
|
||||||
// segment and build the poly from here.
|
// from here.
|
||||||
|
|
||||||
wxPoint startPt( graphic->GetEnd() );
|
wxPoint startPt( graphic->GetEnd() );
|
||||||
prevPt = graphic->GetEnd();
|
prevPt = graphic->GetEnd();
|
||||||
|
@ -722,9 +723,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CURVE:
|
case S_CURVE:
|
||||||
// We do not support Bezier curves in polygons, so approximate
|
// We do not support Bezier curves in polygons, so approximate with a series
|
||||||
// with a series of short lines and put those
|
// of short lines and put those line segments into the !same! PATH.
|
||||||
// line segments into the !same! PATH.
|
|
||||||
{
|
{
|
||||||
wxPoint nextPt;
|
wxPoint nextPt;
|
||||||
bool reverse = false;
|
bool reverse = false;
|
||||||
|
@ -812,8 +812,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
||||||
if( !polygonComplete )
|
if( !polygonComplete )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// All of the silliness that follows is to work around the segment iterator
|
// All of the silliness that follows is to work around the segment iterator while checking
|
||||||
// while checking for collisions.
|
// for collisions.
|
||||||
// TODO: Implement proper segment and point iterators that follow std
|
// TODO: Implement proper segment and point iterators that follow std
|
||||||
bool selfIntersecting = false;
|
bool selfIntersecting = false;
|
||||||
|
|
||||||
|
@ -1067,13 +1067,12 @@ int findEndSegments( SHAPE_LINE_CHAIN& aChain, SEG& aStartSeg, SEG& aEndSeg )
|
||||||
* This function is used to extract a board outline for a footprint view.
|
* This function is used to extract a board outline for a footprint view.
|
||||||
*
|
*
|
||||||
* Notes:
|
* Notes:
|
||||||
* * Incomplete outlines will be closed by joining the end of the outline
|
* * Incomplete outlines will be closed by joining the end of the outline onto the bounding box
|
||||||
* onto the bounding box (by simply projecting the end points) and then take the
|
* (by simply projecting the end points) and then take the area that contains the copper.
|
||||||
* area that contains the copper.
|
* * If all copper lies inside a closed outline, than that outline will be treated as an external
|
||||||
* * If all copper lies inside a closed outline, than that outline will be treated
|
* board outline.
|
||||||
* as an external board outline.
|
* * If copper is located outside a closed outline, then that outline will be treated as a hole,
|
||||||
* * If copper is located outside a closed outline, then that outline will be treated
|
* and the outer edge will be formed using the bounding box.
|
||||||
* as a hole, and the outer edge will be formed using the bounding box.
|
|
||||||
*/
|
*/
|
||||||
bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, int aErrorMax,
|
bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, int aErrorMax,
|
||||||
int aChainingEpsilon, OUTLINE_ERROR_HANDLER* aErrorHandler )
|
int aChainingEpsilon, OUTLINE_ERROR_HANDLER* aErrorHandler )
|
||||||
|
@ -1161,8 +1160,8 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, in
|
||||||
std::vector<SHAPE_LINE_CHAIN> closedChains;
|
std::vector<SHAPE_LINE_CHAIN> closedChains;
|
||||||
std::vector<SHAPE_LINE_CHAIN> openChains;
|
std::vector<SHAPE_LINE_CHAIN> openChains;
|
||||||
|
|
||||||
// The ConvertOutlineToPolygon function returns only one main
|
// The ConvertOutlineToPolygon function returns only one main outline and the rest as
|
||||||
// outline and the rest as holes, so we promote the holes and process them
|
// holes, so we promote the holes and process them
|
||||||
openChains.push_back( outlines.Outline( 0 ) );
|
openChains.push_back( outlines.Outline( 0 ) );
|
||||||
|
|
||||||
for( int j = 0; j < outlines.HoleCount( 0 ); j++ )
|
for( int j = 0; j < outlines.HoleCount( 0 ); j++ )
|
||||||
|
@ -1209,8 +1208,8 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, in
|
||||||
}
|
}
|
||||||
else if( chain.SegmentCount() == 1 )
|
else if( chain.SegmentCount() == 1 )
|
||||||
{
|
{
|
||||||
// This case means there is only 1 line segment making up the edge cuts of the footprint,
|
// This case means there is only 1 line segment making up the edge cuts of the
|
||||||
// so we just need to use it to cut the bounding box in half.
|
// footprint, so we just need to use it to cut the bounding box in half.
|
||||||
wxLogTrace( traceBoardOutline, "Only 1 line segment in provided outline" );
|
wxLogTrace( traceBoardOutline, "Only 1 line segment in provided outline" );
|
||||||
|
|
||||||
startSeg = chain.Segment( 0 );
|
startSeg = chain.Segment( 0 );
|
||||||
|
@ -1264,7 +1263,8 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, in
|
||||||
// Angled line segment that cuts across a corner
|
// Angled line segment that cuts across a corner
|
||||||
wxLogTrace( traceBoardOutline, "Segment intersects two perpendicular bbox sides" );
|
wxLogTrace( traceBoardOutline, "Segment intersects two perpendicular bbox sides" );
|
||||||
|
|
||||||
// Figure out which actual lines are intersected, since IntersectLines assumes an infinite line
|
// Figure out which actual lines are intersected, since IntersectLines assumes
|
||||||
|
// an infinite line
|
||||||
bool hit0 = rect.Segment( 0 ).Contains( *inter0 );
|
bool hit0 = rect.Segment( 0 ).Contains( *inter0 );
|
||||||
bool hit1 = rect.Segment( 1 ).Contains( *inter1 );
|
bool hit1 = rect.Segment( 1 ).Contains( *inter1 );
|
||||||
bool hit2 = rect.Segment( 2 ).Contains( *inter2 );
|
bool hit2 = rect.Segment( 2 ).Contains( *inter2 );
|
||||||
|
|
Loading…
Reference in New Issue