Loading pcbnew/router/direction.h +16 −18 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public: pl.Append( aP1 ); pl.Simplify(); return pl; }; } bool operator==( const DIRECTION_45& aOther ) const { Loading Loading @@ -286,8 +286,6 @@ public: return l; } /** * Function ToVector() * Loading pcbnew/router/pns_algo_base.h +8 −7 Original line number Diff line number Diff line Loading @@ -33,17 +33,18 @@ class PNS_LOGGER; * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) **/ class PNS_ALGO_BASE { class PNS_ALGO_BASE { public: PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : m_router ( aRouter ) {}; {} virtual ~PNS_ALGO_BASE() {} ///> Returns the instance of our router PNS_ROUTER *Router() const { PNS_ROUTER* Router() const { return m_router; } Loading pcbnew/router/pns_dragger.cpp +79 −61 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) : { m_world = NULL; m_shove = NULL; }; } PNS_DRAGGER::~PNS_DRAGGER() { Loading @@ -37,11 +38,13 @@ PNS_DRAGGER::~PNS_DRAGGER() delete m_shove; } void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) { m_world = aWorld; } bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) { int w2 = aSeg->Width() / 2; Loading @@ -59,9 +62,11 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT *aSeg ) m_mode = CORNER; } else m_mode = SEGMENT; return true; } bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) { m_draggedVia = aVia; Loading @@ -83,14 +88,13 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA *aVia ) l->Reverse(); m_origViaConnections.push_back( *l ); } } return true; } bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { m_shove = new PNS_SHOVE( m_world, Router() ); Loading @@ -104,13 +108,16 @@ bool PNS_DRAGGER::Start ( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { case PNS_ITEM::SEGMENT: return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); case PNS_ITEM::VIA: return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); default: return false; } } bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) { if( m_lastNode ) Loading Loading @@ -143,12 +150,12 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) break; } case VIA: // fixme... { m_lastNode = m_shove->CurrentNode()->Branch(); dumbDragVia ( m_initialVia, m_lastNode, aP ); break; } } Loading @@ -161,6 +168,7 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) return true; } void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) { // fixme: this is awful. Loading @@ -187,11 +195,11 @@ void PNS_DRAGGER::dumbDragVia ( PNS_VIA *aVia, PNS_NODE *aNode, const VECTOR2I& } } bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) { bool ok = false; if( m_lastNode ) { delete m_lastNode; Loading @@ -205,12 +213,13 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) { int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; PNS_LINE tmp( *m_draggedLine ); if( m_mode == SEGMENT ) tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); else tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); PNS_SHOVE::ShoveStatus st = m_shove->ShoveLines( tmp ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp ); if( st == PNS_SHOVE::SH_OK ) ok = true; Loading @@ -232,10 +241,11 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; } case VIA: { PNS_VIA *newVia; PNS_SHOVE::ShoveStatus st = m_shove -> ShoveDraggingVia ( m_draggedVia, aP, &newVia ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, &newVia ); if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED ) ok = true; Loading @@ -250,13 +260,14 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; } } m_dragStatus = ok; return ok; } bool PNS_DRAGGER::FixRoute() { if( m_dragStatus ) Loading @@ -268,34 +279,41 @@ bool PNS_DRAGGER::FixRoute( ) return false; } bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) { switch( m_currentMode ) { case RM_MarkObstacles: return dragMarkObstacles( aP ); case RM_Shove: case RM_Walkaround: case RM_Smart: return dragShove( aP ); default: return false; } } PNS_NODE *PNS_DRAGGER::CurrentNode() const { return m_lastNode; } const PNS_ITEMSET PNS_DRAGGER::Traces() { return m_draggedItems; } PNS_LOGGER* PNS_DRAGGER::Logger() { if( m_shove ) return m_shove->Logger(); return NULL; } pcbnew/router/pns_dragger.h +26 −31 Original line number Diff line number Diff line Loading @@ -39,11 +39,9 @@ class PNS_ROUTER_BASE; * * Via, segment and corner dragging algorithm. */ class PNS_DRAGGER : public PNS_ALGO_BASE { public: PNS_DRAGGER( PNS_ROUTER* aRouter ); ~PNS_DRAGGER(); Loading @@ -54,7 +52,6 @@ public: */ void SetWorld( PNS_NODE* aWorld ); /** * Function Start() * Loading Loading @@ -86,7 +83,6 @@ public: * Returns the most recent world state, including all * items changed due to dragging operation. */ PNS_NODE* CurrentNode() const; /** Loading @@ -100,7 +96,6 @@ public: virtual PNS_LOGGER* Logger(); private: typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::vector<LinePair> LinePairVec; Loading pcbnew/router/pns_index.h +19 −23 Original line number Diff line number Diff line Loading @@ -39,13 +39,12 @@ * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * overlap and improving search time. **/ class PNS_INDEX { public: typedef std::list<PNS_ITEM*> NetItemsList; typedef SHAPE_INDEX<PNS_ITEM*> ItemShapeIndex; typedef boost::unordered_set<PNS_ITEM*> ItemSet; typedef std::list<PNS_ITEM*> NET_ITEMS_LIST; typedef SHAPE_INDEX<PNS_ITEM*> ITEM_SHAPE_INDEX; typedef boost::unordered_set<PNS_ITEM*> ITEM_SET; PNS_INDEX(); ~PNS_INDEX(); Loading Loading @@ -115,7 +114,7 @@ public: * * Returns list of all items in a given net. */ NetItemsList* GetItemsForNet( int aNet ); NET_ITEMS_LIST* GetItemsForNet( int aNet ); /** * Function Contains() Loading @@ -134,8 +133,8 @@ public: */ int Size() const { return m_allItems.size(); } ItemSet::iterator begin() { return m_allItems.begin(); } ItemSet::iterator end() { return m_allItems.end(); } ITEM_SET::iterator begin() { return m_allItems.begin(); } ITEM_SET::iterator end() { return m_allItems.end(); } private: static const int MaxSubIndices = 64; Loading @@ -149,21 +148,20 @@ private: template <class Visitor> int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); ItemShapeIndex* getSubindex( const PNS_ITEM* aItem ); ITEM_SHAPE_INDEX* getSubindex( const PNS_ITEM* aItem ); ItemShapeIndex* m_subIndices[MaxSubIndices]; std::map<int, NetItemsList> m_netMap; ItemSet m_allItems; ITEM_SHAPE_INDEX* m_subIndices[MaxSubIndices]; std::map<int, NET_ITEMS_LIST> m_netMap; ITEM_SET m_allItems; }; PNS_INDEX::PNS_INDEX() { memset( m_subIndices, 0, sizeof( m_subIndices ) ); } PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) { int idx_n = -1; Loading Loading @@ -199,7 +197,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) assert( idx_n >= 0 && idx_n < MaxSubIndices ); if( !m_subIndices[idx_n] ) m_subIndices[idx_n] = new ItemShapeIndex; m_subIndices[idx_n] = new ITEM_SHAPE_INDEX; return m_subIndices[idx_n]; } Loading @@ -207,9 +205,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Add( aItem ); m_allItems.insert( aItem ); Loading @@ -224,7 +220,7 @@ void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Remove( aItem ); m_allItems.erase( aItem ); Loading Loading @@ -303,7 +299,7 @@ void PNS_INDEX::Clear() { for( int i = 0; i < MaxSubIndices; ++i ) { ItemShapeIndex* idx = m_subIndices[i]; ITEM_SHAPE_INDEX* idx = m_subIndices[i]; if( idx ) delete idx; Loading @@ -319,7 +315,7 @@ PNS_INDEX::~PNS_INDEX() } PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet ) PNS_INDEX::NET_ITEMS_LIST* PNS_INDEX::GetItemsForNet( int aNet ) { if( m_netMap.find( aNet ) == m_netMap.end() ) return NULL; Loading Loading
pcbnew/router/direction.h +16 −18 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public: pl.Append( aP1 ); pl.Simplify(); return pl; }; } bool operator==( const DIRECTION_45& aOther ) const { Loading Loading @@ -286,8 +286,6 @@ public: return l; } /** * Function ToVector() * Loading
pcbnew/router/pns_algo_base.h +8 −7 Original line number Diff line number Diff line Loading @@ -33,17 +33,18 @@ class PNS_LOGGER; * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) **/ class PNS_ALGO_BASE { class PNS_ALGO_BASE { public: PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : m_router ( aRouter ) {}; {} virtual ~PNS_ALGO_BASE() {} ///> Returns the instance of our router PNS_ROUTER *Router() const { PNS_ROUTER* Router() const { return m_router; } Loading
pcbnew/router/pns_dragger.cpp +79 −61 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) : { m_world = NULL; m_shove = NULL; }; } PNS_DRAGGER::~PNS_DRAGGER() { Loading @@ -37,11 +38,13 @@ PNS_DRAGGER::~PNS_DRAGGER() delete m_shove; } void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) { m_world = aWorld; } bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) { int w2 = aSeg->Width() / 2; Loading @@ -59,9 +62,11 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT *aSeg ) m_mode = CORNER; } else m_mode = SEGMENT; return true; } bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) { m_draggedVia = aVia; Loading @@ -83,14 +88,13 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA *aVia ) l->Reverse(); m_origViaConnections.push_back( *l ); } } return true; } bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { m_shove = new PNS_SHOVE( m_world, Router() ); Loading @@ -104,13 +108,16 @@ bool PNS_DRAGGER::Start ( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { case PNS_ITEM::SEGMENT: return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); case PNS_ITEM::VIA: return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); default: return false; } } bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) { if( m_lastNode ) Loading Loading @@ -143,12 +150,12 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) break; } case VIA: // fixme... { m_lastNode = m_shove->CurrentNode()->Branch(); dumbDragVia ( m_initialVia, m_lastNode, aP ); break; } } Loading @@ -161,6 +168,7 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) return true; } void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) { // fixme: this is awful. Loading @@ -187,11 +195,11 @@ void PNS_DRAGGER::dumbDragVia ( PNS_VIA *aVia, PNS_NODE *aNode, const VECTOR2I& } } bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) { bool ok = false; if( m_lastNode ) { delete m_lastNode; Loading @@ -205,12 +213,13 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) { int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; PNS_LINE tmp( *m_draggedLine ); if( m_mode == SEGMENT ) tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); else tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); PNS_SHOVE::ShoveStatus st = m_shove->ShoveLines( tmp ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp ); if( st == PNS_SHOVE::SH_OK ) ok = true; Loading @@ -232,10 +241,11 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; } case VIA: { PNS_VIA *newVia; PNS_SHOVE::ShoveStatus st = m_shove -> ShoveDraggingVia ( m_draggedVia, aP, &newVia ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, &newVia ); if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED ) ok = true; Loading @@ -250,13 +260,14 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; } } m_dragStatus = ok; return ok; } bool PNS_DRAGGER::FixRoute() { if( m_dragStatus ) Loading @@ -268,34 +279,41 @@ bool PNS_DRAGGER::FixRoute( ) return false; } bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) { switch( m_currentMode ) { case RM_MarkObstacles: return dragMarkObstacles( aP ); case RM_Shove: case RM_Walkaround: case RM_Smart: return dragShove( aP ); default: return false; } } PNS_NODE *PNS_DRAGGER::CurrentNode() const { return m_lastNode; } const PNS_ITEMSET PNS_DRAGGER::Traces() { return m_draggedItems; } PNS_LOGGER* PNS_DRAGGER::Logger() { if( m_shove ) return m_shove->Logger(); return NULL; }
pcbnew/router/pns_dragger.h +26 −31 Original line number Diff line number Diff line Loading @@ -39,11 +39,9 @@ class PNS_ROUTER_BASE; * * Via, segment and corner dragging algorithm. */ class PNS_DRAGGER : public PNS_ALGO_BASE { public: PNS_DRAGGER( PNS_ROUTER* aRouter ); ~PNS_DRAGGER(); Loading @@ -54,7 +52,6 @@ public: */ void SetWorld( PNS_NODE* aWorld ); /** * Function Start() * Loading Loading @@ -86,7 +83,6 @@ public: * Returns the most recent world state, including all * items changed due to dragging operation. */ PNS_NODE* CurrentNode() const; /** Loading @@ -100,7 +96,6 @@ public: virtual PNS_LOGGER* Logger(); private: typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::vector<LinePair> LinePairVec; Loading
pcbnew/router/pns_index.h +19 −23 Original line number Diff line number Diff line Loading @@ -39,13 +39,12 @@ * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * overlap and improving search time. **/ class PNS_INDEX { public: typedef std::list<PNS_ITEM*> NetItemsList; typedef SHAPE_INDEX<PNS_ITEM*> ItemShapeIndex; typedef boost::unordered_set<PNS_ITEM*> ItemSet; typedef std::list<PNS_ITEM*> NET_ITEMS_LIST; typedef SHAPE_INDEX<PNS_ITEM*> ITEM_SHAPE_INDEX; typedef boost::unordered_set<PNS_ITEM*> ITEM_SET; PNS_INDEX(); ~PNS_INDEX(); Loading Loading @@ -115,7 +114,7 @@ public: * * Returns list of all items in a given net. */ NetItemsList* GetItemsForNet( int aNet ); NET_ITEMS_LIST* GetItemsForNet( int aNet ); /** * Function Contains() Loading @@ -134,8 +133,8 @@ public: */ int Size() const { return m_allItems.size(); } ItemSet::iterator begin() { return m_allItems.begin(); } ItemSet::iterator end() { return m_allItems.end(); } ITEM_SET::iterator begin() { return m_allItems.begin(); } ITEM_SET::iterator end() { return m_allItems.end(); } private: static const int MaxSubIndices = 64; Loading @@ -149,21 +148,20 @@ private: template <class Visitor> int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); ItemShapeIndex* getSubindex( const PNS_ITEM* aItem ); ITEM_SHAPE_INDEX* getSubindex( const PNS_ITEM* aItem ); ItemShapeIndex* m_subIndices[MaxSubIndices]; std::map<int, NetItemsList> m_netMap; ItemSet m_allItems; ITEM_SHAPE_INDEX* m_subIndices[MaxSubIndices]; std::map<int, NET_ITEMS_LIST> m_netMap; ITEM_SET m_allItems; }; PNS_INDEX::PNS_INDEX() { memset( m_subIndices, 0, sizeof( m_subIndices ) ); } PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) { int idx_n = -1; Loading Loading @@ -199,7 +197,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) assert( idx_n >= 0 && idx_n < MaxSubIndices ); if( !m_subIndices[idx_n] ) m_subIndices[idx_n] = new ItemShapeIndex; m_subIndices[idx_n] = new ITEM_SHAPE_INDEX; return m_subIndices[idx_n]; } Loading @@ -207,9 +205,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Add( aItem ); m_allItems.insert( aItem ); Loading @@ -224,7 +220,7 @@ void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Remove( aItem ); m_allItems.erase( aItem ); Loading Loading @@ -303,7 +299,7 @@ void PNS_INDEX::Clear() { for( int i = 0; i < MaxSubIndices; ++i ) { ItemShapeIndex* idx = m_subIndices[i]; ITEM_SHAPE_INDEX* idx = m_subIndices[i]; if( idx ) delete idx; Loading @@ -319,7 +315,7 @@ PNS_INDEX::~PNS_INDEX() } PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet ) PNS_INDEX::NET_ITEMS_LIST* PNS_INDEX::GetItemsForNet( int aNet ) { if( m_netMap.find( aNet ) == m_netMap.end() ) return NULL; Loading