KiCad PCB EDA Suite
PNS Namespace Reference

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

Classes

class  ALGO_BASE
 Class ALGO_BASE. More...
 
class  COST_ESTIMATOR
 Class COST_ESTIMATOR. More...
 
class  DEBUG_DECORATOR
 
class  DIFF_PAIR
 Class DIFF_PAIR. More...
 
class  DIFF_PAIR_PLACER
 Class LINE_PLACER. More...
 
class  DP_GATEWAY
 Class DP_GATEWAY. More...
 
class  DP_GATEWAYS
 Class DP_GATEWAYS. More...
 
class  DP_MEANDER_PLACER
 Class DP_MEANDER_PLACER. More...
 
class  DP_PRIMITIVE_PAIR
 Class DP_PRIMITIVE_PAIR. More...
 
class  DRAGGER
 Class DRAGGER. More...
 
struct  HIT_VISITOR
 
class  INDEX
 Class INDEX. More...
 
class  ITEM
 Class ITEM. More...
 
class  ITEM_SET
 
class  JOINT
 Class JOINT. More...
 
class  LINE
 
class  LINE_PLACER
 Class LINE_PLACER. More...
 
class  LINE_RESTRICTIONS
 
class  LOGGER
 
class  MEANDER_PLACER
 Class MEANDER_PLACER. More...
 
class  MEANDER_PLACER_BASE
 Class MEANDER_PLACER_BASE. More...
 
class  MEANDER_SETTINGS
 Class MEANDER_SETTINGS. More...
 
class  MEANDER_SHAPE
 Class MEANDER_SETTINGS. More...
 
class  MEANDER_SKEW_PLACER
 Class MEANDER_SKEW_PLACER. More...
 
class  MEANDERED_LINE
 Class MEANDERED_LINE. More...
 
class  NODE
 Class NODE. More...
 
struct  OBSTACLE
 Struct OBSTACLE. More...
 
class  OBSTACLE_VISITOR
 Struct OBSTACLE_VISITOR. More...
 
class  OPTIMIZER
 Class OPTIMIZER. More...
 
class  PLACEMENT_ALGO
 Class PLACEMENT_ALGO. More...
 
class  ROUTER
 
class  ROUTER_IFACE
 Class ROUTER. More...
 
class  ROUTING_SETTINGS
 Class ROUTING_SETTINGS. More...
 
class  RULE_RESOLVER
 Class RULE_RESOLVER. More...
 
class  SEGMENT
 
class  SHOVE
 Class SHOVE. More...
 
class  SIZES_SETTINGS
 
class  SOLID
 
class  TIME_LIMIT
 
class  TOOL_BASE
 
class  TOPOLOGY
 
class  VIA
 
class  WALKAROUND
 

Enumerations

enum  LineMarker { MK_HEAD = ( 1 << 0 ), MK_VIOLATION = ( 1 << 3 ), MK_LOCKED = ( 1 << 4 ), MK_DP_COUPLED = ( 1 << 5 ) }
 
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 }
 

meander corner shape

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_ANY = 0x7
}
 
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 }
 

Optimization effort

More...
 

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 n, SEG p, SEG &pClip, SEG &nClip)
 
static bool pairOrientation (const DIFF_PAIR::COUPLED_SEGMENTS &aPair)
 
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)
 
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)
 
const SHAPE_LINE_CHAIN OctagonalHull (const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
 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)
 

Variables

static ROUTERtheRouter
 
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

Enumerator
DM_CORNER 
DM_SEGMENT 
DM_VIA 
DM_FREE_ANGLE 
DM_ANY 

Definition at line 72 of file pns_router.h.

73 {
74  DM_CORNER = 0x1,
75  DM_SEGMENT = 0x2,
76  DM_VIA = 0x4,
77  DM_FREE_ANGLE = 0x8,
78  DM_ANY = 0x7
79 };
Enumerator
MK_HEAD 
MK_VIOLATION 
MK_LOCKED 
MK_DP_COUPLED 

Definition at line 39 of file pns_item.h.

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

meander corner shape

Enumerator
MEANDER_STYLE_ROUND 
MEANDER_STYLE_CHAMFER 

