31#include <math_for_graphics.h>
176 return p[aRow *
m_Ncols + aCol];
241 return p[aRow *
m_Ncols + aCol];
265#define OP_CELL( layer, dy, dx ) \
267 if( layer == UNDEFINED_LAYER ) \
269 WriteCell( dy, dx, AR_SIDE_BOTTOM, color ); \
270 if( m_RoutingLayersCount > 1 ) \
271 WriteCell( dy, dx, AR_SIDE_TOP, color ); \
275 if( layer == m_routeLayerBottom ) \
276 WriteCell( dy, dx, AR_SIDE_BOTTOM, color ); \
277 if( m_RoutingLayersCount > 1 ) \
278 if( layer == m_routeLayerTop ) \
279 WriteCell( dy, dx, AR_SIDE_TOP, color ); \
292 int64_t row_max, col_max, row_min, col_min;
302 std::swap( ux1, ux0 );
303 std::swap( uy1, uy0 );
321 if( col_max > (
m_Ncols - 1 ) )
338 if( row_min > (
m_Nrows - 1 ) )
344 if( row_max > (
m_Nrows - 1 ) )
354 for( col = col_min; col <= col_max; col++ )
359 for( row = row_min; row <= row_max; row++ )
371 if( ( cx >= 0 ) && ( cx <= dx ) )
378 if( ( cx < 0 ) && ( cx >= -lg ) )
380 if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
386 if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
388 if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) ) <= ( lg * lg ) )
410 radius =
KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
418 nb_segm = ( 2 * radius ) / lg;
426 for( ii = 1; ii < nb_segm; ii++ )
444 int ux0, uy0, ux1, uy1;
445 int row_max, col_max, row_min, col_min;
447 double fdistmin, fdistx, fdisty;
483 if( row_max >= (
m_Nrows - 1 ) )
489 if( col_max >= (
m_Ncols - 1 ) )
493 if( row_min > row_max )
496 if( col_min > col_max )
499 fdistmin = (double) distmin * distmin;
501 for( row = row_min; row <= row_max; row++ )
506 for( col = col_min; col <= col_max; col++ )
511 if( fdistmin <= ( fdistx + fdisty ) )
531 fdistmin = ( (double) distmin * distmin ) * 2;
533 for( row = row_min; row <= row_max; row++ )
538 for( col = col_min; col <= col_max; col++ )
543 if( fdistmin <= ( fdistx + fdisty ) )
570 radius =
KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
579 nb_segm = ( 2 * radius ) / lg;
588 for( ii = 1; ii <= nb_segm; ii++ )
590 angle = arcAngle * ii / nb_segm;
610 int row_min, row_max, col_min, col_max;
633 cx = ( ux0 + ux1 ) / 2;
634 cy = ( uy0 + uy1 ) / 2;
635 radius =
KiROUND( Distance( ux0, uy0, cx, cy ) );
653 if( row_max >= (
m_Nrows - 1 ) )
659 if( col_max >= (
m_Ncols - 1 ) )
662 for( row = row_min; row <= row_max; row++ )
664 for( col = col_min; col <= col_max; col++ )
696 int row_min, row_max, col_min, col_max;
731 if( row_max >= (
m_Nrows - 1 ) )
737 if( col_max >= (
m_Ncols - 1 ) )
740 for( row = row_min; row <= row_max; row++ )
742 for( col = col_min; col <= col_max; col++ )
757 int half_width = ( aShape->
GetWidth() / 2 ) + aMargin;
762 if( aShape->
GetShape() == SHAPE_T::CIRCLE || aShape->
GetShape() == SHAPE_T::SEGMENT )
769 if( aShape->
GetShape() == SHAPE_T::CIRCLE )
770 traceCircle( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
772 drawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
774 else if( aShape->
GetShape() == SHAPE_T::ARC )
781 traceArc( ux0, uy0, ux1, uy1, aShape->
GetArcAngle(), half_width, layer, aColor, op_logic );
797 int ux0,
int uy0,
int ux1,
int uy1,
int marge,
int aKeepOut,
LSET aLayerMask )
800 int row_min, row_max, col_min, col_max, pmarge;
845 if( row_max >= (
m_Nrows - 1 ) )
851 if( col_max >= (
m_Ncols - 1 ) )
854 for( row = row_min; row <= row_max; row++ )
859 lgain = ( 256 * row ) / pmarge;
860 else if( row > row_max - pmarge )
861 lgain = ( 256 * ( row_max - row ) ) / pmarge;
863 for( col = col_min; col <= col_max; col++ )
872 LocalKeepOut = aKeepOut;
875 cgain = ( 256 * col ) / pmarge;
876 else if( col > col_max - pmarge )
877 cgain = ( 256 * ( col_max - col ) ) / pmarge;
879 cgain = ( cgain * lgain ) / 256;
882 LocalKeepOut = ( LocalKeepOut * cgain ) / 256;
893 data = std::max( data, LocalKeepOut );
#define OP_CELL(layer, dy, dx)
#define AR_MAX_ROUTING_LAYERS_COUNT
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void UnInitRoutingMatrix()
unsigned char MATRIX_CELL
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)
void TraceSegmentPcb(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
PCB_LAYER_ID m_routeLayerBottom
int InitRoutingMatrix()
Initialize the data structures.
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
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 ...
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
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]
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, LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
VECTOR2I GetBrdCoordOrigin()
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void TraceFilledRectangle(int ux0, int uy0, int ux1, int uy1, double angle, LSET aLayerMask, int color, 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,...
void PlacePad(PAD *aPad, int color, int marge, AR_MATRIX::CELL_OP op_logic)
PCB_LAYER_ID m_routeLayerTop
constexpr const Vec GetEnd() const
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr size_type GetHeight() const
constexpr void SetX(coord_type val)
constexpr void SetY(coord_type val)
constexpr void SetEnd(coord_type x, coord_type y)
int AsTenthsOfADegree() const
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
LSET is a set of PCB_LAYER_IDs.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_360
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I