KiCad PCB EDA Suite
ar_matrix.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
7  *
8  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 
29 #ifndef __AR_MATRIX_H
30 #define __AR_MATRIX_H
31 
32 #include <eda_rect.h>
33 #include <layer_ids.h>
34 
35 class PCB_SHAPE;
36 class PAD;
37 class FOOTPRINT;
38 
39 #define AR_MAX_ROUTING_LAYERS_COUNT 2
40 
41 #define AR_SIDE_TOP 0
42 #define AR_SIDE_BOTTOM 1
43 
47 class AR_MATRIX
48 {
49 public:
50  typedef unsigned char MATRIX_CELL;
51  typedef int DIST_CELL;
52 
53  enum CELL_OP
54  {
60  };
61 
62  AR_MATRIX();
63  ~AR_MATRIX();
64 
65  void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell )
66  {
67  ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
68  }
69 
75  {
76  return m_BrdBox.GetOrigin();
77  }
78 
87  bool ComputeMatrixSize( const EDA_RECT& aBoundingBox );
88 
94  int InitRoutingMatrix();
95 
96  void UnInitRoutingMatrix();
97 
98  // Initialize WriteCell to make the aLogicOp
99  void SetCellOperation( CELL_OP aLogicOp );
100 
101  // functions to read/write one cell ( point on grid routing matrix:
102  MATRIX_CELL GetCell( int aRow, int aCol, int aSide );
103  void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
104  void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
105  void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
106  void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
107  void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
108  DIST_CELL GetDist( int aRow, int aCol, int aSide );
109  void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
110 
111  void TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
112 
113  void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut,
114  LSET aLayerMask );
115 
116  void PlacePad( PAD* aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic );
117 
118  void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask,
119  int color, AR_MATRIX::CELL_OP op_logic );
120 
121  void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, LSET aLayerMask, int color,
122  AR_MATRIX::CELL_OP op_logic );
123 
124 private:
125  void drawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color,
126  CELL_OP op_logic );
127 
128  void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer, int color,
129  AR_MATRIX::CELL_OP op_logic );
130 
131  void traceFilledCircle( int cx, int cy, int radius, LSET aLayerMask, int color,
132  AR_MATRIX::CELL_OP op_logic );
133 
134  void traceArc( int ux0, int uy0, int ux1, int uy1, double ArcAngle, int lg, LAYER_NUM layer,
135  int color, AR_MATRIX::CELL_OP op_logic );
136 
137 public:
138  MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
139  DIST_CELL* m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides:
140  // distance to cells
141  int m_RoutingLayersCount; // Number of layers for autorouting (0 or 1)
142  int m_GridRouting; // Size of grid for autoplace/autoroute
143  EDA_RECT m_BrdBox; // Actual board bounding box
144  int m_Nrows, m_Ncols; // Matrix size
145  int m_MemSize; // Memory requirement, just for statistics
146  int m_RouteCount; // Number of routes
147 
150 
151 private:
152  // a pointer to the current selected cell operation
153  void ( AR_MATRIX::*m_opWriteCell )( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
154 };
155 
156 #endif
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
Handle the matrix routing that describes the actual board.
Definition: ar_matrix.h:47
int InitRoutingMatrix()
Initialize the data structures.
Definition: ar_matrix.cpp:91
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
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
EDA_RECT m_BrdBox
Definition: ar_matrix.h:143
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
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,...
Definition: ar_matrix.cpp:807
int DIST_CELL
Definition: ar_matrix.h:51
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:202
void PlacePad(PAD *aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:912
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:148
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:65
const wxPoint GetOrigin() const
Definition: eda_rect.h:101
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:191
MATRIX_CELL GetCell(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:169
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
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:153
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:138
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:180
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 TraceSegmentPcb(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:765
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:213
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
void UnInitRoutingMatrix()
Definition: ar_matrix.cpp:128
int m_RoutingLayersCount
Definition: ar_matrix.h:141
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxPoint GetBrdCoordOrigin()
Definition: ar_matrix.h:74
Handle the component boundary box.
Definition: eda_rect.h:42
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:224
void traceFilledCircle(int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:450
unsigned char MATRIX_CELL
Definition: ar_matrix.h:50
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
Definition: ar_matrix.cpp:244
bool ComputeMatrixSize(const EDA_RECT &aBoundingBox)
Calculate the number of rows and columns of dimensions of aPcb for routing and automatic calculation ...
Definition: ar_matrix.cpp:61
Definition: pad.h:57
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition: ar_matrix.h:39
int m_RouteCount
Definition: ar_matrix.h:146
DIST_CELL GetDist(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:234
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:149