Definition at line 47 of file pns_meander.h.

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

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 35 of file pns_meander.h.

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

Routing modes

Enumerator
RM_MarkObstacles 
RM_Shove 

Ignore collisions, mark obstacles

RM_Walkaround 

Only shove

RM_Smart 

Only walkaround

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

Definition at line 35 of file pns_routing_settings.h.

36 {
37  RM_MarkObstacles = 0,
38  RM_Shove,
40  RM_Smart
41 };
Ignore collisions, mark obstacles
Only walkaround

Optimization effort

Enumerator
OE_LOW 
OE_MEDIUM 
OE_FULL 

Definition at line 44 of file pns_routing_settings.h.

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 64 of file pns_router.h.

Function Documentation

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

Definition at line 180 of file pns_diff_pair.cpp.

References DIRECTION_45::Angle().

Referenced by DXF2BRD_CONVERTER::addArc(), DIMENSION::AdjustDimensionDetails(), EC_45DEGREE::Apply(), EC_CIRCLE::Apply(), HPGL_PLOTTER::Arc(), BuildCornersList_S_Shape(), BuildDimension(), PNS::DP_GATEWAYS::BuildGeneric(), D_PAD::BuildPadPolygon(), LIB_ARC::calcEdit(), CalculateSegmentEndPoint(), PNS::OPTIMIZER::circleBreakouts(), DRAWSEGMENT::computeArcBBox(), ConvertOutlineToPolygon(), AM_PRIMITIVE::ConvertShapeToPolygon(), D_CODE::ConvertShapeToPolygon(), PCB_EDIT_FRAME::Create_MuWaveComponent(), SCH_GLOBALLABEL::CreateGraphicShape(), CreateThermalReliefPadPolygon(), PNS::OPTIMIZER::customBreakouts(), DRC::doTrackDrc(), DRAWING_TOOL::DrawDimension(), DrawSegmentQcq(), D_PAD::DrawShape(), TRACK::DrawShortNetname(), GBR_TO_PCB_EXPORTER::export_non_copper_item(), export_vrml_line(), DSN::SPECCTRA_DB::FromBOARD(), C3D_RENDER_OGL_LEGACY::generate_ring_contour(), TEXTE_MODULE::GetBoundingBox(), PCB_BASE_FRAME::GetScreen(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetStartAngle(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetSubtended(), GRCSegm(), PNS::LINE_PLACER::handlePullback(), ZONE_CONTAINER::HitTestInsideZone(), idf_export_module(), DIALOG_PAD_PROPERTIES::initValues(), PNS::LINE::Is45Degree(), LEGACY_PLUGIN::loadMODULE_EDGE(), LEGACY_PLUGIN::loadPCB_LINE(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPolygon(), EAGLE_PLUGIN::loadSignals(), DSN::SPECCTRA_DB::makeIMAGE(), EAGLE_PLUGIN::packagePolygon(), GPCB_FPL_CACHE::parseMODULE(), PCB_BASE_FRAME::Rotate_Module(), RotatePoint(), TEXTE_MODULE::SetDrawCoord(), D_PAD::SetDrawCoord(), EDGE_MODULE::SetLocalCoord(), TEXTE_MODULE::SetLocalCoord(), ShowBoundingBoxMicroWaveInductor(), TraceArc(), TraceCircle(), TransformCircleToPolygon(), DIALOG_CREATE_ARRAY::ARRAY_CIRCULAR_OPTIONS::TransformItem(), D_PAD::TransformShapeWithClearanceToPolygon(), and TEXTE_MODULE::ViewBBox().

181 {
182  DIRECTION_45 dir_a( a );
183  DIRECTION_45 dir_b( b );
184 
185  return dir_a.Angle( dir_b );
186 }
Class DIRECTION_45.
Definition: direction45.h:36
SHAPE_RECT PNS::ApproximateSegmentAsRect ( const SHAPE_SEGMENT aSeg)

Definition at line 157 of file pns_utils.cpp.

References SEG::A, abs, SHAPE_LINE_CHAIN::Append(), SEG::B, SHAPE_LINE_CHAIN::Clear(), delta, PNS::ROUTER::GetInstance(), BOX2< Vec >::GetOrigin(), SHAPE_SEGMENT::GetSeg(), BOX2< Vec >::GetSize(), SHAPE_SEGMENT::GetWidth(), i, min, DIRECTION_45::ToVector(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

158 {
159  SHAPE_RECT r;
160 
161  VECTOR2I delta( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 );
162  VECTOR2I p0( aSeg.GetSeg().A - delta );
163  VECTOR2I p1( aSeg.GetSeg().B + delta );
164 
165  return SHAPE_RECT( std::min( p0.x, p1.x ), std::min( p0.y, p1.y ),
166  std::abs( p1.x - p0.x ), std::abs( p1.y - p0.y ) );
167 }
#define abs(a)
Definition: auxiliary.h:84
static const int delta[8][2]
Definition: solve.cpp:112
int GetWidth() const
Definition: shape_segment.h:80
const SEG & GetSeg() const
Definition: shape_segment.h:70
VECTOR2I A
Definition: seg.h:46
#define min(a, b)
Definition: auxiliary.h:85
VECTOR2I B
Definition: seg.h:47
OPT_BOX2I PNS::ChangedArea ( const ITEM aItemA,
const ITEM aItemB 
)

Definition at line 231 of file pns_utils.cpp.

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

232 {
233  if( aItemA->OfKind( ITEM::VIA_T ) && aItemB->OfKind( ITEM::VIA_T ) )
234  {
235  const VIA* va = static_cast<const VIA*>( aItemA );
236  const VIA* vb = static_cast<const VIA*>( aItemB );
237 
238  return va->ChangedArea( vb );
239  }
240  else if( aItemA->OfKind( ITEM::LINE_T ) && aItemB->OfKind( ITEM::LINE_T ) )
241  {
242  const LINE* la = static_cast<const LINE*> ( aItemA );
243  const LINE* lb = static_cast<const LINE*> ( aItemB );
244 
245  return la->ChangedArea( lb );
246  }
247 
248  return OPT_BOX2I();
249 }
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:505
OPT_BOX2I PNS::ChangedArea ( const LINE aLineA,
const LINE aLineB 
)

Definition at line 251 of file pns_utils.cpp.

References PNS::LINE::ChangedArea().

252 {
253  return aLineA.ChangedArea( &aLineB );
254 }
bool PNS::checkDpColliding ( NODE aNode,
DIFF_PAIR aPair,
bool  aIsP,
const SHAPE_LINE_CHAIN aPath 
)

Definition at line 1116 of file pns_optimizer.cpp.

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

1117 {
1118  LINE tmp ( aIsP ? aPair->PLine() : aPair->NLine(), aPath );
1119 
1120  return static_cast<bool>( aNode->CheckColliding( &tmp ) );
1121 }
static bool PNS::checkGap ( const SHAPE_LINE_CHAIN p,
const SHAPE_LINE_CHAIN n,
int  gap 
)
static

Definition at line 189 of file pns_diff_pair.cpp.

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

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

190 {
191  int i, j;
192 
193  for( i = 0; i < p.SegmentCount(); i++ )
194  {
195  for( j = 0; j < n.SegmentCount() ; j++ )
196  {
197  int dist = p.CSegment( i ).Distance( n.CSegment( j ) );
198 
199  if( dist < gap - 100 )
200  return false;
201  }
202  }
203 
204  return true;
205 }
static const int dist[10][10]
Definition: dist.cpp:57
const SEG CSegment(int aIndex) const
Function CSegment()
size_t i
Definition: json11.cpp:597
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:195
int SegmentCount() const
Function SegmentCount()
template<typename T >
std::unique_ptr< typename std::remove_const< T >::type > PNS::Clone ( const T &  aItem)

Definition at line 380 of file pns_item.h.

Referenced by PNS::DRAGGER::dumbDragVia(), D_PAD::Duplicate(), PNS::LINE_PLACER::FixRoute(), PNS::DIFF_PAIR_PLACER::FixRoute(), TEXTE_PCB::GetClass(), MODULE::GetClass(), D_PAD::Move(), PNS::SHOVE::pushVia(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::LINE_PLACER::SplitAdjacentSegments().

381 {
382  static_assert(std::is_base_of< ITEM, T >::value, "Need to be handed an ITEM!");
383  return std::unique_ptr< typename std::remove_const< T >::type >( aItem.Clone() );
384 }
bool PNS::commonParallelProjection ( SEG  n,
SEG  p,
SEG pClip,
SEG nClip 
)

Definition at line 774 of file pns_diff_pair.cpp.

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::TOPOLOGY::ConnectedItems(), PNS::DIFF_PAIR::CoupledLength(), and PNS::DIFF_PAIR::CoupledSegmentPairs().

775 {
776  SEG n_proj_p( p.LineProject( n.A ), p.LineProject( n.B ) );
777 
778  int64_t t_a = 0;
779  int64_t t_b = p.TCoef( p.B );
780 
781  int64_t tproj_a = p.TCoef( n_proj_p.A );
782  int64_t tproj_b = p.TCoef( n_proj_p.B );
783 
784  if( t_b < t_a )
785  std::swap( t_b, t_a );
786 
787  if( tproj_b < tproj_a )
788  std::swap( tproj_b, tproj_a );
789 
790  if( t_b <= tproj_a )
791  return false;
792 
793  if( t_a >= tproj_b )
794  return false;
795 
796  int64_t t[4] = { 0, p.TCoef( p.B ), p.TCoef( n_proj_p.A ), p.TCoef( n_proj_p.B ) };
797  std::vector<int64_t> tv( t, t + 4 );
798  std::sort( tv.begin(), tv.end() ); // fixme: awful and disgusting way of finding 2 midpoints
799 
800  int64_t pLenSq = p.SquaredLength();
801 
802  VECTOR2I dp = p.B - p.A;
803  pClip.A.x = p.A.x + rescale( (int64_t)dp.x, tv[1], pLenSq );
804  pClip.A.y = p.A.y + rescale( (int64_t)dp.y, tv[1], pLenSq );
805 
806  pClip.B.x = p.A.x + rescale( (int64_t)dp.x, tv[2], pLenSq );
807  pClip.B.y = p.A.y + rescale( (int64_t)dp.y, tv[2], pLenSq );
808 
809  nClip.A = n.LineProject( pClip.A );
810  nClip.B = n.LineProject( pClip.B );
811 
812  return true;
813 }
ecoord SquaredLength() const
Definition: seg.h:297
VECTOR2I LineProject(const VECTOR2I &aP) const
Function LineProject()
Definition: seg.h:337
ecoord TCoef(const VECTOR2I &aP) const
Definition: seg.h:364
int rescale(int aNumerator, int aValue, int aDenominator)
Definition: math_util.cpp:32
Definition: seg.h:36
VECTOR2I A
Definition: seg.h:46
VECTOR2I B
Definition: seg.h:47
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 101 of file pns_utils.cpp.

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 PNS::SOLID::Hull().

102 {
103  // this defines the horizontal and vertical lines in the hull octagon
104  BOX2I box = aConvex.BBox( aClearance + HULL_MARGIN );
105  box.Normalize();
106 
107  SEG topline = SEG( VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ),
108  VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ) );
109  SEG rightline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ),
110  VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ) );
111  SEG bottomline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ),
112  box.GetOrigin() );
113  SEG leftline = SEG( box.GetOrigin(), VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ) );
114 
115  const SHAPE_LINE_CHAIN& vertices = aConvex.Vertices();
116 
117  // top right diagonal
118  VECTOR2I corner = box.GetOrigin() + box.GetSize();
119  SEG toprightline = SEG( corner,
120  corner + VECTOR2I( box.GetHeight(), -box.GetHeight() ) );
121  MoveDiagonal( toprightline, vertices, aClearance );
122 
123  // bottom right diagonal
124  corner = box.GetOrigin() + VECTOR2I( box.GetWidth(), 0 );
125  SEG bottomrightline = SEG( corner + VECTOR2I( box.GetHeight(), box.GetHeight() ),
126  corner );
127  MoveDiagonal( bottomrightline, vertices, aClearance );
128 
129  // bottom left diagonal
130  corner = box.GetOrigin();
131  SEG bottomleftline = SEG( corner,
132  corner + VECTOR2I( -box.GetHeight(), box.GetHeight() ) );
133  MoveDiagonal( bottomleftline, vertices, aClearance );
134 
135  // top left diagonal
136  corner = box.GetOrigin() + VECTOR2I( 0, box.GetHeight() );
137  SEG topleftline = SEG( corner + VECTOR2I( -box.GetHeight(), -box.GetHeight() ),
138  corner );
139  MoveDiagonal( topleftline, vertices, aClearance );
140 
141  SHAPE_LINE_CHAIN octagon;
142  octagon.SetClosed( true );
143 
144  octagon.Append( *leftline.IntersectLines( bottomleftline ) );
145  octagon.Append( *bottomline.IntersectLines( bottomleftline ) );
146  octagon.Append( *bottomline.IntersectLines( bottomrightline ) );
147  octagon.Append( *rightline.IntersectLines( bottomrightline ) );
148  octagon.Append( *rightline.IntersectLines( toprightline ) );
149  octagon.Append( *topline.IntersectLines( toprightline ) );
150  octagon.Append( *topline.IntersectLines( topleftline ) );
151  octagon.Append( *leftline.IntersectLines( topleftline ) );
152 
153  return octagon;
154 }
const Vec & GetOrigin() const
Definition: box2.h:191
coord_type GetY() const
Definition: box2.h:189
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Function IntersectLines()
Definition: seg.h:179
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_simple.h:139
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Definition: shape_simple.h:74
const Vec & GetSize() const
Definition: box2.h:187
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
coord_type GetWidth() const
Definition: box2.h:195
void SetClosed(bool aClosed)
Function SetClosed()
static void MoveDiagonal(SEG &aDiagonal, const SHAPE_LINE_CHAIN &aVertices, int aClearance)
Definition: pns_utils.cpp:89
BOX2< Vec > & Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: box2.h:127
Definition: seg.h:36
coord_type GetHeight() const
Definition: box2.h:196
Class SHAPE_LINE_CHAIN.
coord_type GetX() const
Definition: box2.h:188
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 1063 of file pns_optimizer.cpp.

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

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

