KiCad PCB EDA Suite
AR_MATRIX Class Reference

Handle the matrix routing that describes the actual board. More...

#include <ar_matrix.h>

Public Types

enum  CELL_OP {
  WRITE_CELL = 0, WRITE_OR_CELL = 1, WRITE_XOR_CELL = 2, WRITE_AND_CELL = 3,
  WRITE_ADD_CELL = 4
}
 
typedef unsigned char MATRIX_CELL
 
typedef int DIST_CELL
 

Public Member Functions

 AR_MATRIX ()
 
 ~AR_MATRIX ()
 
void WriteCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
wxPoint GetBrdCoordOrigin ()
 
bool ComputeMatrixSize (const EDA_RECT &aBoundingBox)
 Calculate the number of rows and columns of dimensions of aPcb for routing and automatic calculation of area. More...
 
int InitRoutingMatrix ()
 Initialize the data structures. More...
 
void UnInitRoutingMatrix ()
 
void SetCellOperation (CELL_OP aLogicOp)
 
MATRIX_CELL GetCell (int aRow, int aCol, int aSide)
 
void SetCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
void OrCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
void XorCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
void AndCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
void AddCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
DIST_CELL GetDist (int aRow, int aCol, int aSide)
 
void SetDist (int aRow, int aCol, int aSide, DIST_CELL)
 
