KiCad PCB EDA Suite
work.cpp File Reference

Automatic routing routines. More...

#include <fctsys.h>
#include <common.h>
#include <pcbnew.h>
#include <autorout.h>
#include <cell.h>

Go to the source code of this file.

Classes

struct  CWORK
 

Functions

void InitWork ()
 
int SetWork (int r1, int c1, int n_c, int r2, int c2, RATSNEST_ITEM *pt_ch, int pri)
 
void GetWork (int *r1, int *c1, int *n_c, int *r2, int *c2, RATSNEST_ITEM **pt_ch)
 
bool sort_by_cost (const CWORK &ref, const CWORK &item)
 
void SortWork ()
 

Variables

static std::vector< CWORKWorkList
 
static unsigned Current = 0
 

Detailed Description

Automatic routing routines.

Definition in file work.cpp.

Function Documentation

void GetWork ( int *  r1,
int *  c1,
int *  n_c,
int *  r2,
int *  c2,
RATSNEST_ITEM **  pt_ch 
)

Definition at line 102 of file work.cpp.

References Current, ILLEGAL, and WorkList.

Referenced by PCB_EDIT_FRAME::Solve().

106 {
107  if( Current < WorkList.size() )
108  {
109  *r1 = WorkList[Current].m_FromRow;
110  *c1 = WorkList[Current].m_FromCol;
111  *n_c = WorkList[Current].m_NetCode;
112  *r2 = WorkList[Current].m_ToRow;
113  *c2 = WorkList[Current].m_ToCol;
114  *pt_ch = WorkList[Current].m_Ratsnest;
115  Current++;
116  }
117  else /* none left */
118  {
119  *r1 = *c1 = *r2 = *c2 = ILLEGAL;
120  *n_c = 0;
121  *pt_ch = NULL;
122  }
123 }
#define ILLEGAL
Definition: autorout.h:52
static unsigned Current
Definition: work.cpp:64
static std::vector< CWORK > WorkList
Definition: work.cpp:63
void InitWork ( )

Definition at line 68 of file work.cpp.

References Current, and WorkList.

Referenced by Build_Work().

69 {
70  WorkList.clear();
71  Current = 0;
72 }
static unsigned Current
Definition: work.cpp:64
static std::vector< CWORK > WorkList
Definition: work.cpp:63
int SetWork ( int  r1,
int  c1,
int  n_c,
int  r2,
int  c2,
RATSNEST_ITEM *  pt_ch,
int  pri 
)

Definition at line 81 of file work.cpp.

References CWORK::CalculateCost(), MATRIX_ROUTING_HEAD::GetApxDist(), CWORK::m_ApxDist, CWORK::m_FromCol, CWORK::m_FromRow, CWORK::m_NetCode, CWORK::m_Priority, CWORK::m_Ratsnest, CWORK::m_ToCol, CWORK::m_ToRow, RoutingMatrix, and WorkList.

Referenced by Build_Work().

85 {
86  CWORK item;
87  item.m_FromRow = r1;
88  item.m_FromCol = c1;
89  item.m_NetCode = n_c;
90  item.m_ToRow = r2;
91  item.m_ToCol = c2;
92  item.m_Ratsnest = pt_ch;
93  item.m_ApxDist = RoutingMatrix.GetApxDist( r1, c1, r2, c2 );
94  item.CalculateCost();
95  item.m_Priority = pri;
96  WorkList.push_back( item );
97  return 1;
98 }
int m_FromRow
Definition: work.cpp:47
int m_ApxDist
Definition: work.cpp:53
int m_ToRow
Definition: work.cpp:49
int m_ToCol
Definition: work.cpp:50
int GetApxDist(int r1, int c1, int r2, int c2)
Definition: dist.cpp:42
int m_FromCol
Definition: work.cpp:48
Definition: work.cpp:44
int m_Priority
Definition: work.cpp:55
MATRIX_ROUTING_HEAD RoutingMatrix
Definition: autorout.cpp:51
static std::vector< CWORK > WorkList
Definition: work.cpp:63
void CalculateCost()
Definition: work.cpp:145
RATSNEST_ITEM * m_Ratsnest
Definition: work.cpp:51
int m_NetCode
Definition: work.cpp:52
bool sort_by_cost ( const CWORK ref,
const CWORK item 
)

Definition at line 127 of file work.cpp.

References CWORK::m_Cost, and CWORK::m_Priority.

Referenced by SortWork().

128 {
129  if( ref.m_Priority == item.m_Priority )
130  return ref.m_Cost < item.m_Cost;
131 
132  return ref.m_Priority >= item.m_Priority;
133 }
int m_Cost
Definition: work.cpp:54
int m_Priority
Definition: work.cpp:55
void SortWork ( )

Definition at line 135 of file work.cpp.

References sort_by_cost(), and WorkList.

Referenced by Build_Work().

136 {
137  sort( WorkList.begin(), WorkList.end(), sort_by_cost );
138 }
bool sort_by_cost(const CWORK &ref, const CWORK &item)
Definition: work.cpp:127
static std::vector< CWORK > WorkList
Definition: work.cpp:63

Variable Documentation

unsigned Current = 0
static

Definition at line 64 of file work.cpp.

Referenced by GetWork(), and InitWork().

std::vector<CWORK> WorkList
static

Definition at line 63 of file work.cpp.

Referenced by GetWork(), InitWork(), SetWork(), and SortWork().