KiCad PCB EDA Suite
|
#include <trigo.h>
#include <macros.h>
#include <math/vector2d.h>
#include <pcb_shape.h>
#include <footprint.h>
#include <pad.h>
#include <base_units.h>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/shape_poly_set.h>
#include <geometry/geometry_utils.h>
#include <convert_shape_list_to_polygon.h>
#include <wx/log.h>
#include <board.h>
#include <collectors.h>
Go to the source code of this file.
Functions | |
bool | close_enough (VECTOR2I aLeft, VECTOR2I aRight, unsigned aLimit) |
Function close_enough is a local and tunable method of qualifying the proximity of two points. More... | |
bool | closer_to_first (VECTOR2I aRef, VECTOR2I aFirst, VECTOR2I aSecond) |
Function closer_to_first Local method which qualifies whether the start or end point of a segment is closest to a point. More... | |
static PCB_SHAPE * | findNext (PCB_SHAPE *aShape, const VECTOR2I &aPoint, const std::vector< PCB_SHAPE * > &aList, unsigned aLimit) |
Searches for a PCB_SHAPE matching a given end point or start point in a list. More... | |
bool | isCopperOutside (const FOOTPRINT *aFootprint, SHAPE_POLY_SET &aShape) |
bool | ConvertOutlineToPolygon (std::vector< PCB_SHAPE * > &aShapeList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, bool aAllowDisjoint, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons) |
Function ConvertOutlineToPolygon build a polygon set (with holes) from a PCB_SHAPE list, which is expected to be one or more top-level closed outlines, with zero or more holes in each. More... | |
bool | BuildBoardPolygonOutlines (BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons) |
Extracts the board outlines and build a closed polygon from lines, arcs and circle items on edge cut layer. More... | |
void | buildBoardBoundingBoxPoly (const BOARD *aBoard, SHAPE_POLY_SET &aOutline) |
Get the complete bounding box of the board (including all items). More... | |
VECTOR2I | projectPointOnSegment (const VECTOR2I &aEndPoint, const SHAPE_POLY_SET &aOutline, int aOutlineNum=0) |
int | findEndSegments (SHAPE_LINE_CHAIN &aChain, SEG &aStartSeg, SEG &aEndSeg) |
bool | BuildFootprintPolygonOutlines (BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler) |
This function is used to extract a board outline for a footprint view. More... | |
Variables | |
const wxChar * | traceBoardOutline = wxT( "KICAD_BOARD_OUTLINE" ) |
Flag to enable debug tracing for the board outline creation. More... | |
void buildBoardBoundingBoxPoly | ( | const BOARD * | aBoard, |
SHAPE_POLY_SET & | aOutline | ||
) |
Get the complete bounding box of the board (including all items).
The vertex numbers and segment numbers of the rectangle returned. 1 ------------— |1 2| 0| |2 |0 3| ------------— 3
Definition at line 742 of file convert_shape_list_to_polygon.cpp.
References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), BOARD::ComputeBoundingBox(), BOARD::GetBoundingBox(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), EDA_IU_SCALE::mmToIU(), pcbIUScale, SHAPE_POLY_SET::RemoveAllContours(), SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BuildFootprintPolygonOutlines(), and RENDER_3D_RAYTRACE::Reload().
bool BuildBoardPolygonOutlines | ( | BOARD * | aBoard, |
SHAPE_POLY_SET & | aOutlines, | ||
int | aErrorMax, | ||
int | aChainingEpsilon, | ||
OUTLINE_ERROR_HANDLER * | aErrorHandler = nullptr , |
||
bool | aAllowUseArcsInPolygons = false |
||
) |
Extracts the board outlines and build a closed polygon from lines, arcs and circle items on edge cut layer.
Any closed outline inside the main outline is a hole. All contours should be closed, i.e. are valid vertices for a closed polygon.
aBoard | is the board to build outlines |
aOutlines | will contain the outlines ( complex polygons ). |
aErrorMax | is the max error distance when polygonizing a curve (internal units) |
aChainingEpsilon | is the max distance from one endPt to the next startPt (internal units) |
aErrorHandler | = an optional error handler |
aAllowUseArcsInPolygons | = an optional option to allow adding arcs in SHAPE_LINE_CHAIN polylines/polygons when building outlines from aShapeList This is mainly for export to STEP files |
Definition at line 601 of file convert_shape_list_to_polygon.cpp.
References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::Append(), PCB_TYPE_COLLECTOR::Collect(), BOARD::ComputeBoundingBox(), ConvertOutlineToPolygon(), SHAPE_LINE_CHAIN::CPoint(), Edge_Cuts, BOARD::Footprints(), BOARD::GetBoardEdgesBoundingBox(), COLLECTOR::GetCount(), BOX2< Vec >::GetEnd(), EDA_ITEM::GetFlags(), BOX2< Vec >::GetHeight(), BOARD_ITEM::GetLayer(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), isCopperOutside(), EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PCB_SHAPE_T, pcbIUScale, SHAPE_LINE_CHAIN_BASE::PointInside(), SHAPE_POLY_SET::RemoveAllContours(), SKIP_STRUCT, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOARD::GetBoardPolygonOutlines(), DIALOG_EXPORT_STEP::onExportButton(), and DRC_TEST_PROVIDER_MISC::testOutline().
bool BuildFootprintPolygonOutlines | ( | BOARD * | aBoard, |
SHAPE_POLY_SET & | aOutlines, | ||
int | aErrorMax, | ||
int | aChainingEpsilon, | ||
OUTLINE_ERROR_HANDLER * | aErrorHandler | ||
) |
This function is used to extract a board outline for a footprint view.
Notes:
Definition at line 855 of file convert_shape_list_to_polygon.cpp.
References SHAPE_POLY_SET::AddHole(), SHAPE_LINE_CHAIN::Append(), SHAPE_POLY_SET::Append(), buildBoardBoundingBoxPoly(), PCB_TYPE_COLLECTOR::Collect(), SEG::Contains(), ConvertOutlineToPolygon(), Edge_Cuts, findEndSegments(), COLLECTOR::GetCount(), BOARD::GetFirstFootprint(), SHAPE_LINE_CHAIN::GetPoint(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), SEG::IntersectLines(), SHAPE_LINE_CHAIN::IsClosed(), isCopperOutside(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PCB_SHAPE_T, SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), SHAPE_LINE_CHAIN::SetClosed(), and traceBoardOutline.
Referenced by BOARD_ADAPTER::createBoardPolygon().
Function close_enough is a local and tunable method of qualifying the proximity of two points.
aLeft | is the first point |
aRight | is the second point |
aLimit | is a measure of proximity that the caller knows about. |
Definition at line 60 of file convert_shape_list_to_polygon.cpp.
References SEG::Square().
Referenced by ConvertOutlineToPolygon().
Function closer_to_first Local method which qualifies whether the start or end point of a segment is closest to a point.
aRef | is the reference point |
aFirst | is the first point |
aSecond | is the second point |
Definition at line 74 of file convert_shape_list_to_polygon.cpp.
Referenced by ConvertOutlineToPolygon().
bool ConvertOutlineToPolygon | ( | std::vector< PCB_SHAPE * > & | aShapeList, |
SHAPE_POLY_SET & | aPolygons, | ||
int | aErrorMax, | ||
int | aChainingEpsilon, | ||
bool | aAllowDisjoint, | ||
OUTLINE_ERROR_HANDLER * | aErrorHandler, | ||
bool | aAllowUseArcsInPolygons = false |
||
) |
Function ConvertOutlineToPolygon build a polygon set (with holes) from a PCB_SHAPE list, which is expected to be one or more top-level closed outlines, with zero or more holes in each.
Optionally, it can be limited to a single top-level closed outline.
aShapeList | the initial list of drawsegments (only lines, circles and arcs). |
aPolygons | will contain the complex polygon. |
aErrorMax | is the max error distance when polygonizing a curve (internal units) |
aChainingEpsilon | is the max distance from one endPt to the next startPt (internal units) |
aAllowDisjoint | indicates multiple top-level outlines are allowed |
aErrorHandler | = an optional error handler |
aAllowUseArcsInPolygons | = an optional option to allow adding arcs in SHAPE_LINE_CHAIN polylines/polygons when building outlines from aShapeList This is mainly for export to STEP files |
Definition at line 175 of file convert_shape_list_to_polygon.cpp.
References _, SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), ANGLE_360, SHAPE_LINE_CHAIN::Append(), ARC, BEZIER, CIRCLE, SHAPE_POLY_SET::CIterate(), SHAPE_LINE_CHAIN::ClearArcs(), close_enough(), closer_to_first(), SHAPE_LINE_CHAIN::CPoint(), findNext(), EDA_SHAPE::GetArcAngle(), GetArcToSegmentCount(), EDA_SHAPE::GetBezierPoints(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), EDA_ITEM::GetFlags(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), SHAPE_LINE_CHAIN::GetSegment(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), SHAPE_POLY_SET::IsEmpty(), SHAPE_POLY_SET::IterateSegmentsWithHoles(), EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), pcbIUScale, SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN_BASE::PointInside(), POLY, EDA_SHAPE::RebuildBezierToSegmentsPointsList(), RECT, RotatePoint(), SEGMENT, SHAPE_LINE_CHAIN::SetClosed(), EDA_ITEM::SetFlags(), EDA_SHAPE::SHAPE_T_asString(), SKIP_STRUCT, UNIMPLEMENTED_FOR, and VECTOR2< T >::x.
Referenced by BuildBoardPolygonOutlines(), FOOTPRINT::BuildCourtyardCaches(), and BuildFootprintPolygonOutlines().
int findEndSegments | ( | SHAPE_LINE_CHAIN & | aChain, |
SEG & | aStartSeg, | ||
SEG & | aEndSeg | ||
) |
Definition at line 791 of file convert_shape_list_to_polygon.cpp.
References SEG::A, SEG::B, SEG::Contains(), SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), traceBoardOutline, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BuildFootprintPolygonOutlines().
|
static |
Searches for a PCB_SHAPE matching a given end point or start point in a list.
aShape | The starting shape. |
aPoint | The starting or ending point to search for. |
aList | The list to remove from. |
aLimit | is the distance from aPoint that still constitutes a valid find. |
Definition at line 89 of file convert_shape_list_to_polygon.cpp.
References SKIP_STRUCT, and SEG::Square().
Referenced by ConvertOutlineToPolygon(), and PAD_TOOL::RecombinePad().
bool isCopperOutside | ( | const FOOTPRINT * | aFootprint, |
SHAPE_POLY_SET & | aShape | ||
) |
Definition at line 135 of file convert_shape_list_to_polygon.cpp.
References SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::CloneDropTriangulation(), SHAPE_POLY_SET::OutlineCount(), pad, FOOTPRINT::Pads(), SHAPE_POLY_SET::PM_FAST, traceBoardOutline, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BuildBoardPolygonOutlines(), and BuildFootprintPolygonOutlines().
VECTOR2I projectPointOnSegment | ( | const VECTOR2I & | aEndPoint, |
const SHAPE_POLY_SET & | aOutline, | ||
int | aOutlineNum = 0 |
||
) |
Definition at line 769 of file convert_shape_list_to_polygon.cpp.
References SHAPE_POLY_SET::CIterateSegments().