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  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)
 
std::size_t hash_value (JOINT::HASH_TAG const &aP)
 
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_CONVEX &convex, 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
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(), PNS::OPTIMIZER::convexBreakouts(), PCB_EDIT_FRAME::Create_MuWaveComponent(), SCH_GLOBALLABEL::CreateGraphicShape(), CreateThermalReliefPadPolygon(), 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(), TEXTE_MODULE::GetBoundingBox(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetStartAngle(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetSubtended(), GRCSegm(), PNS::LINE_PLACER::handlePullback(), idf_export_module(), DIALOG_PAD_PROPERTIES::initValues(), PNS::LINE::Is45Degree(), LIB_TEXT::Load(), LEGACY_PLUGIN::loadMODULE_EDGE(), LEGACY_PLUGIN::loadPCB_LINE(), LEGACY_PLUGIN::loadPCB_TEXT(), DSN::SPECCTRA_DB::makeIMAGE(), GPCB_FPL_CACHE::parseMODULE(), PCB_BASE_FRAME::Rotate_Module(), TEXTE_MODULE::SetDrawCoord(), D_PAD::SetDrawCoord(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetEnd(), EDGE_MODULE::SetLocalCoord(), TEXTE_MODULE::SetLocalCoord(), ShowBoundingBoxMicroWaveInductor(), TraceArc(), TraceCircle(), TransformCircleToPolygon(), DIALOG_CREATE_ARRAY::ARRAY_CIRCULAR_OPTIONS::TransformItem(), D_PAD::TransformShapeWithClearanceToPolygon(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate(), 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:33
SHAPE_RECT PNS::ApproximateSegmentAsRect ( const SHAPE_SEGMENT aSeg)

Definition at line 157 of file pns_utils.cpp.

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

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 }
VECTOR2I & B
Definition: seg.h:52
#define abs(a)
Definition: auxiliary.h:84
static const int delta[8][2]
Definition: solve.cpp:112
VECTOR2I & A
Definition: seg.h:51
int GetWidth() const
Definition: shape_segment.h:80
const SEG & GetSeg() const
Definition: shape_segment.h:70
#define min(a, b)
Definition: auxiliary.h:85
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 }
boost::optional< BOX2I > OPT_BOX2I
Definition: box2.h:471
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 1114 of file pns_optimizer.cpp.

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

1115 {
1116  LINE tmp ( aIsP ? aPair->PLine() : aPair->NLine(), aPath );
1117 
1118  return static_cast<bool>( aNode->CheckColliding( &tmp ) );
1119 }
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(), 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()
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:228
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 367 of file pns_item.h.

Referenced by PNS::DRAGGER::dumbDragVia(), PNS::LINE_PLACER::FixRoute(), PNS::DIFF_PAIR_PLACER::FixRoute(), PNS::SHOVE::pushVia(), PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), and PNS::LINE_PLACER::splitAdjacentSegments().

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

Definition at line 768 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::DIFF_PAIR::CoupledLength(), and PNS::DIFF_PAIR::CoupledSegmentPairs().

769 {
770  SEG n_proj_p( p.LineProject( n.A ), p.LineProject( n.B ) );
771 
772  int64_t t_a = 0;
773  int64_t t_b = p.TCoef( p.B );
774 
775  int64_t tproj_a = p.TCoef( n_proj_p.A );
776  int64_t tproj_b = p.TCoef( n_proj_p.B );
777 
778  if( t_b < t_a )
779  std::swap( t_b, t_a );
780 
781  if( tproj_b < tproj_a )
782  std::swap( tproj_b, tproj_a );
783 
784  if( t_b <= tproj_a )
785  return false;
786 
787  if( t_a >= tproj_b )
788  return false;
789 
790  int64_t t[4] = { 0, p.TCoef( p.B ), p.TCoef( n_proj_p.A ), p.TCoef( n_proj_p.B ) };
791  std::vector<int64_t> tv( t, t + 4 );
792  std::sort( tv.begin(), tv.end() ); // fixme: awful and disgusting way of finding 2 midpoints
793 
794  int64_t pLenSq = p.SquaredLength();
795 
796  VECTOR2I dp = p.B - p.A;
797  pClip.A.x = p.A.x + rescale( (int64_t)dp.x, tv[1], pLenSq );
798  pClip.A.y = p.A.y + rescale( (int64_t)dp.y, tv[1], pLenSq );
799 
800  pClip.B.x = p.A.x + rescale( (int64_t)dp.x, tv[2], pLenSq );
801  pClip.B.y = p.A.y + rescale( (int64_t)dp.y, tv[2], pLenSq );
802 
803  nClip.A = n.LineProject( pClip.A );
804  nClip.B = n.LineProject( pClip.B );
805 
806  return true;
807 }
ecoord SquaredLength() const
Definition: seg.h:330
VECTOR2I & B
Definition: seg.h:52
VECTOR2I LineProject(const VECTOR2I &aP) const
Function LineProject()
Definition: seg.h:364
ecoord TCoef(const VECTOR2I &aP) const
Definition: seg.h:391
VECTOR2I & A
Definition: seg.h:51
int rescale(int aNumerator, int aValue, int aDenominator)
Definition: math_util.cpp:32
Definition: seg.h:37
const SHAPE_LINE_CHAIN PNS::ConvexHull ( const SHAPE_CONVEX convex,
int  aClearance 
)

Function ConvexHull()

Creates an octagonal hull around a convex polygon.

Parameters
convexThe convex polygon.
clearanceThe 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_CONVEX::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_CONVEX::Vertices().

Referenced by PNS::SOLID::Hull().

102 {
103  // this defines the horizontal and vertical lines in the hull octagon
104  BOX2I box = convex.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 = convex.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 ).get() );
145  octagon.Append( bottomline.IntersectLines( bottomleftline ).get() );
146  octagon.Append( bottomline.IntersectLines( bottomrightline ).get() );
147  octagon.Append( rightline.IntersectLines( bottomrightline ).get() );
148  octagon.Append( rightline.IntersectLines( toprightline ).get() );
149  octagon.Append( topline.IntersectLines( toprightline ).get() );
150  octagon.Append( topline.IntersectLines( topleftline ).get() );
151  octagon.Append( leftline.IntersectLines( topleftline ).get() );
152 
153  return octagon;
154 }
const Vec & GetOrigin() const
Definition: box2.h:181
coord_type GetY() const
Definition: box2.h:179
constexpr int HULL_MARGIN
Definition: pns_utils.h:34
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Definition: shape_convex.h:74
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Function IntersectLines()
Definition: seg.h:212
const Vec & GetSize() const
Definition: box2.h:177
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
coord_type GetWidth() const
Definition: box2.h:185
void SetClosed(bool aClosed)
Function SetClosed()
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_convex.h:139
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:117
Definition: seg.h:37
coord_type GetHeight() const
Definition: box2.h:186
Class SHAPE_LINE_CHAIN.
coord_type GetX() const
Definition: box2.h:178
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 1061 of file pns_optimizer.cpp.

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

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

