KiCad PCB EDA Suite
PNS Namespace Reference

Push and Shove diff pair dimensions (gap) settings dialog. More...

Classes

class  ALGO_BASE
 Base class for all P&S algorithms (shoving, walkaround, line placement, dragging, etc.). More...
 
class  ANGLE_CONSTRAINT_45
 
class  ARC
 
class  AREA_CONSTRAINT
 
class  COMPONENT_DRAGGER
 COMPONENT_DRAGGER. More...
 
struct  CONSTRAINT
 
class  COST_ESTIMATOR
 Calculate the cost of a given line, taking corner angles and total length into account. More...
 
class  DEBUG_DECORATOR
 
class  DIFF_PAIR
 DIFF_PAIR. More...
 
class  DIFF_PAIR_PLACER
 Single track placement algorithm. More...
 
class  DP_GATEWAY
 DP_GATEWAY. More...
 
class  DP_GATEWAYS
 DP_GATEWAYS. More...
 
class  DP_MEANDER_PLACER
 Differential Pair length-matching/meandering tool. More...
 
class  DP_PRIMITIVE_PAIR
 DP_PRIMITIVE_PAIR. More...
 
class  DRAG_ALGO
 DRAG_ALGO. More...
 
class  DRAGGER
 DRAGGER. More...
 
class  FIXED_TAIL
 
struct  HIT_VISITOR
 
class  INDEX
 INDEX. More...
 
class  ITEM
 Base class for PNS router board items. More...
 
class  ITEM_SET
 
class  JOINT
 Represents a 2D point on a given set of layers and belonging to a certain net, that links together a number of board items. More...
 
class  KEEP_TOPOLOGY_CONSTRAINT
 
class  LINE
 Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads, junctions between multiple traces or two traces different widths and combinations of these). More...
 
class  LINE_PLACER
 Single track placement algorithm. More...
 
class  LINK_HOLDER
 
class  LINKED_ITEM
 
class  LOGGER
 
class  MEANDER_PLACER
 Single track length matching/meandering tool. More...
 
class  MEANDER_PLACER_BASE
 Base class for Single trace & Differential pair meandering tools, as both of them share a lot of code. More...
 
class  MEANDER_SETTINGS
 Dimensions for the meandering algorithm. More...
 
class  MEANDER_SHAPE
 The geometry of a single meander. More...
 
class  MEANDER_SKEW_PLACER
 MEANDER_SKEW_PLACER. More...
 
class  MEANDERED_LINE
 Represent a set of meanders fitted over a single or two lines. More...
 
class  MOUSE_TRAIL_TRACER
 
class  NODE
 Keep the router "world" - i.e. More...
 
struct  OBSTACLE
 Hold an object colliding with another object, along with some useful data about the collision. More...
 
class  OBSTACLE_VISITOR
 
class  OPT_CONSTRAINT
 
class  OPTIMIZER
 Perform various optimizations of the lines being routed, attempting to make the lines shorter and less cornery. More...
 
class  PLACEMENT_ALGO
 PLACEMENT_ALGO. More...
 
class  PRESERVE_VERTEX_CONSTRAINT
 
class  RESTRICT_VERTEX_RANGE_CONSTRAINT
 
class  ROUTER
 
class  ROUTER_IFACE
 ROUTER. More...
 
class  ROUTING_SETTINGS
 Contain all persistent settings of the router, such as the mode, optimization effort, etc. More...
 
class  RULE_RESOLVER
 
class  SEGMENT
 
class  SHOVE
 SHOVE. More...
 
class  SIZES_SETTINGS
 
class  SOLID
 
class  TIME_LIMIT
 
class  TOOL_BASE
 
class  TOPOLOGY
 
class  VIA
 
struct  VIA_HANDLE
 
class  WALKAROUND
 

Enumerations

enum  LineMarker {
  MK_HEAD = ( 1 << 0 ), MK_VIOLATION = ( 1 << 3 ), MK_LOCKED = ( 1 << 4 ), MK_DP_COUPLED = ( 1 << 5 ),
  MK_HOLE = ( 1 << 6 )
}
 
enum  MEANDER_TYPE {
  MT_SINGLE, MT_START, MT_FINISH, MT_TURN,
  MT_CHECK_START, MT_CHECK_FINISH, MT_CORNER, MT_EMPTY
}
 Shapes of available meanders. More...
 
enum  MEANDER_STYLE { MEANDER_STYLE_ROUND = 1, MEANDER_STYLE_CHAMFER }
 
enum  CONSTRAINT_TYPE {
  CONSTRAINT_TYPE::CT_CLEARANCE = 1, CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP = 2, CONSTRAINT_TYPE::CT_LENGTH = 3, CONSTRAINT_TYPE::CT_WIDTH = 4,
  CONSTRAINT_TYPE::CT_VIA_DIAMETER = 5, CONSTRAINT_TYPE::CT_VIA_HOLE = 6, CONSTRAINT_TYPE::CT_HOLE_CLEARANCE = 7, CONSTRAINT_TYPE::CT_EDGE_CLEARANCE = 8,
  CONSTRAINT_TYPE::CT_HOLE_TO_HOLE = 9
}
 An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between two items. More...
 
enum  ROUTER_MODE {
  PNS_MODE_ROUTE_SINGLE = 1, PNS_MODE_ROUTE_DIFF_PAIR, PNS_MODE_TUNE_SINGLE, PNS_MODE_TUNE_DIFF_PAIR,
  PNS_MODE_TUNE_DIFF_PAIR_SKEW
}
 
enum  DRAG_MODE {
  DM_CORNER = 0x1, DM_SEGMENT = 0x2, DM_VIA = 0x4, DM_FREE_ANGLE = 0x8,
  DM_ARC = 0x10, DM_ANY = 0x17, DM_COMPONENT = 0x20
}
 
enum  PNS_MODE { RM_MarkObstacles = 0, RM_Shove, RM_Walkaround, RM_Smart }
 < Routing modes More...
 
enum  PNS_OPTIMIZATION_EFFORT { OE_LOW = 0, OE_MEDIUM = 1, OE_FULL = 2 }
 
enum  CORNER_MODE { CORNER_MODE::MITERED_90, CORNER_MODE::MITERED_45, CORNER_MODE::ROUNDED_90, CORNER_MODE::ROUNDED_45 }
 

Functions

static DIRECTION_45::AngleType angle (const VECTOR2I &a, const VECTOR2I &b)
 
static bool checkGap (const SHAPE_LINE_CHAIN &p, const SHAPE_LINE_CHAIN &n, int gap)
 
static VECTOR2I makeGapVector (VECTOR2I dir, int length)
 
bool commonParallelProjection (SEG p, SEG n, SEG &pClip, SEG &nClip)
 
OPT_VECTOR2I getDanglingAnchor (NODE *aNode, ITEM *aItem)
 
template<typename T , typename S >
std::unique_ptr< T > ItemCast (std::unique_ptr< S > aPtr)
 
template<typename T >
std::unique_ptr< typename std::remove_const< T >::type > Clone (const T &aItem)
 
bool operator== (JOINT::HASH_TAG const &aP1, JOINT::HASH_TAG const &aP2)
 
SHAPE_LINE_CHAIN dragCornerInternal (const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aP)
 
static void extendBox (BOX2I &aBox, bool &aDefined, const VECTOR2I &aP)
 
VECTOR2I closestProjectedPoint (const SHAPE_LINE_CHAIN &line, const VECTOR2I &p)
 
static bool pointInside2 (const SHAPE_LINE_CHAIN &aL, const VECTOR2I &aP)
 Determine if a point is located within a given polygon. More...
 
int findCoupledVertices (const VECTOR2I &aVertex, const SEG &aOrigSeg, const SHAPE_LINE_CHAIN &aCoupled, DIFF_PAIR *aPair, int *aIndices)
 
bool verifyDpBypass (NODE *aNode, DIFF_PAIR *aPair, bool aRefIsP, const SHAPE_LINE_CHAIN &aNewRef, const SHAPE_LINE_CHAIN &aNewCoupled)
 
bool coupledBypass (NODE *aNode, DIFF_PAIR *aPair, bool aRefIsP, const SHAPE_LINE_CHAIN &aRef, const SHAPE_LINE_CHAIN &aRefBypass, const SHAPE_LINE_CHAIN &aCoupled, SHAPE_LINE_CHAIN &aNewCoupled)
 
bool checkDpColliding (NODE *aNode, DIFF_PAIR *aPair, bool aIsP, const SHAPE_LINE_CHAIN &aPath)
 
