KiCad PCB EDA Suite
AR_MATRIX Class Reference

AR_MATRIX 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
 
typedef char DIR_CELL
 

Public Member Functions

 AR_MATRIX ()
 
 ~AR_MATRIX ()
 
void WriteCell (int aRow, int aCol, int aSide, MATRIX_CELL aCell)
 
wxPoint GetBrdCoordOrigin ()
 function GetBrdCoordOrigin More...
 
bool ComputeMatrixSize (const EDA_RECT &aBoundingBox)
 Function ComputeMatrixSize calculates the number of rows and columns of dimensions of aPcb for routing and automatic calculation of area. More...
 
int InitRoutingMatrix ()
 Function InitBoard initializes 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 (DRAWSEGMENT *pt_segm, int color, int marge, 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 (D_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]
 
DIR_CELLm_DirSide [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

AR_MATRIX handle the matrix routing that describes the actual board.

Definition at line 49 of file ar_matrix.h.

Member Typedef Documentation

◆ DIR_CELL

typedef char AR_MATRIX::DIR_CELL

Definition at line 54 of file ar_matrix.h.

◆ DIST_CELL

typedef int AR_MATRIX::DIST_CELL

Definition at line 53 of file ar_matrix.h.

◆ MATRIX_CELL

typedef unsigned char AR_MATRIX::MATRIX_CELL

Definition at line 52 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 76 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_DirSide[0] = nullptr;
43  m_DirSide[1] = nullptr;
44  m_opWriteCell = nullptr;
45  m_Nrows = 0;
46  m_Ncols = 0;
47  m_MemSize = 0;
49  m_GridRouting = 0;
50  m_RouteCount = 0;
53 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:57
int m_MemSize
Definition: ar_matrix.h:65
int m_Ncols
Definition: ar_matrix.h:64
int m_GridRouting
Definition: ar_matrix.h:62
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:68
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:73
int m_Nrows
Definition: ar_matrix.h:64
DIR_CELL * m_DirSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:59
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
int m_RoutingLayersCount
Definition: ar_matrix.h:61
int m_RouteCount
Definition: ar_matrix.h:66
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:69

References B_Cu, F_Cu, m_BoardSide, m_DirSide, 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 56 of file ar_matrix.cpp.

57 {
58 }

Member Function Documentation

◆ AddCell()

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

Definition at line 242 of file ar_matrix.cpp.

243 {
244  MATRIX_CELL* p;
245 
246  p = m_BoardSide[aSide];
247  p[aRow * m_Ncols + aCol] += x;
248 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

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 231 of file ar_matrix.cpp.

232 {
233  MATRIX_CELL* p;
234 
235  p = m_BoardSide[aSide];
236  p[aRow * m_Ncols + aCol] &= x;
237 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

◆ ComputeMatrixSize()

bool AR_MATRIX::ComputeMatrixSize ( const EDA_RECT aBoundingBox)

Function ComputeMatrixSize calculates the number of rows and columns of dimensions of aPcb for routing and automatic calculation of area.

Parameters
aPcb= the physical board
aUseBoardEdgesOnly= true to use board edges only, = false to use the full board bounding box (default)

Definition at line 63 of file ar_matrix.cpp.

64 {
65  // The boundary box must have its start point on routing grid:
66  m_BrdBox = aBoundingBox;
67 
70 
71  // The boundary box must have its end point on routing grid:
72  wxPoint end = m_BrdBox.GetEnd();
73 
74  end.x -= end.x % m_GridRouting;
75  end.x += m_GridRouting;
76 
77  end.y -= end.y % m_GridRouting;
78  end.y += m_GridRouting;
79 
80  m_BrdBox.SetEnd( end );
81 
84 
85  // gives a small margin
86  m_Ncols += 1;
87  m_Nrows += 1;
88 
89  return true;
90 }
int m_Ncols
Definition: ar_matrix.h:64
int GetX() const
Definition: eda_rect.h:111
int m_GridRouting
Definition: ar_matrix.h:62
EDA_RECT m_BrdBox
Definition: ar_matrix.h:63
int GetWidth() const
Definition: eda_rect.h:119
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetEnd(int x, int y)
Definition: eda_rect.h:192
int m_Nrows
Definition: ar_matrix.h:64
void SetX(int val)
Definition: eda_rect.h:168
int GetHeight() const
Definition: eda_rect.h:120
void SetY(int val)
Definition: eda_rect.h:174
int GetY() const
Definition: eda_rect.h:112

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(), EDA_RECT::SetY(), wxPoint::x, and wxPoint::y.

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 834 of file ar_matrix.cpp.

836 {
837  int row, col;
838  int row_min, row_max, col_min, col_max, pmarge;
839  int trace = 0;
840  DIST_CELL data, LocalKeepOut;
841  int lgain, cgain;
842 
843  if( aLayerMask[m_routeLayerBottom] )
844  trace = 1; // Trace on bottom layer.
845 
846  if( aLayerMask[m_routeLayerTop] && m_RoutingLayersCount )
847  trace |= 2; // Trace on top layer.
848 
849  if( trace == 0 )
850  return;
851 
852  ux0 -= m_BrdBox.GetX();
853  uy0 -= m_BrdBox.GetY();
854  ux1 -= m_BrdBox.GetX();
855  uy1 -= m_BrdBox.GetY();
856 
857  ux0 -= marge;
858  ux1 += marge;
859  uy0 -= marge;
860  uy1 += marge;
861 
862  pmarge = marge / m_GridRouting;
863 
864  if( pmarge < 1 )
865  pmarge = 1;
866 
867  // Calculate the coordinate limits of the rectangle.
868  row_max = uy1 / m_GridRouting;
869  col_max = ux1 / m_GridRouting;
870  row_min = uy0 / m_GridRouting;
871 
872  if( uy0 > row_min * m_GridRouting )
873  row_min++;
874 
875  col_min = ux0 / m_GridRouting;
876 
877  if( ux0 > col_min * m_GridRouting )
878  col_min++;
879 
880  if( row_min < 0 )
881  row_min = 0;
882 
883  if( row_max >= ( m_Nrows - 1 ) )
884  row_max = m_Nrows - 1;
885 
886  if( col_min < 0 )
887  col_min = 0;
888 
889  if( col_max >= ( m_Ncols - 1 ) )
890  col_max = m_Ncols - 1;
891 
892  for( row = row_min; row <= row_max; row++ )
893  {
894  lgain = 256;
895 
896  if( row < pmarge )
897  lgain = ( 256 * row ) / pmarge;
898  else if( row > row_max - pmarge )
899  lgain = ( 256 * ( row_max - row ) ) / pmarge;
900 
901  for( col = col_min; col <= col_max; col++ )
902  {
903  // RoutingMatrix Dist map containt the "cost" of the cell
904  // at position (row, col)
905  // in autoplace this is the cost of the cell, when
906  // a footprint overlaps it, near a "master" footprint
907  // this cost is hight near the "master" footprint
908  // and decrease with the distance
909  cgain = 256;
910  LocalKeepOut = aKeepOut;
911 
912  if( col < pmarge )
913  cgain = ( 256 * col ) / pmarge;
914  else if( col > col_max - pmarge )
915  cgain = ( 256 * ( col_max - col ) ) / pmarge;
916 
917  cgain = ( cgain * lgain ) / 256;
918 
919  if( cgain != 256 )
920  LocalKeepOut = ( LocalKeepOut * cgain ) / 256;
921 
922  if( trace & 1 )
923  {
924  data = GetDist( row, col, AR_SIDE_BOTTOM ) + LocalKeepOut;
925  SetDist( row, col, AR_SIDE_BOTTOM, data );
926  }
927 
928  if( trace & 2 )
929  {
930  data = GetDist( row, col, AR_SIDE_TOP );
931  data = std::max( data, LocalKeepOut );
932  SetDist( row, col, AR_SIDE_TOP, data );
933  }
934  }
935  }
936 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:43
#define AR_SIDE_TOP
Definition: ar_matrix.h:42
int m_Ncols
Definition: ar_matrix.h:64
int GetX() const
Definition: eda_rect.h:111
int m_GridRouting
Definition: ar_matrix.h:62
EDA_RECT m_BrdBox
Definition: ar_matrix.h:63
int DIST_CELL
Definition: ar_matrix.h:53
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:68
int m_Nrows
Definition: ar_matrix.h:64
int m_RoutingLayersCount
Definition: ar_matrix.h:61
int GetY() const
Definition: eda_rect.h:112
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
Definition: ar_matrix.cpp:262
DIST_CELL GetDist(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:252
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:69

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 303 of file ar_matrix.cpp.

305 {
306  int64_t row, col;
307  int64_t inc;
308  int64_t row_max, col_max, row_min, col_min;
309  int64_t demi_pas;
310 
311  int cx, cy, dx, dy;
312 
313 
314  //printf("segmQcq %d %d %d %d\n", ux0, uy0, ux1, uy1);
315 
316  SetCellOperation( op_logic );
317 
318  // Make coordinate ux1 tj > ux0 to simplify calculations
319  if( ux1 < ux0 )
320  {
321  std::swap( ux1, ux0 );
322  std::swap( uy1, uy0 );
323  }
324 
325  // Calculating the incrementing the Y axis
326  inc = 1;
327 
328  if( uy1 < uy0 )
329  inc = -1;
330 
331  demi_pas = m_GridRouting / 2;
332 
333  col_min = ( ux0 - lg ) / m_GridRouting;
334 
335  if( col_min < 0 )
336  col_min = 0;
337 
338  col_max = ( ux1 + lg + demi_pas ) / m_GridRouting;
339 
340  if( col_max > ( m_Ncols - 1 ) )
341  col_max = m_Ncols - 1;
342 
343  if( inc > 0 )
344  {
345  row_min = ( uy0 - lg ) / m_GridRouting;
346  row_max = ( uy1 + lg + demi_pas ) / m_GridRouting;
347  }
348  else
349  {
350  row_min = ( uy1 - lg ) / m_GridRouting;
351  row_max = ( uy0 + lg + demi_pas ) / m_GridRouting;
352  }
353 
354  if( row_min < 0 )
355  row_min = 0;
356 
357  if( row_min > ( m_Nrows - 1 ) )
358  row_min = m_Nrows - 1;
359 
360  if( row_max < 0 )
361  row_max = 0;
362 
363  if( row_max > ( m_Nrows - 1 ) )
364  row_max = m_Nrows - 1;
365 
366  dx = ux1 - ux0;
367  dy = uy1 - uy0;
368 
369  double angle;
370  if( dx )
371  {
372  angle = ArcTangente( dy, dx );
373  }
374  else
375  {
376  angle = 900;
377 
378  if( dy < 0 )
379  angle = -900;
380  }
381 
382  RotatePoint( &dx, &dy, angle ); // dx = length, dy = 0
383 
384 
385  //printf("col_min %d max %d row_min %d max %d\n", col_min, col_max, row_min, row_max);
386 
387  for( col = col_min; col <= col_max; col++ )
388  {
389  int64_t cxr;
390  cxr = ( col * m_GridRouting ) - ux0;
391 
392  for( row = row_min; row <= row_max; row++ )
393  {
394  cy = ( row * m_GridRouting ) - uy0;
395  cx = cxr;
396  RotatePoint( &cx, &cy, angle );
397 
398  if( abs( cy ) > lg )
399  continue; // The point is too far on the Y axis.
400 
401  /* This point a test is close to the segment: the position
402  * along the X axis must be tested.
403  */
404  if( ( cx >= 0 ) && ( cx <= dx ) )
405  {
406  OP_CELL( layer, row, col );
407  continue;
408  }
409 
410  // Examination of extremities are rounded.
411  if( ( cx < 0 ) && ( cx >= -lg ) )
412  {
413  if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
414  OP_CELL( layer, row, col );
415 
416  continue;
417  }
418 
419  if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
420  {
421  if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) ) <= ( lg * lg ) )
422  OP_CELL( layer, row, col );
423 
424  continue;
425  }
426  }
427  }
428 }
int m_Ncols
Definition: ar_matrix.h:64
int m_GridRouting
Definition: ar_matrix.h:62
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
int m_Nrows
Definition: ar_matrix.h:64
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:171
#define OP_CELL(layer, dy, dx)
Definition: ar_matrix.cpp:281
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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

function GetBrdCoordOrigin

Returns
the board coordinate corresponding to the routing matrix origin ( board coordinate offset )

Definition at line 98 of file ar_matrix.h.

99  {
100  return m_BrdBox.GetOrigin();
101  }
EDA_RECT m_BrdBox
Definition: ar_matrix.h:63
const wxPoint GetOrigin() const
Definition: eda_rect.h:114

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 187 of file ar_matrix.cpp.

188 {
189  MATRIX_CELL* p;
190 
191  p = m_BoardSide[aSide];
192  return p[aRow * m_Ncols + aCol];
193 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

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 252 of file ar_matrix.cpp.

253 {
254  DIST_CELL* p;
255 
256  p = m_DistSide[aSide];
257  return p[aRow * m_Ncols + aCol];
258 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:57
int m_Ncols
Definition: ar_matrix.h:64
int DIST_CELL
Definition: ar_matrix.h:53

References m_DistSide, and m_Ncols.

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

◆ InitRoutingMatrix()

int AR_MATRIX::InitRoutingMatrix ( )

Function InitBoard initializes the data structures.

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

Definition at line 93 of file ar_matrix.cpp.

94 {
95  if( m_Nrows <= 0 || m_Ncols <= 0 )
96  return 0;
97 
98  // give a small margin for memory allocation:
99  int ii = ( m_Nrows + 1 ) * ( m_Ncols + 1 );
100 
101  int side = AR_SIDE_BOTTOM;
102  for( int jj = 0; jj < m_RoutingLayersCount; jj++ ) // m_RoutingLayersCount = 1 or 2
103  {
104  m_BoardSide[side] = nullptr;
105  m_DistSide[side] = nullptr;
106  m_DirSide[side] = nullptr;
107 
108  // allocate matrix & initialize everything to empty
109  m_BoardSide[side] = (MATRIX_CELL*) operator new( ii * sizeof( MATRIX_CELL ) );
110  memset( m_BoardSide[side], 0, ii * sizeof( MATRIX_CELL ) );
111 
112  if( m_BoardSide[side] == nullptr )
113  return -1;
114 
115  // allocate Distances
116  m_DistSide[side] = (DIST_CELL*) operator new( ii * sizeof( DIST_CELL ) );
117  memset( m_DistSide[side], 0, ii * sizeof( DIST_CELL ) );
118 
119  if( m_DistSide[side] == nullptr )
120  return -1;
121 
122  // allocate Dir (chars)
123  m_DirSide[side] = (char*) operator new( ii );
124  memset( m_DirSide[side], 0, ii );
125 
126  if( m_DirSide[side] == nullptr )
127  return -1;
128 
129  side = AR_SIDE_TOP;
130  }
131 
132  m_MemSize =
133  m_RouteCount * ii * ( sizeof( MATRIX_CELL ) + sizeof( DIST_CELL ) + sizeof( char ) );
134 
135  return m_MemSize;
136 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:43
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:57
int m_MemSize
Definition: ar_matrix.h:65
#define AR_SIDE_TOP
Definition: ar_matrix.h:42
int m_Ncols
Definition: ar_matrix.h:64
int DIST_CELL
Definition: ar_matrix.h:53
int m_Nrows
Definition: ar_matrix.h:64
DIR_CELL * m_DirSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:59
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
int m_RoutingLayersCount
Definition: ar_matrix.h:61
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52
int m_RouteCount
Definition: ar_matrix.h:66

References AR_SIDE_BOTTOM, AR_SIDE_TOP, m_BoardSide, m_DirSide, 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 209 of file ar_matrix.cpp.

210 {
211  MATRIX_CELL* p;
212 
213  p = m_BoardSide[aSide];
214  p[aRow * m_Ncols + aCol] |= x;
215 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

◆ PlacePad()

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

Definition at line 939 of file ar_matrix.cpp.

940 {
941  int dx, dy;
942  wxPoint shape_pos = aPad->ShapePos();
943 
944  dx = aPad->GetSize().x / 2;
945  dx += marge;
946 
947  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
948  {
949  traceFilledCircle( shape_pos.x, shape_pos.y, dx, aPad->GetLayerSet(), color, op_logic );
950  return;
951  }
952 
953  dy = aPad->GetSize().y / 2;
954  dy += marge;
955 
956  if( aPad->GetShape() == PAD_SHAPE_TRAPEZOID )
957  {
958  dx += abs( aPad->GetDelta().y ) / 2;
959  dy += abs( aPad->GetDelta().x ) / 2;
960  }
961 
962  // The pad is a rectangle ( horizontal or vertical )
963  if( int( aPad->GetOrientation() ) % 900 == 0 )
964  {
965  // Orientation turned 90 deg.
966  if( aPad->GetOrientation() == 900 || aPad->GetOrientation() == 2700 )
967  {
968  std::swap( dx, dy );
969  }
970 
971  TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx,
972  shape_pos.y + dy, aPad->GetLayerSet(), color, op_logic );
973  }
974  else
975  {
976  TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx,
977  shape_pos.y + dy, aPad->GetOrientation(), aPad->GetLayerSet(), color, op_logic );
978  }
979 }
int color
Definition: DXF_plotter.cpp:61
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:639
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:335
const wxSize & GetDelta() const
Definition: class_pad.h:227
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:325
wxPoint ShapePos() const
Definition: class_pad.cpp:563
void traceFilledCircle(int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:474
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
const wxSize & GetSize() const
Definition: class_pad.h:224

References color, D_PAD::GetDelta(), D_PAD::GetLayerSet(), D_PAD::GetOrientation(), D_PAD::GetShape(), D_PAD::GetSize(), PAD_SHAPE_CIRCLE, PAD_SHAPE_TRAPEZOID, D_PAD::ShapePos(), traceFilledCircle(), TraceFilledRectangle(), wxPoint::x, and wxPoint::y.

Referenced by AR_AUTOPLACER::genModuleOnRoutingMatrix().

◆ SetCell()

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

Definition at line 198 of file ar_matrix.cpp.

199 {
200  MATRIX_CELL* p;
201 
202  p = m_BoardSide[aSide];
203  p[aRow * m_Ncols + aCol] = x;
204 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

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 171 of file ar_matrix.cpp.

172 {
173  switch( aLogicOp )
174  {
175  default:
181  }
182 }
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:220
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:209
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:73
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:198
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:231
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:242

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 262 of file ar_matrix.cpp.

263 {
264  DIST_CELL* p;
265 
266  p = m_DistSide[aSide];
267  p[aRow * m_Ncols + aCol] = x;
268 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:57
int m_Ncols
Definition: ar_matrix.h:64
int DIST_CELL
Definition: ar_matrix.h:53

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 595 of file ar_matrix.cpp.

597 {
598  int radius, nb_segm;
599  int x0, y0, // Starting point of the current segment trace
600  x1, y1; // End point
601  int ii;
602  double angle, StAngle;
603 
604 
605  radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
606 
607  x0 = ux1 - ux0;
608  y0 = uy1 - uy0;
609  StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 );
610 
611  if( lg < 1 )
612  lg = 1;
613 
614  nb_segm = ( 2 * radius ) / lg;
615  nb_segm = ( nb_segm * std::abs( ArcAngle ) ) / 3600;
616 
617  if( nb_segm < 5 )
618  nb_segm = 5;
619 
620  if( nb_segm > 100 )
621  nb_segm = 100;
622 
623  for( ii = 1; ii <= nb_segm; ii++ )
624  {
625  angle = ( ArcAngle * ii ) / nb_segm;
626  angle += StAngle;
627 
629 
630  x1 = KiROUND( cosdecideg( radius, angle ) );
631  y1 = KiROUND( cosdecideg( radius, angle ) );
632  drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
633  x0 = x1;
634  y0 = y1;
635  }
636 }
int color
Definition: DXF_plotter.cpp:61
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
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:303
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:408
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:68
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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 435 of file ar_matrix.cpp.

437 {
438  int radius, nb_segm;
439  int x0, y0, // Starting point of the current segment trace.
440  x1, y1; // End point.
441  int ii;
442  int angle;
443 
444  radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
445 
446  x0 = x1 = radius;
447  y0 = y1 = 0;
448 
449  if( lg < 1 )
450  lg = 1;
451 
452  nb_segm = ( 2 * radius ) / lg;
453 
454  if( nb_segm < 5 )
455  nb_segm = 5;
456 
457  if( nb_segm > 100 )
458  nb_segm = 100;
459 
460  for( ii = 1; ii < nb_segm; ii++ )
461  {
462  angle = ( 3600 * ii ) / nb_segm;
463  x1 = KiROUND( cosdecideg( radius, angle ) );
464  y1 = KiROUND( sindecideg( radius, angle ) );
465  drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
466  x0 = x1;
467  y0 = y1;
468  }
469 
470  drawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + radius, uy0, lg, layer, color, op_logic );
471 }
int color
Definition: DXF_plotter.cpp:61
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:303
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:408
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:399
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:68

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 474 of file ar_matrix.cpp.

476 {
477  int row, col;
478  int ux0, uy0, ux1, uy1;
479  int row_max, col_max, row_min, col_min;
480  int trace = 0;
481  double fdistmin, fdistx, fdisty;
482  int tstwrite = 0;
483  int distmin;
484 
485  if( aLayerMask[m_routeLayerBottom] )
486  trace = 1; // Trace on BOTTOM
487 
488  if( aLayerMask[m_routeLayerTop] )
489  if( m_RoutingLayersCount > 1 )
490  trace |= 2; // Trace on TOP
491 
492  if( trace == 0 )
493  return;
494 
495  SetCellOperation( op_logic );
496 
497  cx -= GetBrdCoordOrigin().x;
498  cy -= GetBrdCoordOrigin().y;
499 
500  distmin = radius;
501 
502  // Calculate the bounding rectangle of the circle.
503  ux0 = cx - radius;
504  uy0 = cy - radius;
505  ux1 = cx + radius;
506  uy1 = cy + radius;
507 
508  // Calculate limit coordinates of cells belonging to the rectangle.
509  row_max = uy1 / m_GridRouting;
510  col_max = ux1 / m_GridRouting;
511  row_min = uy0 / m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
512  col_min = ux0 / m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
513 
514  if( row_min < 0 )
515  row_min = 0;
516 
517  if( row_max >= ( m_Nrows - 1 ) )
518  row_max = m_Nrows - 1;
519 
520  if( col_min < 0 )
521  col_min = 0;
522 
523  if( col_max >= ( m_Ncols - 1 ) )
524  col_max = m_Ncols - 1;
525 
526  // Calculate coordinate limits of cell belonging to the rectangle.
527  if( row_min > row_max )
528  row_max = row_min;
529 
530  if( col_min > col_max )
531  col_max = col_min;
532 
533  fdistmin = (double) distmin * distmin;
534 
535  for( row = row_min; row <= row_max; row++ )
536  {
537  fdisty = (double) ( cy - ( row * m_GridRouting ) );
538  fdisty *= fdisty;
539 
540  for( col = col_min; col <= col_max; col++ )
541  {
542  fdistx = (double) ( cx - ( col * m_GridRouting ) );
543  fdistx *= fdistx;
544 
545  if( fdistmin <= ( fdistx + fdisty ) )
546  continue;
547 
548  if( trace & 1 )
549  WriteCell( row, col, AR_SIDE_BOTTOM, color );
550 
551  if( trace & 2 )
552  WriteCell( row, col, AR_SIDE_TOP, color );
553 
554  tstwrite = 1;
555  }
556  }
557 
558  if( tstwrite )
559  return;
560 
561  /* If no cell has been written, it affects the 4 neighboring diagonal
562  * (Adverse event: pad off grid in the center of the 4 neighboring
563  * diagonal) */
564  distmin = m_GridRouting / 2 + 1;
565  fdistmin = ( (double) distmin * distmin ) * 2; // Distance to center point diagonally
566 
567  for( row = row_min; row <= row_max; row++ )
568  {
569  fdisty = (double) ( cy - ( row * m_GridRouting ) );
570  fdisty *= fdisty;
571 
572  for( col = col_min; col <= col_max; col++ )
573  {
574  fdistx = (double) ( cx - ( col * m_GridRouting ) );
575  fdistx *= fdistx;
576 
577  if( fdistmin <= ( fdistx + fdisty ) )
578  continue;
579 
580  if( trace & 1 )
581  WriteCell( row, col, AR_SIDE_BOTTOM, color );
582 
583  if( trace & 2 )
584  WriteCell( row, col, AR_SIDE_TOP, color );
585  }
586  }
587 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:43
#define AR_SIDE_TOP
Definition: ar_matrix.h:42
int m_Ncols
Definition: ar_matrix.h:64
int m_GridRouting
Definition: ar_matrix.h:62
int color
Definition: DXF_plotter.cpp:61
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:68
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:88
int m_Nrows
Definition: ar_matrix.h:64
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:171
int m_RoutingLayersCount
Definition: ar_matrix.h:61
wxPoint GetBrdCoordOrigin()
function GetBrdCoordOrigin
Definition: ar_matrix.h:98
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:69

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

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 639 of file ar_matrix.cpp.

641 {
642  int row, col;
643  int cx, cy; // Center of rectangle
644  int radius; // Radius of the circle
645  int row_min, row_max, col_min, col_max;
646  int rotrow, rotcol;
647  int trace = 0;
648 
649  if( aLayerMask[m_routeLayerBottom] )
650  trace = 1; // Trace on BOTTOM
651 
652  if( aLayerMask[m_routeLayerTop] )
653  {
654  if( m_RoutingLayersCount > 1 )
655  trace |= 2; // Trace on TOP
656  }
657 
658  if( trace == 0 )
659  return;
660 
661  SetCellOperation( op_logic );
662 
663  ux0 -= GetBrdCoordOrigin().x;
664  uy0 -= GetBrdCoordOrigin().y;
665  ux1 -= GetBrdCoordOrigin().x;
666  uy1 -= GetBrdCoordOrigin().y;
667 
668  cx = ( ux0 + ux1 ) / 2;
669  cy = ( uy0 + uy1 ) / 2;
670  radius = KiROUND( Distance( ux0, uy0, cx, cy ) );
671 
672  // Calculating coordinate limits belonging to the rectangle.
673  row_max = ( cy + radius ) / m_GridRouting;
674  col_max = ( cx + radius ) / m_GridRouting;
675  row_min = ( cy - radius ) / m_GridRouting;
676 
677  if( uy0 > row_min * m_GridRouting )
678  row_min++;
679 
680  col_min = ( cx - radius ) / m_GridRouting;
681 
682  if( ux0 > col_min * m_GridRouting )
683  col_min++;
684 
685  if( row_min < 0 )
686  row_min = 0;
687 
688  if( row_max >= ( m_Nrows - 1 ) )
689  row_max = m_Nrows - 1;
690 
691  if( col_min < 0 )
692  col_min = 0;
693 
694  if( col_max >= ( m_Ncols - 1 ) )
695  col_max = m_Ncols - 1;
696 
697  for( row = row_min; row <= row_max; row++ )
698  {
699  for( col = col_min; col <= col_max; col++ )
700  {
701  rotrow = row * m_GridRouting;
702  rotcol = col * m_GridRouting;
703  RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
704 
705  if( rotrow <= uy0 )
706  continue;
707 
708  if( rotrow >= uy1 )
709  continue;
710 
711  if( rotcol <= ux0 )
712  continue;
713 
714  if( rotcol >= ux1 )
715  continue;
716 
717  if( trace & 1 )
718  WriteCell( row, col, AR_SIDE_BOTTOM, color );
719 
720  if( trace & 2 )
721  WriteCell( row, col, AR_SIDE_TOP, color );
722  }
723  }
724 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:43
#define AR_SIDE_TOP
Definition: ar_matrix.h:42
int m_Ncols
Definition: ar_matrix.h:64
int m_GridRouting
Definition: ar_matrix.h:62
int color
Definition: DXF_plotter.cpp:61
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:68
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:88
int m_Nrows
Definition: ar_matrix.h:64
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:171
int m_RoutingLayersCount
Definition: ar_matrix.h:61
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxPoint GetBrdCoordOrigin()
function GetBrdCoordOrigin
Definition: ar_matrix.h:98
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:68
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:69

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(), WriteCell(), wxPoint::x, and wxPoint::y.

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 727 of file ar_matrix.cpp.

729 {
730  int row, col;
731  int row_min, row_max, col_min, col_max;
732  int trace = 0;
733 
734  if( aLayerMask[m_routeLayerBottom] )
735  trace = 1; // Trace on BOTTOM
736 
737  if( aLayerMask[m_routeLayerTop] && m_RoutingLayersCount > 1 )
738  trace |= 2; // Trace on TOP
739 
740  if( trace == 0 )
741  return;
742 
743  SetCellOperation( op_logic );
744 
745  ux0 -= GetBrdCoordOrigin().x;
746  uy0 -= GetBrdCoordOrigin().y;
747  ux1 -= GetBrdCoordOrigin().x;
748  uy1 -= GetBrdCoordOrigin().y;
749 
750  // Calculating limits coord cells belonging to the rectangle.
751  row_max = uy1 / m_GridRouting;
752  col_max = ux1 / m_GridRouting;
753  row_min = uy0 / m_GridRouting;
754 
755  if( uy0 > row_min * m_GridRouting )
756  row_min++;
757 
758  col_min = ux0 / m_GridRouting;
759 
760  if( ux0 > col_min * m_GridRouting )
761  col_min++;
762 
763  if( row_min < 0 )
764  row_min = 0;
765 
766  if( row_max >= ( m_Nrows - 1 ) )
767  row_max = m_Nrows - 1;
768 
769  if( col_min < 0 )
770  col_min = 0;
771 
772  if( col_max >= ( m_Ncols - 1 ) )
773  col_max = m_Ncols - 1;
774 
775  for( row = row_min; row <= row_max; row++ )
776  {
777  for( col = col_min; col <= col_max; col++ )
778  {
779  if( trace & 1 )
780  WriteCell( row, col, AR_SIDE_BOTTOM, color );
781 
782  if( trace & 2 )
783  WriteCell( row, col, AR_SIDE_TOP, color );
784  }
785  }
786 }
#define AR_SIDE_BOTTOM
Definition: ar_matrix.h:43
#define AR_SIDE_TOP
Definition: ar_matrix.h:42
int m_Ncols
Definition: ar_matrix.h:64
int m_GridRouting
Definition: ar_matrix.h:62
int color
Definition: DXF_plotter.cpp:61
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:68
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:88
int m_Nrows
Definition: ar_matrix.h:64
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:171
int m_RoutingLayersCount
Definition: ar_matrix.h:61
wxPoint GetBrdCoordOrigin()
function GetBrdCoordOrigin
Definition: ar_matrix.h:98
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:69

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

◆ TraceSegmentPcb()

void AR_MATRIX::TraceSegmentPcb ( DRAWSEGMENT pt_segm,
int  color,
int  marge,
AR_MATRIX::CELL_OP  op_logic 
)

Definition at line 789 of file ar_matrix.cpp.

791 {
792  int half_width = ( pt_segm->GetWidth() / 2 ) + marge;
793 
794  // Calculate the bounding rectangle of the segment (if H, V or Via)
795  int ux0 = pt_segm->GetStart().x - GetBrdCoordOrigin().x;
796  int uy0 = pt_segm->GetStart().y - GetBrdCoordOrigin().y;
797  int ux1 = pt_segm->GetEnd().x - GetBrdCoordOrigin().x;
798  int uy1 = pt_segm->GetEnd().y - GetBrdCoordOrigin().y;
799 
800  //printf("traceSegm %d %d %d %d\n", ux0, uy0, ux1, uy1);
801 
802  LAYER_NUM layer = UNDEFINED_LAYER; // Draw on all layers
803 
804  switch( pt_segm->GetShape() )
805  {
806  case S_CIRCLE:
807  traceCircle( ux0, uy0, ux1, uy1, half_width, layer, color, op_logic );
808  break;
809 
810  case S_ARC:
811  traceArc( ux0, uy0, ux1, uy1, pt_segm->GetAngle(), half_width, layer, color, op_logic );
812  break;
813 
814  case S_SEGMENT:
815  drawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, color, op_logic );
816  break;
817 
818  default:
819  break;
820  }
821 }
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:595
STROKE_T GetShape() const
int color
Definition: DXF_plotter.cpp:61
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Arcs (with rounded ends)
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:303
int GetWidth() const
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:435
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
double GetAngle() const
wxPoint GetBrdCoordOrigin()
function GetBrdCoordOrigin
Definition: ar_matrix.h:98
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.

References color, drawSegmentQcq(), DRAWSEGMENT::GetAngle(), GetBrdCoordOrigin(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), S_ARC, S_CIRCLE, S_SEGMENT, traceArc(), traceCircle(), UNDEFINED_LAYER, wxPoint::x, and wxPoint::y.

Referenced by AR_AUTOPLACER::genPlacementRoutingMatrix().

◆ UnInitRoutingMatrix()

void AR_MATRIX::UnInitRoutingMatrix ( )

Definition at line 139 of file ar_matrix.cpp.

140 {
141  int ii;
142 
143  for( ii = 0; ii < AR_MAX_ROUTING_LAYERS_COUNT; ii++ )
144  {
145  // de-allocate Dir matrix
146  if( m_DirSide[ii] )
147  {
148  delete m_DirSide[ii];
149  m_DirSide[ii] = nullptr;
150  }
151 
152  // de-allocate Distances matrix
153  if( m_DistSide[ii] )
154  {
155  delete m_DistSide[ii];
156  m_DistSide[ii] = nullptr;
157  }
158 
159  // de-allocate cells matrix
160  if( m_BoardSide[ii] )
161  {
162  delete m_BoardSide[ii];
163  m_BoardSide[ii] = nullptr;
164  }
165  }
166 
167  m_Nrows = m_Ncols = 0;
168 }
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:57
int m_Ncols
Definition: ar_matrix.h:64
int m_Nrows
Definition: ar_matrix.h:64
DIR_CELL * m_DirSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:59
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition: ar_matrix.h:40

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

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

◆ WriteCell()

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

Definition at line 88 of file ar_matrix.h.

89  {
90  ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
91  }
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:73

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 220 of file ar_matrix.cpp.

221 {
222  MATRIX_CELL* p;
223 
224  p = m_BoardSide[aSide];
225  p[aRow * m_Ncols + aCol] ^= x;
226 }
int m_Ncols
Definition: ar_matrix.h:64
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:56
unsigned char MATRIX_CELL
Definition: ar_matrix.h:52

References m_BoardSide, and m_Ncols.

Referenced by SetCellOperation().

Member Data Documentation

◆ m_BoardSide

◆ m_BrdBox

◆ m_DirSide

DIR_CELL* AR_MATRIX::m_DirSide[AR_MAX_ROUTING_LAYERS_COUNT]

Definition at line 59 of file ar_matrix.h.

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

◆ m_DistSide

DIST_CELL* AR_MATRIX::m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]

Definition at line 57 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 65 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 73 of file ar_matrix.h.

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

◆ m_RouteCount

int AR_MATRIX::m_RouteCount

Definition at line 66 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: