KiCad PCB EDA Suite
|
Represent route directions & corner angles in a 45-degree metric. More...
#include <direction45.h>
Public Types | |
enum | Directions : int { N = 0 , NE = 1 , E = 2 , SE = 3 , S = 4 , SW = 5 , W = 6 , NW = 7 , LAST = 8 , UNDEFINED = -1 } |
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined direction, reserved for traces that don't respect 45-degree routing regime. More... | |
enum | CORNER_MODE { MITERED_45 = 0 , ROUNDED_45 = 1 , MITERED_90 = 2 , ROUNDED_90 = 3 } |
Corner modes. More... | |
enum | AngleType { ANG_OBTUSE = 0x01 , ANG_RIGHT = 0x02 , ANG_ACUTE = 0x04 , ANG_STRAIGHT = 0x08 , ANG_HALF_FULL = 0x10 , ANG_UNDEFINED = 0x20 } |
Represent kind of angle formed by vectors heading in two DIRECTION_45s. More... | |
Public Member Functions | |
DIRECTION_45 (Directions aDir=UNDEFINED) | |
DIRECTION_45 (const VECTOR2I &aVec, bool a90=false) | |
DIRECTION_45 (const SEG &aSeg, bool a90=false) | |
DIRECTION_45 (const SHAPE_ARC &aArc, bool a90=false) | |
Create a DIRECTION_45 from the endpoints of a given arc. | |
const std::string | Format () const |
Format the direction in a human readable word. | |
DIRECTION_45 | Opposite () const |
Return a direction opposite (180 degree) to (this). | |
AngleType | Angle (const DIRECTION_45 &aOther) const |
Return the type of angle between directions (this) and aOther. | |
bool | IsObtuse (const DIRECTION_45 &aOther) const |
bool | IsDiagonal () const |
Returns true if the direction is diagonal (e.g. | |
bool | IsDefined () const |
const SHAPE_LINE_CHAIN | BuildInitialTrace (const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, CORNER_MODE aMode=CORNER_MODE::MITERED_45) const |
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime. | |
bool | operator== (const DIRECTION_45 &aOther) const |
bool | operator!= (const DIRECTION_45 &aOther) const |
const DIRECTION_45 | Right () const |
Return the direction on the right side of this (i.e. | |
const DIRECTION_45 | Left () const |
Return the direction on the left side of this (i.e. | |
const VECTOR2I | ToVector () const |
int | Mask () const |
Private Member Functions | |
void | construct_ (const VECTOR2I &aVec) |
Calculate the direction from a vector. | |
Private Attributes | |
Directions | m_dir |
Are we routing on 45 or 90 degree increments. | |
bool | m_90deg |
Represent route directions & corner angles in a 45-degree metric.
Definition at line 36 of file direction45.h.
Represent kind of angle formed by vectors heading in two DIRECTION_45s.
Enumerator | |
---|---|
ANG_OBTUSE | |
ANG_RIGHT | |
ANG_ACUTE | |
ANG_STRAIGHT | |
ANG_HALF_FULL | |
ANG_UNDEFINED |
Definition at line 77 of file direction45.h.
Corner modes.
A corner can either be 45° or 90° and can be fillet/rounded or mitered
Enumerator | |
---|---|
MITERED_45 | H/V/45 with mitered corners (default) |
ROUNDED_45 | H/V/45 with filleted corners. |
MITERED_90 | H/V only (90-degree corners) |
ROUNDED_90 | H/V with filleted corners. |
Definition at line 66 of file direction45.h.
enum DIRECTION_45::Directions : int |
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined direction, reserved for traces that don't respect 45-degree routing regime.
Enumerator | |
---|---|
N | |
NE | |
E | |
SE | |
S | |
SW | |
W | |
NW | |
LAST | |
UNDEFINED |
Definition at line 48 of file direction45.h.
|
inline |
Definition at line 87 of file direction45.h.
|
inline |
aVec | vector in world space, whose direction will be translated into a DIRECTION_45. |
Definition at line 92 of file direction45.h.
References construct_(), and VECTOR2< T >::y.
|
inline |
aSeg | segment, whose direction will be translated into a DIRECTION_45. |
Definition at line 103 of file direction45.h.
References SEG::A, SEG::B, construct_(), and VECTOR2< T >::y.
|
inline |
Create a DIRECTION_45 from the endpoints of a given arc.
aArc | will be translated into the closest DIRECTION_45 |
Definition at line 116 of file direction45.h.
References construct_(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), and VECTOR2< T >::y.
|
inline |
Return the type of angle between directions (this) and aOther.
aOther | direction to compare angle with |
Definition at line 181 of file direction45.h.
References std::abs(), ANG_ACUTE, ANG_HALF_FULL, ANG_OBTUSE, ANG_RIGHT, ANG_STRAIGHT, ANG_UNDEFINED, m_dir, and UNDEFINED.
Referenced by PNS::angle(), PNS::DIFF_PAIR::CheckConnectionAngle(), PNS::LINE::CountCorners(), PNS::MULTI_DRAGGER::Drag(), PNS::LINE::dragSegment45(), PNS::DP_GATEWAYS::FilterByOrientation(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), PNS::LINE_PLACER::handlePullback(), IsObtuse(), PNS::LINE_PLACER::mergeHead(), PNS::OPTIMIZER::smartPadsSingle(), and PNS::tightenSegment().
const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace | ( | const VECTOR2I & | aP0, |
const VECTOR2I & | aP1, | ||
bool | aStartDiagonal = false , |
||
CORNER_MODE | aMode = CORNER_MODE::MITERED_45 |
||
) | const |
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
If aStartDiagonal is true, the trace starts with a diagonal segment.
aP0 | starting point |
aP1 | ending point |
aStartDiagonal | whether the first segment has to be diagonal |
aMode | How the corner is made. If it is a 90° corner, aStartDiagonal means start with the shorter direction first / use arc before the straight segment. |
Definition at line 24 of file direction_45.cpp.
References std::abs(), ANGLE_45, ANGLE_90, SHAPE_LINE_CHAIN::Append(), SHAPE_ARC::ConstructFromStartEndAngle(), SHAPE_ARC::ConstructFromStartEndCenter(), VECTOR2< T >::EuclideanNorm(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), IsDiagonal(), KiROUND(), m_dir, SHAPE::MIN_PRECISION_IU, MITERED_45, MITERED_90, VECTOR2< T >::Resize(), RotatePoint(), ROUNDED_45, ROUNDED_90, sign(), SHAPE_LINE_CHAIN::Simplify(), VECTOR2< T >::SquaredEuclideanNorm(), UNDEFINED, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PNS::DP_GATEWAYS::buildEntries(), PNS::DIFF_PAIR::BuildInitial(), PNS::LINE_PLACER::buildInitialLine(), PNS::coupledBypass(), PNS::dragCornerInternal(), PNS::OPTIMIZER::fanoutCleanup(), PNS::OPTIMIZER::mergeDpStep(), PNS::OPTIMIZER::mergeStep(), PNS::LINE_PLACER::reduceTail(), and PNS::OPTIMIZER::smartPadsSingle().
|
inlineprivate |
Calculate the direction from a vector.
If the vector's angle is not a multiple of 45 degrees, the direction is rounded to the nearest octant.
aVec | our vector our actual direction |
Definition at line 317 of file direction45.h.
References LAST, m_dir, UNDEFINED, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by DIRECTION_45().
|
inline |
Format the direction in a human readable word.
Definition at line 129 of file direction45.h.
References E, m_dir, N, NE, NW, S, SE, SW, UNDEFINED, and W.
Referenced by PNS::LINE_PLACER::buildInitialLine(), PNS::MULTI_DRAGGER::findNewLeaderSegment(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::initPlacement(), PNS::LINE_PLACER::mergeHead(), PNS::LINE_PLACER::routeStep(), and PNS::LINE_PLACER::Start().
|
inline |
Definition at line 218 of file direction45.h.
|
inline |
Returns true if the direction is diagonal (e.g.
North-West, South-East, etc).
Definition at line 213 of file direction45.h.
References m_dir.
Referenced by BuildInitialTrace(), PNS::coupledBypass(), PNS::dragCornerInternal(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::MOUSE_TRAIL_TRACER::GetPosture(), and PNS::OPTIMIZER::mergeDpStep().
|
inline |
Definition at line 203 of file direction45.h.
References ANG_OBTUSE, and Angle().
Referenced by PNS::OPTIMIZER::mergeDpStep(), and PNS::tightenSegment().
|
inline |
Return the direction on the left side of this (i.e.
turns left by 45 or 90 deg).
Definition at line 269 of file direction45.h.
References LAST, m_90deg, m_dir, and UNDEFINED.
Referenced by PNS::LINE::dragSegment45().
|
inline |
Definition at line 305 of file direction45.h.
References m_dir.
|
inline |
Definition at line 243 of file direction45.h.
References m_dir.
|
inline |
Definition at line 238 of file direction45.h.
References m_dir.
|
inline |
|
inline |
Return the direction on the right side of this (i.e.
turns right by 45 or 90 deg).
Definition at line 251 of file direction45.h.
References LAST, m_90deg, m_dir, and UNDEFINED.
Referenced by PNS::LINE::dragSegment45(), PNS::MOUSE_TRAIL_TRACER::FlipPosture(), and PNS::MOUSE_TRAIL_TRACER::GetPosture().
|
inline |
Definition at line 287 of file direction45.h.
References E, m_dir, N, NE, NW, S, SE, SW, and W.
Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), and PNS::LINE::dragSegment45().
|
private |
Definition at line 349 of file direction45.h.
|
private |
Are we routing on 45 or 90 degree increments.
Definition at line 346 of file direction45.h.
Referenced by Angle(), BuildInitialTrace(), construct_(), Format(), IsDefined(), IsDiagonal(), Left(), Mask(), operator!=(), operator==(), Opposite(), Right(), and ToVector().