static int64_t shovedArea (const SHAPE_LINE_CHAIN &aOld, const SHAPE_LINE_CHAIN &aNew)
 
bool tightenSegment (bool dir, NODE *aNode, const LINE &cur, const SHAPE_LINE_CHAIN &in, SHAPE_LINE_CHAIN &out)
 
void Tighten (NODE *aNode, const SHAPE_LINE_CHAIN &aOldLine, const LINE &aNewLine, LINE &aOptimized)
 
static VIAfindViaByHandle (NODE *aNode, const VIA_HANDLE &handle)
 
static const SHAPE_LINE_CHAIN buildHullForPrimitiveShape (const SHAPE *aShape, int aClearance, int aWalkaroundThickness)
 
const SHAPE_LINE_CHAIN OctagonalHull (const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
 
const SHAPE_LINE_CHAIN ArcHull (const SHAPE_ARC &aSeg, int aClearance, int aWalkaroundThickness)
 Various utility functions. More...
 
const SHAPE_LINE_CHAIN SegmentHull (const SHAPE_SEGMENT &aSeg, int aClearance, int aWalkaroundThickness)
 
static void MoveDiagonal (SEG &aDiagonal, const SHAPE_LINE_CHAIN &aVertices, int aClearance)
 
const SHAPE_LINE_CHAIN ConvexHull (const SHAPE_SIMPLE &aConvex, int aClearance)
 Function ConvexHull() More...
 
SHAPE_RECT ApproximateSegmentAsRect (const SHAPE_SEGMENT &aSeg)
 
OPT_BOX2I ChangedArea (const ITEM *aItemA, const ITEM *aItemB)
 
OPT_BOX2I ChangedArea (const LINE &aLineA, const LINE &aLineB)
 
bool clipToLoopStart (SHAPE_LINE_CHAIN &l)
 

Variables

static DEBUG_DECORATORg_dbg
 
static ROUTERtheRouter
 
const int pnsSchemaVersion = 0
 
constexpr int HULL_MARGIN = 10
 

Detailed Description

Push and Shove diff pair dimensions (gap) settings dialog.

Push and Shove router settings dialog.

Enumeration Type Documentation

◆ CONSTRAINT_TYPE

enum PNS::CONSTRAINT_TYPE
strong

An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between two items.

Enumerator
CT_CLEARANCE 
CT_DIFF_PAIR_GAP 
CT_LENGTH 
CT_WIDTH 
CT_VIA_DIAMETER 
CT_VIA_HOLE 
CT_HOLE_CLEARANCE 
CT_EDGE_CLEARANCE 
CT_HOLE_TO_HOLE 

Definition at line 54 of file pns_node.h.

◆ CORNER_MODE

enum PNS::CORNER_MODE
strong
Enumerator
MITERED_90 

H/V only (90-degree corners) (not yet implemented)

MITERED_45 

H/V/45 with mitered corners (default)

ROUNDED_90 

H/V with filleted corners (not yet implemented)

ROUNDED_45 

H/V/45 with filleted corners.

Definition at line 55 of file pns_routing_settings.h.

56 {
57  MITERED_90,
58  MITERED_45,
59  ROUNDED_90,
60  ROUNDED_45
61 };
H/V/45 with filleted corners.
H/V with filleted corners (not yet implemented)
H/V only (90-degree corners) (not yet implemented)
H/V/45 with mitered corners (default)

◆ DRAG_MODE

Enumerator
DM_CORNER 
DM_SEGMENT 
DM_VIA 
DM_FREE_ANGLE 
DM_ARC 
DM_ANY 
DM_COMPONENT 

Definition at line 70 of file pns_router.h.

71 {
72  DM_CORNER = 0x1,
73  DM_SEGMENT = 0x2,
74  DM_VIA = 0x4,
75  DM_FREE_ANGLE = 0x8,
76  DM_ARC = 0x10,
77  DM_ANY = 0x17,
78  DM_COMPONENT = 0x20
79 };

◆ LineMarker

Enumerator
MK_HEAD 
MK_VIOLATION 
MK_LOCKED 
MK_DP_COUPLED 
MK_HOLE 

Definition at line 40 of file pns_item.h.

40  {
41  MK_HEAD = ( 1 << 0 ),
42  MK_VIOLATION = ( 1 << 3 ),
43  MK_LOCKED = ( 1 << 4 ),
44  MK_DP_COUPLED = ( 1 << 5 ),
45  MK_HOLE = ( 1 << 6 )
46 };

◆ MEANDER_STYLE

Enumerator
MEANDER_STYLE_ROUND 
MEANDER_STYLE_CHAMFER 

Definition at line 49 of file pns_meander.h.

49  {
50  MEANDER_STYLE_ROUND = 1, // rounded (90 degree arc)
51  MEANDER_STYLE_CHAMFER // chamfered (45 degree segment)
52 };

◆ MEANDER_TYPE

Shapes of available meanders.

Enumerator
MT_SINGLE 
MT_START 
MT_FINISH 
MT_TURN 
MT_CHECK_START 
MT_CHECK_FINISH 
MT_CORNER 
MT_EMPTY 

Definition at line 37 of file pns_meander.h.

37  {
38  MT_SINGLE, // _|^|_, single-sided
39  MT_START, // _|^|
40  MT_FINISH, // |^|_
41  MT_TURN, // |^| or |_|
42  MT_CHECK_START, // try fitting a start type, but don't produce a line
43  MT_CHECK_FINISH, // try fitting a finish type, but don't produce a line
44  MT_CORNER, // line corner
45  MT_EMPTY // no meander (straight line)
46 };

◆ PNS_MODE

< Routing modes

Enumerator
RM_MarkObstacles 

Ignore collisions, mark obstacles.

RM_Shove 

Only shove.

RM_Walkaround 

Only walk around.

RM_Smart 

Guess what's better, try to make least mess on the PCB.

Definition at line 38 of file pns_routing_settings.h.

39 {
40  RM_MarkObstacles = 0,
41  RM_Shove,
43  RM_Smart
44 };
Guess what's better, try to make least mess on the PCB.
Ignore collisions, mark obstacles.
Only walk around.

◆ PNS_OPTIMIZATION_EFFORT

Enumerator
OE_LOW 
OE_MEDIUM 
OE_FULL 

Definition at line 47 of file pns_routing_settings.h.

◆ ROUTER_MODE

Enumerator
PNS_MODE_ROUTE_SINGLE 
PNS_MODE_ROUTE_DIFF_PAIR 
PNS_MODE_TUNE_SINGLE 
PNS_MODE_TUNE_DIFF_PAIR 
PNS_MODE_TUNE_DIFF_PAIR_SKEW 

Definition at line 62 of file pns_router.h.

Function Documentation

◆ angle()

static DIRECTION_45::AngleType PNS::angle ( const VECTOR2I a,
const VECTOR2I b 
)
static

Definition at line 168 of file pns_diff_pair.cpp.

169 {
170  DIRECTION_45 dir_a( a );
171  DIRECTION_45 dir_b( b );
172 
173  return dir_a.Angle( dir_b );
174 }
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36

References DIRECTION_45::Angle().

Referenced by DXF_IMPORT_PLUGIN::addArc(), EC_45DEGREE::Apply(), EC_CIRCLE::Apply(), HPGL_PLOTTER::Arc(), GEOM_TEST::ArePerpendicular(), BuildCornersList_S_Shape(), PNS::DP_GATEWAYS::BuildGeneric(), PNS::OPTIMIZER::circleBreakouts(), PCB_SHAPE::computeArcBBox(), ConvertOutlineToPolygon(), AM_PRIMITIVE::ConvertShapeToPolygon(), D_CODE::ConvertShapeToPolygon(), MICROWAVE_TOOL::createFootprint(), SCH_GLOBALLABEL::CreateGraphicShape(), PNS::OPTIMIZER::customBreakouts(), KIGFX::PCB_PAINTER::draw(), DRAWING_TOOL::DrawDimension(), ROUTER_PREVIEW_ITEM::drawLineChain(), AR_MATRIX::drawSegmentQcq(), ROUTER_PREVIEW_ITEM::drawShape(), GBR_TO_PCB_EXPORTER::export_non_copper_item(), DSN::SPECCTRA_DB::FromBOARD(), RENDER_3D_LEGACY::generateRing(), GetArcAngle(), FP_TEXT::GetBoundingBox(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetStartAngle(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetSubtended(), ARRAY_CIRCULAR_OPTIONS::GetTransform(), GRCSegm(), PNS::LINE_PLACER::handlePullback(), HelperShapeLineChainFromAltiumVertices(), idf_export_footprint(), DIALOG_PAD_PROPERTIES::initValues(), DXF_IMPORT_PLUGIN::insertArc(), PNS::LINE::Is45Degree(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), LEGACY_PLUGIN::loadFP_SHAPE(), LEGACY_PLUGIN::loadPCB_LINE(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadPolygon(), EAGLE_PLUGIN::loadSignals(), DSN::SPECCTRA_DB::makeIMAGE(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), SHAPE_LINE_CHAIN::Parse(), ALTIUM_PCB::ParseArcs6Data(), GPCB_FPL_CACHE::parseFOOTPRINT(), SCH_SEXPR_PARSER::parseSchSheetPin(), FABMASTER::processArc(), processComp(), processSolid(), AR_AUTOPLACER::rotateFootprint(), RotatePoint(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_SEXPR_PLUGIN::saveText(), PCB_SHAPE::SetArcGeometry(), FP_TEXT::SetDrawCoord(), PAD::SetDrawCoord(), FP_SHAPE::SetLocalCoord(), FP_TEXT::SetLocalCoord(), PNS::LINE_PLACER::Start(), AR_MATRIX::traceArc(), AR_MATRIX::traceCircle(), AR_MATRIX::TraceFilledRectangle(), TransformCircleToPolygon(), TransformOvalToPolygon(), TransformRoundRectToPolygon(), PAD::TransformShapeWithClearanceToPolygon(), and FP_TEXT::ViewBBox().

◆ ApproximateSegmentAsRect()

SHAPE_RECT PNS::ApproximateSegmentAsRect ( const SHAPE_SEGMENT aSeg)

Definition at line 225 of file pns_utils.cpp.

226 {
227  SHAPE_RECT r;
228 
229  VECTOR2I delta( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 );
230  VECTOR2I p0( aSeg.GetSeg().A - delta );
231  VECTOR2I p1( aSeg.GetSeg().B + delta );
232 
233  return SHAPE_RECT( std::min( p0.x, p1.x ), std::min( p0.y, p1.y ),
234  std::abs( p1.x - p0.x ), std::abs( p1.y - p0.y ) );
235 }
const SEG & GetSeg() const
VECTOR2I A
Definition: seg.h:49
int GetWidth() const
VECTOR2I B
Definition: seg.h:50

References SEG::A, SEG::B, SHAPE_SEGMENT::GetSeg(), and SHAPE_SEGMENT::GetWidth().

Referenced by PNS::OPTIMIZER::computeBreakouts().

◆ ArcHull()

const SHAPE_LINE_CHAIN PNS::ArcHull ( const SHAPE_ARC aSeg,
int  aClearance,
int  aWalkaroundThickness 
)

Various utility functions.

Definition at line 55 of file pns_utils.cpp.

57 {
58  int d = aSeg.GetWidth() / 2 + aClearance + aWalkaroundThickness / 2 + HULL_MARGIN;
59  int x = (int)( 2.0 / ( 1.0 + M_SQRT2 ) * d ) / 2;
60 
61  auto line = aSeg.ConvertToPolyline();
62 
64  s.SetClosed( true );
65  std::vector<VECTOR2I> reverse_line;
66 
67  auto seg = line.Segment( 0 );
68  VECTOR2I dir = seg.B - seg.A;
69  VECTOR2I p0 = dir.Perpendicular().Resize( d );
70  VECTOR2I ds = dir.Perpendicular().Resize( x );
71  VECTOR2I pd = dir.Resize( x );
72  VECTOR2I dp = dir.Resize( d );
73 
74  // Append the first curve
75  s.Append( seg.A + p0 - pd );
76  s.Append( seg.A - dp + ds );
77  s.Append( seg.A - dp - ds );
78  s.Append( seg.A - p0 - pd );
79 
80  for( int i = 1; i < line.SegmentCount(); i++ )
81  {
82  auto old_seg = seg;
83  auto endpt = ( old_seg.A - old_seg.B ).Resize( seg.Length() );
84  old_seg.A = old_seg.B + endpt;
85 
86  seg = line.Segment( i );
87  auto dir2 = old_seg.A - seg.B;
88 
89  p0 = dir2.Perpendicular().Resize( d );
90  s.Append( seg.A - p0 );
91  reverse_line.push_back( seg.A + p0 );
92  }
93 
94  pd = dir.Resize( x );
95  dp = dir.Resize( d );
96  s.Append( seg.B - p0 + pd );
97  s.Append( seg.B + dp - ds );
98  s.Append( seg.B + dp + ds );
99  s.Append( seg.B + p0 + pd );
100 
101  for( int i = reverse_line.size() - 1; i >= 0; i-- )
102  s.Append( reverse_line[i] );
103 
104  // make sure the hull outline is always clockwise
105  if( s.CSegment( 0 ).Side( line.Segment( 0 ).A ) < 0 )
106  return s.Reverse();
107  else
108  return s;
109 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:314
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
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.
Definition: shape_arc.cpp:408
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
int GetWidth() const
Definition: shape_arc.h:112
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
Definition: seg.h:143

References SHAPE_LINE_CHAIN::Append(), SHAPE_ARC::ConvertToPolyline(), SHAPE_LINE_CHAIN::CSegment(), SHAPE_ARC::GetWidth(), HULL_MARGIN, VECTOR2< T >::Perpendicular(), VECTOR2< T >::Resize(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::SetClosed(), and SEG::Side().

Referenced by buildHullForPrimitiveShape(), and PNS::ARC::Hull().

◆ buildHullForPrimitiveShape()

static const SHAPE_LINE_CHAIN PNS::buildHullForPrimitiveShape ( const SHAPE aShape,
int  aClearance,
int  aWalkaroundThickness 
)
static

Definition at line 37 of file pns_solid.cpp.

39 {
40  int cl = aClearance + ( aWalkaroundThickness + 1 )/ 2;
41 
42  switch( aShape->Type() )
43  {
44  case SH_RECT:
45  {
46  const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>( aShape );
47  return OctagonalHull( rect->GetPosition(),
48  rect->GetSize(),
49  cl + 1,
50  0.2 * cl );
51  }
52 
53  case SH_CIRCLE:
54  {
55  const SHAPE_CIRCLE* circle = static_cast<const SHAPE_CIRCLE*>( aShape );
56  int r = circle->GetRadius();
57  return OctagonalHull( circle->GetCenter() - VECTOR2I( r, r ),
58  VECTOR2I( 2 * r, 2 * r ),
59  cl + 1,
60  0.52 * ( r + cl ) );
61  }
62 
63  case SH_SEGMENT:
64  {
65  const SHAPE_SEGMENT* seg = static_cast<const SHAPE_SEGMENT*>( aShape );
66  return SegmentHull( *seg, aClearance, aWalkaroundThickness );
67  }
68 
69  case SH_ARC:
70  {
71  const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( aShape );
72  return ArcHull( *arc, aClearance, aWalkaroundThickness );
73  }
74 
75  case SH_SIMPLE:
76  {
77  const SHAPE_SIMPLE* convex = static_cast<const SHAPE_SIMPLE*>( aShape );
78 
79  return ConvexHull( *convex, cl );
80  }
81  default:
82  {
83  wxLogError( "Unsupported hull shape: %d (%s)", aShape->Type(),
84  SHAPE_TYPE_asString( aShape->Type() ) );
85  break;
86  }
87  }
88 
89  return SHAPE_LINE_CHAIN();
90 }
const SHAPE_LINE_CHAIN ConvexHull(const SHAPE_SIMPLE &aConvex, int aClearance)
Function ConvexHull()
Definition: pns_utils.cpp:169
SHAPE_SIMPLE.
Definition: shape_simple.h:43
int GetRadius() const
Definition: shape_circle.h:107
const VECTOR2I GetCenter() const
Definition: shape_circle.h:112
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
const SHAPE_LINE_CHAIN SegmentHull(const SHAPE_SEGMENT &aSeg, int aClearance, int aWalkaroundThickness)
Definition: pns_utils.cpp:112
const VECTOR2I GetSize() const
Definition: shape_rect.h:124
const VECTOR2I & GetPosition() const
Definition: shape_rect.h:116
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:55
circular arc
Definition: shape.h:50
const SHAPE_LINE_CHAIN OctagonalHull(const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
Definition: pns_utils.cpp:35
circle
Definition: shape.h:46
const SHAPE_LINE_CHAIN ArcHull(const SHAPE_ARC &aSeg, int aClearance, int aWalkaroundThickness)
Various utility functions.
Definition: pns_utils.cpp:55
SHAPE_LINE_CHAIN.
axis-aligned rectangle
Definition: shape.h:43
simple polygon
Definition: shape.h:47
SHAPE_TYPE Type() const
Return the type of the shape.
Definition: shape.h:94
line segment
Definition: shape.h:44

References ArcHull(), ConvexHull(), SHAPE_CIRCLE::GetCenter(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_RECT::GetSize(), OctagonalHull(), SegmentHull(), SH_ARC, SH_CIRCLE, SH_RECT, SH_SEGMENT, SH_SIMPLE, SHAPE_TYPE_asString(), and SHAPE_BASE::Type().

Referenced by PNS::SOLID::HoleHull(), and PNS::SOLID::Hull().

◆ ChangedArea() [1/2]

OPT_BOX2I PNS::ChangedArea ( const ITEM aItemA,
const ITEM aItemB 
)

Definition at line 299 of file pns_utils.cpp.

300 {
301  if( aItemA->OfKind( ITEM::VIA_T ) && aItemB->OfKind( ITEM::VIA_T ) )
302  {
303  const VIA* va = static_cast<const VIA*>( aItemA );
304  const VIA* vb = static_cast<const VIA*>( aItemB );
305 
306  return va->ChangedArea( vb );
307  }
308  else if( aItemA->OfKind( ITEM::LINE_T ) && aItemB->OfKind( ITEM::LINE_T ) )
309  {
310  const LINE* la = static_cast<const LINE*> ( aItemA );
311  const LINE* lb = static_cast<const LINE*> ( aItemB );
312 
313  return la->ChangedArea( lb );
314  }
315 
316  return OPT_BOX2I();
317 }
Definition: track.h:343
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:525

References PNS::VIA::ChangedArea(), PNS::LINE::ChangedArea(), PNS::ITEM::LINE_T, PNS::ITEM::OfKind(), and PNS::ITEM::VIA_T.

Referenced by PNS::SHOVE::replaceItems(), and PNS::SHOVE::replaceLine().

◆ ChangedArea() [2/2]

OPT_BOX2I PNS::ChangedArea ( const LINE aLineA,
const LINE aLineB 
)

Definition at line 319 of file pns_utils.cpp.

320 {
321  return aLineA.ChangedArea( &aLineB );
322 }

References PNS::LINE::ChangedArea().

◆ checkDpColliding()

bool PNS::checkDpColliding ( NODE aNode,
DIFF_PAIR aPair,
bool  aIsP,
const SHAPE_LINE_CHAIN aPath 
)

Definition at line 1215 of file pns_optimizer.cpp.

1216 {
1217  LINE tmp ( aIsP ? aPair->PLine() : aPair->NLine(), aPath );
1218 
1219  return static_cast<bool>( aNode->CheckColliding( &tmp ) );
1220 }

References PNS::NODE::CheckColliding(), PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

◆ checkGap()

static bool PNS::checkGap ( const SHAPE_LINE_CHAIN p,
const SHAPE_LINE_CHAIN n,
int  gap 
)
static

Definition at line 177 of file pns_diff_pair.cpp.

178 {
179  int i, j;
180 
181  for( i = 0; i < p.SegmentCount(); i++ )
182  {
183  for( j = 0; j < n.SegmentCount() ; j++ )
184  {
185  int dist = p.CSegment( i ).Distance( n.CSegment( j ) );
186 
187  if( dist < gap - 100 )
188  return false;
189  }
190  }
191 
192  return true;
193 }
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
Definition: seg.h:239
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()

References SHAPE_LINE_CHAIN::CSegment(), SEG::Distance(), and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by PNS::DIFF_PAIR::BuildInitial().

◆ clipToLoopStart()

bool PNS::clipToLoopStart ( SHAPE_LINE_CHAIN l)

Definition at line 151 of file pns_walkaround.cpp.

152 {
153  auto ip = l.SelfIntersecting();
154 
155  if(!ip)
156  return false;
157  else {
158  int pidx = l.Split( ip->p );
159  auto lead = l.Slice(0, pidx);
160  auto tail = l.Slice(pidx + 1, -1);
161 
162  int pidx2 = tail.Split( ip->p );
163 
164  auto dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
165  dbg->AddPoint( ip->p, 5 );
166 
167  l = lead;
168  l.Append( tail.Slice( 0, pidx2 ) );
169  //l = l.Slice(0, pidx);
170  return true;
171  }
172 
173 
174 }
int Split(const VECTOR2I &aP)
Function Split()
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
const OPT< INTERSECTION > SelfIntersecting() const
Function SelfIntersecting()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()

References PNS::DEBUG_DECORATOR::AddPoint(), SHAPE_LINE_CHAIN::Append(), PNS::ROUTER_IFACE::GetDebugDecorator(), PNS::ROUTER::GetInstance(), PNS::ROUTER::GetInterface(), SHAPE_LINE_CHAIN::SelfIntersecting(), SHAPE_LINE_CHAIN::Slice(), and SHAPE_LINE_CHAIN::Split().

Referenced by PNS::WALKAROUND::Route().

◆ Clone()

template<typename T >
std::unique_ptr< typename std::remove_const<T>::type > PNS::Clone ( const T &  aItem)

Definition at line 257 of file pns_item.h.

258 {
259  static_assert( std::is_base_of<ITEM, T>::value, "Need to be handed an ITEM!" );
260  return std::unique_ptr<typename std::remove_const<T>::type>( aItem.Clone() );
261 }

Referenced by PNS::DRAGGER::dragViaMarkObstacles(), PNS::DRAGGER::dragViaWalkaround(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::LINE_PLACER::FixRoute(), PNS::SHOVE::pushOrShoveVia(), DIALOG_PAD_PROPERTIES::redraw(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::LINE_PLACER::SplitAdjacentSegments().

◆ closestProjectedPoint()

VECTOR2I PNS::closestProjectedPoint ( const SHAPE_LINE_CHAIN line,
const VECTOR2I p 
)

Definition at line 406 of file pns_line_placer.cpp.

407 {
408  // Keep distances squared for performance
409  SEG::ecoord min_dist_sq = VECTOR2I::ECOORD_MAX;
410  VECTOR2I closest;
411 
412  for( int i = 0; i < line.SegmentCount(); i++ )
413  {
414  const SEG& s = line.CSegment( i );
415  VECTOR2I a = s.NearestPoint( p );
416  int d_sq = (a - p).SquaredEuclideanNorm();
417 
418  if( d_sq < min_dist_sq )
419  {
420  min_dist_sq = d_sq;
421  closest = a;
422  }
423  }
424 
425  return closest;
426 }
VECTOR2I::extended_type ecoord
Definition: seg.h:44
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:79
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition: seg.h:437
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:41
const SEG CSegment(int aIndex) const
Function CSegment()

References SHAPE_LINE_CHAIN::CSegment(), VECTOR2< T >::ECOORD_MAX, SEG::NearestPoint(), and SHAPE_LINE_CHAIN::SegmentCount().

Referenced by PNS::LINE_PLACER::rhWalkOnly().

◆ commonParallelProjection()

bool PNS::commonParallelProjection ( SEG  p,
SEG  n,
SEG pClip,
SEG nClip 
)

Definition at line 762 of file pns_diff_pair.cpp.

763 {
764  SEG n_proj_p( p.LineProject( n.A ), p.LineProject( n.B ) );
765 
766  int64_t t_a = 0;
767  int64_t t_b = p.TCoef( p.B );
768 
769  int64_t tproj_a = p.TCoef( n_proj_p.A );
770  int64_t tproj_b = p.TCoef( n_proj_p.B );
771 
772  if( t_b < t_a )
773  std::swap( t_b, t_a );
774 
775  if( tproj_b < tproj_a )
776  std::swap( tproj_b, tproj_a );
777 
778  if( t_b <= tproj_a )
779  return false;
780 
781  if( t_a >= tproj_b )
782  return false;
783 
784  int64_t t[4] = { 0, p.TCoef( p.B ), p.TCoef( n_proj_p.A ), p.TCoef( n_proj_p.B ) };
785  std::vector<int64_t> tv( t, t + 4 );
786  std::sort( tv.begin(), tv.end() ); // fixme: awful and disgusting way of finding 2 midpoints
787 
788  int64_t pLenSq = p.SquaredLength();
789 
790  VECTOR2I dp = p.B - p.A;
791  pClip.A.x = p.A.x + rescale( (int64_t)dp.x, tv[1], pLenSq );
792  pClip.A.y = p.A.y + rescale( (int64_t)dp.y, tv[1], pLenSq );
793 
794  pClip.B.x = p.A.x + rescale( (int64_t)dp.x, tv[2], pLenSq );
795  pClip.B.y = p.A.y + rescale( (int64_t)dp.y, tv[2], pLenSq );
796 
797  nClip.A = n.LineProject( pClip.A );
798  nClip.B = n.LineProject( pClip.B );
799 
800  return true;
801 }
ecoord SquaredLength() const
Definition: seg.h:360
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.h:404
ecoord TCoef(const VECTOR2I &aP) const
Definition: seg.h:431
Definition: seg.h:41
VECTOR2I A
Definition: seg.h:49
T rescale(T aNumerator, T aValue, T aDenominator)
Function rescale()
Definition: util.h:95
VECTOR2I B
Definition: seg.h:50

References SEG::A, SEG::B, SEG::LineProject(), rescale(), SEG::SquaredLength(), SEG::TCoef(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::DIFF_PAIR::CoupledLength(), PNS::DIFF_PAIR::CoupledSegmentPairs(), and extractDiffPair().

◆ ConvexHull()

const SHAPE_LINE_CHAIN PNS::ConvexHull ( const SHAPE_SIMPLE aConvex,
int  aClearance 
)

Function ConvexHull()

Creates an octagonal hull around a convex polygon.

Parameters
aConvexThe convex polygon.
aClearanceThe minimum distance between polygon and hull.
Returns
A closed line chain describing the octagon.

Definition at line 169 of file pns_utils.cpp.

170 {
171  // this defines the horizontal and vertical lines in the hull octagon
172  BOX2I box = aConvex.BBox( aClearance + HULL_MARGIN );
173  box.Normalize();
174 
175  SEG topline = SEG( VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ),
176  VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ) );
177  SEG rightline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ),
178  VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ) );
179  SEG bottomline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ),
180  box.GetOrigin() );
181  SEG leftline = SEG( box.GetOrigin(), VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ) );
182 
183  const SHAPE_LINE_CHAIN& vertices = aConvex.Vertices();
184 
185  // top right diagonal
186  VECTOR2I corner = box.GetOrigin() + box.GetSize();
187  SEG toprightline = SEG( corner,
188  corner + VECTOR2I( box.GetHeight(), -box.GetHeight() ) );
189  MoveDiagonal( toprightline, vertices, aClearance );
190 
191  // bottom right diagonal
192  corner = box.GetOrigin() + VECTOR2I( box.GetWidth(), 0 );
193  SEG bottomrightline = SEG( corner + VECTOR2I( box.GetHeight(), box.GetHeight() ),
194  corner );
195  MoveDiagonal( bottomrightline, vertices, aClearance );
196 
197  // bottom left diagonal
198  corner = box.GetOrigin();
199  SEG bottomleftline = SEG( corner,
200  corner + VECTOR2I( -box.GetHeight(), box.GetHeight() ) );
201  MoveDiagonal( bottomleftline, vertices, aClearance );
202 
203  // top left diagonal
204  corner = box.GetOrigin() + VECTOR2I( 0, box.GetHeight() );
205  SEG topleftline = SEG( corner + VECTOR2I( -box.GetHeight(), -box.GetHeight() ),
206  corner );
207  MoveDiagonal( topleftline, vertices, aClearance );
208 
209  SHAPE_LINE_CHAIN octagon;
210  octagon.SetClosed( true );
211 
212  octagon.Append( *leftline.IntersectLines( bottomleftline ) );
213  octagon.Append( *bottomline.IntersectLines( bottomleftline ) );
214  octagon.Append( *bottomline.IntersectLines( bottomrightline ) );
215  octagon.Append( *rightline.IntersectLines( bottomrightline ) );
216  octagon.Append( *rightline.IntersectLines( toprightline ) );
217  octagon.Append( *topline.IntersectLines( toprightline ) );
218  octagon.Append( *topline.IntersectLines( topleftline ) );
219  octagon.Append( *leftline.IntersectLines( topleftline ) );
220 
221  return octagon;
222 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
coord_type GetX() const
Definition: box2.h:190
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
Definition: seg.h:208
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition: shape_simple.h:82
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
static void MoveDiagonal(SEG &aDiagonal, const SHAPE_LINE_CHAIN &aVertices, int aClearance)
Definition: pns_utils.cpp:157
coord_type GetWidth() const
Definition: box2.h:197
BOX2< Vec > & Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: box2.h:129
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_simple.h:133
Definition: seg.h:41
coord_type GetY() const
Definition: box2.h:191
SHAPE_LINE_CHAIN.
coord_type GetHeight() const
Definition: box2.h:198
const Vec & GetSize() const
Definition: box2.h:189
const Vec & GetOrigin() const
Definition: box2.h:193

References SHAPE_LINE_CHAIN::Append(), SHAPE_SIMPLE::BBox(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetSize(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), HULL_MARGIN, SEG::IntersectLines(), MoveDiagonal(), BOX2< Vec >::Normalize(), SHAPE_LINE_CHAIN::SetClosed(), and SHAPE_SIMPLE::Vertices().

Referenced by buildHullForPrimitiveShape().

◆ coupledBypass()

bool PNS::coupledBypass ( NODE aNode,
DIFF_PAIR aPair,
bool  aRefIsP,
const SHAPE_LINE_CHAIN aRef,
const SHAPE_LINE_CHAIN aRefBypass,
const SHAPE_LINE_CHAIN aCoupled,
SHAPE_LINE_CHAIN aNewCoupled 
)

Definition at line 1158 of file pns_optimizer.cpp.

1161 {
1162  int vStartIdx[1024]; // fixme: possible overflow
1163  int nStarts = findCoupledVertices( aRefBypass.CPoint( 0 ),
1164  aRefBypass.CSegment( 0 ),
1165  aCoupled, aPair, vStartIdx );
1166  DIRECTION_45 dir( aRefBypass.CSegment( 0 ) );
1167 
1168  int64_t bestLength = -1;
1169  bool found = false;
1170  SHAPE_LINE_CHAIN bestBypass;
1171  int si, ei;
1172 
1173  for( int i=0; i< nStarts; i++ )
1174  {
1175  for( int j = 1; j < aCoupled.PointCount() - 1; j++ )
1176  {
1177  int delta = std::abs ( vStartIdx[i] - j );
1178 
1179  if( delta > 1 )
1180  {
1181  const VECTOR2I& vs = aCoupled.CPoint( vStartIdx[i] );
1182  SHAPE_LINE_CHAIN bypass = dir.BuildInitialTrace( vs, aCoupled.CPoint(j),
1183  dir.IsDiagonal() );
1184 
1185  int64_t coupledLength = aPair->CoupledLength( aRef, bypass );
1186 
1187  SHAPE_LINE_CHAIN newCoupled = aCoupled;
1188 
1189  si = vStartIdx[i];
1190  ei = j;
1191 
1192  if(si < ei)
1193  newCoupled.Replace( si, ei, bypass );
1194  else
1195  newCoupled.Replace( ei, si, bypass.Reverse() );
1196 
1197  if( coupledLength > bestLength && verifyDpBypass( aNode, aPair, aRefIsP, aRef,
1198  newCoupled) )
1199  {
1200  bestBypass = newCoupled;
1201  bestLength = coupledLength;
1202  found = true;
1203  }
1204  }
1205  }
1206  }
1207 
1208  if( found )
1209  aNewCoupled = bestBypass;
1210 
1211  return found;
1212 }
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
int findCoupledVertices(const VECTOR2I &aVertex, const SEG &aOrigSeg, const SHAPE_LINE_CHAIN &aCoupled, DIFF_PAIR *aPair, int *aIndices)
bool verifyDpBypass(NODE *aNode, DIFF_PAIR *aPair, bool aRefIsP, const SHAPE_LINE_CHAIN &aNewRef, const SHAPE_LINE_CHAIN &aNewCoupled)
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Function Replace()

References SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::CSegment(), findCoupledVertices(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Replace(), SHAPE_LINE_CHAIN::Reverse(), and verifyDpBypass().

Referenced by PNS::OPTIMIZER::mergeDpStep().

◆ dragCornerInternal()

SHAPE_LINE_CHAIN PNS::dragCornerInternal ( const SHAPE_LINE_CHAIN aOrigin,
const VECTOR2I aP 
)

Definition at line 483 of file pns_line.cpp.

484 {
485  OPT<SHAPE_LINE_CHAIN> picked;
486  int i;
487  int d = 2;
488 
489  wxASSERT( aOrigin.PointCount() > 0 );
490 
491  if( aOrigin.PointCount() == 1 )
492  {
493  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP );
494  }
495  else if( aOrigin.SegmentCount() == 1 )
496  {
497  DIRECTION_45 dir( aOrigin.CPoint( 0 ) - aOrigin.CPoint( 1 ) );
498 
499  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
500  }
501 
502  if( aOrigin.CSegment( -1 ).Length() > 100000 * 30 ) // fixme: constant/parameter?
503  d = 1;
504 
505  for( i = aOrigin.SegmentCount() - d; i >= 0; i-- )
506  {
507  DIRECTION_45 d_start( aOrigin.CSegment( i ) );
508  VECTOR2I p_start = aOrigin.CPoint( i );
509  SHAPE_LINE_CHAIN paths[2];
510  DIRECTION_45 dirs[2];
511  DIRECTION_45 d_prev = ( i > 0 ? DIRECTION_45( aOrigin.CSegment( i-1 ) ) : DIRECTION_45() );
512  int dirCount = 0;
513 
514  for( int j = 0; j < 2; j++ )
515  {
516  paths[j] = d_start.BuildInitialTrace( p_start, aP, j );
517 
518  if( paths[j].SegmentCount() < 1 )
519  continue;
520 
521  assert( dirCount < int( sizeof( dirs ) / sizeof( dirs[0] ) ) );
522 
523  dirs[dirCount] = DIRECTION_45( paths[j].CSegment( 0 ) );
524  ++dirCount;
525  }
526 
527  for( int j = 0; j < dirCount; j++ )
528  {
529  if( dirs[j] == d_start )
530  {
531  picked = paths[j];
532  break;
533  }
534  }
535 
536  if( picked )
537  break;
538 
539  for( int j = 0; j < dirCount; j++ )
540  {
541  if( dirs[j].IsObtuse( d_prev ) )
542  {
543  picked = paths[j];
544  break;
545  }
546  }
547 
548  if( picked )
549  break;
550  }
551 
552  if( picked )
553  {
554  SHAPE_LINE_CHAIN path = aOrigin.Slice( 0, i );
555  path.Append( *picked );
556 
557  return path;
558  }
559 
560  DIRECTION_45 dir( aOrigin.CPoint( -1 ) - aOrigin.CPoint( -2 ) );
561 
562  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
563 }
int Length() const
Return the length (this).
Definition: seg.h:355
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, bool aFillet=false) const
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
boost::optional< T > OPT
Definition: optional.h:7

References DIRECTION_45::BuildInitialTrace(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::CSegment(), SEG::Length(), path, SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::SegmentCount(), and SHAPE_LINE_CHAIN::Slice().

Referenced by PNS::LINE::dragCorner45().

◆ extendBox()

static void PNS::extendBox ( BOX2I aBox,
bool &  aDefined,
const VECTOR2I aP 
)
static

Definition at line 1037 of file pns_line.cpp.

1038 {
1039  if( aDefined )
1040  {
1041  aBox.Merge( aP );
1042  }
1043  else
1044  {
1045  aBox = BOX2I( aP, VECTOR2I( 0, 0 ) );
1046  aDefined = true;
1047  }
1048 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:386

References BOX2< Vec >::Merge().

Referenced by PNS::LINE::ChangedArea().

◆ findCoupledVertices()

int PNS::findCoupledVertices ( const VECTOR2I aVertex,
const SEG aOrigSeg,
const SHAPE_LINE_CHAIN aCoupled,
DIFF_PAIR aPair,
int *  aIndices 
)

Definition at line 1113 of file pns_optimizer.cpp.

1115 {
1116  int count = 0;
1117 
1118  for ( int i = 0; i < aCoupled.SegmentCount(); i++ )
1119  {
1120  SEG s = aCoupled.CSegment( i );
1121  VECTOR2I projOverCoupled = s.LineProject ( aVertex );
1122 
1123  if( s.ApproxParallel( aOrigSeg ) )
1124  {
1125  int64_t dist = int64_t{(( projOverCoupled - aVertex ).EuclideanNorm())} - aPair->Width();
1126 
1127  if( aPair->GapConstraint().Matches( dist ) )
1128  {
1129  *aIndices++ = i;
1130  count++;
1131  }
1132  }
1133  }
1134 
1135  return count;
1136 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.h:404
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:295
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:41
const SEG CSegment(int aIndex) const
Function CSegment()

References SEG::ApproxParallel(), SHAPE_LINE_CHAIN::CSegment(), EuclideanNorm(), PNS::DIFF_PAIR::GapConstraint(), SEG::LineProject(), RANGED_NUM< T >::Matches(), SHAPE_LINE_CHAIN::SegmentCount(), and PNS::DIFF_PAIR::Width().

Referenced by coupledBypass().

◆ findViaByHandle()

static VIA* PNS::findViaByHandle ( NODE aNode,
const VIA_HANDLE handle 
)
static

Definition at line 1493 of file pns_shove.cpp.

1494 {
1495  JOINT* jt = aNode->FindJoint( handle.pos, handle.layers.Start(), handle.net );
1496 
1497  if( !jt )
1498  return nullptr;
1499 
1500  for( ITEM* item : jt->LinkList() )
1501  {
1502  if( item->OfKind( ITEM::VIA_T ) )
1503  {
1504  if( item->Net() == handle.net && item->Layers().Overlaps(handle.layers) )
1505  return static_cast<VIA*>( item );
1506  }
1507  }
1508 
1509  return nullptr;
1510 }

References PNS::NODE::FindJoint(), PNS::VIA_HANDLE::layers, PNS::JOINT::LinkList(), PNS::VIA_HANDLE::net, PNS::VIA_HANDLE::pos, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

Referenced by PNS::SHOVE::ShoveDraggingVia().

◆ getDanglingAnchor()

OPT_VECTOR2I PNS::getDanglingAnchor ( NODE aNode,
ITEM aItem 
)

Definition at line 401 of file pns_diff_pair_placer.cpp.

402 {
403  switch( aItem->Kind() )
404  {
405  case ITEM::VIA_T:
406  case ITEM::SOLID_T:
407  return aItem->Anchor( 0 );
408 
409  case ITEM::ARC_T:
410  case ITEM::SEGMENT_T:
411  {
412  SEGMENT* s = static_cast<SEGMENT*>( aItem );
413 
414  JOINT* jA = aNode->FindJoint( aItem->Anchor( 0 ), aItem );
415  JOINT* jB = aNode->FindJoint( aItem->Anchor( 1 ), aItem );
416 
417  if( jA && jA->LinkCount() == 1 )
418  return s->Seg().A;
419  else if( jB && jB->LinkCount() == 1 )
420  return s->Seg().B;
421  else
422  return OPT_VECTOR2I();
423  }
424 
425  default:
426  return OPT_VECTOR2I();
427  }
428 }
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39

References SEG::A, PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, SEG::B, PNS::NODE::FindJoint(), PNS::ITEM::Kind(), PNS::JOINT::LinkCount(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS::DIFF_PAIR_PLACER::FindDpPrimitivePair().

◆ ItemCast()

template<typename T , typename S >
std::unique_ptr<T> PNS::ItemCast ( std::unique_ptr< S >  aPtr)

Definition at line 249 of file pns_item.h.

250 {
251  static_assert( std::is_base_of<ITEM, S>::value, "Need to be handed a ITEM!" );
252  static_assert( std::is_base_of<ITEM, T>::value, "Need to cast to an ITEM!" );
253  return std::unique_ptr<T>( static_cast<T*>( aPtr.release() ) );
254 }

◆ makeGapVector()

static VECTOR2I PNS::makeGapVector ( VECTOR2I  dir,
int  length 
)
static

Definition at line 399 of file pns_diff_pair.cpp.

400 {
401  int l = length / 2;
402  VECTOR2I rv;
403 
404  if( dir.EuclideanNorm() == 0 )
405  return dir;
406 
407  do
408  {
409  rv = dir.Resize( l );
410  l++;
411  } while( ( rv * 2 ).EuclideanNorm() < length );
412 
413  return rv;
414 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293

References VECTOR2< T >::EuclideanNorm(), EuclideanNorm(), and VECTOR2< T >::Resize().

Referenced by PNS::DP_GATEWAYS::buildDpContinuation(), PNS::DP_GATEWAYS::BuildForCursor(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), and PNS::DP_GATEWAYS::BuildGeneric().

◆ MoveDiagonal()

static void PNS::MoveDiagonal ( SEG aDiagonal,
const SHAPE_LINE_CHAIN aVertices,
int  aClearance 
)
static

Definition at line 157 of file pns_utils.cpp.

158 {
159  int dist;
160 
161  aVertices.NearestPoint( aDiagonal, dist );
162  dist -= HULL_MARGIN;
163  VECTOR2I moveBy = ( aDiagonal.A - aDiagonal.B ).Perpendicular().Resize( dist - aClearance );
164  aDiagonal.A += moveBy;
165  aDiagonal.B += moveBy;
166 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Finds a point on the line chain that is closest to point aP.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

References SEG::A, SEG::B, HULL_MARGIN, SHAPE_LINE_CHAIN::NearestPoint(), and VECTOR2< T >::Resize().

Referenced by ConvexHull().

◆ OctagonalHull()

const SHAPE_LINE_CHAIN PNS::OctagonalHull ( const VECTOR2I aP0,
const VECTOR2I aSize,
int  aClearance,
int  aChamfer 
)

Definition at line 35 of file pns_utils.cpp.

37 {
39 
40  s.SetClosed( true );
41 
42  s.Append( aP0.x - aClearance, aP0.y - aClearance + aChamfer );
43  s.Append( aP0.x - aClearance + aChamfer, aP0.y - aClearance );
44  s.Append( aP0.x + aSize.x + aClearance - aChamfer, aP0.y - aClearance );
45  s.Append( aP0.x + aSize.x + aClearance, aP0.y - aClearance + aChamfer );
46  s.Append( aP0.x + aSize.x + aClearance, aP0.y + aSize.y + aClearance - aChamfer );
47  s.Append( aP0.x + aSize.x + aClearance - aChamfer, aP0.y + aSize.y + aClearance );
48  s.Append( aP0.x - aClearance + aChamfer, aP0.y + aSize.y + aClearance );
49  s.Append( aP0.x - aClearance, aP0.y + aSize.y + aClearance - aChamfer );
50 
51  return s;
52 }
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
SHAPE_LINE_CHAIN.

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by buildHullForPrimitiveShape(), PNS::VIA::Hull(), and SegmentHull().

◆ operator==()

bool PNS::operator== ( JOINT::HASH_TAG const &  aP1,
JOINT::HASH_TAG const &  aP2 
)
inline

Definition at line 265 of file pns_joint.h.

266 {
267  return aP1.pos == aP2.pos && aP1.net == aP2.net;
268 }

References PNS::JOINT::HASH_TAG::net, and PNS::JOINT::HASH_TAG::pos.

◆ pointInside2()

static bool PNS::pointInside2 ( const SHAPE_LINE_CHAIN aL,
const VECTOR2I aP 
)
static

Determine if a point is located within a given polygon.

Todo:
fixme: integrate into SHAPE_LINE_CHAIN, check corner cases against current PointInside implementation
Parameters
aLPolygon
aPPoint to check for location within the polygon
Returns
false if point is not polygon boundary aL, true if within or on the polygon boundary

Definition at line 286 of file pns_optimizer.cpp.

287 {
288  if( !aL.IsClosed() || aL.SegmentCount() < 3 )
289  return false;
290 
291  int result = 0;
292  size_t cnt = aL.PointCount();
293 
294  VECTOR2I ip = aL.CPoint( 0 );
295 
296  for( size_t i = 1; i <= cnt; ++i )
297  {
298  VECTOR2I ipNext = (i == cnt ? aL.CPoint( 0 ) : aL.CPoint( i ));
299 
300  if( ipNext.y == aP.y )
301  {
302  if( (ipNext.x ==aP.x) || ( ip.y == aP.y && ( (ipNext.x >aP.x) == (ip.x <aP.x) ) ) )
303  return true; // pt on polyground boundary
304  }
305 
306  if( (ip.y <aP.y) != (ipNext.y <aP.y) )
307  {
308  if( ip.x >=aP.x )
309  {
310  if( ipNext.x >aP.x )
311  result = 1 - result;
312  else
313  {
314  double d = static_cast<double>( ip.x - aP.x ) *
315  static_cast<double>( ipNext.y - aP.y ) -
316  static_cast<double>( ipNext.x - aP.x ) *
317  static_cast<double>( ip.y - aP.y );
318 
319  if( !d )
320  return true; // pt on polyground boundary
321 
322  if( (d > 0) == (ipNext.y > ip.y) )
323  result = 1 - result;
324  }
325  }
326  else
327  {
328  if( ipNext.x >aP.x )
329  {
330  double d = ((double)ip.x -aP.x) * ((double)ipNext.y -aP.y) -
331  ((double)ipNext.x -aP.x) * ((double)ip.y -aP.y);
332 
333  if( !d )
334  return true; // pt on polyground boundary
335 
336  if( (d > 0) == (ipNext.y > ip.y) )
337  result = 1 - result;
338  }
339  }
340  }
341 
342  ip = ipNext;
343  }
344 
345  return result > 0;
346 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool IsClosed() const override
Function IsClosed()
int SegmentCount() const
Function SegmentCount()

References SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::IsClosed(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::SegmentCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS::KEEP_TOPOLOGY_CONSTRAINT::Check().

◆ SegmentHull()

const SHAPE_LINE_CHAIN PNS::SegmentHull ( const SHAPE_SEGMENT aSeg,
int  aClearance,
int  aWalkaroundThickness 
)

Definition at line 112 of file pns_utils.cpp.

114 {
115  int cl = aClearance + aWalkaroundThickness / 2 + HULL_MARGIN;
116  int d = aSeg.GetWidth() / 2 + cl;
117  int x = (int)( 2.0 / ( 1.0 + M_SQRT2 ) * d );
118 
119  const VECTOR2I a = aSeg.GetSeg().A;
120  const VECTOR2I b = aSeg.GetSeg().B;
121 
122  if( a == b )
123  {
124  return OctagonalHull( a - VECTOR2I( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 ),
125  VECTOR2I( aSeg.GetWidth(), aSeg.GetWidth() ),
126  cl + 1,
127  0.52 * d );
128  }
129 
130  VECTOR2I dir = b - a;
131  VECTOR2I p0 = dir.Perpendicular().Resize( d );
132  VECTOR2I ds = dir.Perpendicular().Resize( x / 2 );
133  VECTOR2I pd = dir.Resize( x / 2 );
134  VECTOR2I dp = dir.Resize( d );
135 
137 
138  s.SetClosed( true );
139 
140  s.Append( b + p0 + pd );
141  s.Append( b + dp + ds );
142  s.Append( b + dp - ds );
143  s.Append( b - p0 + pd );
144  s.Append( a - p0 - pd );
145  s.Append( a - dp - ds );
146  s.Append( a - dp + ds );
147  s.Append( a + p0 - pd );
148 
149  // make sure the hull outline is always clockwise
150  if( s.CSegment( 0 ).Side( a ) < 0 )
151  return s.Reverse();
152  else
153  return s;
154 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:314
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
const SEG & GetSeg() const
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
const SHAPE_LINE_CHAIN OctagonalHull(const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
Definition: pns_utils.cpp:35
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:49
int GetWidth() const
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
Definition: seg.h:143
VECTOR2I B
Definition: seg.h:50

References SEG::A, SHAPE_LINE_CHAIN::Append(), SEG::B, SHAPE_LINE_CHAIN::CSegment(), SHAPE_SEGMENT::GetSeg(), SHAPE_SEGMENT::GetWidth(), HULL_MARGIN, OctagonalHull(), VECTOR2< T >::Perpendicular(), VECTOR2< T >::Resize(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::SetClosed(), and SEG::Side().

Referenced by buildHullForPrimitiveShape(), and PNS::SEGMENT::Hull().

◆ shovedArea()

static int64_t PNS::shovedArea ( const SHAPE_LINE_CHAIN aOld,
const SHAPE_LINE_CHAIN aNew 
)
static

Definition at line 1333 of file pns_optimizer.cpp.

1334 {
1335  int64_t area = 0;
1336  const int oc = aOld.PointCount();
1337  const int nc = aNew.PointCount();
1338  const int total = oc + nc;
1339 
1340  for(int i = 0; i < total; i++)
1341  {
1342  int i_next = (i + 1 == total ? 0 : i + 1);
1343 
1344  const VECTOR2I &v0 = i < oc ? aOld.CPoint(i)
1345  : aNew.CPoint( nc - 1 - (i - oc) );
1346  const VECTOR2I &v1 = i_next < oc ? aOld.CPoint ( i_next )
1347  : aNew.CPoint( nc - 1 - (i_next - oc) );
1348  area += -(int64_t) v0.y * v1.x + (int64_t) v0.x * v1.y;
1349  }
1350 
1351  return std::abs( area / 2 );
1352 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()

References SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Tighten().

◆ Tighten()

void PNS::Tighten ( NODE aNode,
const SHAPE_LINE_CHAIN aOldLine,
const LINE aNewLine,
LINE aOptimized 
)

Definition at line 1455 of file pns_optimizer.cpp.

1457 {
1458  LINE tmp;
1459 
1460  if( aNewLine.SegmentCount() < 3 )
1461  return;
1462 
1463  SHAPE_LINE_CHAIN current ( aNewLine.CLine() );
1464 
1465  for( int step = 0; step < 3; step++ )
1466  {
1467  current.Simplify();
1468 
1469  for( int i = 0; i <= current.SegmentCount() - 3; i++)
1470  {
1471  SHAPE_LINE_CHAIN l_in, l_out;
1472 
1473  l_in = current.Slice( i, i + 3 );
1474 
1475  for( int dir = 0; dir <= 1; dir++ )
1476  {
1477  if( tightenSegment( dir ? true : false, aNode, aNewLine, l_in, l_out ) )
1478  {
1479  SHAPE_LINE_CHAIN opt = current;
1480  opt.Replace(i, i + 3, l_out);
1481  auto optArea = std::abs( shovedArea( aOldLine, opt ) );
1482  auto prevArea = std::abs( shovedArea( aOldLine, current ) );
1483 
1484  if( optArea < prevArea )
1485  current = opt;
1486 
1487  break;
1488  }
1489  }
1490  }
1491  }
1492 
1493  aOptimized = LINE(aNewLine, current);
1494 
1495  //auto dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
1496  //dbg->AddLine ( current, 4, 100000 );
1497 }
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
static int64_t shovedArea(const SHAPE_LINE_CHAIN &aOld, const SHAPE_LINE_CHAIN &aNew)
bool tightenSegment(bool dir, NODE *aNode, const LINE &cur, const SHAPE_LINE_CHAIN &in, SHAPE_LINE_CHAIN &out)
SHAPE_LINE_CHAIN.
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Function Replace()

References PNS::LINE::CLine(), SHAPE_LINE_CHAIN::Replace(), PNS::LINE::SegmentCount(), shovedArea(), SHAPE_LINE_CHAIN::Simplify(), SHAPE_LINE_CHAIN::Slice(), and tightenSegment().

◆ tightenSegment()

bool PNS::tightenSegment ( bool  dir,
NODE aNode,
const LINE cur,
const SHAPE_LINE_CHAIN in,
SHAPE_LINE_CHAIN out 
)

Definition at line 1355 of file pns_optimizer.cpp.

1357 {
1358  SEG a = in.CSegment(0);
1359  SEG center = in.CSegment(1);
1360  SEG b = in.CSegment(2);
1361 
1362  DIRECTION_45 dirA ( a );
1363  DIRECTION_45 dirCenter ( center );
1364  DIRECTION_45 dirB ( b );
1365 
1366  if (!dirA.IsObtuse( dirCenter) || !dirCenter.IsObtuse(dirB))
1367  return false;
1368 
1369  //VECTOR2I perp = (center.B - center.A).Perpendicular();
1370  VECTOR2I guideA, guideB ;
1371 
1372  SEG guide;
1373  int initial;
1374 
1375  //auto dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
1376  if ( dirA.Angle ( dirB ) != DIRECTION_45::ANG_RIGHT )
1377  return false;
1378 
1379  {
1380  /*
1381  auto rC = *a.IntersectLines( b );
1382  dbg->AddSegment ( SEG( center.A, rC ), 1 );
1383  dbg->AddSegment ( SEG( center.B, rC ), 2 );
1384  auto perp = dirCenter.Left().Left();
1385 
1386  SEG sperp ( center.A, center.A + perp.ToVector() );
1387 
1388  auto vpc = sperp.LineProject( rC );
1389  auto vpa = sperp.LineProject( a.A );
1390  auto vpb = sperp.LineProject( b.B );
1391 
1392  auto da = (vpc - vpa).EuclideanNorm();
1393  auto db = (vpc - vpb).EuclideanNorm();
1394 
1395  auto vp = (da < db) ? vpa : vpb;
1396  dbg->AddSegment ( SEG( vpc, vp ), 5 );
1397 
1398 
1399  guide = SEG ( vpc, vp );
1400  */
1401  }
1402 
1403  int da = a.Length();
1404  int db = b.Length();
1405 
1406  if( da < db )
1407  guide = a;
1408  else
1409  guide = b;
1410 
1411  initial = guide.Length();
1412 
1413  int step = initial;
1414  int current = step;
1415  SHAPE_LINE_CHAIN snew;
1416 
1417  while( step > 1 )
1418  {
1419  LINE l( cur );
1420 
1421  snew.Clear();
1422  snew.Append( a.A );
1423  snew.Append( a.B + (a.A - a.B).Resize( current ) );
1424  snew.Append( b.A + (b.B - b.A).Resize( current ) );
1425  snew.Append( b.B );
1426 
1427  step /= 2;
1428 
1429  l.SetShape(snew);
1430 
1431  if( aNode->CheckColliding(&l) )
1432  current -= step;
1433  else if ( current + step >= initial )
1434  current = initial;
1435  else
1436  current += step;
1437 
1438  //dbg->AddSegment ( SEG( center.A , a.LineProject( center.A + gr ) ), 3 );
1439  //dbg->AddSegment ( SEG( center.A , center.A + guideA ), 3 );
1440  //dbg->AddSegment ( SEG( center.B , center.B + guideB ), 4 );
1441 
1442  if ( current == initial )
1443  break;
1444 
1445 
1446  }
1447 
1448  out = snew;
1449 
1450  //dbg->AddLine ( snew, 3, 100000 );
1451 
1452  return true;
1453 }
int Length() const
Return the length (this).
Definition: seg.h:355
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
Definition: seg.h:41
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404
const SEG CSegment(int aIndex) const
Function CSegment()
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:49
void Clear()
Function Clear() Removes all points from the line chain.
VECTOR2I B
Definition: seg.h:50

References SEG::A, DIRECTION_45::ANG_RIGHT, DIRECTION_45::Angle(), SHAPE_LINE_CHAIN::Append(), SEG::B, PNS::NODE::CheckColliding(), SHAPE_LINE_CHAIN::Clear(), SHAPE_LINE_CHAIN::CSegment(), DIRECTION_45::IsObtuse(), SEG::Length(), VECTOR2< T >::Resize(), and PNS::LINE::SetShape().

Referenced by Tighten().

◆ verifyDpBypass()

bool PNS::verifyDpBypass ( NODE aNode,
DIFF_PAIR aPair,
bool  aRefIsP,
const SHAPE_LINE_CHAIN aNewRef,
const SHAPE_LINE_CHAIN aNewCoupled 
)

Definition at line 1139 of file pns_optimizer.cpp.

1141 {
1142  LINE refLine ( aRefIsP ? aPair->PLine() : aPair->NLine(), aNewRef );
1143  LINE coupledLine ( aRefIsP ? aPair->NLine() : aPair->PLine(), aNewCoupled );
1144 
1145  if( refLine.Collide( &coupledLine, aNode ) )
1146  return false;
1147 
1148  if( aNode->CheckColliding ( &refLine ) )
1149  return false;
1150 
1151  if( aNode->CheckColliding ( &coupledLine ) )
1152  return false;
1153 
1154  return true;
1155 }

References PNS::NODE::CheckColliding(), PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

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

Variable Documentation

◆ g_dbg

DEBUG_DECORATOR* PNS::g_dbg
static

Definition at line 43 of file pns_optimizer.cpp.

Referenced by PNS::OPTIMIZER::Optimize().

◆ HULL_MARGIN

constexpr int PNS::HULL_MARGIN = 10

Definition at line 34 of file pns_utils.h.

Referenced by ArcHull(), ConvexHull(), MoveDiagonal(), and SegmentHull().

◆ pnsSchemaVersion

const int PNS::pnsSchemaVersion = 0

Definition at line 29 of file pns_routing_settings.cpp.

◆ theRouter