diff --git a/include/ttl/halfedge/hetriang.h b/include/ttl/halfedge/hetriang.h index e10af65aad..91a6354ce0 100644 --- a/include/ttl/halfedge/hetriang.h +++ b/include/ttl/halfedge/hetriang.h @@ -43,7 +43,7 @@ #define _HE_TRIANG_H_ //#define TTL_USE_NODE_ID // Each node gets it's own unique id -#define TTL_USE_NODE_FLAG // Each node gets a flag (can be set to true or false) +//#define TTL_USE_NODE_FLAG // Each node gets a flag (can be set to true or false) #include #include @@ -106,6 +106,9 @@ protected: /// Tag for quick connection resolution int m_tag; + /// Whether it the node can be a target for ratsnest lines + bool m_noline; + /// List of board items that share this node std::unordered_set m_parents; @@ -124,7 +127,7 @@ public: #ifdef TTL_USE_NODE_ID m_id( id_count++ ), #endif - m_x( aX ), m_y( aY ), m_tag( -1 ) + m_x( aX ), m_y( aY ), m_tag( -1 ), m_noline( false ) { m_layers.reset(); } @@ -156,6 +159,18 @@ public: m_tag = aTag; } + /// Decides whether this node can be a ratsnest line target + inline void SetNoLine( bool aEnable ) + { + m_noline = aEnable; + } + + /// Returns true if this node can be a target for ratsnest lines + inline const bool& GetNoLine() const + { + return m_noline; + } + #ifdef TTL_USE_NODE_ID /// Returns the id (TTL_USE_NODE_ID must be defined) inline int Id() const diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index 93f1084a8a..9735814800 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -215,11 +215,11 @@ void RN_NET::validateEdge( RN_EDGE_MST_PTR& aEdge ) // If any of nodes belonging to the edge has the flag set, // change it to the closest node that has flag cleared - if( source->GetFlag() ) + if( source->GetNoLine() ) { valid = false; + std::list closest = GetClosestNodes( source, LINE_TARGET() ); - std::list closest = GetClosestNodes( source, WITHOUT_FLAG() ); for( RN_NODE_PTR& node : closest ) { if( node && node != target ) @@ -230,11 +230,11 @@ void RN_NET::validateEdge( RN_EDGE_MST_PTR& aEdge ) } } - if( target->GetFlag() ) + if( target->GetNoLine() ) { valid = false; + std::list closest = GetClosestNodes( target, LINE_TARGET() ); - std::list closest = GetClosestNodes( target, WITHOUT_FLAG() ); for( RN_NODE_PTR& node : closest ) { if( node && node != source ) @@ -398,7 +398,7 @@ RN_POLY::RN_POLY( const SHAPE_POLY_SET* aParent, // Mark it as not appropriate as a destination of ratsnest edges // (edges coming out from a polygon vertex look weird) - m_node->SetFlag( true ); + m_node->SetNoLine( true ); } @@ -761,7 +761,7 @@ void RN_NET::GetAllItems( std::list& aOutput, RN_ITEM_TYP void RN_NET::ClearSimple() { for( const RN_NODE_PTR& node : m_blockedNodes ) - node->SetFlag( false ); + node->SetNoLine( false ); m_blockedNodes.clear(); m_simpleNodes.clear(); diff --git a/pcbnew/ratsnest_data.h b/pcbnew/ratsnest_data.h index 134e32e3e8..71dc17cf90 100644 --- a/pcbnew/ratsnest_data.h +++ b/pcbnew/ratsnest_data.h @@ -92,19 +92,19 @@ struct RN_NODE_FILTER : public std::unary_function RN_NODE_AND_FILTER operator&&( const RN_NODE_FILTER& aFilter1, const RN_NODE_FILTER& aFilter2 ); RN_NODE_OR_FILTER operator||( const RN_NODE_FILTER& aFilter1, const RN_NODE_FILTER& aFilter2 ); -///> Filters out nodes that have the flag set. -struct WITHOUT_FLAG : public RN_NODE_FILTER +///> Filters out nodes that cannot be a ratsnest line target +struct LINE_TARGET : public RN_NODE_FILTER { bool operator()( const RN_NODE_PTR& aNode ) const { - return !aNode->GetFlag(); + return !aNode->GetNoLine(); } }; ///> Filters out nodes with a specific tag -struct DIFFERENT_TAG : public RN_NODE_FILTER +struct DIFF_TAG : public RN_NODE_FILTER { - DIFFERENT_TAG( int aTag ) : + DIFF_TAG( int aTag ) : m_tag( aTag ) {} @@ -515,7 +515,7 @@ public: inline void AddBlockedNode( RN_NODE_PTR& aNode ) { m_blockedNodes.insert( aNode ); - aNode->SetFlag( true ); + aNode->SetNoLine( true ); } /** diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp index a2b6c89bbb..9561b2e6c4 100644 --- a/pcbnew/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest_viewitem.cpp @@ -79,7 +79,7 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const if( node->GetRefCount() > 1 ) continue; - RN_NODE_PTR dest = net.GetClosestNode( node, WITHOUT_FLAG() ); + RN_NODE_PTR dest = net.GetClosestNode( node, LINE_TARGET() ); if( dest ) {