57 return unsigned(
std::abs( aLeft.
x - aRight.
x ) +
abs( aLeft.
y - aRight.
y ) );
104 unsigned min_d = INT_MAX;
108 for(
size_t i = 0;
i < aList.size(); ++
i )
118 aList.erase( aList.begin() +
i );
138 if( aPoint == graphic->
GetStart() || aPoint == graphic->
GetEnd() )
140 aList.erase( aList.begin() +
i );
160 if( min_d <= aLimit )
163 aList.erase( aList.begin() + ndx_min );
184 if( aSegList.size() == 0 )
190 std::vector< DRAWSEGMENT* > segList = aSegList;
201 for(
size_t i = 0;
i < segList.size();
i++ )
235 for(
int step = 1; step<=steps; ++step )
237 double rotation = ( angle * step ) / steps;
280 segList.erase( segList.begin() + xmini );
284 prox = Millimeter2iu( 0.01 );
299 prevPt = graphic->
GetEnd();
301 aPolygons.
Append( prevPt );
319 nextPt = graphic->
GetEnd();
323 aPolygons.
Append( nextPt );
345 std::swap( pstart, pend );
350 for(
int step = 1; step<=steps; ++step )
352 double rotation = ( angle * step ) / steps;
356 aPolygons.
Append( nextPt );
366 msg.Printf( _(
"Unsupported DRAWSEGMENT type %s" ),
369 *aErrorText << msg <<
"\n";
377 graphic =
findPoint( prevPt, segList, prox );
394 _(
"Unable to find the next boundary segment with an endpoint of (%s mm, %s mm). " 395 "graphic outline must form a contiguous, closed polygon." ),
400 *aErrorText << msg <<
"\n";
413 prox = Millimeter2iu( 0.05 );
415 while( segList.size() )
418 int hole = aPolygons.
NewHole();
421 segList.erase( segList.begin() );
427 double angle = 3600.0;
435 for(
int step = 0; step < steps; ++step )
437 double rotation = ( angle * step ) / steps;
440 aPolygons.
Append( nextPt, -1, hole );
449 prevPt = graphic->
GetEnd();
450 aPolygons.
Append( prevPt, -1, hole );
467 nextPt = graphic->
GetEnd();
475 aPolygons.
Append( prevPt, -1, hole );
496 std::swap( pstart, pend );
501 for(
int step = 1; step <= steps; ++step )
503 double rotation = ( angle * step ) / steps;
508 aPolygons.
Append( nextPt, -1, hole );
518 msg.Printf( _(
"Unsupported DRAWSEGMENT type %s" ),
521 *aErrorText << msg <<
"\n";
529 graphic =
findPoint( prevPt, segList, prox );
546 _(
"Unable to find the next graphic segment with an endpoint of (%s mm, %s mm).\n" 547 "Edit graphics, making them contiguous polygons each." ),
552 *aErrorText << msg <<
"\n";
575 wxString* aErrorText )
582 items.
Collect( aBoard, scan_graphics );
585 std::vector< DRAWSEGMENT* > segList;
587 for(
int ii = 0; ii < items.
GetCount(); ii++ )
590 segList.push_back( static_cast< DRAWSEGMENT* >( items[ii] ) );
611 bbbox.
Inflate( Millimeter2iu( 1.0 ) );
621 aOutlines.
Append( corner );
627 aOutlines.
Append( corner );
int GetCount() const
Function GetCount returns the number of objects in the list.
int NewHole(int aOutline=-1)
Creates a new hole in a given outline
static wxString ShowShape(STROKE_T aShape)
Function ShowShape converts the enum STROKE_T integer value to a wxString.
const wxPoint GetOrigin() const
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
Implementation of conversion functions that require both schematic and board internal units...
const wxPoint GetCenter() const override
Function GetCenter()
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
Class BOARD to handle a board.
bool ConvertOutlineToPolygon(std::vector< DRAWSEGMENT * > &aSegList, SHAPE_POLY_SET &aPolygons, wxString *aErrorText)
Function ConvertOutlineToPolygon build a polygon (with holes) from a DRAWSEGMENT list, which is expected to be a outline, therefore a closed main outline with perhaps closed inner outlines.
usual segment : line with rounded ends
void RotatePoint(int *pX, int *pY, double angle)
int OutlineCount() const
Returns the number of outlines in the set
static unsigned close_ness(const wxPoint &aLeft, const wxPoint &aRight)
Function close_ness is a non-exact distance (also called Manhattan distance) used to approximate the ...
class EDGE_MODULE, a footprint edge
search types array terminator (End Of Types)
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
static std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from board internal units to a string appropriate for wr...
bool close_st(const wxPoint &aReference, const wxPoint &aFirst, const wxPoint &aSecond)
Function close_st is a local method of qualifying if either the start of end point of a segment is cl...
This file contains miscellaneous commonly used macros and functions.
const wxPoint & GetArcStart() const
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, wxString *aErrorText)
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
a few functions useful in geometry calculations.
bool close_enough(const wxPoint &aLeft, const wxPoint &aRight, unsigned aLimit)
Function close_enough is a local and tunable method of qualifying the proximity of two points...
int NewOutline()
Creates a new empty polygon in the set and returns its index
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
const wxPoint GetEnd() const
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Class to handle a graphic segment.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
const wxPoint GetArcEnd() const
static DRAWSEGMENT * findPoint(const wxPoint &aPoint, std::vector< DRAWSEGMENT * > &aList, unsigned aLimit)
Searches for a DRAWSEGMENT matching a given end point or start point in a list, and if found...
Class EDA_RECT handles the component boundary box.
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
class DRAWSEGMENT, a segment not on copper layers
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...