KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 *
8 * Copyright (C) 1992-2022 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 <layer_ids.h>
33#include <math/box2.h>
34
35class PCB_SHAPE;
36class PAD;
37class FOOTPRINT;
38class LSET;
39
40#define AR_MAX_ROUTING_LAYERS_COUNT 2
41
42#define AR_SIDE_TOP 0
43#define AR_SIDE_BOTTOM 1
44
49{
50public:
51 typedef unsigned char MATRIX_CELL;
52 typedef int DIST_CELL;
53
55 {
61 };
62
63 AR_MATRIX();
64 ~AR_MATRIX();
65
66 void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell )
67 {
68 ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
69 }
70
76 {
77 return m_BrdBox.GetOrigin();
78 }
79
88 bool ComputeMatrixSize( const BOX2I& aBoundingBox );
89
96
98
99 // Initialize WriteCell to make the aLogicOp
100 void SetCellOperation( CELL_OP aLogicOp );
101
102 // functions to read/write one cell ( point on grid routing matrix:
103 MATRIX_CELL GetCell( int aRow, int aCol, int aSide );
104 void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
105 void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
106 void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
107 void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
108 void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
109 DIST_CELL GetDist( int aRow, int aCol, int aSide );
110 void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
111
112 void TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
113
114 void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut,
115 LSET aLayerMask );
116
117 void PlacePad( PAD* aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic );
118
119 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask,
120 int color, AR_MATRIX::CELL_OP op_logic );
121
122 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, LSET aLayerMask, int color,
123 AR_MATRIX::CELL_OP op_logic );
124
125private:
126 void drawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color,
127 CELL_OP op_logic );
128
129 void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color,
130 AR_MATRIX::CELL_OP op_logic );
131
132 void traceFilledCircle( int cx, int cy, int radius, LSET aLayerMask, int color,
133 AR_MATRIX::CELL_OP op_logic );
134
135 void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg,
136 int layer, int color, AR_MATRIX::CELL_OP op_logic );
137
138public:
139 MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
140 DIST_CELL* m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides:
141 // distance to cells
142 int m_RoutingLayersCount; // Number of layers for autorouting (0 or 1)
143 int m_GridRouting; // Size of grid for autoplace/autoroute
144 BOX2I m_BrdBox; // Actual board bounding box
145 int m_Nrows, m_Ncols; // Matrix size
146 int m_MemSize; // Memory requirement, just for statistics
147 int m_RouteCount; // Number of routes
148
151
152private:
153 // a pointer to the current selected cell operation
154 void ( AR_MATRIX::*m_opWriteCell )( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
155};
156
157#endif
int color
Definition: DXF_plotter.cpp:58
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition: ar_matrix.h:40
Handle the matrix routing that describes the actual board.
Definition: ar_matrix.h:49
void UnInitRoutingMatrix()
Definition: ar_matrix.cpp:130
int m_Nrows
Definition: ar_matrix.h:145
unsigned char MATRIX_CELL
Definition: ar_matrix.h:51
BOX2I m_BrdBox
Definition: ar_matrix.h:144
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:226
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:215
void SetCellOperation(CELL_OP aLogicOp)
Definition: ar_matrix.cpp:155
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:154
void TraceSegmentPcb(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:754
int m_RouteCount
Definition: ar_matrix.h:147
int DIST_CELL
Definition: ar_matrix.h:52
int m_RoutingLayersCount
Definition: ar_matrix.h:142
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:182
@ WRITE_OR_CELL
Definition: ar_matrix.h:57
@ WRITE_AND_CELL
Definition: ar_matrix.h:59
@ WRITE_XOR_CELL
Definition: ar_matrix.h:58
@ WRITE_CELL
Definition: ar_matrix.h:56
@ WRITE_ADD_CELL
Definition: ar_matrix.h:60
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:204
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
Definition: ar_matrix.cpp:246
int m_MemSize
Definition: ar_matrix.h:146
PCB_LAYER_ID m_routeLayerBottom
Definition: ar_matrix.h:150
int InitRoutingMatrix()
Initialize the data structures.
Definition: ar_matrix.cpp:93
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:139
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, CELL_OP op_logic)
Definition: ar_matrix.cpp:287
bool ComputeMatrixSize(const BOX2I &aBoundingBox)
Calculate the number of rows and columns of dimensions of aPcb for routing and automatic calculation ...
Definition: ar_matrix.cpp:63
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.cpp:193
int m_GridRouting
Definition: ar_matrix.h:143
void traceCircle(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:402
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition: ar_matrix.h:140
DIST_CELL GetDist(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:236
MATRIX_CELL GetCell(int aRow, int aCol, int aSide)
Definition: ar_matrix.cpp:171
void traceArc(int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE &arcAngle, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:561
void traceFilledCircle(int cx, int cy, int radius, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:440
VECTOR2I GetBrdCoordOrigin()
Definition: ar_matrix.h:75
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition: ar_matrix.h:66
int m_Ncols
Definition: ar_matrix.h:145
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:604
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:796
void PlacePad(PAD *aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic)
Definition: ar_matrix.cpp:901
PCB_LAYER_ID m_routeLayerTop
Definition: ar_matrix.h:149
constexpr const Vec & GetOrigin() const
Definition: box2.h:210
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
Definition: pad.h:54
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60