30#include <math_for_graphics.h>
175 return p[aRow *
m_Ncols + aCol];
240 return p[aRow *
m_Ncols + aCol];
264#define OP_CELL( layer, dy, dx ) \
266 if( layer == UNDEFINED_LAYER ) \
268 WriteCell( dy, dx, AR_SIDE_BOTTOM, color ); \
269 if( m_RoutingLayersCount > 1 ) \
270 WriteCell( dy, dx, AR_SIDE_TOP, color ); \
274 if( layer == m_routeLayerBottom ) \
275 WriteCell( dy, dx, AR_SIDE_BOTTOM, color ); \
276 if( m_RoutingLayersCount > 1 ) \
277 if( layer == m_routeLayerTop ) \
278 WriteCell( dy, dx, AR_SIDE_TOP, color ); \
291 int64_t row_max, col_max, row_min, col_min;
301 std::swap( ux1, ux0 );
302 std::swap( uy1, uy0 );
320 if( col_max > (
m_Ncols - 1 ) )
337 if( row_min > (
m_Nrows - 1 ) )
343 if( row_max > (
m_Nrows - 1 ) )
353 for( col = col_min; col <= col_max; col++ )
358 for( row = row_min; row <= row_max; row++ )
370 if( ( cx >= 0 ) && ( cx <= dx ) )
377 if( ( cx < 0 ) && ( cx >= -lg ) )
379 if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
385 if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
387 if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) ) <= ( lg * lg ) )
409 radius =
KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
417 nb_segm = ( 2 * radius ) / lg;
425 for( ii = 1; ii < nb_segm; ii++ )
443 int ux0, uy0, ux1, uy1;
444 int row_max, col_max, row_min, col_min;
446 double fdistmin, fdistx, fdisty;
482 if( row_max >= (
m_Nrows - 1 ) )
488 if( col_max >= (
m_Ncols - 1 ) )
492 if( row_min > row_max )
495 if( col_min > col_max )
498 fdistmin = (double) distmin * distmin;
500 for( row = row_min; row <= row_max; row++ )
505 for( col = col_min; col <= col_max; col++ )
510 if( fdistmin <= ( fdistx + fdisty ) )
530 fdistmin = ( (double) distmin * distmin ) * 2;
532 for( row = row_min; row <= row_max; row++ )
537 for( col = col_min; col <= col_max; col++ )
542 if( fdistmin <= ( fdistx + fdisty ) )
569 radius =
KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
578 nb_segm = ( 2 * radius ) / lg;
587 for( ii = 1; ii <= nb_segm; ii++ )
589 angle = arcAngle * ii / nb_segm;
609 int row_min, row_max, col_min, col_max;
632 cx = ( ux0 + ux1 ) / 2;
633 cy = ( uy0 + uy1 ) / 2;
634 radius =
KiROUND( Distance( ux0, uy0, cx, cy ) );
652 if( row_max >= (
m_Nrows - 1 ) )
658 if( col_max >= (
m_Ncols - 1 ) )
661 for( row = row_min; row <= row_max; row++ )
663 for( col = col_min; col <= col_max; col++ )
695 int row_min, row_max, col_min, col_max;
730 if( row_max >= (
m_Nrows - 1 ) )
736 if( col_max >= (
m_Ncols - 1 ) )
739 for( row = row_min; row <= row_max; row++ )
741 for( col = col_min; col <= col_max; col++ )
756 int half_width = ( aShape->
GetWidth() / 2 ) + aMargin;
761 if( aShape->
GetShape() == SHAPE_T::CIRCLE || aShape->
GetShape() == SHAPE_T::SEGMENT )
768 if( aShape->
GetShape() == SHAPE_T::CIRCLE )
769 traceCircle( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
771 drawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, aColor, op_logic );
773 else if( aShape->
GetShape() == SHAPE_T::ARC )
780 traceArc( ux0, uy0, ux1, uy1, aShape->
GetArcAngle(), half_width, layer, aColor, op_logic );
796 int ux0,
int uy0,
int ux1,
int uy1,
int marge,
int aKeepOut,
LSET aLayerMask )
799 int row_min, row_max, col_min, col_max, pmarge;
844 if( row_max >= (
m_Nrows - 1 ) )
850 if( col_max >= (
m_Ncols - 1 ) )
853 for( row = row_min; row <= row_max; row++ )
858 lgain = ( 256 * row ) / pmarge;
859 else if( row > row_max - pmarge )
860 lgain = ( 256 * ( row_max - row ) ) / pmarge;
862 for( col = col_min; col <= col_max; col++ )
871 LocalKeepOut = aKeepOut;
874 cgain = ( 256 * col ) / pmarge;
875 else if( col > col_max - pmarge )
876 cgain = ( 256 * ( col_max - col ) ) / pmarge;
878 cgain = ( cgain * lgain ) / 256;
881 LocalKeepOut = ( LocalKeepOut * cgain ) / 256;
892 data = std::max( data, LocalKeepOut );
908 if( aPad->
GetShape() == PAD_SHAPE::CIRCLE )
917 if( aPad->
GetShape() == PAD_SHAPE::TRAPEZOID )
#define OP_CELL(layer, dy, dx)
#define AR_MAX_ROUTING_LAYERS_COUNT
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
void SetX(coord_type val)
void SetY(coord_type val)
coord_type GetHeight() const
coord_type GetWidth() const
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.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
VECTOR2I ShapePos() const
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
const VECTOR2I & GetSize() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_270
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".