void TraceSegmentPcb (PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
 
void CreateKeepOutRectangle (int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut, LSET aLayerMask)
 Function CreateKeepOutRectangle builds the cost map: Cells ( in Dist map ) inside the rect x0,y0 a x1,y1 are incremented by value aKeepOut Cell outside this rectangle, but inside the rectangle x0,y0 -marge to x1,y1 + marge are incremented by a decreasing value (aKeepOut ... More...
 
void PlacePad (PAD *aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic)
 
void TraceFilledRectangle (int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
 
void TraceFilledRectangle (int ux0, int uy0, int ux1, int uy1, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
 

Public Attributes

MATRIX_CELLm_BoardSide [AR_MAX_ROUTING_LAYERS_COUNT]
 
DIST_CELLm_DistSide [AR_MAX_ROUTING_LAYERS_COUNT]
 
int m_RoutingLayersCount
 
int m_GridRouting
 
EDA_RECT m_BrdBox
 
int m_Nrows
 
int m_Ncols
 
int m_MemSize
 
int m_RouteCount
 
PCB_LAYER_ID m_routeLayerTop
 
PCB_LAYER_ID m_routeLayerBottom
 

Private Member Functions

void drawSegmentQcq (int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, CELL_OP op_logic)
 
void traceCircle (int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, AR_MATRIX::CELL_OP op_logic)
 
void traceFilledCircle (int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
 
void traceArc (int ux0, int uy0, int ux1, int uy1, double ArcAngle, int lg, LAYER_NUM layer, int color, AR_MATRIX::CELL_OP op_logic)
 

Private Attributes

void(AR_MATRIX::* m_opWriteCell )(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 

Detailed Description

Handle the matrix routing that describes the actual board.

Definition at line 47 of file ar_matrix.h.

Member Typedef Documentation

◆ DIST_CELL

typedef int AR_MATRIX::DIST_CELL

Definition at line 51 of file ar_matrix.h.

◆ MATRIX_CELL

typedef unsigned char AR_MATRIX::MATRIX_CELL

Definition at line 50 of file ar_matrix.h.

Member Enumeration Documentation

◆ CELL_OP

Enumerator
WRITE_CELL 
WRITE_OR_CELL 
WRITE_XOR_CELL 
WRITE_AND_CELL 
WRITE_ADD_CELL 

Definition at line 53 of file ar_matrix.h.

Constructor & Destructor Documentation

◆ AR_MATRIX()

AR_MATRIX::AR_MATRIX ( )

Definition at line 36 of file ar_matrix.cpp.

37 {
38  m_BoardSide[0] = nullptr;
39  m_BoardSide[1] = nullptr;
40  m_DistSide[0] = nullptr;
41  m_DistSide[1] = nullptr;
42  m_opWriteCell = nullptr;
43  m_Nrows = 0;
44  m_Ncols = 0;
45  m_MemSize = 0;
47  m_GridRouting = 0;
48  m_RouteCount = 0;
51 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
int m_MemSize
Definition: ar_matrix.h:145
int m_Ncols
Definition: ar_matrix.h:144
int m_GridRouting
Definition: ar_matrix.h:142
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:153
int m_Nrows
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
int m_RoutingLayersCount
Definition: ar_matrix.h:141
Definition: layer_ids.h:71
int m_RouteCount
Definition: ar_matrix.h:146
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149

References B_Cu, F_Cu, m_BoardSide, m_DistSide, m_GridRouting, m_MemSize, m_Ncols, m_Nrows, m_opWriteCell, m_RouteCount, m_routeLayerBottom, m_routeLayerTop, and m_RoutingLayersCount.

◆ ~AR_MATRIX()

AR_MATRIX::~AR_MATRIX ( )

Definition at line 54 of file ar_matrix.cpp.

55 {
56 }

Member Function Documentation

◆ AddCell()

void AR_MATRIX::AddCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)

Definition at line 224 of file ar_matrix.cpp.

225 {
226  MATRIX_CELL* p;
227 
228  p = m_BoardSide[aSide];
229  p[aRow * m_Ncols + aCol] += x;
230 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

◆ AndCell()

void AR_MATRIX::AndCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)

Definition at line 213 of file ar_matrix.cpp.

214 {
215  MATRIX_CELL* p;
216 
217  p = m_BoardSide[aSide];
218  p[aRow * m_Ncols + aCol] &= x;
219 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

◆ ComputeMatrixSize()

bool AR_MATRIX::ComputeMatrixSize ( const EDA_RECT aBoundingBox)

Calculate the number of rows and columns of dimensions of aPcb for routing and automatic calculation of area.

Parameters
aPcbis the physical board.
aUseBoardEdgesOnlyset to true to use board edges only or false to use the full board bounding box (default).

Definition at line 61 of file ar_matrix.cpp.

62 {
63  // The boundary box must have its start point on routing grid:
64  m_BrdBox = aBoundingBox;
65 
68 
69  // The boundary box must have its end point on routing grid:
70  wxPoint end = m_BrdBox.GetEnd();
71 
72  end.x -= end.x % m_GridRouting;
73  end.x += m_GridRouting;
74 
75  end.y -= end.y % m_GridRouting;
76  end.y += m_GridRouting;
77 
78  m_BrdBox.SetEnd( end );
79 
82 
83  // gives a small margin
84  m_Ncols += 1;
85  m_Nrows += 1;
86 
87  return true;
88 }
int m_Ncols
Definition: ar_matrix.h:144
int GetX() const
Definition: eda_rect.h:98
int m_GridRouting
Definition: ar_matrix.h:142
EDA_RECT m_BrdBox
Definition: ar_matrix.h:143
int GetWidth() const
Definition: eda_rect.h:109
const wxPoint GetEnd() const
Definition: eda_rect.h:103
void SetEnd(int x, int y)
Definition: eda_rect.h:182
int m_Nrows
Definition: ar_matrix.h:144
void SetX(int val)
Definition: eda_rect.h:158
int GetHeight() const
Definition: eda_rect.h:110
void SetY(int val)
Definition: eda_rect.h:164
int GetY() const
Definition: eda_rect.h:99

References EDA_RECT::GetEnd(), EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), m_BrdBox, m_GridRouting, m_Ncols, m_Nrows, EDA_RECT::SetEnd(), EDA_RECT::SetX(), and EDA_RECT::SetY().

Referenced by AR_AUTOPLACER::genPlacementRoutingMatrix().

◆ CreateKeepOutRectangle()

void AR_MATRIX::CreateKeepOutRectangle ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
int  marge,
int  aKeepOut,
LSET  aLayerMask 
)

Function CreateKeepOutRectangle builds the cost map: Cells ( in Dist map ) inside the rect x0,y0 a x1,y1 are incremented by value aKeepOut Cell outside this rectangle, but inside the rectangle x0,y0 -marge to x1,y1 + marge are incremented by a decreasing value (aKeepOut ...

0). The decreasing value depends on the distance to the first rectangle Therefore the cost is high in rect x0,y0 to x1,y1, and decrease outside this rectangle

Definition at line 807 of file ar_matrix.cpp.

809 {
810  int row, col;
811  int row_min, row_max, col_min, col_max, pmarge;
812  int trace = 0;
813  DIST_CELL data, LocalKeepOut;
814  int lgain, cgain;
815 
816  if( aLayerMask[m_routeLayerBottom] )
817  trace = 1; // Trace on bottom layer.
818 
819  if( aLayerMask[m_routeLayerTop] && m_RoutingLayersCount )
820  trace |= 2; // Trace on top layer.
821 
822  if( trace == 0 )
823  return;
824 
825  ux0 -= m_BrdBox.GetX();
826  uy0 -= m_BrdBox.GetY();
827  ux1 -= m_BrdBox.GetX();
828  uy1 -= m_BrdBox.GetY();
829 
830  ux0 -= marge;
831  ux1 += marge;
832  uy0 -= marge;
833  uy1 += marge;
834 
835  pmarge = marge / m_GridRouting;
836 
837  if( pmarge < 1 )
838  pmarge = 1;
839 
840  // Calculate the coordinate limits of the rectangle.
841  row_max = uy1 / m_GridRouting;
842  col_max = ux1 / m_GridRouting;
843  row_min = uy0 / m_GridRouting;
844 
845  if( uy0 > row_min * m_GridRouting )
846  row_min++;
847 
848  col_min = ux0 / m_GridRouting;
849 
850  if( ux0 > col_min * m_GridRouting )
851  col_min++;
852 
853  if( row_min < 0 )
854  row_min = 0;
855 
856  if( row_max >= ( m_Nrows - 1 ) )
857  row_max = m_Nrows - 1;
858 
859  if( col_min < 0 )
860  col_min = 0;
861 
862  if( col_max >= ( m_Ncols - 1 ) )
863  col_max = m_Ncols - 1;
864 
865  for( row = row_min; row <= row_max; row++ )
866  {
867  lgain = 256;
868 
869  if( row < pmarge )
870  lgain = ( 256 * row ) / pmarge;
871  else if( row > row_max - pmarge )
872  lgain = ( 256 * ( row_max - row ) ) / pmarge;
873 
874  for( col = col_min; col <= col_max; col++ )
875  {
876  // RoutingMatrix Dist map contained the "cost" of the cell
877  // at position (row, col)
878  // in autoplace this is the cost of the cell, when
879  // a footprint overlaps it, near a "master" footprint
880  // this cost is high near the "master" footprint
881  // and decrease with the distance
882  cgain = 256;
883  LocalKeepOut = aKeepOut;
884 
885  if( col < pmarge )
886  cgain = ( 256 * col ) / pmarge;
887  else if( col > col_max - pmarge )
888  cgain = ( 256 * ( col_max - col ) ) / pmarge;
889 
890  cgain = ( cgain * lgain ) / 256;
891 
892  if( cgain != 256 )
893  LocalKeepOut = ( LocalKeepOut * cgain ) / 256;
894 
895  if( trace & 1 )
896  {
897  data = GetDist( row, col, AR_SIDE_BOTTOM ) + LocalKeepOut;
898  SetDist( row, col, AR_SIDE_BOTTOM, data );
899  }
900 
901  if( trace & 2 )
902  {
903  data = GetDist( row, col, AR_SIDE_TOP );
904  data = std::max( data, LocalKeepOut );
905  SetDist( row, col, AR_SIDE_TOP, data );
906  }
907  }
908  }
909 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:42
#define AR_SIDE_TOP
Definition: ar_matrix.h:41
int m_Ncols
Definition: ar_matrix.h:144
int GetX() const
Definition: eda_rect.h:98
int m_GridRouting
Definition: ar_matrix.h:142
EDA_RECT m_BrdBox
Definition: ar_matrix.h:143
int DIST_CELL
Definition: ar_matrix.h:51
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
int m_Nrows
Definition: ar_matrix.h:144
int m_RoutingLayersCount
Definition: ar_matrix.h:141
int GetY() const
Definition: eda_rect.h:99
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
Definition: ar_matrix.cpp:244
DIST_CELL GetDist(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:234
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149

References AR_SIDE_BOTTOM, AR_SIDE_TOP, GetDist(), EDA_RECT::GetX(), EDA_RECT::GetY(), m_BrdBox, m_GridRouting, m_Ncols, m_Nrows, m_routeLayerBottom, m_routeLayerTop, m_RoutingLayersCount, and SetDist().

Referenced by AR_AUTOPLACER::genModuleOnRoutingMatrix().

◆ drawSegmentQcq()

void AR_MATRIX::drawSegmentQcq ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
int  lg,
LAYER_NUM  layer,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)
private

Definition at line 285 of file ar_matrix.cpp.

287 {
288  int64_t row, col;
289  int64_t inc;
290  int64_t row_max, col_max, row_min, col_min;
291  int64_t demi_pas;
292 
293  int cx, cy, dx, dy;
294 
295  SetCellOperation( op_logic );
296 
297  // Make coordinate ux1 tj > ux0 to simplify calculations
298  if( ux1 < ux0 )
299  {
300  std::swap( ux1, ux0 );
301  std::swap( uy1, uy0 );
302  }
303 
304  // Calculating the incrementing the Y axis
305  inc = 1;
306 
307  if( uy1 < uy0 )
308  inc = -1;
309 
310  demi_pas = m_GridRouting / 2;
311 
312  col_min = ( ux0 - lg ) / m_GridRouting;
313 
314  if( col_min < 0 )
315  col_min = 0;
316 
317  col_max = ( ux1 + lg + demi_pas ) / m_GridRouting;
318 
319  if( col_max > ( m_Ncols - 1 ) )
320  col_max = m_Ncols - 1;
321 
322  if( inc > 0 )
323  {
324  row_min = ( uy0 - lg ) / m_GridRouting;
325  row_max = ( uy1 + lg + demi_pas ) / m_GridRouting;
326  }
327  else
328  {
329  row_min = ( uy1 - lg ) / m_GridRouting;
330  row_max = ( uy0 + lg + demi_pas ) / m_GridRouting;
331  }
332 
333  if( row_min < 0 )
334  row_min = 0;
335 
336  if( row_min > ( m_Nrows - 1 ) )
337  row_min = m_Nrows - 1;
338 
339  if( row_max < 0 )
340  row_max = 0;
341 
342  if( row_max > ( m_Nrows - 1 ) )
343  row_max = m_Nrows - 1;
344 
345  dx = ux1 - ux0;
346  dy = uy1 - uy0;
347 
348  double angle;
349  if( dx )
350  {
351  angle = ArcTangente( dy, dx );
352  }
353  else
354  {
355  angle = 900;
356 
357  if( dy < 0 )
358  angle = -900;
359  }
360 
361  RotatePoint( &dx, &dy, angle ); // dx = length, dy = 0
362 
363  for( col = col_min; col <= col_max; col++ )
364  {
365  int64_t cxr;
366  cxr = ( col * m_GridRouting ) - ux0;
367 
368  for( row = row_min; row <= row_max; row++ )
369  {
370  cy = ( row * m_GridRouting ) - uy0;
371  cx = cxr;
372  RotatePoint( &cx, &cy, angle );
373 
374  if( abs( cy ) > lg )
375  continue; // The point is too far on the Y axis.
376 
377  /* This point a test is close to the segment: the position
378  * along the X axis must be tested.
379  */
380  if( ( cx >= 0 ) && ( cx <= dx ) )
381  {
382  OP_CELL( layer, row, col );
383  continue;
384  }
385 
386  // Examination of extremities are rounded.
387  if( ( cx < 0 ) && ( cx >= -lg ) )
388  {
389  if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
390  OP_CELL( layer, row, col );
391 
392  continue;
393  }
394 
395  if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
396  {
397  if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) ) <= ( lg * lg ) )
398  OP_CELL( layer, row, col );
399 
400  continue;
401  }
402  }
403  }
404 }
int m_Ncols
Definition: ar_matrix.h:144
int m_GridRouting
Definition: ar_matrix.h:142
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int m_Nrows
Definition: ar_matrix.h:144
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:153
#define OP_CELL(layer, dy, dx)
Definition: ar_matrix.cpp:263
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References PNS::angle(), ArcTangente(), m_GridRouting, m_Ncols, m_Nrows, OP_CELL, RotatePoint(), and SetCellOperation().

Referenced by traceArc(), traceCircle(), and TraceSegmentPcb().

◆ GetBrdCoordOrigin()

wxPoint AR_MATRIX::GetBrdCoordOrigin ( )
inline
Returns
the board coordinate corresponding to the routing matrix origin ( board coordinate offset ).

Definition at line 74 of file ar_matrix.h.

75  {
76  return m_BrdBox.GetOrigin();
77  }
EDA_RECT m_BrdBox
Definition: ar_matrix.h:143
const wxPoint GetOrigin() const
Definition: eda_rect.h:101

References EDA_RECT::GetOrigin(), and m_BrdBox.

Referenced by AR_AUTOPLACER::fillMatrix(), traceFilledCircle(), TraceFilledRectangle(), and TraceSegmentPcb().

◆ GetCell()

AR_MATRIX::MATRIX_CELL AR_MATRIX::GetCell ( int  aRow,
int  aCol,
int  aSide 
)

Definition at line 169 of file ar_matrix.cpp.

170 {
171  MATRIX_CELL* p;
172 
173  p = m_BoardSide[aSide];
174  return p[aRow * m_Ncols + aCol];
175 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by AR_AUTOPLACER::testRectangle().

◆ GetDist()

AR_MATRIX::DIST_CELL AR_MATRIX::GetDist ( int  aRow,
int  aCol,
int  aSide 
)

Definition at line 234 of file ar_matrix.cpp.

235 {
236  DIST_CELL* p;
237 
238  p = m_DistSide[aSide];
239  return p[aRow * m_Ncols + aCol];
240 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
int m_Ncols
Definition: ar_matrix.h:144
int DIST_CELL
Definition: ar_matrix.h:51

References m_DistSide, and m_Ncols.

Referenced by AR_AUTOPLACER::calculateKeepOutArea(), and CreateKeepOutRectangle().

◆ InitRoutingMatrix()

int AR_MATRIX::InitRoutingMatrix ( )

Initialize the data structures.

Returns
the amount of memory used or -1 if default.

Definition at line 91 of file ar_matrix.cpp.

92 {
93  if( m_Nrows <= 0 || m_Ncols <= 0 )
94  return 0;
95 
96  // give a small margin for memory allocation:
97  int ii = ( m_Nrows + 1 ) * ( m_Ncols + 1 );
98 
99  int side = AR_SIDE_BOTTOM;
100  for( int jj = 0; jj < m_RoutingLayersCount; jj++ ) // m_RoutingLayersCount = 1 or 2
101  {
102  m_BoardSide[side] = nullptr;
103  m_DistSide[side] = nullptr;
104 
105  // allocate matrix & initialize everything to empty
106  m_BoardSide[side] = new MATRIX_CELL[ ii * sizeof( MATRIX_CELL ) ];
107  memset( m_BoardSide[side], 0, ii * sizeof( MATRIX_CELL ) );
108 
109  if( m_BoardSide[side] == nullptr )
110  return -1;
111 
112  // allocate Distances
113  m_DistSide[side] = new DIST_CELL[ ii * sizeof( DIST_CELL ) ];
114  memset( m_DistSide[side], 0, ii * sizeof( DIST_CELL ) );
115 
116  if( m_DistSide[side] == nullptr )
117  return -1;
118 
119  side = AR_SIDE_TOP;
120  }
121 
122  m_MemSize = m_RouteCount * ii * ( sizeof( MATRIX_CELL ) + sizeof( DIST_CELL ) );
123 
124  return m_MemSize;
125 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:42
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
int m_MemSize
Definition: ar_matrix.h:145
#define AR_SIDE_TOP
Definition: ar_matrix.h:41
int m_Ncols
Definition: ar_matrix.h:144
int DIST_CELL
Definition: ar_matrix.h:51
int m_Nrows
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
int m_RoutingLayersCount
Definition: ar_matrix.h:141
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50
int m_RouteCount
Definition: ar_matrix.h:146

References AR_SIDE_BOTTOM, AR_SIDE_TOP, m_BoardSide, m_DistSide, m_MemSize, m_Ncols, m_Nrows, m_RouteCount, and m_RoutingLayersCount.

Referenced by AR_AUTOPLACER::genPlacementRoutingMatrix().

◆ OrCell()

void AR_MATRIX::OrCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)

Definition at line 191 of file ar_matrix.cpp.

192 {
193  MATRIX_CELL* p;
194 
195  p = m_BoardSide[aSide];
196  p[aRow * m_Ncols + aCol] |= x;
197 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

◆ PlacePad()

void AR_MATRIX::PlacePad ( PAD aPad,
int  color,
int  marge,
AR_MATRIX::CELL_OP  op_logic 
)

Definition at line 912 of file ar_matrix.cpp.

913 {
914  int dx, dy;
915  wxPoint shape_pos = aPad->ShapePos();
916 
917  dx = aPad->GetSize().x / 2;
918  dx += marge;
919 
920  if( aPad->GetShape() == PAD_SHAPE::CIRCLE )
921  {
922  traceFilledCircle( shape_pos.x, shape_pos.y, dx, aPad->GetLayerSet(), color, op_logic );
923  return;
924  }
925 
926  dy = aPad->GetSize().y / 2;
927  dy += marge;
928 
929  if( aPad->GetShape() == PAD_SHAPE::TRAPEZOID )
930  {
931  dx += abs( aPad->GetDelta().y ) / 2;
932  dy += abs( aPad->GetDelta().x ) / 2;
933  }
934 
935  // The pad is a rectangle ( horizontal or vertical )
936  if( int( aPad->GetOrientation() ) % 900 == 0 )
937  {
938  // Orientation turned 90 deg.
939  if( aPad->GetOrientation() == 900 || aPad->GetOrientation() == 2700 )
940  {
941  std::swap( dx, dy );
942  }
943 
944  TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx,
945  shape_pos.y + dy, aPad->GetLayerSet(), color, op_logic );
946  }
947  else
948  {
949  TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx,
950  shape_pos.y + dy, aPad->GetOrientation(), aPad->GetLayerSet(), color, op_logic );
951  }
952 }
int color
Definition: DXF_plotter.cpp:57
void TraceFilledRectangle(int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:615
wxPoint ShapePos() const
Definition: pad.cpp:673
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
Definition: pad.h:349
const wxSize & GetSize() const
Definition: pad.h:233
PAD_SHAPE GetShape() const
Definition: pad.h:170
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:368
const wxSize & GetDelta() const
Definition: pad.h:240
void traceFilledCircle(int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:450

References CIRCLE, color, PAD::GetDelta(), PAD::GetLayerSet(), PAD::GetOrientation(), PAD::GetShape(), PAD::GetSize(), PAD::ShapePos(), traceFilledCircle(), TraceFilledRectangle(), and TRAPEZOID.

Referenced by AR_AUTOPLACER::genModuleOnRoutingMatrix().

◆ SetCell()

void AR_MATRIX::SetCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)

Definition at line 180 of file ar_matrix.cpp.

181 {
182  MATRIX_CELL* p;
183 
184  p = m_BoardSide[aSide];
185  p[aRow * m_Ncols + aCol] = x;
186 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by AR_AUTOPLACER::fillMatrix(), and SetCellOperation().

◆ SetCellOperation()

void AR_MATRIX::SetCellOperation ( AR_MATRIX::CELL_OP  aLogicOp)

Definition at line 153 of file ar_matrix.cpp.

154 {
155  switch( aLogicOp )
156  {
157  default:
163  }
164 }
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:202
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:191
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:153
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:180
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:213
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:224

References AddCell(), AndCell(), m_opWriteCell, OrCell(), SetCell(), WRITE_ADD_CELL, WRITE_AND_CELL, WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, and XorCell().

Referenced by drawSegmentQcq(), traceFilledCircle(), and TraceFilledRectangle().

◆ SetDist()

void AR_MATRIX::SetDist ( int  aRow,
int  aCol,
int  aSide,
DIST_CELL  x 
)

Definition at line 244 of file ar_matrix.cpp.

245 {
246  DIST_CELL* p;
247 
248  p = m_DistSide[aSide];
249  p[aRow * m_Ncols + aCol] = x;
250 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
int m_Ncols
Definition: ar_matrix.h:144
int DIST_CELL
Definition: ar_matrix.h:51

References m_DistSide, and m_Ncols.

Referenced by CreateKeepOutRectangle().

◆ traceArc()

void AR_MATRIX::traceArc ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
double  ArcAngle,
int  lg,
LAYER_NUM  layer,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)
private

Definition at line 571 of file ar_matrix.cpp.

573 {
574  int radius, nb_segm;
575  int x0, y0, // Starting point of the current segment trace
576  x1, y1; // End point
577  int ii;
578  double angle, StAngle;
579 
580 
581  radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
582 
583  x0 = ux1 - ux0;
584  y0 = uy1 - uy0;
585  StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 );
586 
587  if( lg < 1 )
588  lg = 1;
589 
590  nb_segm = ( 2 * radius ) / lg;
591  nb_segm = ( nb_segm * std::abs( ArcAngle ) ) / 3600;
592 
593  if( nb_segm < 5 )
594  nb_segm = 5;
595 
596  if( nb_segm > 100 )
597  nb_segm = 100;
598 
599  for( ii = 1; ii <= nb_segm; ii++ )
600  {
601  angle = ( ArcAngle * ii ) / nb_segm;
602  angle += StAngle;
603 
605 
606  x1 = KiROUND( cosdecideg( radius, angle ) );
607  y1 = KiROUND( cosdecideg( radius, angle ) );
608  drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
609  x0 = x1;
610  y0 = y1;
611  }
612 }
int color
Definition: DXF_plotter.cpp:57
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, CELL_OP op_logic)
Definition: ar_matrix.cpp:285
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:452
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References PNS::angle(), ArcTangente(), color, cosdecideg(), drawSegmentQcq(), KiROUND(), and NORMALIZE_ANGLE_POS().

Referenced by TraceSegmentPcb().

◆ traceCircle()

void AR_MATRIX::traceCircle ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
int  lg,
LAYER_NUM  layer,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)
private

Definition at line 411 of file ar_matrix.cpp.

413 {
414  int radius, nb_segm;
415  int x0, y0, // Starting point of the current segment trace.
416  x1, y1; // End point.
417  int ii;
418  int angle;
419 
420  radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
421 
422  x0 = x1 = radius;
423  y0 = y1 = 0;
424 
425  if( lg < 1 )
426  lg = 1;
427 
428  nb_segm = ( 2 * radius ) / lg;
429 
430  if( nb_segm < 5 )
431  nb_segm = 5;
432 
433  if( nb_segm > 100 )
434  nb_segm = 100;
435 
436  for( ii = 1; ii < nb_segm; ii++ )
437  {
438  angle = ( 3600 * ii ) / nb_segm;
439  x1 = KiROUND( cosdecideg( radius, angle ) );
440  y1 = KiROUND( sindecideg( radius, angle ) );
441  drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
442  x0 = x1;
443  y0 = y1;
444  }
445 
446  drawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + radius, uy0, lg, layer, color, op_logic );
447 }
int color
Definition: DXF_plotter.cpp:57
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, CELL_OP op_logic)
Definition: ar_matrix.cpp:285
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:452
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:443
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References PNS::angle(), color, cosdecideg(), drawSegmentQcq(), KiROUND(), and sindecideg().

Referenced by TraceSegmentPcb().

◆ traceFilledCircle()

void AR_MATRIX::traceFilledCircle ( int  cx,
int  cy,
int  radius,
LSET  aLayerMask,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)
private

Definition at line 450 of file ar_matrix.cpp.

452 {
453  int row, col;
454  int ux0, uy0, ux1, uy1;
455  int row_max, col_max, row_min, col_min;
456  int trace = 0;
457  double fdistmin, fdistx, fdisty;
458  int tstwrite = 0;
459  int distmin;
460 
461  if( aLayerMask[m_routeLayerBottom] )
462  trace = 1; // Trace on BOTTOM
463 
464  if( aLayerMask[m_routeLayerTop] )
465  if( m_RoutingLayersCount > 1 )
466  trace |= 2; // Trace on TOP
467 
468  if( trace == 0 )
469  return;
470 
471  SetCellOperation( op_logic );
472 
473  cx -= GetBrdCoordOrigin().x;
474  cy -= GetBrdCoordOrigin().y;
475 
476  distmin = radius;
477 
478  // Calculate the bounding rectangle of the circle.
479  ux0 = cx - radius;
480  uy0 = cy - radius;
481  ux1 = cx + radius;
482  uy1 = cy + radius;
483 
484  // Calculate limit coordinates of cells belonging to the rectangle.
485  row_max = uy1 / m_GridRouting;
486  col_max = ux1 / m_GridRouting;
487  row_min = uy0 / m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
488  col_min = ux0 / m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
489 
490  if( row_min < 0 )
491  row_min = 0;
492 
493  if( row_max >= ( m_Nrows - 1 ) )
494  row_max = m_Nrows - 1;
495 
496  if( col_min < 0 )
497  col_min = 0;
498 
499  if( col_max >= ( m_Ncols - 1 ) )
500  col_max = m_Ncols - 1;
501 
502  // Calculate coordinate limits of cell belonging to the rectangle.
503  if( row_min > row_max )
504  row_max = row_min;
505 
506  if( col_min > col_max )
507  col_max = col_min;
508 
509  fdistmin = (double) distmin * distmin;
510 
511  for( row = row_min; row <= row_max; row++ )
512  {
513  fdisty = (double) ( cy - ( row * m_GridRouting ) );
514  fdisty *= fdisty;
515 
516  for( col = col_min; col <= col_max; col++ )
517  {
518  fdistx = (double) ( cx - ( col * m_GridRouting ) );
519  fdistx *= fdistx;
520 
521  if( fdistmin <= ( fdistx + fdisty ) )
522  continue;
523 
524  if( trace & 1 )
525  WriteCell( row, col, AR_SIDE_BOTTOM, color );
526 
527  if( trace & 2 )
528  WriteCell( row, col, AR_SIDE_TOP, color );
529 
530  tstwrite = 1;
531  }
532  }
533 
534  if( tstwrite )
535  return;
536 
537  /* If no cell has been written, it affects the 4 neighboring diagonal
538  * (Adverse event: pad off grid in the center of the 4 neighboring
539  * diagonal) */
540  distmin = m_GridRouting / 2 + 1;
541  fdistmin = ( (double) distmin * distmin ) * 2; // Distance to center point diagonally
542 
543  for( row = row_min; row <= row_max; row++ )
544  {
545  fdisty = (double) ( cy - ( row * m_GridRouting ) );
546  fdisty *= fdisty;
547 
548  for( col = col_min; col <= col_max; col++ )
549  {
550  fdistx = (double) ( cx - ( col * m_GridRouting ) );
551  fdistx *= fdistx;
552 
553  if( fdistmin <= ( fdistx + fdisty ) )
554  continue;
555 
556  if( trace & 1 )
557  WriteCell( row, col, AR_SIDE_BOTTOM, color );
558 
559  if( trace & 2 )
560  WriteCell( row, col, AR_SIDE_TOP, color );
561  }
562  }
563 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:42
#define AR_SIDE_TOP
Definition: ar_matrix.h:41
int m_Ncols
Definition: ar_matrix.h:144
int m_GridRouting
Definition: ar_matrix.h:142
int color
Definition: DXF_plotter.cpp:57
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:65
int m_Nrows
Definition: ar_matrix.h:144
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:153
int m_RoutingLayersCount
Definition: ar_matrix.h:141
wxPoint GetBrdCoordOrigin()
Definition: ar_matrix.h:74
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149

References AR_SIDE_BOTTOM, AR_SIDE_TOP, color, GetBrdCoordOrigin(), m_GridRouting, m_Ncols, m_Nrows, m_routeLayerBottom, m_routeLayerTop, m_RoutingLayersCount, SetCellOperation(), and WriteCell().

Referenced by PlacePad().

◆ TraceFilledRectangle() [1/2]

void AR_MATRIX::TraceFilledRectangle ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
double  angle,
LSET  aLayerMask,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)

Definition at line 615 of file ar_matrix.cpp.

617 {
618  int row, col;
619  int cx, cy; // Center of rectangle
620  int radius; // Radius of the circle
621  int row_min, row_max, col_min, col_max;
622  int rotrow, rotcol;
623  int trace = 0;
624 
625  if( aLayerMask[m_routeLayerBottom] )
626  trace = 1; // Trace on BOTTOM
627 
628  if( aLayerMask[m_routeLayerTop] )
629  {
630  if( m_RoutingLayersCount > 1 )
631  trace |= 2; // Trace on TOP
632  }
633 
634  if( trace == 0 )
635  return;
636 
637  SetCellOperation( op_logic );
638 
639  ux0 -= GetBrdCoordOrigin().x;
640  uy0 -= GetBrdCoordOrigin().y;
641  ux1 -= GetBrdCoordOrigin().x;
642  uy1 -= GetBrdCoordOrigin().y;
643 
644  cx = ( ux0 + ux1 ) / 2;
645  cy = ( uy0 + uy1 ) / 2;
646  radius = KiROUND( Distance( ux0, uy0, cx, cy ) );
647 
648  // Calculating coordinate limits belonging to the rectangle.
649  row_max = ( cy + radius ) / m_GridRouting;
650  col_max = ( cx + radius ) / m_GridRouting;
651  row_min = ( cy - radius ) / m_GridRouting;
652 
653  if( uy0 > row_min * m_GridRouting )
654  row_min++;
655 
656  col_min = ( cx - radius ) / m_GridRouting;
657 
658  if( ux0 > col_min * m_GridRouting )
659  col_min++;
660 
661  if( row_min < 0 )
662  row_min = 0;
663 
664  if( row_max >= ( m_Nrows - 1 ) )
665  row_max = m_Nrows - 1;
666 
667  if( col_min < 0 )
668  col_min = 0;
669 
670  if( col_max >= ( m_Ncols - 1 ) )
671  col_max = m_Ncols - 1;
672 
673  for( row = row_min; row <= row_max; row++ )
674  {
675  for( col = col_min; col <= col_max; col++ )
676  {
677  rotrow = row * m_GridRouting;
678  rotcol = col * m_GridRouting;
679  RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
680 
681  if( rotrow <= uy0 )
682  continue;
683 
684  if( rotrow >= uy1 )
685  continue;
686 
687  if( rotcol <= ux0 )
688  continue;
689 
690  if( rotcol >= ux1 )
691  continue;
692 
693  if( trace & 1 )
694  WriteCell( row, col, AR_SIDE_BOTTOM, color );
695 
696  if( trace & 2 )
697  WriteCell( row, col, AR_SIDE_TOP, color );
698  }
699  }
700 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:42
#define AR_SIDE_TOP
Definition: ar_matrix.h:41
int m_Ncols
Definition: ar_matrix.h:144
int m_GridRouting
Definition: ar_matrix.h:142
int color
Definition: DXF_plotter.cpp:57
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:65
int m_Nrows
Definition: ar_matrix.h:144
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:153
int m_RoutingLayersCount
Definition: ar_matrix.h:141
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxPoint GetBrdCoordOrigin()
Definition: ar_matrix.h:74
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149

References PNS::angle(), AR_SIDE_BOTTOM, AR_SIDE_TOP, color, GetBrdCoordOrigin(), KiROUND(), m_GridRouting, m_Ncols, m_Nrows, m_routeLayerBottom, m_routeLayerTop, m_RoutingLayersCount, RotatePoint(), SetCellOperation(), and WriteCell().

Referenced by AR_AUTOPLACER::genModuleOnRoutingMatrix(), and PlacePad().

◆ TraceFilledRectangle() [2/2]

void AR_MATRIX::TraceFilledRectangle ( int  ux0,
int  uy0,
int  ux1,
int  uy1,
LSET  aLayerMask,
int  color,
AR_MATRIX::CELL_OP  op_logic 
)

Definition at line 703 of file ar_matrix.cpp.

705 {
706  int row, col;
707  int row_min, row_max, col_min, col_max;
708  int trace = 0;
709 
710  if( aLayerMask[m_routeLayerBottom] )
711  trace = 1; // Trace on BOTTOM
712 
713  if( aLayerMask[m_routeLayerTop] && m_RoutingLayersCount > 1 )
714  trace |= 2; // Trace on TOP
715 
716  if( trace == 0 )
717  return;
718 
719  SetCellOperation( op_logic );
720 
721  ux0 -= GetBrdCoordOrigin().x;
722  uy0 -= GetBrdCoordOrigin().y;
723  ux1 -= GetBrdCoordOrigin().x;
724  uy1 -= GetBrdCoordOrigin().y;
725 
726  // Calculating limits coord cells belonging to the rectangle.
727  row_max = uy1 / m_GridRouting;
728  col_max = ux1 / m_GridRouting;
729  row_min = uy0 / m_GridRouting;
730 
731  if( uy0 > row_min * m_GridRouting )
732  row_min++;
733 
734  col_min = ux0 / m_GridRouting;
735 
736  if( ux0 > col_min * m_GridRouting )
737  col_min++;
738 
739  if( row_min < 0 )
740  row_min = 0;
741 
742  if( row_max >= ( m_Nrows - 1 ) )
743  row_max = m_Nrows - 1;
744 
745  if( col_min < 0 )
746  col_min = 0;
747 
748  if( col_max >= ( m_Ncols - 1 ) )
749  col_max = m_Ncols - 1;
750 
751  for( row = row_min; row <= row_max; row++ )
752  {
753  for( col = col_min; col <= col_max; col++ )
754  {
755  if( trace & 1 )
756  WriteCell( row, col, AR_SIDE_BOTTOM, color );
757 
758  if( trace & 2 )
759  WriteCell( row, col, AR_SIDE_TOP, color );
760  }
761  }
762 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:42
#define AR_SIDE_TOP
Definition: ar_matrix.h:41
int m_Ncols
Definition: ar_matrix.h:144
int m_GridRouting
Definition: ar_matrix.h:142
int color
Definition: DXF_plotter.cpp:57
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:65
int m_Nrows
Definition: ar_matrix.h:144
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:153
int m_RoutingLayersCount
Definition: ar_matrix.h:141
wxPoint GetBrdCoordOrigin()
Definition: ar_matrix.h:74
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149

References AR_SIDE_BOTTOM, AR_SIDE_TOP, color, GetBrdCoordOrigin(), m_GridRouting, m_Ncols, m_Nrows, m_routeLayerBottom, m_routeLayerTop, m_RoutingLayersCount, SetCellOperation(), and WriteCell().

◆ TraceSegmentPcb()

void AR_MATRIX::TraceSegmentPcb ( PCB_SHAPE aShape,
int  aColor,
int  aMargin,
AR_MATRIX::CELL_OP  op_logic 
)

Definition at line 765 of file ar_matrix.cpp.

767 {
768  int half_width = ( aShape->GetWidth() / 2 ) + aMargin;
769 
770  // Calculate the bounding rectangle of the segment (if H, V or Via)
771  LAYER_NUM layer = UNDEFINED_LAYER; // Draw on all layers
772 
773  if( aShape->GetShape() == SHAPE_T::CIRCLE || aShape->GetShape() == SHAPE_T::SEGMENT )
774  {
775  int ux0 = aShape->GetStart().x - GetBrdCoordOrigin().x;
776  int uy0 = aShape->GetStart().y - GetBrdCoordOrigin().y;
777  int ux1 = aShape->GetEnd().x - GetBrdCoordOrigin().x;
778  int uy1 = aShape->GetEnd().y - GetBrdCoordOrigin().y;
779 
780  if( aShape->GetShape() == SHAPE_T::CIRCLE )
781  traceCircle( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
782  else
783  drawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
784  }
785  else if( aShape->GetShape() == SHAPE_T::ARC )
786  {
787  int ux0 = aShape->GetCenter().x - GetBrdCoordOrigin().x;
788  int uy0 = aShape->GetCenter().y - GetBrdCoordOrigin().y;
789  int ux1 = aShape->GetStart().x - GetBrdCoordOrigin().x;
790  int uy1 = aShape->GetStart().y - GetBrdCoordOrigin().y;
791 
792  traceArc( ux0, uy0, ux1, uy1, aShape->GetArcAngle(), half_width, layer, aColor, op_logic );
793  }
794 }
void traceArc(int ux0, int uy0, int ux1, int uy1, double ArcAngle, int lg, LAYER_NUM layer, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:571
int GetWidth() const
Definition: eda_shape.h:89
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
double GetArcAngle() const
Definition: eda_shape.cpp:495
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:79
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, CELL_OP op_logic)
Definition: ar_matrix.cpp:285
void traceCircle(int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:411
wxPoint GetBrdCoordOrigin()
Definition: ar_matrix.h:74
SHAPE_T GetShape() const
Definition: eda_shape.h:92

References ARC, CIRCLE, drawSegmentQcq(), EDA_SHAPE::GetArcAngle(), GetBrdCoordOrigin(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), SEGMENT, traceArc(), traceCircle(), and UNDEFINED_LAYER.

Referenced by AR_AUTOPLACER::genPlacementRoutingMatrix().

◆ UnInitRoutingMatrix()

void AR_MATRIX::UnInitRoutingMatrix ( )

Definition at line 128 of file ar_matrix.cpp.

129 {
130  int ii;
131 
132  for( ii = 0; ii < AR_MAX_ROUTING_LAYERS_COUNT; ii++ )
133  {
134  // de-allocate Distances matrix
135  if( m_DistSide[ii] )
136  {
137  delete[] m_DistSide[ii];
138  m_DistSide[ii] = nullptr;
139  }
140 
141  // de-allocate cells matrix
142  if( m_BoardSide[ii] )
143  {
144  delete[] m_BoardSide[ii];
145  m_BoardSide[ii] = nullptr;
146  }
147  }
148 
149  m_Nrows = m_Ncols = 0;
150 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
int m_Ncols
Definition: ar_matrix.h:144
int m_Nrows
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition: ar_matrix.h:39

References AR_MAX_ROUTING_LAYERS_COUNT, m_BoardSide, m_DistSide, m_Ncols, and m_Nrows.

Referenced by AR_AUTOPLACER::AutoplaceFootprints(), and AR_AUTOPLACER::genPlacementRoutingMatrix().

◆ WriteCell()

void AR_MATRIX::WriteCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)
inline

Definition at line 65 of file ar_matrix.h.

66  {
67  ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
68  }
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:153

References m_opWriteCell.

Referenced by traceFilledCircle(), and TraceFilledRectangle().

◆ XorCell()

void AR_MATRIX::XorCell ( int  aRow,
int  aCol,
int  aSide,
MATRIX_CELL  aCell 
)

Definition at line 202 of file ar_matrix.cpp.

203 {
204  MATRIX_CELL* p;
205 
206  p = m_BoardSide[aSide];
207  p[aRow * m_Ncols + aCol] ^= x;
208 }
int m_Ncols
Definition: ar_matrix.h:144
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

Member Data Documentation

◆ m_BoardSide

◆ m_BrdBox

◆ m_DistSide

DIST_CELL* AR_MATRIX::m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]

Definition at line 139 of file ar_matrix.h.

Referenced by AR_MATRIX(), GetDist(), InitRoutingMatrix(), SetDist(), and UnInitRoutingMatrix().

◆ m_GridRouting

◆ m_MemSize

int AR_MATRIX::m_MemSize

Definition at line 145 of file ar_matrix.h.

Referenced by AR_MATRIX(), and InitRoutingMatrix().

◆ m_Ncols

◆ m_Nrows

◆ m_opWriteCell

void( AR_MATRIX::* AR_MATRIX::m_opWriteCell) (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
private

Definition at line 153 of file ar_matrix.h.

Referenced by AR_MATRIX(), SetCellOperation(), and WriteCell().

◆ m_RouteCount

int AR_MATRIX::m_RouteCount

Definition at line 146 of file ar_matrix.h.

Referenced by AR_MATRIX(), and InitRoutingMatrix().

◆ m_routeLayerBottom

◆ m_routeLayerTop

◆ m_RoutingLayersCount


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