1062 {
1063  int vStartIdx[1024]; // fixme: possible overflow
1064 
1065  int nStarts = findCoupledVertices( aRefBypass.CPoint( 0 ), aRefBypass.CSegment( 0 ), aCoupled, aPair, vStartIdx );
1066  DIRECTION_45 dir( aRefBypass.CSegment( 0 ) );
1067 
1068  int64_t bestLength = -1;
1069  bool found = false;
1070  SHAPE_LINE_CHAIN bestBypass;
1071  int si, ei;
1072 
1073  for( int i=0; i< nStarts; i++ )
1074  {
1075  for( int j = 1; j < aCoupled.PointCount() - 1; j++ )
1076  {
1077  int delta = std::abs ( vStartIdx[i] - j );
1078 
1079  if( delta > 1 )
1080  {
1081  const VECTOR2I& vs = aCoupled.CPoint( vStartIdx[i] );
1082  SHAPE_LINE_CHAIN bypass = dir.BuildInitialTrace( vs, aCoupled.CPoint(j), dir.IsDiagonal() );
1083 
1084  int64_t coupledLength = aPair->CoupledLength( aRef, bypass );
1085 
1086  SHAPE_LINE_CHAIN newCoupled = aCoupled;
1087 
1088  si = vStartIdx[i];
1089  ei = j;
1090 
1091  if(si < ei)
1092  newCoupled.Replace( si, ei, bypass );
1093  else
1094  newCoupled.Replace( ei, si, bypass.Reverse() );
1095 
1096  if(coupledLength > bestLength && verifyDpBypass( aNode, aPair, aRefIsP, aRef, newCoupled) )
1097  {
1098  bestBypass = newCoupled;
1099  bestLength = coupledLength;
1100  found = true;
1101  }
1102  }
1103  }
1104  }
1105 
1106 
1107  if( found )
1108  aNewCoupled = bestBypass;
1109 
1110  return found;
1111 }
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:33
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.
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 339 of file pns_line.cpp.

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

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

