KiCad PCB EDA Suite
RN_LINKS Class Reference

Class RN_LINKS Manages data describing nodes and connections for a given net. More...

#include <ratsnest_data.h>

Public Types

typedef std::unordered_set< RN_NODE_PTR, RN_NODE_HASH, RN_NODE_COMPARERN_NODE_SET
 
typedef std::list< RN_EDGE_PTRRN_EDGE_LIST
 

Public Member Functions

const RN_NODE_PTRAddNode (int aX, int aY)
 Function AddNode() Adds a node with given coordinates and returns pointer to the newly added node. More...
 
bool RemoveNode (const RN_NODE_PTR &aNode)
 Function RemoveNode() Removes a node described by a given node pointer. More...
 
const RN_NODE_SETGetNodes () const
 Function GetNodes() Returns the set of currently used nodes. More...
 
RN_EDGE_MST_PTR AddConnection (const RN_NODE_PTR &aNode1, const RN_NODE_PTR &aNode2, unsigned int aDistance=0)
 Function AddConnection() Adds a connection between two nodes and of given distance. More...
 
void RemoveConnection (const RN_EDGE_PTR &aEdge)
 Function RemoveConnection() Removes a connection described by a given edge pointer. More...
 
const RN_EDGE_LISTGetConnections () const
 Function GetConnections() Returns the list of edges that currently connect nodes. More...
 

Protected Attributes

RN_NODE_SET m_nodes
 

Set of nodes that are expected to be connected together (vias, tracks, pads).

More...
 
RN_EDGE_LIST m_edges
 

List of edges that currently connect nodes.

More...
 

Detailed Description

Class RN_LINKS Manages data describing nodes and connections for a given net.

Definition at line 198 of file ratsnest_data.h.

Member Typedef Documentation

typedef std::list<RN_EDGE_PTR> RN_LINKS::RN_EDGE_LIST

Definition at line 203 of file ratsnest_data.h.

Definition at line 202 of file ratsnest_data.h.

Member Function Documentation

RN_EDGE_MST_PTR RN_LINKS::AddConnection ( const RN_NODE_PTR aNode1,
const RN_NODE_PTR aNode2,
unsigned int  aDistance = 0 
)

Function AddConnection() Adds a connection between two nodes and of given distance.

Edges with distance equal 0 are considered to be existing connections. Distance different than 0 means that the connection is missing.

Parameters
aNode1is the origin node of a new connection.
aNode2is the end node of a new connection.
aDistanceis the distance of the connection (0 means that nodes are actually connected, >0 means a missing connection).

Definition at line 334 of file ratsnest_data.cpp.

Referenced by RN_NET::AddItem(), RN_NET::processPads(), and RN_NET::processZones().

336 {
337  assert( aNode1 != aNode2 );
338  RN_EDGE_MST_PTR edge = std::make_shared<RN_EDGE_MST>( aNode1, aNode2, aDistance );
339  m_edges.push_back( edge );
340 
341  return edge;
342 }
std::shared_ptr< hed::EDGE_MST > RN_EDGE_MST_PTR
Definition: ratsnest_data.h:69
const RN_NODE_PTR & RN_LINKS::AddNode ( int  aX,
int  aY 
)

Function AddNode() Adds a node with given coordinates and returns pointer to the newly added node.

If the node existed before, only appropriate pointer is returned.

Parameters
aXis the x coordinate of a node.
aYis the y coordinate of a node.
Returns
Pointer to the node with given coordinates.

Definition at line 310 of file ratsnest_data.cpp.

Referenced by RN_NET::AddItem(), and RN_POLY::RN_POLY().

311 {
312  RN_NODE_SET::iterator node;
313  bool wasNewElement;
314 
315  std::tie( node, wasNewElement ) = m_nodes.emplace( std::make_shared<RN_NODE>( aX, aY ) );
316 
317  return *node;
318 }
const RN_EDGE_LIST& RN_LINKS::GetConnections ( ) const
inline

Function GetConnections() Returns the list of edges that currently connect nodes.

Returns
the list of edges that currently connect nodes.

Definition at line 261 of file ratsnest_data.h.

References m_edges.

262  {
263  return m_edges;
264  }
const RN_NODE_SET& RN_LINKS::GetNodes ( ) const
inline

Function GetNodes() Returns the set of currently used nodes.

Returns
The set of currently used nodes.

Definition at line 228 of file ratsnest_data.h.

References m_nodes.

Referenced by RN_NET::GetClosestNode(), RN_NET::GetClosestNodes(), RN_NET::processPads(), and RN_NET::processZones().

229  {
230  return m_nodes;
231  }
void RN_LINKS::RemoveConnection ( const RN_EDGE_PTR aEdge)
inline

Function RemoveConnection() Removes a connection described by a given edge pointer.

Parameters
aEdgeis a pointer to edge to be removed.

Definition at line 251 of file ratsnest_data.h.

References m_edges.

Referenced by RN_NET::processPads(), and RN_NET::processZones().

252  {
253  m_edges.remove( aEdge );
254  }
bool RN_LINKS::RemoveNode ( const RN_NODE_PTR aNode)

Function RemoveNode() Removes a node described by a given node pointer.

Parameters
aNodeis a pointer to node to be removed.
Returns
True if node was removed, false if there were other references, so it was kept.

Definition at line 321 of file ratsnest_data.cpp.

322 {
323  if( aNode->GetRefCount() == 0 )
324  {
325  m_nodes.erase( aNode );
326 
327  return true;
328  }
329 
330  return false;
331 }

Member Data Documentation

RN_EDGE_LIST RN_LINKS::m_edges
protected

List of edges that currently connect nodes.

Definition at line 271 of file ratsnest_data.h.

Referenced by GetConnections(), and RemoveConnection().

RN_NODE_SET RN_LINKS::m_nodes
protected

Set of nodes that are expected to be connected together (vias, tracks, pads).

Definition at line 268 of file ratsnest_data.h.

Referenced by GetNodes().


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