1064 {
1065  int vStartIdx[1024]; // fixme: possible overflow
1066 
1067  int nStarts = findCoupledVertices( aRefBypass.CPoint( 0 ), aRefBypass.CSegment( 0 ), aCoupled, aPair, vStartIdx );
1068  DIRECTION_45 dir( aRefBypass.CSegment( 0 ) );
1069 
1070  int64_t bestLength = -1;
1071  bool found = false;
1072  SHAPE_LINE_CHAIN bestBypass;
1073  int si, ei;
1074 
1075  for( int i=0; i< nStarts; i++ )
1076  {
1077  for( int j = 1; j < aCoupled.PointCount() - 1; j++ )
1078  {
1079  int delta = std::abs ( vStartIdx[i] - j );
1080 
1081  if( delta > 1 )
1082  {
1083  const VECTOR2I& vs = aCoupled.CPoint( vStartIdx[i] );
1084  SHAPE_LINE_CHAIN bypass = dir.BuildInitialTrace( vs, aCoupled.CPoint(j), dir.IsDiagonal() );
1085 
1086  int64_t coupledLength = aPair->CoupledLength( aRef, bypass );
1087 
1088  SHAPE_LINE_CHAIN newCoupled = aCoupled;
1089 
1090  si = vStartIdx[i];
1091  ei = j;
1092 
1093  if(si < ei)
1094  newCoupled.Replace( si, ei, bypass );
1095  else
1096  newCoupled.Replace( ei, si, bypass.Reverse() );
1097 
1098  if(coupledLength > bestLength && verifyDpBypass( aNode, aPair, aRefIsP, aRef, newCoupled) )
1099  {
1100  bestBypass = newCoupled;
1101  bestLength = coupledLength;
1102  found = true;
1103  }
1104  }
1105  }
1106  }
1107 
1108 
1109  if( found )
1110  aNewCoupled = bestBypass;
1111 
1112  return found;
1113 }
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
int PointCount() const
Function PointCount()
#define abs(a)
Definition: auxiliary.h:84
static const int delta[8][2]
Definition: solve.cpp:112
const SEG CSegment(int aIndex) const
Function CSegment()
Class DIRECTION_45.
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)
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Function Replace()
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
SHAPE_LINE_CHAIN PNS::dragCornerInternal ( const SHAPE_LINE_CHAIN aOrigin,
const VECTOR2I aP 
)