340 {
342  int i;
343  int d = 2;
344 
345  if( aOrigin.SegmentCount() == 1)
346  {
347  DIRECTION_45 dir( aOrigin.CPoint( 0 ) - aOrigin.CPoint( 1 ) );
348 
349  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
350  }
351 
352  if( aOrigin.CSegment( -1 ).Length() > 100000 * 30 ) // fixme: constant/parameter?
353  d = 1;
354 
355  for( i = aOrigin.SegmentCount() - d; i >= 0; i-- )
356  {
357  DIRECTION_45 d_start( aOrigin.CSegment( i ) );
358  VECTOR2I p_start = aOrigin.CPoint( i );
359  SHAPE_LINE_CHAIN paths[2];
360  DIRECTION_45 dirs[2];
361  DIRECTION_45 d_prev = ( i > 0 ? DIRECTION_45( aOrigin.CSegment( i-1 ) ) : DIRECTION_45() );
362 
363  for( int j = 0; j < 2; j++ )
364  {
365  paths[j] = d_start.BuildInitialTrace( p_start, aP, j );
366  dirs[j] = DIRECTION_45( paths[j].CSegment( 0 ) );
367  }
368 
369  for( int j = 0; j < 2; j++ )
370  {
371  if( dirs[j] == d_start )
372  {
373  picked = paths[j];
374  break;
375  }
376  }
377 
378  if( picked )
379  break;
380 
381  for( int j = 0; j < 2; j++ )
382  {
383  if( dirs[j].IsObtuse( d_prev ) )
384  {
385  picked = paths[j];
386  break;
387  }
388  }
389 
390  if( picked )
391  break;
392  }
393 
394  if( picked )
395  {
396  SHAPE_LINE_CHAIN path = aOrigin.Slice( 0, i );
397  path.Append( *picked );
398 
399  return path;
400  }
401 
402  DIRECTION_45 dir( aOrigin.CPoint( -1 ) - aOrigin.CPoint( -2 ) );
403 
404  return DIRECTION_45().BuildInitialTrace( aOrigin.CPoint( 0 ), aP, dir.IsDiagonal() );
405 }
int Length() const
Function Length()
Definition: seg.h:325
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:33
Class SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
Function BuildInitialTrace()
Definition: direction45.h:199
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 790 of file pns_line.cpp.

References BOX2< Vec >::Merge().

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

