KiCad PCB EDA Suite
am_primitive.cpp File Reference
#include <trigo.h>
#include <convert_to_biu.h>
#include <convert_basic_shapes_to_polygon.h>
#include <math/util.h>
#include <gerbview.h>
#include <gerber_file_image.h>

Go to the source code of this file.

Macros

#define TO_POLY_SHAPE
 

Functions

int scaletoIU (double aCoord, bool isMetric)
 Convert a distance given in floating point to our internal units. More...
 
static VECTOR2I mapPt (double x, double y, bool isMetric)
 Translate a point from the aperture macro coordinate system to our deci-mils coordinate system. More...
 

Variables

const int seg_per_circle = 64
 

Macro Definition Documentation

◆ TO_POLY_SHAPE

#define TO_POLY_SHAPE
Value:
{ \
if( polybuffer.size() > 1 ) \
{ \
aShapeBuffer.NewOutline(); \
\
for( unsigned jj = 0; jj < polybuffer.size(); jj++ ) \
aShapeBuffer.Append( polybuffer[jj].x, polybuffer[jj].y ); \
\
aShapeBuffer.Append( polybuffer[0].x, polybuffer[0].y ); \
} \
}

Function Documentation

◆ mapPt()

static VECTOR2I mapPt ( double  x,
double  y,
bool  isMetric 
)
static

Translate a point from the aperture macro coordinate system to our deci-mils coordinate system.

Returns
The GerbView coordinate system vector.

Definition at line 51 of file am_primitive.cpp.

52{
53 VECTOR2I ret( scaletoIU( x, isMetric ), scaletoIU( y, isMetric ) );
54
55 return ret;
56}
int scaletoIU(double aCoord, bool isMetric)
Convert a distance given in floating point to our internal units.

References scaletoIU().

Referenced by AM_PRIMITIVE::ConvertShapeToPolygon(), AM_PRIMITIVE::DrawBasicShape(), and AM_PRIMITIVE::GetShapeDim().

◆ scaletoIU()

int scaletoIU ( double  aCoord,
bool  isMetric 
)

Convert a distance given in floating point to our internal units.

Convert a distance given in floating point to our internal units.

Definition at line 58 of file rs274_read_XY_and_IJ_coordinates.cpp.

59{
60 int ret;
61
62 if( isMetric ) // gerber are units in mm
63 ret = KiROUND( aCoord * GERB_IU_PER_MM );
64 else // gerber are units in inches
65 ret = KiROUND( aCoord * GERB_IU_PER_MM * 25.4 );
66
67 return ret;
68}
constexpr double GERB_IU_PER_MM
some define and functions to convert a value in mils, decimils or mm to the internal unit used in pcb...
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:80

References GERB_IU_PER_MM, and KiROUND().

Referenced by AM_PRIMITIVE::ConvertShapeToPolygon(), AM_PRIMITIVE::DrawBasicShape(), AM_PRIMITIVE::GetShapeDim(), and mapPt().

Variable Documentation

◆ seg_per_circle

const int seg_per_circle = 64

Definition at line 94 of file am_primitive.cpp.

Referenced by AM_PRIMITIVE::ConvertShapeToPolygon().