Definition at line 342 of file pns_line.cpp.

References SHAPE_LINE_CHAIN::Append(), DIRECTION_45::BuildInitialTrace(), SHAPE_LINE_CHAIN::CPoint(), PNS::LINE::CSegment(), SHAPE_LINE_CHAIN::CSegment(), i, SEG::Length(), SHAPE_LINE_CHAIN::SegmentCount(), and SHAPE_LINE_CHAIN::Slice().

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

343 {
344  OPT<SHAPE_LINE_CHAIN> picked;
345  int i;
346  int d = 2;
347 
348  if( aOrigin.SegmentCount() == 1)
349  {
350  DIRECTION_45 dir( aOrigin.CPoint( 0 ) - aOrigin.CPoint( 1 ) );
351 
352  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
353  }
354 
355  if( aOrigin.CSegment( -1 ).Length() > 100000 * 30 ) // fixme: constant/parameter?
356  d = 1;
357 
358  for( i = aOrigin.SegmentCount() - d; i >= 0; i-- )
359  {
360  DIRECTION_45 d_start( aOrigin.CSegment( i ) );
361  VECTOR2I p_start = aOrigin.CPoint( i );
362  SHAPE_LINE_CHAIN paths[2];
363  DIRECTION_45 dirs[2];
364  DIRECTION_45 d_prev = ( i > 0 ? DIRECTION_45( aOrigin.CSegment( i-1 ) ) : DIRECTION_45() );
365 
366  for( int j = 0; j < 2; j++ )
367  {
368  paths[j] = d_start.BuildInitialTrace( p_start, aP, j );
369  dirs[j] = DIRECTION_45( paths[j].CSegment( 0 ) );
370  }
371 
372  for( int j = 0; j < 2; j++ )
373  {
374  if( dirs[j] == d_start )
375  {
376  picked = paths[j];
377  break;
378  }
379  }
380 
381  if( picked )
382  break;
383 
384  for( int j = 0; j < 2; j++ )
385  {
386  if( dirs[j].IsObtuse( d_prev ) )
387  {
388  picked = paths[j];
389  break;
390  }
391  }
392 
393  if( picked )
394  break;
395  }
396 
397  if( picked )
398  {
399  SHAPE_LINE_CHAIN path = aOrigin.Slice( 0, i );
400  path.Append( *picked );
401 
402  return path;
403  }
404 
405  DIRECTION_45 dir( aOrigin.CPoint( -1 ) - aOrigin.CPoint( -2 ) );
406 
407  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
408 }
int Length() const
Function Length()
Definition: seg.h:292
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
const SEG CSegment(int aIndex) const
Function CSegment()
Class DIRECTION_45.
Definition: direction45.h:36
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
boost::optional< T > OPT
Definition: optional.h:7
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
Function BuildInitialTrace()
Definition: direction45.h:202
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
int SegmentCount() const
Function SegmentCount()
static void PNS::extendBox ( BOX2I aBox,
bool &  aDefined,
const VECTOR2I aP 
)
static

Definition at line 824 of file pns_line.cpp.

References BOX2< Vec >::Merge().

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

825 {
826  if( aDefined )
827  {
828  aBox.Merge( aP );
829  }
830  else
831  {
832  aBox = BOX2I( aP, VECTOR2I( 0, 0 ) );
833  aDefined = true;
834  }
835 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:502
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
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:384
int PNS::findCoupledVertices ( const VECTOR2I aVertex,
const SEG aOrigSeg,
const SHAPE_LINE_CHAIN aCoupled,
DIFF_PAIR aPair,
int *  aIndices 
)

Definition at line 1021 of file pns_optimizer.cpp.

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

Referenced by coupledBypass().

1022 {
1023  int count = 0;
1024  for ( int i = 0; i < aCoupled.SegmentCount(); i++ )
1025  {
1026  SEG s = aCoupled.CSegment( i );
1027  VECTOR2I projOverCoupled = s.LineProject ( aVertex );
1028 
1029  if( s.ApproxParallel ( aOrigSeg ) )
1030  {
1031  int64_t dist = ( projOverCoupled - aVertex ).EuclideanNorm() - aPair->Width();
1032 
1033  if( aPair->GapConstraint().Matches( dist ) )
1034  {
1035  *aIndices++ = i;
1036  count++;
1037  }
1038  }
1039  }
1040 
1041  return count;
1042 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
VECTOR2I LineProject(const VECTOR2I &aP) const
Function LineProject()
Definition: seg.h:337
static const int dist[10][10]
Definition: dist.cpp:57
const SEG CSegment(int aIndex) const
Function CSegment()
Definition: seg.h:36
size_t i
Definition: json11.cpp:597
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:253
int SegmentCount() const
Function SegmentCount()
template<typename T , typename S >
std::unique_ptr< T > PNS::ItemCast ( std::unique_ptr< S >  aPtr)

Definition at line 372 of file pns_item.h.

373 {
374  static_assert(std::is_base_of< ITEM, S >::value, "Need to be handed a ITEM!");
375  static_assert(std::is_base_of< ITEM, T >::value, "Need to cast to an ITEM!");
376  return std::unique_ptr< T >( static_cast<T*>(aPtr.release()) );
377 }
static VECTOR2I PNS::makeGapVector ( VECTOR2I  dir,
int  length 
)
static

Definition at line 411 of file pns_diff_pair.cpp.

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

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

412 {
413  int l = length / 2;
414  VECTOR2I rv;
415 
416  if( dir.EuclideanNorm() == 0 )
417  return dir;
418 
419  do
420  {
421  rv = dir.Resize( l );
422  l++;
423  } while( ( rv * 2 ).EuclideanNorm() < length );
424 
425  return rv;
426 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:385
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:292
static void PNS::MoveDiagonal ( SEG aDiagonal,
const SHAPE_LINE_CHAIN aVertices,
int  aClearance 
)
static

Definition at line 89 of file pns_utils.cpp.

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

Referenced by ConvexHull().

90 {
91  int dist;
92 
93  aVertices.NearestPoint( aDiagonal, dist );
94  dist -= HULL_MARGIN;
95  VECTOR2I moveBy = ( aDiagonal.A - aDiagonal.B ).Perpendicular().Resize( dist - aClearance );
96  aDiagonal.A += moveBy;
97  aDiagonal.B += moveBy;
98 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:385
static const int dist[10][10]
Definition: dist.cpp:57
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
VECTOR2I A
Definition: seg.h:46
VECTOR2I B
Definition: seg.h:47
const SHAPE_LINE_CHAIN PNS::OctagonalHull ( const VECTOR2I aP0,
const VECTOR2I aSize,
int  aClearance,
int  aChamfer 
)

Various utility functions.

Definition at line 33 of file pns_utils.cpp.

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

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

35 {
37 
38  s.SetClosed( true );
39 
40  s.Append( aP0.x - aClearance, aP0.y - aClearance + aChamfer );
41  s.Append( aP0.x - aClearance + aChamfer, aP0.y - aClearance );
42  s.Append( aP0.x + aSize.x + aClearance - aChamfer, aP0.y - aClearance );
43  s.Append( aP0.x + aSize.x + aClearance, aP0.y - aClearance + aChamfer );
44  s.Append( aP0.x + aSize.x + aClearance, aP0.y + aSize.y + aClearance - aChamfer );
45  s.Append( aP0.x + aSize.x + aClearance - aChamfer, aP0.y + aSize.y + aClearance );
46  s.Append( aP0.x - aClearance + aChamfer, aP0.y + aSize.y + aClearance );
47  s.Append( aP0.x - aClearance, aP0.y + aSize.y + aClearance - aChamfer );
48 
49  return s;
50 }
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
Class SHAPE_LINE_CHAIN.
bool PNS::operator== ( JOINT::HASH_TAG const &  aP1,
JOINT::HASH_TAG const &  aP2 
)
inline

Definition at line 260 of file pns_joint.h.

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

261 {
262  return aP1.pos == aP2.pos && aP1.net == aP2.net;
263 }
static bool PNS::pairOrientation ( const DIFF_PAIR::COUPLED_SEGMENTS aPair)
static

Definition at line 153 of file pns_dp_meander_placer.cpp.

References SEG::A, PNS::DIFF_PAIR::COUPLED_SEGMENTS::coupledN, PNS::DIFF_PAIR::COUPLED_SEGMENTS::coupledP, and SEG::Side().

Referenced by PNS::DP_MEANDER_PLACER::Move().

154 {
155  VECTOR2I midp = ( aPair.coupledP.A + aPair.coupledN.A ) / 2;
156 
157  //DrawDebugPoint(midp, 6);
158 
159  return aPair.coupledP.Side( midp ) > 0;
160 }
const SHAPE_LINE_CHAIN PNS::SegmentHull ( const SHAPE_SEGMENT aSeg,
int  aClearance,
int  aWalkaroundThickness 
)

Definition at line 53 of file pns_utils.cpp.

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

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

55 {
56  int d = aSeg.GetWidth() / 2 + aClearance + aWalkaroundThickness / 2 + HULL_MARGIN;
57  int x = (int)( 2.0 / ( 1.0 + M_SQRT2 ) * d );
58 
59  const VECTOR2I a = aSeg.GetSeg().A;
60  const VECTOR2I b = aSeg.GetSeg().B;
61 
62  VECTOR2I dir = b - a;
63  VECTOR2I p0 = dir.Perpendicular().Resize( d );
64  VECTOR2I ds = dir.Perpendicular().Resize( x / 2 );
65  VECTOR2I pd = dir.Resize( x / 2 );
66  VECTOR2I dp = dir.Resize( d );
67 
69 
70  s.SetClosed( true );
71 
72  s.Append( b + p0 + pd );
73  s.Append( b + dp + ds );
74  s.Append( b + dp - ds );
75  s.Append( b - p0 + pd );
76  s.Append( a - p0 - pd );
77  s.Append( a - dp - ds );
78  s.Append( a - dp + ds );
79  s.Append( a + p0 - pd );
80 
81  // make sure the hull outline is always clockwise
82  if( s.CSegment( 0 ).Side( a ) < 0 )
83  return s.Reverse();
84  else
85  return s;
86 }
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:385
int Side(const VECTOR2I &aP) const
Function Side()
Definition: seg.h:132
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
const SEG CSegment(int aIndex) const
Function CSegment()
void SetClosed(bool aClosed)
Function SetClosed()
int GetWidth() const
Definition: shape_segment.h:80
const SEG & GetSeg() const
Definition: shape_segment.h:70
Class SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:46
VECTOR2< T > Perpendicular() const
Function Perpendicular computes the perpendicular vector.
Definition: vector2d.h:313
VECTOR2I B
Definition: seg.h:47
bool PNS::verifyDpBypass ( NODE aNode,
DIFF_PAIR aPair,
bool  aRefIsP,
const SHAPE_LINE_CHAIN aNewRef,
const SHAPE_LINE_CHAIN aNewCoupled 
)

Definition at line 1045 of file pns_optimizer.cpp.

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

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

1046 {
1047  LINE refLine ( aRefIsP ? aPair->PLine() : aPair->NLine(), aNewRef );
1048  LINE coupledLine ( aRefIsP ? aPair->NLine() : aPair->PLine(), aNewCoupled );
1049 
1050  if( aNode->CheckColliding( &refLine, &coupledLine, ITEM::ANY_T, aPair->Gap() - 10 ) )
1051  return false;
1052 
1053  if( aNode->CheckColliding ( &refLine ) )
1054  return false;
1055 
1056  if( aNode->CheckColliding ( &coupledLine ) )
1057  return false;
1058 
1059  return true;
1060 }

Variable Documentation

constexpr int PNS::HULL_MARGIN = 10

Definition at line 34 of file pns_utils.h.

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

ROUTER* PNS::theRouter
static