Searching...
No Matches
DIRECTION_45 Class Reference

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 (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

## 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

## Detailed Description

Represent route directions & corner angles in a 45-degree metric.

Definition at line 36 of file direction45.h.

## ◆ AngleType

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_MODE

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.

## ◆ Directions

 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.

Note
North represents "up" to the user looking at the application, which is the negative-y direction in the world coordinate space!
Enumerator
NE
SE
SW
NW
LAST
UNDEFINED

Definition at line 48 of file direction45.h.

## ◆ DIRECTION_45() [1/4]

 DIRECTION_45::DIRECTION_45 ( Directions aDir = `UNDEFINED` )
inline

Definition at line 87 of file direction45.h.

## ◆ DIRECTION_45() [2/4]

 DIRECTION_45::DIRECTION_45 ( const VECTOR2I & aVec, bool a90 = `false` )
inline
Parameters
 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.

## ◆ DIRECTION_45() [3/4]

 DIRECTION_45::DIRECTION_45 ( const SEG & aSeg, bool a90 = `false` )
inline
Parameters
 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.

## ◆ DIRECTION_45() [4/4]

 DIRECTION_45::DIRECTION_45 ( const SHAPE_ARC & aArc, bool a90 = `false` )
inline

Create a DIRECTION_45 from the endpoints of a given arc.

Parameters
 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.

## ◆ Angle()

 AngleType DIRECTION_45::Angle ( const DIRECTION_45 & aOther ) const
inline

Return the type of angle between directions (this) and aOther.

Parameters
 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.

## ◆ BuildInitialTrace()

 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.

Parameters
 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.
Returns
the trace

Definition at line 24 of file direction_45.cpp.

## ◆ construct_()

 void DIRECTION_45::construct_ ( const VECTOR2I & aVec )
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.

Parameters
 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().

## ◆ Format()

 const std::string DIRECTION_45::Format ( ) const
inline

Format the direction in a human readable word.

Returns
name of the direction

Definition at line 129 of file direction45.h.

References E, m_dir, N, NE, NW, S, SE, SW, UNDEFINED, and W.

## ◆ IsDefined()

 bool DIRECTION_45::IsDefined ( ) const
inline

Definition at line 218 of file direction45.h.

References m_dir, and UNDEFINED.

## ◆ IsDiagonal()

 bool DIRECTION_45::IsDiagonal ( ) const
inline

Returns true if the direction is diagonal (e.g.

North-West, South-East, etc).

Returns
true, when diagonal.

Definition at line 213 of file direction45.h.

References m_dir.

## ◆ IsObtuse()

 bool DIRECTION_45::IsObtuse ( const DIRECTION_45 & aOther ) const
inline
Returns
true, when (this) forms an obtuse angle with aOther.

Definition at line 203 of file direction45.h.

References ANG_OBTUSE, and Angle().

Referenced by PNS::OPTIMIZER::mergeDpStep(), and PNS::tightenSegment().

## ◆ Left()

 const DIRECTION_45 DIRECTION_45::Left ( ) const
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.

## ◆ operator!=()

 bool DIRECTION_45::operator!= ( const DIRECTION_45 & aOther ) const
inline

Definition at line 243 of file direction45.h.

References m_dir.

## ◆ operator==()

 bool DIRECTION_45::operator== ( const DIRECTION_45 & aOther ) const
inline

Definition at line 238 of file direction45.h.

References m_dir.

## ◆ Opposite()

 DIRECTION_45 DIRECTION_45::Opposite ( ) const
inline

Return a direction opposite (180 degree) to (this).

Returns
opposite direction

Definition at line 170 of file direction45.h.

References E, m_dir, N, NE, NW, S, SE, SW, UNDEFINED, and W.

## ◆ Right()

 const DIRECTION_45 DIRECTION_45::Right ( ) const
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.

## ◆ ToVector()

 const VECTOR2I DIRECTION_45::ToVector ( ) const
inline
Returns
a unit vector in world coordinate system corresponding to our direction.

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().

## ◆ m_90deg

 bool DIRECTION_45::m_90deg
private

Definition at line 349 of file direction45.h.

Referenced by Left(), and Right().

## ◆ m_dir

 Directions DIRECTION_45::m_dir
private

Are we routing on 45 or 90 degree increments.

Definition at line 346 of file direction45.h.

The documentation for this class was generated from the following files: