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#ifndef __AR_MATRIX_H
26#define __AR_MATRIX_H
27
28#include <layer_ids.h>
29#include <math/box2.h>
30
31class PCB_SHAPE;
32class PAD;
33class FOOTPRINT;
34class LSET;
35
36#define AR_MAX_ROUTING_LAYERS_COUNT 2
37
38#define AR_SIDE_TOP 0
39#define AR_SIDE_BOTTOM 1
40
45{
46public:
47 typedef unsigned char MATRIX_CELL;
48 typedef int DIST_CELL;
49
58
59 AR_MATRIX();
60 ~AR_MATRIX();
61
62 void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell )
63 {
64 ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
65 }
66
72 {
73 return m_BrdBox.GetOrigin();
74 }
75
84 bool ComputeMatrixSize( const BOX2I& aBoundingBox );
85
92
94
95 // Initialize WriteCell to make the aLogicOp
96 void SetCellOperation( CELL_OP aLogicOp );
97
98 // functions to read/write one cell ( point on grid routing matrix:
99 MATRIX_CELL GetCell( int aRow, int aCol, int aSide );
100 void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
101 void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
102 void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
103 void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
104 void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
105 DIST_CELL GetDist( int aRow, int aCol, int aSide );
106 void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
107
108 void TracePcbShape( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
109
110 void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut,
111 const LSET& aLayerMask );
112
113 void PlacePad( PAD* aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic );
114
115 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle, const LSET& aLayerMask,
116 int color, AR_MATRIX::CELL_OP op_logic );
117
118 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const LSET& aLayerMask, int color,
119 AR_MATRIX::CELL_OP op_logic );
120
121private:
122 void drawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color,
123 CELL_OP op_logic );
124
125 void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color,
126 AR_MATRIX::CELL_OP op_logic );
127
128 void traceFilledCircle( int cx, int cy, int radius, const LSET& aLayerMask, int color,
129 AR_MATRIX::CELL_OP op_logic );
130
131 void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg,
132 int layer, int color, AR_MATRIX::CELL_OP op_logic );
133
134public:
135 MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
136 DIST_CELL* m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides:
137 // distance to cells
138 int m_RoutingLayersCount; // Number of layers for autorouting (0 or 1)
139 int m_GridRouting; // Size of grid for autoplace/autoroute
140 BOX2I m_BrdBox; // Actual board bounding box
141 int m_Nrows, m_Ncols; // Matrix size
142 int m_MemSize; // Memory requirement, just for statistics
143 int m_RouteCount; // Number of routes
144
147
148private:
149 // a pointer to the current selected cell operation
150 void ( AR_MATRIX::*m_opWriteCell )( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
151};
152
153#endif
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition ar_matrix.h:36
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
void UnInitRoutingMatrix()
int m_Nrows
Definition ar_matrix.h:141
unsigned char MATRIX_CELL
Definition ar_matrix.h:47
void TraceFilledRectangle(int ux0, int uy0, int ux1, int uy1, double angle, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
BOX2I m_BrdBox
Definition ar_matrix.h:140
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void CreateKeepOutRectangle(int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut, const LSET &aLayerMask)
Function CreateKeepOutRectangle builds the cost map: Cells ( in Dist map ) inside the rect x0,...
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:150
void TracePcbShape(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
int m_RouteCount
Definition ar_matrix.h:143
int DIST_CELL
Definition ar_matrix.h:48
int m_RoutingLayersCount
Definition ar_matrix.h:138
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
@ WRITE_OR_CELL
Definition ar_matrix.h:53
@ WRITE_AND_CELL
Definition ar_matrix.h:55
@ WRITE_XOR_CELL
Definition ar_matrix.h:54
@ WRITE_ADD_CELL
Definition ar_matrix.h:56
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:142
PCB_LAYER_ID m_routeLayerBottom
Definition ar_matrix.h:146
int InitRoutingMatrix()
Initialize the data structures.
Definition ar_matrix.cpp:88
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition ar_matrix.h:135
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:58
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
int m_GridRouting
Definition ar_matrix.h:139
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:136
DIST_CELL GetDist(int aRow, int aCol, int aSide)
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 traceFilledCircle(int cx, int cy, int radius, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
VECTOR2I GetBrdCoordOrigin()
Definition ar_matrix.h:71
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition ar_matrix.h:62
int m_Ncols
Definition ar_matrix.h:141
void PlacePad(PAD *aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic)
PCB_LAYER_ID m_routeLayerTop
Definition ar_matrix.h:145
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
int radius
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683