KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PNS::SHOVE Class Reference

The actual Push and Shove algorithm. More...

#include <pns_shove.h>

Inheritance diagram for PNS::SHOVE:
PNS::ALGO_BASE

Classes

struct  HEAD_LINE_ENTRY
 
struct  ROOT_LINE_ENTRY
 
struct  SPRINGBACK_TAG
 

Public Types

enum  SHOVE_STATUS {
  SH_OK = 0 , SH_NULL , SH_INCOMPLETE , SH_HEAD_MODIFIED ,
  SH_TRY_WALK
}
 
enum  SHOVE_POLICY {
  SHP_DEFAULT = 0 , SHP_SHOVE = 0x1 , SHP_WALK_FORWARD = 0x2 , SHP_WALK_BACK = 0x4 ,
  SHP_IGNORE = 0x8 , SHP_DONT_OPTIMIZE = 0x10
}
 

Public Member Functions

void SetDefaultShovePolicy (int aPolicy)
 
void SetShovePolicy (const LINKED_ITEM *aItem, int aPolicy)
 
void SetShovePolicy (const LINE &aLine, int aPolicy)
 
 SHOVE (NODE *aWorld, ROUTER *aRouter)
 
 ~SHOVE ()
 
void ClearHeads ()
 
void AddHeads (const LINE &aHead, int aPolicy=SHP_DEFAULT)
 
void AddHeads (VIA_HANDLE aHead, VECTOR2I aNewPos, int aPolicy=SHP_DEFAULT)
 
SHOVE_STATUS Run ()
 
SHOVE_STATUS ShoveDraggingVia (const VIA_HANDLE aOldVia, const VECTOR2I &aWhere, VIA_HANDLE &aNewVia)
 
