41 std::vector<wxPoint> points;
45 poly_no_hole.
Append( aPoly );
48 for(
auto iter = poly_no_hole.
CIterate(); iter; iter++ )
49 points.emplace_back( iter->x, iter->y );
99 const wxPoint& aCtrl2,
int aThickness )
121 item->
SetEnd( wxPoint( aCenter.x + aRadius, aCenter.y ) );
150 if( aPrimitivesList.size() )
160 for(
const std::shared_ptr<PCB_SHAPE>& prim : aPrimitivesList )
191 primitive->TransformShapeWithClearanceToPolygon( polyset, aLayer, 0, aError, aErrorLoc );
240 const int minSteps = 10;
241 const int maxSteps = 50;
245 auto bbox = poly.
BBox();
247 if( bbox.GetWidth() < bbox.GetHeight() )
250 stepsY = minSteps * (double) bbox.
GetHeight() / (double )(bbox.GetWidth() + 1);
255 stepsX = minSteps * (double) bbox.GetWidth() / (double )(bbox.GetHeight() + 1);
258 stepsX = std::max(minSteps, std::min( maxSteps, stepsX ) );
259 stepsY = std::max(minSteps, std::min( maxSteps, stepsY ) );
263 int64_t minDist = std::numeric_limits<int64_t>::max();
277 for(
int y = 0; y < stepsY ; y++ )
279 for(
int x = 0; x < stepsX; x++ )
282 p.
x +=
rescale( x, bbox.GetWidth(), (stepsX - 1) );
283 p.
y +=
rescale( y, bbox.GetHeight(), (stepsY - 1) );
291 if( distEdge >= minDistEdge )
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN Outline() const
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void DeletePrimitivesList()
Clear the basic shapes list.
void SetBezControl2(const wxPoint &aPoint)
void SetFilled(bool aFlag)
polygon (not yet used for tracks, but could be in microwave apps)
void AddPrimitiveRect(const wxPoint &aStart, const wxPoint &aEnd, int aThickness, bool aFilled)
usual segment : line with rounded ends
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
int Distance(const VECTOR2I &aP, bool aOutlineOnly=false) const
Function Distance()
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE >> &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
void AddPrimitiveSegment(const wxPoint &aStart, const wxPoint &aEnd, int aThickness)
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
segment with non rounded ends
virtual void SetParent(EDA_ITEM *aParent)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
PCB_LAYER_ID
A quick note on layer IDs:
void SetShape(PCB_SHAPE_TYPE_T aShape)
Represent a set of closed polygons.
const wxSize & GetSize() const
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
void Simplify(POLYGON_MODE aFastMode)
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
PAD_SHAPE_T GetAnchorPadShape() const
void SetBezControl1(const wxPoint &aPoint)
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void AddPrimitiveCurve(const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aCtrl1, const wxPoint &aCtrl2, int aThickness)
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, PCB_LAYER_ID aLayer) const
Merge all basic shapes to a SHAPE_POLY_SET.
void SetStart(const wxPoint &aStart)
Information pertinent to a Pcbnew printed circuit board.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetWidth(int aWidth)
T rescale(T aNumerator, T aValue, T aDenominator)
Function rescale()
void AddPrimitiveArc(const wxPoint &aCenter, const wxPoint &aStart, int aArcAngle, int aThickness)
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
coord_type GetHeight() const
void AppendPrimitives(const std::vector< std::shared_ptr< PCB_SHAPE >> &aPrimitivesList)
Import a custom shape primitive list (composed of basic shapes) and add items to the current list.
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
bool GetBestAnchorPosition(VECTOR2I &aPos)
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
void SetEnd(const wxPoint &aEnd)
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
void AddPrimitiveCircle(const wxPoint &aCenter, int aRadius, int aThickness, bool aFilled)
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, PCB_LAYER_ID aLayer, int aError, ERROR_LOC aErrorLoc) const