KiCad PCB EDA Suite
dcode.cpp File Reference

D_CODE class implementation. More...

#include <trigo.h>
#include <eda_rect.h>
#include <gerbview_frame.h>
#include <gerber_file_image.h>
#include <convert_to_biu.h>
#include <convert_basic_shapes_to_polygon.h>

Go to the source code of this file.

Macros

#define DCODE_DEFAULT_SIZE   Millimeter2iu( 0.1 )
 
#define SEGS_CNT   64
 

Functions

static void addHoleToPolygon (SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, const wxSize &aSize, const wxPoint &aAnchorPos)
 

Detailed Description

D_CODE class implementation.

Definition in file dcode.cpp.

Macro Definition Documentation

◆ DCODE_DEFAULT_SIZE

#define DCODE_DEFAULT_SIZE   Millimeter2iu( 0.1 )

Definition at line 38 of file dcode.cpp.

◆ SEGS_CNT

#define SEGS_CNT   64

Definition at line 288 of file dcode.cpp.

Function Documentation

◆ addHoleToPolygon()

static void addHoleToPolygon ( SHAPE_POLY_SET aPolygon,
APERTURE_DEF_HOLETYPE  aHoleShape,
const wxSize &  aSize,
const wxPoint &  aAnchorPos 
)
static

Definition at line 422 of file dcode.cpp.

426 {
427  wxPoint currpos;
428  SHAPE_POLY_SET holeBuffer;
429 
430  if( aHoleShape == APT_DEF_ROUND_HOLE )
431  {
432  TransformCircleToPolygon( holeBuffer, wxPoint( 0, 0 ), aSize.x / 2, ARC_HIGH_DEF,
433  ERROR_INSIDE );
434  }
435  else if( aHoleShape == APT_DEF_RECT_HOLE )
436  {
437  holeBuffer.NewOutline();
438  currpos.x = aSize.x / 2;
439  currpos.y = aSize.y / 2;
440  holeBuffer.Append( VECTOR2I( currpos ) ); // link to hole and begin hole
441  currpos.x -= aSize.x;
442  holeBuffer.Append( VECTOR2I( currpos ) );
443  currpos.y -= aSize.y;
444  holeBuffer.Append( VECTOR2I( currpos ) );
445  currpos.x += aSize.x;
446  holeBuffer.Append( VECTOR2I( currpos ) );
447  currpos.y += aSize.y;
448  holeBuffer.Append( VECTOR2I( currpos ) ); // close hole
449  }
450 
451  aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
452  aPolygon->Fracture( SHAPE_POLY_SET::PM_FAST );
453 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Represent a set of closed polygons.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
int NewOutline()
Creates a new hole in a given outline.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), APT_DEF_RECT_HOLE, APT_DEF_ROUND_HOLE, SHAPE_POLY_SET::BooleanSubtract(), ERROR_INSIDE, SHAPE_POLY_SET::Fracture(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::PM_FAST, and TransformCircleToPolygon().

Referenced by D_CODE::ConvertShapeToPolygon().