bool ShoveObstacleLine (const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
 
void ForceClearance (bool aEnabled, int aClearance)
 
NODECurrentNode ()
 
bool HeadsModified (int aIndex=-1) const
 
const PNS::LINE GetModifiedHead (int aIndex) const
 
const VIA_HANDLE GetModifiedHeadVia (int aIndex) const
 
bool AddLockedSpringbackNode (NODE *aNode)
 
void UnlockSpringbackNode (NODE *aNode)
 
bool RewindSpringbackTo (NODE *aNode)
 
bool RewindToLastLockedNode ()
 
void DisablePostShoveOptimizations (int aMask)
 
void SetSpringbackDoNotTouchNode (const NODE *aNode)
 
ROUTERRouter () const
 Return current router settings.
 
ROUTING_SETTINGSSettings () const
 Return the logger object, allowing to dump geometry to a file.
 
virtual LOGGERLogger ()
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.
 
DEBUG_DECORATORDbg () const
 
const BOX2IVisibleViewArea () const
 

Protected Attributes

DEBUG_DECORATORm_debugDecorator
 
ROUTERm_router
 
LOGGERm_logger
 

Private Types

typedef std::vector< SHAPE_LINE_CHAINHULL_SET
 
typedef std::optional< LINEOPT_LINE
 
typedef std::pair< LINE, LINELINE_PAIR
 
typedef std::vector< LINE_PAIRLINE_PAIR_VEC
 

Private Member Functions

bool shoveLineToHullSet (const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine, const HULL_SET &aHulls)
 
NODEreduceSpringback (const ITEM_SET &aHeadSet)
 
bool pushSpringback (NODE *aNode, const OPT_BOX2I &aAffectedArea)
 
bool shoveLineFromLoneVia (const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
 
bool checkShoveDirection (const LINE &aCurLine, const LINE &aObstacleLine, const LINE &aShovedLine) const
 
SHOVE_STATUS onCollidingArc (LINE &aCurrent, ARC *aObstacleArc)
 
SHOVE_STATUS onCollidingLine (LINE &aCurrent, LINE &aObstacle, int aNextRank)
 
SHOVE_STATUS onCollidingSegment (LINE &aCurrent, SEGMENT *aObstacleSeg)
 
SHOVE_STATUS onCollidingSolid (LINE &aCurrent, ITEM *aObstacle, OBSTACLE &aObstacleInfo)
 
SHOVE_STATUS onCollidingVia (ITEM *aCurrent, VIA *aObstacleVia, OBSTACLE &aObstacleInfo, int aNextRank)
 
SHOVE_STATUS onReverseCollidingVia (LINE &aCurrent, VIA *aObstacleVia, OBSTACLE &aObstacleInfo)
 
SHOVE_STATUS pushOrShoveVia (VIA *aVia, const VECTOR2I &aForce, int aNextRank)
 
OPT_BOX2I totalAffectedArea () const
 
void unwindLineStack (const LINKED_ITEM *aSeg)
 
void unwindLineStack (const ITEM *aItem)
 
void runOptimizer (NODE *aNode)
 
bool pushLineStack (const LINE &aL, bool aKeepCurrentOnTop=false)
 
void popLineStack ()
 
LINE assembleLine (const LINKED_ITEM *aSeg, int *aIndex=nullptr, bool aPreCleanup=false)
 
void replaceItems (ITEM *aOld, std::unique_ptr< ITEM > aNew)
 
ROOT_LINE_ENTRYreplaceLine (LINE &aOld, LINE &aNew, bool aIncludeInChangedArea=true, NODE *aNode=nullptr)
 
ROOT_LINE_ENTRYfindRootLine (const LINE &aLine)
 
ROOT_LINE_ENTRYfindRootLine (const LINKED_ITEM *aItem)
 
ROOT_LINE_ENTRYtouchRootLine (const LINE &aLine)
 
ROOT_LINE_ENTRYtouchRootLine (const LINKED_ITEM *aItem)
 
void pruneRootLines (NODE *aRemovedNode)
 
SHOVE_STATUS shoveIteration (int aIter)
 
SHOVE_STATUS shoveMainLoop ()
 
int getClearance (const ITEM *aA, const ITEM *aB) const
 
bool fixupViaCollisions (const LINE *aCurrent, OBSTACLE &obs)
 
void sanityCheck (LINE *aOld, LINE *aNew)
 
void reconstructHeads (bool aShoveFailed)
 
void removeHeads ()
 
bool preShoveCleanup (LINE *aOld, LINE *aNew)
 
const wxString formatPolicy (int aPolicy)
 

Private Attributes

std::vector< SPRINGBACK_TAGm_nodeStack
 
std::vector< LINEm_lineStack
 
std::vector< LINEm_optimizerQueue
 
std::deque< HEAD_LINE_ENTRYm_headLines
 
std::unordered_map< LINKED_ITEM::UNIQ_ID, ROOT_LINE_ENTRY * > m_rootLineHistory
 
NODEm_root
 
NODEm_currentNode
 
const NODEm_springbackDoNotTouchNode
 
int m_restrictSpringbackTagId
 
VIAm_draggedVia
 
int m_iter
 
bool m_headsModified
 
int m_forceClearance
 
bool m_multiLineMode
 
int m_optFlagDisableMask
 
int m_defaultPolicy
 
OPT_BOX2I m_affectedArea
 

Detailed Description

The actual Push and Shove algorithm.

Definition at line 45 of file pns_shove.h.

Member Typedef Documentation

◆ HULL_SET

typedef std::vector<SHAPE_LINE_CHAIN> PNS::SHOVE::HULL_SET
private

Definition at line 110 of file pns_shove.h.

◆ LINE_PAIR

typedef std::pair<LINE, LINE> PNS::SHOVE::LINE_PAIR
private

Definition at line 112 of file pns_shove.h.

◆ LINE_PAIR_VEC

typedef std::vector<LINE_PAIR> PNS::SHOVE::LINE_PAIR_VEC
private

Definition at line 113 of file pns_shove.h.

◆ OPT_LINE

typedef std::optional<LINE> PNS::SHOVE::OPT_LINE
private

Definition at line 111 of file pns_shove.h.

Member Enumeration Documentation

◆ SHOVE_POLICY

Enumerator
SHP_DEFAULT 
SHP_SHOVE 
SHP_WALK_FORWARD 
SHP_WALK_BACK 
SHP_IGNORE 
SHP_DONT_OPTIMIZE 

Definition at line 58 of file pns_shove.h.

◆ SHOVE_STATUS

Enumerator
SH_OK 
SH_NULL 
SH_INCOMPLETE 
SH_HEAD_MODIFIED 
SH_TRY_WALK 

Definition at line 49 of file pns_shove.h.

Constructor & Destructor Documentation

◆ SHOVE()

◆ ~SHOVE()

PNS::SHOVE::~SHOVE ( )

Definition at line 204 of file pns_shove.cpp.

Member Function Documentation

◆ AddHeads() [1/2]

void PNS::SHOVE::AddHeads ( const LINE aHead,
int  aPolicy = SHP_DEFAULT 
)

Definition at line 2088 of file pns_shove.cpp.

References m_headLines.

◆ AddHeads() [2/2]

void PNS::SHOVE::AddHeads ( VIA_HANDLE  aHead,
VECTOR2I  aNewPos,
int  aPolicy = SHP_DEFAULT 
)

◆ AddLockedSpringbackNode()

bool PNS::SHOVE::AddLockedSpringbackNode ( NODE aNode)

◆ assembleLine()

LINE PNS::SHOVE::assembleLine ( const LINKED_ITEM aSeg,
int *  aIndex = nullptr,
bool  aPreCleanup = false 
)
private

◆ checkShoveDirection()

bool PNS::SHOVE::checkShoveDirection ( const LINE aCurLine,
const LINE aObstacleLine,
const LINE aShovedLine 
) const
private

◆ ClearHeads()

void PNS::SHOVE::ClearHeads ( )

Definition at line 2082 of file pns_shove.cpp.

References m_headLines.

◆ CurrentNode()

NODE * PNS::SHOVE::CurrentNode ( )

Definition at line 1966 of file pns_shove.cpp.

References m_currentNode, and m_root.

◆ Dbg()

DEBUG_DECORATOR * PNS::ALGO_BASE::Dbg ( ) const
inlineinherited

Definition at line 78 of file pns_algo_base.h.

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by AddLockedSpringbackNode(), PNS::LINE_PLACER::buildInitialLine(), PNS::LINE_PLACER::clipAndCheckCollisions(), PNS::MEANDER_PLACER::doMove(), PNS::COMPONENT_DRAGGER::Drag(), PNS::MULTI_DRAGGER::Drag(), PNS::DRAGGER::dragShove(), PNS::DRAGGER::dragWalkaround(), PNS::MULTI_DRAGGER::findNewLeaderSegment(), fixupViaCollisions(), PNS::LINE_PLACER::handlePullback(), PNS::LINE_PLACER::mergeHead(), PNS::DP_MEANDER_PLACER::Move(), PNS::MEANDER_SKEW_PLACER::Move(), PNS::MULTI_DRAGGER::multidragShove(), PNS::MULTI_DRAGGER::multidragWalkaround(), onCollidingArc(), onCollidingLine(), onCollidingSegment(), onCollidingSolid(), onCollidingVia(), onReverseCollidingVia(), PNS::DRAGGER::optimizeAndUpdateDraggedLine(), PNS::LINE_PLACER::optimizeTailHeadTransition(), preShoveCleanup(), pruneRootLines(), pushLineStack(), pushOrShoveVia(), pushSpringback(), reconstructHeads(), reduceSpringback(), PNS::LINE_PLACER::reduceTail(), removeHeads(), PNS::LINE_PLACER::removeLoops(), replaceItems(), replaceLine(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkBase(), PNS::LINE_PLACER::rhWalkOnly(), PNS::WALKAROUND::Route(), PNS::LINE_PLACER::routeStep(), Run(), runOptimizer(), shoveIteration(), shoveLineToHullSet(), shoveMainLoop(), ShoveObstacleLine(), PNS::WALKAROUND::singleStep(), PNS::LINE_PLACER::splitHeadTail(), PNS::LINE_PLACER::Start(), PNS::DRAGGER::Start(), PNS::MULTI_DRAGGER::Start(), touchRootLine(), PNS::LINE_PLACER::Trace(), PNS::DRAGGER::tryWalkaround(), PNS::MULTI_DRAGGER::tryWalkaround(), and unwindLineStack().

◆ DisablePostShoveOptimizations()

void PNS::SHOVE::DisablePostShoveOptimizations ( int  aMask)

Definition at line 2051 of file pns_shove.cpp.

References m_optFlagDisableMask.

◆ findRootLine() [1/2]

SHOVE::ROOT_LINE_ENTRY * PNS::SHOVE::findRootLine ( const LINE aLine)
private

Definition at line 1772 of file pns_shove.cpp.

References PNS::LINK_HOLDER::Links(), and m_rootLineHistory.

Referenced by reconstructHeads(), Run(), runOptimizer(), and shoveIteration().

◆ findRootLine() [2/2]

SHOVE::ROOT_LINE_ENTRY * PNS::SHOVE::findRootLine ( const LINKED_ITEM aItem)
private

Definition at line 1785 of file pns_shove.cpp.

References m_rootLineHistory, and PNS::LINKED_ITEM::Uid().

◆ fixupViaCollisions()

◆ ForceClearance()

void PNS::SHOVE::ForceClearance ( bool  aEnabled,
int  aClearance 
)
inline

Definition at line 88 of file pns_shove.h.

References m_forceClearance.

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

◆ formatPolicy()

const wxString PNS::SHOVE::formatPolicy ( int  aPolicy)
private

Definition at line 2474 of file pns_shove.cpp.

References m_defaultPolicy, SHP_DEFAULT, SHP_IGNORE, SHP_SHOVE, and SHP_WALK_FORWARD.

Referenced by Run().

◆ getClearance()

int PNS::SHOVE::getClearance ( const ITEM aA,
const ITEM aB 
) const
private

◆ GetModifiedHead()

const PNS::LINE PNS::SHOVE::GetModifiedHead ( int  aIndex) const

Definition at line 2503 of file pns_shove.cpp.

References m_headLines.

◆ GetModifiedHeadVia()

const VIA_HANDLE PNS::SHOVE::GetModifiedHeadVia ( int  aIndex) const

Definition at line 2508 of file pns_shove.cpp.

References m_headLines.

◆ HeadsModified()

bool PNS::SHOVE::HeadsModified ( int  aIndex = -1) const

Definition at line 2495 of file pns_shove.cpp.

References m_headLines, and m_headsModified.

◆ Logger()

◆ onCollidingArc()

◆ onCollidingLine()

SHOVE::SHOVE_STATUS PNS::SHOVE::onCollidingLine ( LINE aCurrent,
LINE aObstacle,
int  aNextRank 
)
private

◆ onCollidingSegment()

◆ onCollidingSolid()

◆ onCollidingVia()

◆ onReverseCollidingVia()

◆ popLineStack()

void PNS::SHOVE::popLineStack ( )
private

Definition at line 1355 of file pns_shove.cpp.

References PNS::LINK_HOLDER::Links(), m_lineStack, and m_optimizerQueue.

Referenced by onCollidingSolid(), and shoveIteration().

◆ preShoveCleanup()

bool PNS::SHOVE::preShoveCleanup ( LINE aOld,
LINE aNew 
)
private

◆ pruneRootLines()

void PNS::SHOVE::pruneRootLines ( NODE aRemovedNode)
private

◆ pushLineStack()

bool PNS::SHOVE::pushLineStack ( const LINE aL,
bool  aKeepCurrentOnTop = false 
)
private

◆ pushOrShoveVia()

◆ pushSpringback()

◆ reconstructHeads()

void PNS::SHOVE::reconstructHeads ( bool  aShoveFailed)
private

◆ reduceSpringback()

◆ removeHeads()

void PNS::SHOVE::removeHeads ( )
private

◆ replaceItems()

void PNS::SHOVE::replaceItems ( ITEM aOld,
std::unique_ptr< ITEM aNew 
)
private

◆ replaceLine()

◆ RewindSpringbackTo()

bool PNS::SHOVE::RewindSpringbackTo ( NODE aNode)

Definition at line 1986 of file pns_shove.cpp.

References PNS::NODE::KillChildren(), m_currentNode, m_nodeStack, and m_root.

◆ RewindToLastLockedNode()

bool PNS::SHOVE::RewindToLastLockedNode ( )

Definition at line 2020 of file pns_shove.cpp.

References m_currentNode, and m_nodeStack.

◆ Router()

◆ Run()

◆ runOptimizer()

◆ sanityCheck()

void PNS::SHOVE::sanityCheck ( LINE aOld,
LINE aNew 
)
private

◆ SetDebugDecorator()

void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.

Definition at line 73 of file pns_algo_base.h.

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by onCollidingSolid(), PNS::LINE_PLACER::rhWalkBase(), SHOVE(), PNS::DRAGGER::tryWalkaround(), and PNS::MULTI_DRAGGER::tryWalkaround().

◆ SetDefaultShovePolicy()

void PNS::SHOVE::SetDefaultShovePolicy ( int  aPolicy)

Definition at line 2063 of file pns_shove.cpp.

References m_defaultPolicy.

◆ SetLogger()

void PNS::ALGO_BASE::SetLogger ( LOGGER aLogger)
inlineinherited

◆ SetShovePolicy() [1/2]

void PNS::SHOVE::SetShovePolicy ( const LINE aLine,
int  aPolicy 
)

Definition at line 2075 of file pns_shove.cpp.

References touchRootLine().

◆ SetShovePolicy() [2/2]

void PNS::SHOVE::SetShovePolicy ( const LINKED_ITEM aItem,
int  aPolicy 
)

Definition at line 2069 of file pns_shove.cpp.

References touchRootLine().

Referenced by Run().

◆ SetSpringbackDoNotTouchNode()

void PNS::SHOVE::SetSpringbackDoNotTouchNode ( const NODE aNode)

Definition at line 2057 of file pns_shove.cpp.

References m_springbackDoNotTouchNode.

◆ Settings()

◆ ShoveDraggingVia()

SHOVE_STATUS PNS::SHOVE::ShoveDraggingVia ( const VIA_HANDLE  aOldVia,
const VECTOR2I aWhere,
VIA_HANDLE aNewVia 
)

◆ shoveIteration()

◆ shoveLineFromLoneVia()

◆ shoveLineToHullSet()

◆ shoveMainLoop()

◆ ShoveObstacleLine()

◆ totalAffectedArea()

OPT_BOX2I PNS::SHOVE::totalAffectedArea ( ) const
private

Definition at line 1756 of file pns_shove.cpp.

References m_affectedArea, and m_nodeStack.

Referenced by runOptimizer().

◆ touchRootLine() [1/2]

SHOVE::ROOT_LINE_ENTRY * PNS::SHOVE::touchRootLine ( const LINE aLine)
private

◆ touchRootLine() [2/2]

SHOVE::ROOT_LINE_ENTRY * PNS::SHOVE::touchRootLine ( const LINKED_ITEM aItem)
private

◆ UnlockSpringbackNode()

void PNS::SHOVE::UnlockSpringbackNode ( NODE aNode)

Definition at line 2034 of file pns_shove.cpp.

References m_nodeStack.

◆ unwindLineStack() [1/2]

void PNS::SHOVE::unwindLineStack ( const ITEM aItem)
private

◆ unwindLineStack() [2/2]

void PNS::SHOVE::unwindLineStack ( const LINKED_ITEM aSeg)
private

◆ VisibleViewArea()

const BOX2I & PNS::ALGO_BASE::VisibleViewArea ( ) const
inherited

Definition at line 40 of file pns_algo_base.cpp.

References PNS::ALGO_BASE::m_router, and PNS::ROUTER::VisibleViewArea().

Referenced by runOptimizer().

Member Data Documentation

◆ m_affectedArea

OPT_BOX2I PNS::SHOVE::m_affectedArea
private

Definition at line 246 of file pns_shove.h.

Referenced by replaceItems(), replaceLine(), Run(), shoveMainLoop(), and totalAffectedArea().

◆ m_currentNode

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 86 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Dbg(), and PNS::ALGO_BASE::SetDebugDecorator().

◆ m_defaultPolicy

int PNS::SHOVE::m_defaultPolicy
private

Definition at line 245 of file pns_shove.h.

Referenced by formatPolicy(), SetDefaultShovePolicy(), SHOVE(), and shoveIteration().

◆ m_draggedVia

VIA* PNS::SHOVE::m_draggedVia
private

Definition at line 237 of file pns_shove.h.

Referenced by SHOVE(), and shoveMainLoop().

◆ m_forceClearance

int PNS::SHOVE::m_forceClearance
private

Definition at line 240 of file pns_shove.h.

Referenced by ForceClearance(), getClearance(), and SHOVE().

◆ m_headLines

◆ m_headsModified

bool PNS::SHOVE::m_headsModified
private

Definition at line 239 of file pns_shove.h.

Referenced by HeadsModified(), reconstructHeads(), and Run().

◆ m_iter

int PNS::SHOVE::m_iter
private

Definition at line 238 of file pns_shove.h.

Referenced by onReverseCollidingVia(), Run(), SHOVE(), and shoveMainLoop().

◆ m_lineStack

std::vector<LINE> PNS::SHOVE::m_lineStack
private

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 88 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Logger(), and PNS::ALGO_BASE::SetLogger().

◆ m_multiLineMode

bool PNS::SHOVE::m_multiLineMode
private

Definition at line 241 of file pns_shove.h.

Referenced by onCollidingLine(), onCollidingSolid(), Run(), and SHOVE().

◆ m_nodeStack

◆ m_optFlagDisableMask

int PNS::SHOVE::m_optFlagDisableMask
private

Definition at line 243 of file pns_shove.h.

Referenced by DisablePostShoveOptimizations(), runOptimizer(), and SHOVE().

◆ m_optimizerQueue

std::vector<LINE> PNS::SHOVE::m_optimizerQueue
private

Definition at line 228 of file pns_shove.h.

Referenced by popLineStack(), pushLineStack(), Run(), runOptimizer(), and unwindLineStack().

◆ m_restrictSpringbackTagId

int PNS::SHOVE::m_restrictSpringbackTagId
private

Definition at line 236 of file pns_shove.h.

Referenced by SHOVE().

◆ m_root

NODE* PNS::SHOVE::m_root
private

Definition at line 233 of file pns_shove.h.

Referenced by CurrentNode(), reduceSpringback(), RewindSpringbackTo(), SHOVE(), and shoveMainLoop().

◆ m_rootLineHistory

std::unordered_map<LINKED_ITEM::UNIQ_ID, ROOT_LINE_ENTRY*> PNS::SHOVE::m_rootLineHistory
private

Definition at line 231 of file pns_shove.h.

Referenced by findRootLine(), pruneRootLines(), replaceItems(), replaceLine(), Run(), and touchRootLine().

◆ m_router

◆ m_springbackDoNotTouchNode

const NODE* PNS::SHOVE::m_springbackDoNotTouchNode
private

Definition at line 235 of file pns_shove.h.

Referenced by reduceSpringback(), SetSpringbackDoNotTouchNode(), and SHOVE().


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