791 {
792  if( aDefined )
793  {
794  aBox.Merge( aP );
795  }
796  else
797  {
798  aBox = BOX2I( aP, VECTOR2I( 0, 0 ) );
799  aDefined = true;
800  }
801 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
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:350
int PNS::findCoupledVertices ( const VECTOR2I aVertex,
const SEG aOrigSeg,
const SHAPE_LINE_CHAIN aCoupled,
DIFF_PAIR aPair,
int *  aIndices 
)

Definition at line 1019 of file pns_optimizer.cpp.

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

Referenced by coupledBypass().

1020 {
1021  int count = 0;
1022  for ( int i = 0; i < aCoupled.SegmentCount(); i++ )
1023  {
1024  SEG s = aCoupled.CSegment( i );
1025  VECTOR2I projOverCoupled = s.LineProject ( aVertex );
1026 
1027  if( s.ApproxParallel ( aOrigSeg ) )
1028  {
1029  int64_t dist = ( projOverCoupled - aVertex ).EuclideanNorm() - aPair->Width();
1030 
1031  if( aPair->GapConstraint().Matches( dist ) )
1032  {
1033  *aIndices++ = i;
1034  count++;
1035  }
1036  }
1037  }
1038 
1039  return count;
1040 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
VECTOR2I LineProject(const VECTOR2I &aP) const
Function LineProject()
Definition: seg.h:364
static const int dist[10][10]
Definition: dist.cpp:57
const SEG CSegment(int aIndex) const
Function CSegment()
Definition: seg.h:37
bool ApproxParallel(const SEG &aSeg) const
Definition: seg.h:286
int SegmentCount() const
Function SegmentCount()
std::size_t PNS::hash_value ( JOINT::HASH_TAG const &  aP)
inline

Definition at line 252 of file pns_joint.h.

References PNS::JOINT::HASH_TAG::net, PNS::JOINT::HASH_TAG::pos, VECTOR2< T >::x, and VECTOR2< T >::y.

253 {
254  std::size_t seed = 0;
255  boost::hash_combine( seed, aP.pos.x );
256  boost::hash_combine( seed, aP.pos.y );
257  boost::hash_combine( seed, aP.net );
258 
259  return seed;
260 }
template<typename T , typename S >
std::unique_ptr< T > PNS::ItemCast ( std::unique_ptr< S >  aPtr)

Definition at line 359 of file pns_item.h.

360 {
361  static_assert(std::is_base_of< ITEM, S >::value, "Need to be handed a ITEM!");
362  static_assert(std::is_base_of< ITEM, T >::value, "Need to cast to an ITEM!");
363  return std::unique_ptr< T >( static_cast<T*>(aPtr.release()) );
364 }
T
enum T contains all this lexer's tokens.
static VECTOR2I PNS::makeGapVector ( VECTOR2I  dir,
int  length 
)
static

Definition at line 409 of file pns_diff_pair.cpp.

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

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

410 {
411  int l = length / 2;
412  VECTOR2I rv;
413  do
414  {
415  rv = dir.Resize( l );
416  l++;
417  } while( ( rv * 2 ).EuclideanNorm() < length );
418 
419  return rv;
420 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:388
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
VECTOR2I & B
Definition: seg.h:52
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:388
static const int dist[10][10]
Definition: dist.cpp:57
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
VECTOR2I & A
Definition: seg.h:51
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 247 of file pns_joint.h.

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

248 {
249  return aP1.pos == aP2.pos && aP1.net == aP2.net;
250 }
static bool PNS::pairOrientation ( const DIFF_PAIR::COUPLED_SEGMENTS aPair)
static

Definition at line 155 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().

156 {
157  VECTOR2I midp = ( aPair.coupledP.A + aPair.coupledN.A ) / 2;
158 
159  //DrawDebugPoint(midp, 6);
160 
161  return aPair.coupledP.Side( midp ) > 0;
162 }
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
VECTOR2I & B
Definition: seg.h:52
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:388
int Side(const VECTOR2I &aP) const
Function Side()
Definition: seg.h:166
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()
VECTOR2I & A
Definition: seg.h:51
int GetWidth() const
Definition: shape_segment.h:80
const SEG & GetSeg() const
Definition: shape_segment.h:70
Class SHAPE_LINE_CHAIN.
VECTOR2< T > Perpendicular() const
Function Perpendicular computes the perpendicular vector.
Definition: vector2d.h:316
bool PNS::verifyDpBypass ( NODE aNode,
DIFF_PAIR aPair,
bool  aRefIsP,
const SHAPE_LINE_CHAIN aNewRef,
const SHAPE_LINE_CHAIN aNewCoupled 
)

Definition at line 1043 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().

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

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

Definition at line 66 of file pns_router.cpp.

Referenced by PNS::ROUTER::GetInstance(), and EDIT_TOOL::invokeInlineRouter().