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 The 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, see <https://www.gnu.org/licenses/>.
22 */
23
24
25#pragma once
26
27#include <math/box2.h>
28
29class PCB_SHAPE;
30class PAD;
31class FOOTPRINT;
32class LSET;
33
34#define AR_MAX_ROUTING_LAYERS_COUNT 2
35
36#define AR_SIDE_TOP 0
37#define AR_SIDE_BOTTOM 1
38
43{
44public:
45 typedef unsigned char MATRIX_CELL;
46 typedef int DIST_CELL;
47
56
57 AR_MATRIX();
59
60 void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell )
61 {
62 ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
63 }
64
70 {
71 return m_BrdBox.GetOrigin();
72 }
73
78 bool ComputeMatrixSize( const BOX2I& aBoundingBox );
79
86
88
89 // Initialize WriteCell to make the aLogicOp
90 void SetCellOperation( CELL_OP aLogicOp );
91
92 // functions to read/write one cell ( point on grid routing matrix:
93 MATRIX_CELL GetCell( int aRow, int aCol, int aSide );
94 void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
95 void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
96 void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
97 void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
98 void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
99 DIST_CELL GetDist( int aRow, int aCol, int aSide );
100 void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
101
102 void TracePcbShape( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
103
104 void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int margin, int aKeepOut, const LSET& aLayerMask );
105
106 void PlacePad( PAD* aPad, int color, int margin, AR_MATRIX::CELL_OP op_logic );
107
108 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& angle, const LSET& aLayerMask,
109 int color, AR_MATRIX::CELL_OP op_logic );
110
111 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const LSET& aLayerMask, int color,
112 AR_MATRIX::CELL_OP op_logic );
113
114private:
115 void drawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, CELL_OP op_logic );
116
117 void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic );
118
119 void traceFilledCircle( int cx, int cy, int radius, const LSET& aLayerMask, int color,
120 AR_MATRIX::CELL_OP op_logic );
121
122 void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg, int layer, int color,
123 AR_MATRIX::CELL_OP op_logic );
124
125public:
126 MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
127 DIST_CELL* m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides:
128 // distance to cells
129 int m_RoutingLayersCount; // Number of layers for autorouting (0 or 1)
130 int m_GridRouting; // Size of grid for autoplace/autoroute
131 BOX2I m_BrdBox; // Actual board bounding box
132 int m_Nrows, m_Ncols; // Matrix size
133 int m_MemSize; // Memory requirement, just for statistics
134 int m_RouteCount; // Number of routes
135
136private:
137 // a pointer to the current selected cell operation
138 void ( AR_MATRIX::*m_opWriteCell )( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
139};
140
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition ar_matrix.h:34
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
void UnInitRoutingMatrix()
int m_Nrows
Definition ar_matrix.h:132
unsigned char MATRIX_CELL
Definition ar_matrix.h:45
BOX2I m_BrdBox
Definition ar_matrix.h:131
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void SetCellOperation(CELL_OP aLogicOp)
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition ar_matrix.h:138
void TracePcbShape(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
int m_RouteCount
Definition ar_matrix.h:134
int DIST_CELL
Definition ar_matrix.h:46
int m_RoutingLayersCount
Definition ar_matrix.h:129
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
@ WRITE_OR_CELL
Definition ar_matrix.h:51
@ WRITE_AND_CELL
Definition ar_matrix.h:53
@ WRITE_XOR_CELL
Definition ar_matrix.h:52
@ WRITE_ADD_CELL
Definition ar_matrix.h:54
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
int m_MemSize
Definition ar_matrix.h:133
int InitRoutingMatrix()
Initialize the data structures.
Definition ar_matrix.cpp:79
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition ar_matrix.h:126
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, CELL_OP op_logic)
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:49
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
int m_GridRouting
Definition ar_matrix.h:130
void traceCircle(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic)
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition ar_matrix.h:127
DIST_CELL GetDist(int aRow, int aCol, int aSide)
void CreateKeepOutRectangle(int ux0, int uy0, int ux1, int uy1, int margin, int aKeepOut, const LSET &aLayerMask)
Function CreateKeepOutRectangle builds the cost map: Cells ( in Dist map ) inside the rect x0,...
MATRIX_CELL GetCell(int aRow, int aCol, int aSide)
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)
void TraceFilledRectangle(int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE &angle, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
void traceFilledCircle(int cx, int cy, int radius, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
VECTOR2I GetBrdCoordOrigin()
Definition ar_matrix.h:69
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition ar_matrix.h:60
int m_Ncols
Definition ar_matrix.h:132
void PlacePad(PAD *aPad, int color, int margin, AR_MATRIX::CELL_OP op_logic)
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
int radius
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683