![]() |
KiCad PCB EDA Suite
|
#include <shape_arc.h>
Public Member Functions | |
SHAPE_ARC () | |
SHAPE_ARC (const VECTOR2I &aArcCenter, const VECTOR2I &aArcStartPoint, double aCenterAngle, int aWidth=0) | |
SHAPE_ARC ctor using center, start, angle. More... | |
SHAPE_ARC (const VECTOR2I &aArcStart, const VECTOR2I &aArcMid, const VECTOR2I &aArcEnd, int aWidth) | |
SHAPE_ARC ctor. More... | |
SHAPE_ARC (const SEG &aSegmentA, const SEG &aSegmentB, int aRadius, int aWidth=0) | |
SHAPE_ARC ctor. More... | |
SHAPE_ARC (const SHAPE_ARC &aOther) | |
virtual | ~SHAPE_ARC () |
SHAPE * | Clone () const override |
Return a dynamically allocated copy of the shape. More... | |
SHAPE_ARC & | ConstructFromStartEndAngle (const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle, double aWidth=0) |
Constructs this arc from the given start, end and angle. More... | |
const VECTOR2I & | GetP0 () const |
const VECTOR2I & | GetP1 () const |
const VECTOR2I & | GetArcMid () const |
VECTOR2I | GetCenter () const |
const BOX2I | BBox (int aClearance=0) const override |
Compute a bounding box of the shape, with a margin of aClearance a collision. More... | |
bool | Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision. More... | |
bool | Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override |
Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. More... | |
void | SetWidth (int aWidth) |
int | GetWidth () const |
bool | IsSolid () const override |
void | Move (const VECTOR2I &aVector) override |
void | Rotate (double aAngle, const VECTOR2I &aCenter) override |
Function Rotate rotates the arc by a given angle about a point. More... | |
void | Mirror (bool aX=true, bool aY=false, const VECTOR2I &aVector={ 0, 0 }) |
void | Mirror (const SEG &axis) |
void | Reverse () |
SHAPE_ARC | Reversed () const |
double | GetRadius () const |
SEG | GetChord () const |
double | GetCentralAngle () const |
double | GetStartAngle () const |
double | GetEndAngle () const |
const SHAPE_LINE_CHAIN | ConvertToPolyline (double aAccuracy=0.005 *PCB_IU_PER_MM) const |
Constructs a SHAPE_LINE_CHAIN of segments from a given arc. More... | |
bool | IsNull () const |
Return true if the shape is a null shape. More... | |
virtual bool | Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. More... | |
virtual bool | Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const |
virtual VECTOR2I | Centre () const |
Compute a center-of-mass of the shape. More... | |
virtual bool | Parse (std::stringstream &aStream) |
virtual const std::string | Format () const |
FACET * | NewFacet () |
SGNODE * | CalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false) |
SHAPE_TYPE | Type () const |
Return the type of the shape. More... | |
virtual bool | HasIndexableSubshapes () const |
virtual size_t | GetIndexableSubshapeCount () const |
virtual void | GetIndexableSubshapes (std::vector< SHAPE * > &aSubshapes) |
Static Public Attributes | |
static const int | MIN_PRECISION_IU = 4 |
This is the minimum precision for all the points in a shape. More... | |
Protected Types | |
typedef VECTOR2I::extended_type | ecoord |
Protected Attributes | |
SHAPE_TYPE | m_type |
< type of our shape More... | |
Private Member Functions | |
bool | ccw (const VECTOR2I &aA, const VECTOR2I &aB, const VECTOR2I &aC) const |
void | update_bbox () |
Private Attributes | |
VECTOR2I | m_start |
VECTOR2I | m_mid |
VECTOR2I | m_end |
int | m_width |
BOX2I | m_bbox |
Definition at line 35 of file shape_arc.h.
|
protectedinherited |
|
inline |
SHAPE_ARC::SHAPE_ARC | ( | const VECTOR2I & | aArcCenter, |
const VECTOR2I & | aArcStartPoint, | ||
double | aCenterAngle, | ||
int | aWidth = 0 |
||
) |
SHAPE_ARC ctor using center, start, angle.
Center and angle are used to calculate the mid and end points of the arc, and are not stored
aArcCenter | is the arc center |
aArcStartPoint | is the arc start point |
aCenterAngle | is the arc angle in degrees |
aWidth | is the arc line thickness |
Definition at line 33 of file shape_arc.cpp.
References m_end, m_mid, m_start, RotatePoint(), and update_bbox().
SHAPE_ARC::SHAPE_ARC | ( | const VECTOR2I & | aArcStart, |
const VECTOR2I & | aArcMid, | ||
const VECTOR2I & | aArcEnd, | ||
int | aWidth | ||
) |
SHAPE_ARC ctor.
aArcStart | is the arc start point |
aArcEnd | is the arc end point |
aArcMid | is the arc mid point |
aWidth | is the arc line thickness |
Definition at line 48 of file shape_arc.cpp.
References update_bbox().
SHAPE_ARC ctor.
Builds a SHAPE_ARC which is tangent to two segments and a given radius
aSegmentA | is the first segment |
aSegmentB | is the second segment |
aRadius | is the arc radius |
aWidth | is the arc line thickness |
Definition at line 57 of file shape_arc.cpp.
References SEG::A, ArcTangente(), SEG::B, SEG::Center(), DECIDEG2RAD(), VECTOR2< T >::EuclideanNorm(), SEG::Intersect(), KiROUND(), SEG::Length(), SEG::LineProject(), m_end, m_mid, m_start, m_width, NormalizeAngle180(), RotatePoint(), update_bbox(), VECTOR2< T >::x, and VECTOR2< T >::y.
SHAPE_ARC::SHAPE_ARC | ( | const SHAPE_ARC & | aOther | ) |
Definition at line 162 of file shape_arc.cpp.
|
inlinevirtual |
Definition at line 77 of file shape_arc.h.
|
overridevirtual |
Compute a bounding box of the shape, with a margin of aClearance a collision.
aClearance | how much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape. |
Implements SHAPE.
Definition at line 305 of file shape_arc.cpp.
References BOX2< Vec >::Inflate(), and m_bbox.
Referenced by CheckArcGeom(), Collide(), and GERBER_DRAW_ITEM::GetBoundingBox().
|
inherited |
Definition at line 713 of file wrlfacet.cpp.
References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), SHAPE::facets, IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), IFSG_SHAPE::NewNode(), IFSG_FACESET::NewNode(), NULL, IFSG_COLORS::SetColorList(), IFSG_COORDS::SetCoordsList(), IFSG_NORMALS::SetNormalList(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.
Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().
|
inlineprivate |
Definition at line 164 of file shape_arc.h.
References VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Collide().
|
inlinevirtualinherited |
Compute a center-of-mass of the shape.
Definition at line 216 of file shape.h.
References SHAPE::BBox(), and BOX2< Vec >::Centre().
Referenced by Collide().
|
inlineoverridevirtual |
Return a dynamically allocated copy of the shape.
copy | of the shape |
Reimplemented from SHAPE.
Definition at line 79 of file shape_arc.h.
References SHAPE_ARC().
Referenced by CheckArc().
|
overridevirtual |
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision.
aActual | [out] an optional pointer to an int to be updated with the actual distance int the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Implements SHAPE.
Definition at line 191 of file shape_arc.cpp.
References SEG::A, SEG::B, VECTOR2< T >::Dot(), VECTOR2< T >::ECOORD_MAX, GetCenter(), m_end, m_start, m_width, SEG::Square(), SEG::SquaredDistance(), VECTOR2< T >::SquaredEuclideanNorm(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE().
|
overridevirtual |
Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.
aActual | [out] an optional pointer to an int to store the actual distance in the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Reimplemented from SHAPE.
Definition at line 316 of file shape_arc.cpp.
References VECTOR2< T >::Angle(), BBox(), ccw(), VECTOR2< T >::EuclideanNorm(), EuclideanNorm(), GetCenter(), GetCentralAngle(), GetEndAngle(), GetRadius(), GetStartAngle(), m_end, m_start, m_width, NormalizeAngleDegreesPos(), and RAD2DEG().
|
virtualinherited |
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
aShape | shape to check collision against |
aClearance | minimum clearance |
aMTV | minimum translation vector |
aActual | [out] an optional pointer to an int to store the actual distance in the event of a collision. |
aLocation | [out] an option pointer to a point to store a nearby location in the event of a collision. |
Reimplemented in SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 881 of file shape_collisions.cpp.
References collideShapes().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 887 of file shape_collisions.cpp.
References collideShapes().
SHAPE_ARC & SHAPE_ARC::ConstructFromStartEndAngle | ( | const VECTOR2I & | aStart, |
const VECTOR2I & | aEnd, | ||
double | aAngle, | ||
double | aWidth = 0 |
||
) |
Constructs this arc from the given start, end and angle.
aStart | is the arc starting point |
aEnd | is the arc endpoint |
aAngle | is the arc included angle |
aWidth | is the arc line thickness |
Definition at line 173 of file shape_arc.cpp.
References GetArcCenter(), m_end, m_mid, m_start, m_width, RotatePoint(), and update_bbox().
Referenced by DIRECTION_45::BuildInitialTrace().
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline | ( | double | aAccuracy = 0.005 * PCB_IU_PER_MM | ) | const |
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
aAccuracy | maximum divergence from true arc given in internal units ** Note that the default is ARC_HIGH_DEF in PCBNew units This is to allow common geometry collision functions Other programs should call this using explicit accuracy values TODO: unify KiCad internal units |
Definition at line 408 of file shape_arc.cpp.
References SHAPE_LINE_CHAIN::Append(), GetArcToSegmentCount(), GetCenter(), GetCentralAngle(), GetRadius(), GetStartAngle(), KiROUND(), m_end, and m_start.
Referenced by SHAPE_LINE_CHAIN::Append(), PNS::ArcHull(), Collide(), BOARD_ADAPTER::createPadWithClearance(), SHAPE_LINE_CHAIN::Insert(), CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices(), PCB_SHAPE::MakeEffectiveShapes(), SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN(), and TransformArcToPolygon().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, SHAPE_LINE_CHAIN, SHAPE_RECT, SHAPE_SEGMENT, and SHAPE_COMPOUND.
Definition at line 35 of file shape.cpp.
Referenced by SHAPE_FILE_IO::Write().
|
inline |
Definition at line 97 of file shape_arc.h.
References m_mid.
Referenced by ARC::ARC(), PCB_GRID_HELPER::computeAnchors(), and PNS_KICAD_IFACE::UpdateItem().
VECTOR2I SHAPE_ARC::GetCenter | ( | ) | const |
Definition at line 383 of file shape_arc.cpp.
References GetArcCenter(), m_end, m_mid, and m_start.
Referenced by CheckArcGeom(), Collide(), ConvertToPolyline(), ROUTER_PREVIEW_ITEM::drawLineChain(), ROUTER_PREVIEW_ITEM::drawShape(), GetCentralAngle(), GetEndAngle(), GetRadius(), GetStartAngle(), and update_bbox().
double SHAPE_ARC::GetCentralAngle | ( | ) | const |
Definition at line 389 of file shape_arc.cpp.
References ArcTangente(), GetCenter(), m_end, m_mid, m_start, NormalizeAngle180(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by CheckArcGeom(), Collide(), ConvertToPolyline(), ROUTER_PREVIEW_ITEM::drawLineChain(), ROUTER_PREVIEW_ITEM::drawShape(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), FABMASTER::loadOutline(), and update_bbox().
|
inline |
Definition at line 142 of file shape_arc.h.
References m_end, and m_start.
Referenced by CheckArcGeom().
double SHAPE_ARC::GetEndAngle | ( | ) | const |
Definition at line 373 of file shape_arc.cpp.
References GetCenter(), m_end, NormalizeAngleDegrees(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by CheckArcGeom(), and Collide().
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
Definition at line 106 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inline |
Definition at line 95 of file shape_arc.h.
References m_start.
Referenced by PCB_GRID_HELPER::AlignToArc(), PNS::ARC::Anchor(), ARC::ARC(), DIRECTION_45::BuildInitialTrace(), PCB_GRID_HELPER::computeAnchors(), DIRECTION_45::DIRECTION_45(), EDIT_TOOL::FilletTracks(), PNS::LINE_PLACER::handlePullback(), and PNS_KICAD_IFACE::UpdateItem().
|
inline |
Definition at line 96 of file shape_arc.h.
References m_end.
Referenced by PCB_GRID_HELPER::AlignToArc(), PNS::ARC::Anchor(), ARC::ARC(), DIRECTION_45::BuildInitialTrace(), CheckArcGeom(), PCB_GRID_HELPER::computeAnchors(), DIRECTION_45::DIRECTION_45(), EDIT_TOOL::FilletTracks(), and PNS_KICAD_IFACE::UpdateItem().
double SHAPE_ARC::GetRadius | ( | ) | const |
Definition at line 402 of file shape_arc.cpp.
References GetCenter(), and m_start.
Referenced by CheckArcGeom(), Collide(), ConvertToPolyline(), ROUTER_PREVIEW_ITEM::drawLineChain(), ROUTER_PREVIEW_ITEM::drawShape(), and update_bbox().
double SHAPE_ARC::GetStartAngle | ( | ) | const |
Definition at line 363 of file shape_arc.cpp.
References GetCenter(), m_start, NormalizeAngleDegrees(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by CheckArcGeom(), Collide(), ConvertToPolyline(), ROUTER_PREVIEW_ITEM::drawLineChain(), ROUTER_PREVIEW_ITEM::drawShape(), and update_bbox().
|
inline |
Definition at line 112 of file shape_arc.h.
References m_width.
Referenced by PNS::ArcHull(), Collide(), BOARD_ADAPTER::createPadWithClearance(), ROUTER_PREVIEW_ITEM::drawShape(), and PNS::ARC::Width().
|
inlinevirtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_COMPOUND.
Definition at line 99 of file shape.h.
Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().
|
inlineinherited |
Return true if the shape is a null shape.
true | if null :-) |
Definition at line 150 of file shape.h.
References SHAPE_BASE::m_type, and SH_NULL.
|
inlineoverridevirtual |
void SHAPE_ARC::Mirror | ( | bool | aX = true , |
bool | aY = false , |
||
const VECTOR2I & | aVector = { 0, 0 } |
||
) |
Definition at line 477 of file shape_arc.cpp.
References m_end, m_mid, m_start, update_bbox(), VECTOR2< T >::x, and VECTOR2< T >::y.
void SHAPE_ARC::Mirror | ( | const SEG & | axis | ) |
Definition at line 497 of file shape_arc.cpp.
References m_end, m_mid, m_start, SEG::ReflectPoint(), and update_bbox().
|
overridevirtual |
Implements SHAPE.
Definition at line 450 of file shape_arc.cpp.
References m_end, m_mid, m_start, and update_bbox().
|
inherited |
Definition at line 705 of file wrlfacet.cpp.
References SHAPE::facets.
Referenced by WRL1FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL2FACESET::TranslateToSG().
|
virtualinherited |
Reimplemented in SHAPE_POLY_SET, and SHAPE_LINE_CHAIN.
void SHAPE_ARC::Reverse | ( | ) |
Definition at line 507 of file shape_arc.cpp.
References m_end, and m_start.
Referenced by SHAPE_LINE_CHAIN::Reverse().
SHAPE_ARC SHAPE_ARC::Reversed | ( | ) | const |
Definition at line 513 of file shape_arc.cpp.
References m_end, m_mid, m_start, m_width, and SHAPE_ARC().
Referenced by PNS::NODE::AssembleLine().
|
overridevirtual |
Function Rotate rotates the arc by a given angle about a point.
aCenter | is the rotation center |
aAngle | rotation angle in radians |
Implements SHAPE.
Definition at line 459 of file shape_arc.cpp.
References m_end, m_mid, m_start, VECTOR2< T >::Rotate(), and update_bbox().
|
inline |
Definition at line 107 of file shape_arc.h.
References m_width.
Referenced by BOOST_AUTO_TEST_CASE(), and PNS::ARC::SetWidth().
|
inlineinherited |
Return the type of the shape.
the | type |
Definition at line 94 of file shape.h.
References SHAPE_BASE::m_type.
Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::buildHullForPrimitiveShape(), Collide(), SHAPE_POLY_SET::Collide(), collideShapes(), collideSingleShapes(), PNS::OPTIMIZER::computeBreakouts(), ROUTER_PREVIEW_ITEM::drawShape(), PNS::SOLID::HoleHull(), PNS::SOLID::Hull(), and SHAPE_FILE_IO::Write().
|
private |
Definition at line 263 of file shape_arc.cpp.
References BOX2< Vec >::Compute(), GetCenter(), GetCentralAngle(), GetRadius(), GetStartAngle(), KiROUND(), m_bbox, m_end, and m_start.
Referenced by ConstructFromStartEndAngle(), Mirror(), Move(), Rotate(), and SHAPE_ARC().
|
private |
Definition at line 178 of file shape_arc.h.
Referenced by BBox(), SHAPE_ARC(), and update_bbox().
|
private |
Definition at line 175 of file shape_arc.h.
Referenced by Collide(), ConstructFromStartEndAngle(), ConvertToPolyline(), GetCenter(), GetCentralAngle(), GetChord(), GetEndAngle(), GetP1(), Mirror(), Move(), Reverse(), Reversed(), Rotate(), SHAPE_ARC(), and update_bbox().
|
private |
Definition at line 174 of file shape_arc.h.
Referenced by ConstructFromStartEndAngle(), GetArcMid(), GetCenter(), GetCentralAngle(), Mirror(), Move(), Reversed(), Rotate(), and SHAPE_ARC().
|
private |
Definition at line 173 of file shape_arc.h.
Referenced by Collide(), ConstructFromStartEndAngle(), ConvertToPolyline(), GetCenter(), GetCentralAngle(), GetChord(), GetP0(), GetRadius(), GetStartAngle(), Mirror(), Move(), Reverse(), Reversed(), Rotate(), SHAPE_ARC(), and update_bbox().
|
protectedinherited |
< type of our shape
Definition at line 110 of file shape.h.
Referenced by SHAPE::IsNull(), and SHAPE_BASE::Type().
|
private |
Definition at line 177 of file shape_arc.h.
Referenced by BOOST_AUTO_TEST_CASE(), Collide(), ConstructFromStartEndAngle(), GetWidth(), Reversed(), SetWidth(), and SHAPE_ARC().
|
staticinherited |
This is the minimum precision for all the points in a shape.
Definition at line 122 of file shape.h.
Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), EDIT_TOOL::FilletTracks(), and CIRCLE::IntersectLine().