Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
cb49ca5a
Commit
cb49ca5a
authored
May 04, 2013
by
Lorenzo Marcantonio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More int casts to rounding conversions
parent
b2a76062
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
143 additions
and
151 deletions
+143
-151
info3d_visu.cpp
3d-viewer/info3d_visu.cpp
+3
-3
info3d_visu.h
3d-viewer/info3d_visu.h
+4
-4
class_plotter.cpp
common/class_plotter.cpp
+1
-1
lib_arc.cpp
eeschema/lib_arc.cpp
+2
-2
lib_circle.cpp
eeschema/lib_circle.cpp
+2
-6
export_to_pcbnew.cpp
gerbview/export_to_pcbnew.cpp
+2
-0
onleftclick.cpp
gerbview/onleftclick.cpp
+1
-1
trigo.h
include/trigo.h
+6
-0
autoplac.cpp
pcbnew/autorouter/autoplac.cpp
+2
-2
board_items_to_polygon_shape_transform.cpp
pcbnew/board_items_to_polygon_shape_transform.cpp
+15
-16
class_dimension.cpp
pcbnew/class_dimension.cpp
+3
-3
class_pad.cpp
pcbnew/class_pad.cpp
+2
-3
class_track.cpp
pcbnew/class_track.cpp
+7
-18
class_zone.cpp
pcbnew/class_zone.cpp
+8
-7
dialog_edit_module_for_BoardEditor.cpp
pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
+1
-1
dialog_print_using_printer.cpp
pcbnew/dialogs/dialog_print_using_printer.cpp
+2
-2
drc_clearance_test_functions.cpp
pcbnew/drc_clearance_test_functions.cpp
+1
-1
editrack.cpp
pcbnew/editrack.cpp
+1
-1
export_vrml.cpp
pcbnew/export_vrml.cpp
+1
-1
gen_drill_report_files.cpp
pcbnew/gen_drill_report_files.cpp
+20
-20
globaleditpad.cpp
pcbnew/globaleditpad.cpp
+1
-1
gpcb_plugin.cpp
pcbnew/gpcb_plugin.cpp
+1
-1
pcbplot.h
pcbnew/pcbplot.h
+1
-1
printout_controler.cpp
pcbnew/printout_controler.cpp
+3
-3
specctra_import.cpp
pcbnew/specctra_import.cpp
+2
-2
zones_convert_to_polygons_aux_functions.cpp
pcbnew/zones_convert_to_polygons_aux_functions.cpp
+2
-2
PolyLine.cpp
polygon/PolyLine.cpp
+29
-27
math_for_graphics.cpp
polygon/math_for_graphics.cpp
+14
-20
math_for_graphics.h
polygon/math_for_graphics.h
+6
-2
No files found.
3d-viewer/info3d_visu.cpp
View file @
cb49ca5a
...
@@ -39,9 +39,9 @@
...
@@ -39,9 +39,9 @@
// Thickness of copper
// Thickness of copper
// TODO: define the actual copper thickness by user
// TODO: define the actual copper thickness by user
#define COPPER_THICKNESS
(int)(0.035 * IU_PER_MM) // for 35 u
#define COPPER_THICKNESS
KiROUND( 0.035 * IU_PER_MM ) // for 35 µm
#define TECH_LAYER_THICKNESS
(int)(0.04 * IU_PER_MM
)
#define TECH_LAYER_THICKNESS
KiROUND( 0.04 * IU_PER_MM
)
#define EPOXY_THICKNESS
(int)(1.6 * IU_PER_MM
) // for 1.6 mm
#define EPOXY_THICKNESS
KiROUND( 1.6 * IU_PER_MM
) // for 1.6 mm
/* INFO3D_VISU in an helper class to store parameters like scaling factors,
/* INFO3D_VISU in an helper class to store parameters like scaling factors,
...
...
3d-viewer/info3d_visu.h
View file @
cb49ca5a
...
@@ -123,7 +123,7 @@ public: INFO3D_VISU();
...
@@ -123,7 +123,7 @@ public: INFO3D_VISU();
*/
*/
int
GetLayerZcoordBIU
(
int
aLayerId
)
int
GetLayerZcoordBIU
(
int
aLayerId
)
{
{
return
(
int
)
(
m_LayerZcoord
[
aLayerId
]
/
m_BiuTo3Dunits
);
return
KiROUND
(
m_LayerZcoord
[
aLayerId
]
/
m_BiuTo3Dunits
);
}
}
/**
/**
...
@@ -137,7 +137,7 @@ public: INFO3D_VISU();
...
@@ -137,7 +137,7 @@ public: INFO3D_VISU();
int
GetCopperThicknessBIU
()
const
int
GetCopperThicknessBIU
()
const
{
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
(
int
)
(
m_CopperThickness
/
m_BiuTo3Dunits
)
KiROUND
(
m_CopperThickness
/
m_BiuTo3Dunits
)
:
0
;
:
0
;
}
}
...
@@ -147,7 +147,7 @@ public: INFO3D_VISU();
...
@@ -147,7 +147,7 @@ public: INFO3D_VISU();
*/
*/
int
GetEpoxyThicknessBIU
()
const
int
GetEpoxyThicknessBIU
()
const
{
{
return
(
int
)
(
m_EpoxyThickness
/
m_BiuTo3Dunits
);
return
KiROUND
(
m_EpoxyThickness
/
m_BiuTo3Dunits
);
}
}
/**
/**
...
@@ -160,7 +160,7 @@ public: INFO3D_VISU();
...
@@ -160,7 +160,7 @@ public: INFO3D_VISU();
int
GetNonCopperLayerThicknessBIU
()
const
int
GetNonCopperLayerThicknessBIU
()
const
{
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
(
int
)
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
KiROUND
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
:
0
;
:
0
;
}
}
...
...
common/class_plotter.cpp
View file @
cb49ca5a
...
@@ -389,7 +389,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
...
@@ -389,7 +389,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
else
else
orient
=
-
ArcTangente
(
size
.
y
,
size
.
x
);
orient
=
-
ArcTangente
(
size
.
y
,
size
.
x
);
size
.
x
=
KiROUND
(
hypot
(
size
.
x
,
size
.
y
)
)
+
width
;
size
.
x
=
KiROUND
(
EuclideanNorm
(
size
)
)
+
width
;
size
.
y
=
width
;
size
.
y
=
width
;
FlashPadOval
(
center
,
size
,
orient
,
tracemode
);
FlashPadOval
(
center
,
size
,
orient
,
tracemode
);
...
...
eeschema/lib_arc.cpp
View file @
cb49ca5a
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#include <transform.h>
#include <transform.h>
// Helper function
// Helper function
static
inline
wxPoint
twoPointVector
(
wxPoint
startPoint
,
wxPoint
endPoint
)
static
inline
wxPoint
twoPointVector
(
const
wxPoint
&
startPoint
,
const
wxPoint
&
endPoint
)
{
{
return
endPoint
-
startPoint
;
return
endPoint
-
startPoint
;
}
}
...
@@ -195,7 +195,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran
...
@@ -195,7 +195,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran
NEGATE
(
relativePosition
.
y
);
// reverse Y axis
NEGATE
(
relativePosition
.
y
);
// reverse Y axis
int
distance
=
KiROUND
(
EuclideanNorm
(
twoPointVector
(
m_Pos
,
relativePosition
)
)
);
int
distance
=
KiROUND
(
GetLineLength
(
m_Pos
,
relativePosition
)
);
if
(
abs
(
distance
-
m_Radius
)
>
aThreshold
)
if
(
abs
(
distance
-
m_Radius
)
>
aThreshold
)
return
false
;
return
false
;
...
...
eeschema/lib_circle.cpp
View file @
cb49ca5a
...
@@ -105,9 +105,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
...
@@ -105,9 +105,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
if
(
aThreshold
<
0
)
if
(
aThreshold
<
0
)
aThreshold
=
GetPenSize
()
/
2
;
aThreshold
=
GetPenSize
()
/
2
;
wxPoint
relpos
=
aPosRef
-
aTransform
.
TransformCoordinate
(
m_Pos
);
int
dist
=
KiROUND
(
GetLineLength
(
aPosRef
,
aTransform
.
TransformCoordinate
(
m_Pos
)
)
);
int
dist
=
KiROUND
(
EuclideanNorm
(
relpos
)
);
if
(
abs
(
dist
-
m_Radius
)
<=
aThreshold
)
if
(
abs
(
dist
-
m_Radius
)
<=
aThreshold
)
return
true
;
return
true
;
...
@@ -345,9 +343,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
...
@@ -345,9 +343,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
if
(
m_Flags
==
IS_NEW
)
if
(
m_Flags
==
IS_NEW
)
SetEraseLastDrawItem
();
SetEraseLastDrawItem
();
int
dx
=
m_Pos
.
x
-
aPosition
.
x
;
m_Radius
=
KiROUND
(
GetLineLength
(
m_Pos
,
aPosition
)
);
int
dy
=
m_Pos
.
y
-
aPosition
.
y
;
m_Radius
=
KiROUND
(
hypot
(
dx
,
dy
)
);
}
}
else
else
{
{
...
...
gerbview/export_to_pcbnew.cpp
View file @
cb49ca5a
...
@@ -233,6 +233,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
...
@@ -233,6 +233,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
#define SEG_SHAPE 0
#define SEG_SHAPE 0
#define ARC_SHAPE 2
#define ARC_SHAPE 2
int
shape
=
SEG_SHAPE
;
int
shape
=
SEG_SHAPE
;
// please note: the old PCB format only has integer support for angles
int
angle
=
0
;
int
angle
=
0
;
wxPoint
seg_start
,
seg_end
;
wxPoint
seg_start
,
seg_end
;
...
...
gerbview/onleftclick.cpp
View file @
cb49ca5a
...
@@ -28,7 +28,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
...
@@ -28,7 +28,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
{
if
(
DrawStruct
&&
DrawStruct
->
GetFlags
()
)
if
(
DrawStruct
&&
DrawStruct
->
GetFlags
()
)
{
{
msg
.
Printf
(
wxT
(
"GERBVIEW_FRAME::OnLeftClick err: Struct %
d
, m_Flags = %X"
),
msg
.
Printf
(
wxT
(
"GERBVIEW_FRAME::OnLeftClick err: Struct %
u
, m_Flags = %X"
),
(
unsigned
)
DrawStruct
->
Type
(),
(
unsigned
)
DrawStruct
->
Type
(),
(
unsigned
)
DrawStruct
->
GetFlags
()
);
(
unsigned
)
DrawStruct
->
GetFlags
()
);
wxFAIL_MSG
(
msg
);
wxFAIL_MSG
(
msg
);
...
...
include/trigo.h
View file @
cb49ca5a
...
@@ -81,6 +81,12 @@ inline double EuclideanNorm( const wxPoint &vector )
...
@@ -81,6 +81,12 @@ inline double EuclideanNorm( const wxPoint &vector )
return
hypot
(
vector
.
x
,
vector
.
y
);
return
hypot
(
vector
.
x
,
vector
.
y
);
}
}
inline
double
EuclideanNorm
(
const
wxSize
&
vector
)
{
// this is working with doubles, too
return
hypot
(
vector
.
x
,
vector
.
y
);
}
//! @brief Compute the distance between a line and a reference point
//! @brief Compute the distance between a line and a reference point
//! Reference: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
//! Reference: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
//! @param linePointA Point on line
//! @param linePointA Point on line
...
...
pcbnew/autorouter/autoplac.cpp
View file @
cb49ca5a
...
@@ -942,8 +942,8 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
...
@@ -942,8 +942,8 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
// the penalty is max for 45 degrees ratsnests,
// the penalty is max for 45 degrees ratsnests,
// and 0 for horizontal or vertical ratsnests.
// and 0 for horizontal or vertical ratsnests.
// For Horizontal and Vertical ratsnests, dy = 0;
// For Horizontal and Vertical ratsnests, dy = 0;
icout
=
hypot
(
(
double
)
dx
,
(
double
)
dy
*
2.0
);
icout
=
hypot
(
dx
,
dy
*
2.0
);
cout
+=
icout
;
/
* Total cost = sum of costs of each connection. */
cout
+=
icout
;
/
/ Total cost = sum of costs of each connection
}
}
return
cout
;
return
cout
;
...
...
pcbnew/board_items_to_polygon_shape_transform.cpp
View file @
cb49ca5a
...
@@ -431,7 +431,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
...
@@ -431,7 +431,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
switch
(
m_PadShape
)
switch
(
m_PadShape
)
{
{
case
PAD_CIRCLE
:
case
PAD_CIRCLE
:
dx
=
(
int
)
(
dx
*
aCorrectionFactor
);
dx
=
KiROUND
(
dx
*
aCorrectionFactor
);
TransformCircleToPolygon
(
aCornerBuffer
,
PadShapePos
,
dx
,
TransformCircleToPolygon
(
aCornerBuffer
,
PadShapePos
,
dx
,
aCircleToSegmentsCount
);
aCircleToSegmentsCount
);
break
;
break
;
...
@@ -444,13 +444,13 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
...
@@ -444,13 +444,13 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
wxPoint
shape_offset
;
wxPoint
shape_offset
;
if
(
dy
>
dx
)
// Oval pad X/Y ratio for choosing translation axis
if
(
dy
>
dx
)
// Oval pad X/Y ratio for choosing translation axis
{
{
dy
=
(
int
)
(
dy
*
aCorrectionFactor
);
dy
=
KiROUND
(
dy
*
aCorrectionFactor
);
shape_offset
.
y
=
dy
-
dx
;
shape_offset
.
y
=
dy
-
dx
;
width
=
dx
*
2
;
width
=
dx
*
2
;
}
}
else
//if( dy <= dx )
else
//if( dy <= dx )
{
{
dx
=
(
int
)
(
dx
*
aCorrectionFactor
);
dx
=
KiROUND
(
dx
*
aCorrectionFactor
);
shape_offset
.
x
=
dy
-
dx
;
shape_offset
.
x
=
dy
-
dx
;
width
=
dy
*
2
;
width
=
dy
*
2
;
}
}
...
@@ -474,8 +474,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
...
@@ -474,8 +474,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
angle
=
m_Orient
;
angle
=
m_Orient
;
// Corner rounding radius
// Corner rounding radius
int
rounding_radius
=
(
int
)
(
aClearanceValue
*
aCorrectionFactor
);
int
rounding_radius
=
KiROUND
(
aClearanceValue
*
aCorrectionFactor
);
int
angle_pg
;
// Polygon increment angle
double
angle_pg
;
// Polygon increment angle
for
(
int
i
=
0
;
i
<
aCircleToSegmentsCount
/
4
+
1
;
i
++
)
for
(
int
i
=
0
;
i
<
aCircleToSegmentsCount
/
4
+
1
;
i
++
)
{
{
...
@@ -716,7 +716,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -716,7 +716,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
std
::
vector
<
wxPoint
>
corners_buffer
;
std
::
vector
<
wxPoint
>
corners_buffer
;
// Radius of outer arcs of the shape corrected for arc approximation by lines
// Radius of outer arcs of the shape corrected for arc approximation by lines
int
outer_radius
=
(
int
)
(
(
dx
+
aThermalGap
)
*
aCorrectionFactor
);
int
outer_radius
=
KiROUND
(
(
dx
+
aThermalGap
)
*
aCorrectionFactor
);
// Crosspoint of thermal spoke sides, the first point of polygon buffer
// Crosspoint of thermal spoke sides, the first point of polygon buffer
corners_buffer
.
push_back
(
wxPoint
(
copper_thickness
.
x
/
2
,
copper_thickness
.
y
/
2
)
);
corners_buffer
.
push_back
(
wxPoint
(
copper_thickness
.
x
/
2
,
copper_thickness
.
y
/
2
)
);
...
@@ -725,7 +725,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -725,7 +725,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
// and first seg of arc approx
// and first seg of arc approx
corner
.
x
=
copper_thickness
.
x
/
2
;
corner
.
x
=
copper_thickness
.
x
/
2
;
int
y
=
outer_radius
-
(
aThermalGap
/
4
);
int
y
=
outer_radius
-
(
aThermalGap
/
4
);
corner
.
y
=
(
int
)
sqrt
(
(
(
(
double
)
y
*
y
)
-
(
double
)
corner
.
x
*
corner
.
x
)
);
corner
.
y
=
KiROUND
(
sqrt
(
(
(
double
)
y
*
y
-
(
double
)
corner
.
x
*
corner
.
x
)
)
);
if
(
aThermalRot
!=
0
)
if
(
aThermalRot
!=
0
)
corners_buffer
.
push_back
(
corner
);
corners_buffer
.
push_back
(
corner
);
...
@@ -733,9 +733,8 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -733,9 +733,8 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
// calculate the starting point of the outter arc
// calculate the starting point of the outter arc
corner
.
x
=
copper_thickness
.
x
/
2
;
corner
.
x
=
copper_thickness
.
x
/
2
;
double
dtmp
=
sqrt
(
(
(
double
)
outer_radius
*
outer_radius
)
-
corner
.
y
=
KiROUND
(
sqrt
(
(
(
double
)
outer_radius
*
outer_radius
)
-
(
(
double
)
corner
.
x
*
corner
.
x
)
);
(
(
double
)
corner
.
x
*
corner
.
x
)
)
);
corner
.
y
=
(
int
)
dtmp
;
RotatePoint
(
&
corner
,
90
);
// 9 degrees is the spoke fillet size
RotatePoint
(
&
corner
,
90
);
// 9 degrees is the spoke fillet size
// calculate the ending point of the outter arc
// calculate the ending point of the outter arc
...
@@ -818,8 +817,8 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -818,8 +817,8 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
if
(
copper_thickness
.
x
>
deltasize
)
if
(
copper_thickness
.
x
>
deltasize
)
{
{
corner
.
x
=
copper_thickness
.
x
/
2
;
corner
.
x
=
copper_thickness
.
x
/
2
;
corner
.
y
=
(
int
)
sqrt
(
(
(
double
)
outer_radius
*
outer_radius
)
-
corner
.
y
=
KiROUND
(
sqrt
(
(
(
double
)
outer_radius
*
outer_radius
)
-
(
(
double
)
(
corner
.
x
-
delta
)
*
(
corner
.
x
-
deltasize
)
)
);
(
(
double
)
(
corner
.
x
-
delta
)
*
(
corner
.
x
-
deltasize
)
)
)
)
;
corner
.
x
-=
deltasize
;
corner
.
x
-=
deltasize
;
/* creates an intermediate point, to have a > 90 deg angle
/* creates an intermediate point, to have a > 90 deg angle
...
@@ -843,13 +842,13 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -843,13 +842,13 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
last_corner
.
y
=
copper_thickness
.
y
/
2
;
last_corner
.
y
=
copper_thickness
.
y
/
2
;
int
px
=
outer_radius
-
(
aThermalGap
/
4
);
int
px
=
outer_radius
-
(
aThermalGap
/
4
);
last_corner
.
x
=
last_corner
.
x
=
(
int
)
sqrt
(
(
(
(
double
)
px
*
px
)
-
(
double
)
last_corner
.
y
*
last_corner
.
y
)
);
KiROUND
(
sqrt
(
(
(
(
double
)
px
*
px
)
-
(
double
)
last_corner
.
y
*
last_corner
.
y
)
)
);
// Arc stop point calculation, the intersecting point of cutout arc and thermal spoke edge
// Arc stop point calculation, the intersecting point of cutout arc and thermal spoke edge
corner_end
.
y
=
copper_thickness
.
y
/
2
;
corner_end
.
y
=
copper_thickness
.
y
/
2
;
corner_end
.
x
=
corner_end
.
x
=
(
int
)
sqrt
(
(
(
double
)
outer_radius
*
KiROUND
(
sqrt
(
(
(
double
)
outer_radius
*
outer_radius
)
-
(
(
double
)
corner_end
.
y
*
corner_end
.
y
)
);
outer_radius
)
-
(
(
double
)
corner_end
.
y
*
corner_end
.
y
)
)
)
;
RotatePoint
(
&
corner_end
,
-
90
);
// 9 degrees of thermal fillet
RotatePoint
(
&
corner_end
,
-
90
);
// 9 degrees of thermal fillet
// calculate intermediate arc points till limit is reached
// calculate intermediate arc points till limit is reached
...
@@ -948,7 +947,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -948,7 +947,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
corners_buffer
.
push_back
(
wxPoint
(
-
(
aThermalGap
/
4
+
copper_thickness
.
x
/
2
),
-
dy
)
);
corners_buffer
.
push_back
(
wxPoint
(
-
(
aThermalGap
/
4
+
copper_thickness
.
x
/
2
),
-
dy
)
);
int
angle
=
aPad
.
GetOrientation
();
int
angle
=
aPad
.
GetOrientation
();
int
rounding_radius
=
(
int
)
(
aThermalGap
*
aCorrectionFactor
);
// Corner rounding radius
int
rounding_radius
=
KiROUND
(
aThermalGap
*
aCorrectionFactor
);
// Corner rounding radius
int
angle_pg
;
// Polygon increment angle
int
angle_pg
;
// Polygon increment angle
for
(
int
i
=
0
;
i
<
aCircleToSegmentsCount
/
4
+
1
;
i
++
)
for
(
int
i
=
0
;
i
<
aCircleToSegmentsCount
/
4
+
1
;
i
++
)
...
...
pcbnew/class_dimension.cpp
View file @
cb49ca5a
...
@@ -238,7 +238,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
...
@@ -238,7 +238,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
deltay
=
m_featureLineDO
.
y
-
m_featureLineGO
.
y
;
deltay
=
m_featureLineDO
.
y
-
m_featureLineGO
.
y
;
// Calculate dimension value
// Calculate dimension value
measure
=
KiROUND
(
hypot
(
(
double
)
deltax
,
(
double
)
deltay
)
);
measure
=
KiROUND
(
hypot
(
deltax
,
deltay
)
);
angle
=
atan2
(
deltay
,
deltax
);
angle
=
atan2
(
deltay
,
deltax
);
...
@@ -248,8 +248,8 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
...
@@ -248,8 +248,8 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
// Taking into account the slope of the side lines.
// Taking into account the slope of the side lines.
if
(
measure
)
if
(
measure
)
{
{
hx
=
(
abs
)
(
(
int
)
(
(
(
double
)
deltay
*
hx
)
/
measure
)
);
hx
=
abs
(
KiROUND
(
(
(
double
)
deltay
*
hx
)
/
measure
)
);
hy
=
(
abs
)
(
(
int
)
(
(
(
double
)
deltax
*
hy
)
/
measure
)
);
hy
=
abs
(
KiROUND
(
(
(
double
)
deltax
*
hy
)
/
measure
)
);
if
(
m_featureLineGO
.
x
>
m_crossBarO
.
x
)
if
(
m_featureLineGO
.
x
>
m_crossBarO
.
x
)
hx
=
-
hx
;
hx
=
-
hx
;
...
...
pcbnew/class_pad.cpp
View file @
cb49ca5a
...
@@ -103,14 +103,13 @@ int D_PAD::boundingRadius() const
...
@@ -103,14 +103,13 @@ int D_PAD::boundingRadius() const
break
;
break
;
case
PAD_RECT
:
case
PAD_RECT
:
radius
=
1
+
(
int
)
(
sqrt
(
(
double
)
m_Size
.
y
*
m_Size
.
y
radius
=
1
+
KiROUND
(
EuclideanNorm
(
m_Size
)
/
2
);
+
(
double
)
m_Size
.
x
*
m_Size
.
x
)
/
2
);
break
;
break
;
case
PAD_TRAPEZOID
:
case
PAD_TRAPEZOID
:
x
=
m_Size
.
x
+
std
::
abs
(
m_DeltaSize
.
y
);
// Remember: m_DeltaSize.y is the m_Size.x change
x
=
m_Size
.
x
+
std
::
abs
(
m_DeltaSize
.
y
);
// Remember: m_DeltaSize.y is the m_Size.x change
y
=
m_Size
.
y
+
std
::
abs
(
m_DeltaSize
.
x
);
// Remember: m_DeltaSize.x is the m_Size.y change
y
=
m_Size
.
y
+
std
::
abs
(
m_DeltaSize
.
x
);
// Remember: m_DeltaSize.x is the m_Size.y change
radius
=
1
+
(
int
)
(
sqrt
(
(
double
)
y
*
y
+
(
double
)
x
*
x
)
/
2
);
radius
=
1
+
KiROUND
(
hypot
(
x
,
y
)
/
2
);
break
;
break
;
default
:
default
:
...
...
pcbnew/class_track.cpp
View file @
cb49ca5a
...
@@ -284,33 +284,22 @@ STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
...
@@ -284,33 +284,22 @@ STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
if
(
min_dist
<
0
)
if
(
min_dist
<
0
)
min_dist
=
m_Width
/
2
;
min_dist
=
m_Width
/
2
;
int
dx
=
m_Start
.
x
-
point
.
x
;
int
dy
=
m_Start
.
y
-
point
.
y
;
if
(
min_dist
==
0
)
if
(
min_dist
==
0
)
{
{
if
(
(
dx
==
0
)
&&
(
dy
==
0
)
)
if
(
m_Start
==
point
)
result
|=
STARTPOINT
;
result
|=
STARTPOINT
;
if
(
m_End
==
point
)
result
|=
ENDPOINT
;
}
}
else
else
{
{
double
dist
=
hypot
(
(
double
)
dx
,
(
double
)
dy
);
double
dist
=
GetLineLength
(
m_Start
,
point
);
if
(
min_dist
>=
KiROUND
(
dist
)
)
if
(
min_dist
>=
KiROUND
(
dist
)
)
result
|=
STARTPOINT
;
result
|=
STARTPOINT
;
}
dx
=
m_End
.
x
-
point
.
x
;
dy
=
m_End
.
y
-
point
.
y
;
if
(
min_dist
==
0
)
dist
=
GetLineLength
(
m_End
,
point
);
{
if
(
(
dx
==
0
)
&&
(
dy
==
0
)
)
result
|=
ENDPOINT
;
}
else
{
double
dist
=
hypot
(
(
double
)
dx
,
(
double
)
dy
);
if
(
min_dist
>=
KiROUND
(
dist
)
)
if
(
min_dist
>=
KiROUND
(
dist
)
)
result
|=
ENDPOINT
;
result
|=
ENDPOINT
;
...
@@ -1152,7 +1141,7 @@ void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
...
@@ -1152,7 +1141,7 @@ void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
// Display drill value
// Display drill value
int
drill_value
=
GetDrillValue
();
int
drill_value
=
GetDrillValue
();
msg
=
::
CoordinateToString
(
(
unsigned
)
drill_value
);
msg
=
::
CoordinateToString
(
drill_value
);
wxString
title
=
_
(
"Drill"
);
wxString
title
=
_
(
"Drill"
);
title
+=
wxT
(
" "
);
title
+=
wxT
(
" "
);
...
...
pcbnew/class_zone.cpp
View file @
cb49ca5a
...
@@ -540,13 +540,14 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
...
@@ -540,13 +540,14 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
end_segm
=
tmp
;
// end_segm is the beginning of the current outline
end_segm
=
tmp
;
// end_segm is the beginning of the current outline
}
}
/* test the dist between segment and ref point */
// test the dist between segment and ref point
int
dist
=
(
int
)
GetPointToLineSegmentDistance
(
refPos
.
x
,
int
dist
=
KiROUND
(
GetPointToLineSegmentDistance
(
refPos
.
y
,
refPos
.
x
,
m_Poly
->
m_CornersList
[
item_pos
].
x
,
refPos
.
y
,
m_Poly
->
m_CornersList
[
item_pos
].
y
,
m_Poly
->
m_CornersList
[
item_pos
].
x
,
m_Poly
->
m_CornersList
[
end_segm
].
x
,
m_Poly
->
m_CornersList
[
item_pos
].
y
,
m_Poly
->
m_CornersList
[
end_segm
].
y
);
m_Poly
->
m_CornersList
[
end_segm
].
x
,
m_Poly
->
m_CornersList
[
end_segm
].
y
)
);
if
(
dist
<
min_dist
)
if
(
dist
<
min_dist
)
{
{
...
...
pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
View file @
cb49ca5a
...
@@ -98,7 +98,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
...
@@ -98,7 +98,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
(
m_CurrentModule
->
GetLayer
()
==
LAYER_N_BACK
)
?
1
:
0
);
(
m_CurrentModule
->
GetLayer
()
==
LAYER_N_BACK
)
?
1
:
0
);
bool
select
=
false
;
bool
select
=
false
;
switch
(
(
int
)
m_CurrentModule
->
GetOrientation
(
)
)
switch
(
int
(
m_CurrentModule
->
GetOrientation
()
)
)
{
{
case
0
:
case
0
:
m_OrientCtrl
->
SetSelection
(
0
);
m_OrientCtrl
->
SetSelection
(
0
);
...
...
pcbnew/dialogs/dialog_print_using_printer.cpp
View file @
cb49ca5a
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
#include <dialog_print_using_printer_base.h>
#include <dialog_print_using_printer_base.h>
#define PEN_WIDTH_MAX_VALUE (
(int)(5 * IU_PER_MM
) )
#define PEN_WIDTH_MAX_VALUE (
KiROUND( 5 * IU_PER_MM
) )
#define PEN_WIDTH_MIN_VALUE (
(int)(0.005 * IU_PER_MM
) )
#define PEN_WIDTH_MIN_VALUE (
KiROUND( 0.005 * IU_PER_MM
) )
extern
int
g_DrawDefaultLineThickness
;
extern
int
g_DrawDefaultLineThickness
;
...
...
pcbnew/drc_clearance_test_functions.cpp
View file @
cb49ca5a
...
@@ -1028,7 +1028,7 @@ static inline int USCALE( unsigned arg, unsigned num, unsigned den )
...
@@ -1028,7 +1028,7 @@ static inline int USCALE( unsigned arg, unsigned num, unsigned den )
{
{
int
ii
;
int
ii
;
ii
=
(
int
)
(
(
(
double
)
arg
*
num
)
/
den
);
ii
=
KiROUND
(
(
(
double
)
arg
*
num
)
/
den
);
return
ii
;
return
ii
;
}
}
...
...
pcbnew/editrack.cpp
View file @
cb49ca5a
...
@@ -652,7 +652,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel )
...
@@ -652,7 +652,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel )
}
}
//Help
re function: Draws Via circle and Via Cleare
nce circle.
//Help
er function: Draws Via circle and Via Cleara
nce circle.
inline
void
DrawViaCirclesWhenEditingNewTrack
(
EDA_RECT
*
aPanelClipBox
,
inline
void
DrawViaCirclesWhenEditingNewTrack
(
EDA_RECT
*
aPanelClipBox
,
wxDC
*
aDC
,
const
wxPoint
&
aPos
,
wxDC
*
aDC
,
const
wxPoint
&
aPos
,
int
aViaRadius
,
int
aViaRadius
,
...
...
pcbnew/export_vrml.cpp
View file @
cb49ca5a
...
@@ -406,7 +406,7 @@ static void export_vrml_circle( LAYER_NUM layer, double startx, double starty, /
...
@@ -406,7 +406,7 @@ static void export_vrml_circle( LAYER_NUM layer, double startx, double starty, /
double
hole
,
radius
;
double
hole
,
radius
;
FLAT_RING
ring
;
FLAT_RING
ring
;
radius
=
hypot
(
startx
-
endx
,
starty
-
endy
)
+
(
width
/
2
);
radius
=
Distance
(
startx
,
starty
,
endx
,
endy
)
+
(
width
/
2
);
hole
=
radius
-
width
;
hole
=
radius
-
width
;
for
(
double
alpha
=
0
;
alpha
<
M_PI
*
2
;
alpha
+=
INC_ANGLE
)
for
(
double
alpha
=
0
;
alpha
<
M_PI
*
2
;
alpha
+=
INC_ANGLE
)
...
...
pcbnew/gen_drill_report_files.cpp
View file @
cb49ca5a
...
@@ -109,15 +109,15 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -109,15 +109,15 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
wxSize
pageSizeIU
=
pageA4
.
GetSizeIU
();
wxSize
pageSizeIU
=
pageA4
.
GetSizeIU
();
// Reserve a margin around the page.
// Reserve a margin around the page.
int
margin
=
(
int
)
(
20
*
IU_PER_MM
);
int
margin
=
KiROUND
(
20
*
IU_PER_MM
);
// Calculate a scaling factor to print the board on the sheet
// Calculate a scaling factor to print the board on the sheet
double
Xscale
=
(
double
)
(
pageSizeIU
.
x
-
(
2
*
margin
)
)
/
bbbox
.
GetWidth
();
double
Xscale
=
double
(
pageSizeIU
.
x
-
(
2
*
margin
)
)
/
bbbox
.
GetWidth
();
// We should print the list of drill sizes, so reserve room for it
// We should print the list of drill sizes, so reserve room for it
// 60% height for board 40% height for list
// 60% height for board 40% height for list
int
ypagesize_for_board
=
(
int
)
(
pageSizeIU
.
y
*
0.6
);
int
ypagesize_for_board
=
KiROUND
(
pageSizeIU
.
y
*
0.6
);
double
Yscale
=
(
double
)
(
ypagesize_for_board
-
margin
)
/
bbbox
.
GetHeight
();
double
Yscale
=
double
(
ypagesize_for_board
-
margin
)
/
bbbox
.
GetHeight
();
scale
=
std
::
min
(
Xscale
,
Yscale
);
scale
=
std
::
min
(
Xscale
,
Yscale
);
...
@@ -126,8 +126,9 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -126,8 +126,9 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
// So the scale is clipped at 3.0;
// So the scale is clipped at 3.0;
scale
=
std
::
min
(
scale
,
3.0
);
scale
=
std
::
min
(
scale
,
3.0
);
offset
.
x
=
(
int
)
(
(
double
)
bbbox
.
Centre
().
x
-
(
pageSizeIU
.
x
/
2.0
)
/
scale
);
offset
.
x
=
KiROUND
(
double
(
bbbox
.
Centre
().
x
)
-
offset
.
y
=
(
int
)
(
(
double
)
bbbox
.
Centre
().
y
-
(
pageSizeIU
.
x
/
2.0
)
/
scale
);
offset
.
y
=
KiROUND
(
double
(
bbbox
.
Centre
().
y
)
-
(
ypagesize_for_board
/
2.0
)
/
scale
);
(
ypagesize_for_board
/
2.0
)
/
scale
);
if
(
aFormat
==
PLOT_FORMAT_PDF
)
if
(
aFormat
==
PLOT_FORMAT_PDF
)
...
@@ -200,7 +201,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -200,7 +201,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
int
intervalle
=
0
;
int
intervalle
=
0
;
char
line
[
1024
];
char
line
[
1024
];
wxString
msg
;
wxString
msg
;
int
textmarginaftersymbol
=
(
int
)
(
2
*
IU_PER_MM
);
int
textmarginaftersymbol
=
KiROUND
(
2
*
IU_PER_MM
);
// Set Drill Symbols width
// Set Drill Symbols width
plotter
->
SetDefaultLineWidth
(
0.2
*
IU_PER_MM
/
scale
);
plotter
->
SetDefaultLineWidth
(
0.2
*
IU_PER_MM
/
scale
);
...
@@ -213,18 +214,18 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -213,18 +214,18 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
int
charSize
=
3
*
IU_PER_MM
;
// text size in IUs
int
charSize
=
3
*
IU_PER_MM
;
// text size in IUs
double
charScale
=
1.0
/
scale
;
// real scale will be 1/scale,
double
charScale
=
1.0
/
scale
;
// real scale will be 1/scale,
// because the global plot scale is scale
// because the global plot scale is scale
TextWidth
=
(
int
)
(
(
charSize
*
charScale
)
/
1
0
);
// Set text width (thickness)
TextWidth
=
KiROUND
(
(
charSize
*
charScale
)
/
10.
0
);
// Set text width (thickness)
intervalle
=
(
int
)
(
charSize
*
charScale
)
+
TextWidth
;
intervalle
=
KiROUND
(
charSize
*
charScale
)
+
TextWidth
;
// Trace information.
// Trace information.
plotX
=
(
int
)
(
(
double
)
bbbox
.
GetX
()
+
textmarginaftersymbol
*
charScale
);
plotX
=
KiROUND
(
bbbox
.
GetX
()
+
textmarginaftersymbol
*
charScale
);
plotY
=
bbbox
.
GetBottom
()
+
intervalle
;
plotY
=
bbbox
.
GetBottom
()
+
intervalle
;
// Plot title "Info"
// Plot title "Info"
wxString
Text
=
wxT
(
"Drill Map:"
);
wxString
Text
=
wxT
(
"Drill Map:"
);
plotter
->
Text
(
wxPoint
(
plotX
,
plotY
),
UNSPECIFIED_COLOR
,
Text
,
0
,
plotter
->
Text
(
wxPoint
(
plotX
,
plotY
),
UNSPECIFIED_COLOR
,
Text
,
0
,
wxSize
(
(
int
)
(
charSize
*
charScale
),
wxSize
(
KiROUND
(
charSize
*
charScale
),
(
int
)
(
charSize
*
charScale
)
),
KiROUND
(
charSize
*
charScale
)
),
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
TextWidth
,
false
,
false
);
TextWidth
,
false
,
false
);
...
@@ -237,10 +238,10 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -237,10 +238,10 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
plotY
+=
intervalle
;
plotY
+=
intervalle
;
plot_diam
=
(
int
)
m_toolListBuffer
[
ii
].
m_Diameter
;
plot_diam
=
KiROUND
(
m_toolListBuffer
[
ii
].
m_Diameter
)
;
x
=
(
int
)
(
(
double
)
plotX
-
textmarginaftersymbol
*
charScale
x
=
KiROUND
(
plotX
-
textmarginaftersymbol
*
charScale
-
(
double
)
plot_diam
/
2.0
);
-
plot_diam
/
2.0
);
y
=
(
int
)
(
(
double
)
plotY
+
(
double
)
charSize
*
charScale
);
y
=
KiROUND
(
plotY
+
charSize
*
charScale
);
plotter
->
Marker
(
wxPoint
(
x
,
y
),
plot_diam
,
ii
);
plotter
->
Marker
(
wxPoint
(
x
,
y
),
plot_diam
,
ii
);
// List the diameter of each drill in mm and inches.
// List the diameter of each drill in mm and inches.
...
@@ -268,13 +269,12 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
...
@@ -268,13 +269,12 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
msg
+=
FROM_UTF8
(
line
);
msg
+=
FROM_UTF8
(
line
);
plotter
->
Text
(
wxPoint
(
plotX
,
y
),
UNSPECIFIED_COLOR
,
plotter
->
Text
(
wxPoint
(
plotX
,
y
),
UNSPECIFIED_COLOR
,
msg
,
msg
,
0
,
wxSize
(
(
int
)
(
charSize
*
charScale
),
0
,
wxSize
(
KiROUND
(
charSize
*
charScale
),
(
int
)
(
charSize
*
charScale
)
),
KiROUND
(
charSize
*
charScale
)
),
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
TextWidth
,
false
,
false
);
TextWidth
,
false
,
false
);
intervalle
=
(
int
)
(
charSize
*
charScale
)
+
TextWidth
;
intervalle
=
KiROUND
(
((
charSize
*
charScale
)
+
TextWidth
)
*
1.2
);
intervalle
=
(
int
)
(
intervalle
*
1.2
);
if
(
intervalle
<
(
plot_diam
+
(
1
*
IU_PER_MM
/
scale
)
+
TextWidth
)
)
if
(
intervalle
<
(
plot_diam
+
(
1
*
IU_PER_MM
/
scale
)
+
TextWidth
)
)
intervalle
=
plot_diam
+
(
1
*
IU_PER_MM
/
scale
)
+
TextWidth
;
intervalle
=
plot_diam
+
(
1
*
IU_PER_MM
/
scale
)
+
TextWidth
;
...
...
pcbnew/globaleditpad.cpp
View file @
cb49ca5a
...
@@ -229,7 +229,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
...
@@ -229,7 +229,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
// Search and copy the name of library reference.
// Search and copy the name of library reference.
MODULE
*
Module_Ref
=
module
;
MODULE
*
Module_Ref
=
module
;
int
pad_orient
=
aPad
->
GetOrientation
()
-
Module_Ref
->
GetOrientation
();
double
pad_orient
=
aPad
->
GetOrientation
()
-
Module_Ref
->
GetOrientation
();
// Prepare an undo list:
// Prepare an undo list:
if
(
aSaveForUndo
)
if
(
aSaveForUndo
)
...
...
pcbnew/gpcb_plugin.cpp
View file @
cb49ca5a
...
@@ -408,7 +408,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
...
@@ -408,7 +408,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
int
tsize
=
(
parseInt
(
parameters
[
paramCnt
-
3
]
)
*
TEXT_DEFAULT_SIZE
)
/
100
;
int
tsize
=
(
parseInt
(
parameters
[
paramCnt
-
3
]
)
*
TEXT_DEFAULT_SIZE
)
/
100
;
int
thickness
=
module
->
Reference
().
GetSize
().
x
/
6
;
int
thickness
=
module
->
Reference
().
GetSize
().
x
/
6
;
tsize
=
std
::
max
(
(
int
)(
5
*
IU_PER_MILS
),
tsize
);
// Ensure a minimal size = 5 mils
tsize
=
std
::
max
(
KiROUND
(
5
*
IU_PER_MILS
),
tsize
);
// Ensure a minimal size = 5 mils
module
->
Reference
().
SetSize
(
wxSize
(
tsize
,
tsize
)
);
module
->
Reference
().
SetSize
(
wxSize
(
tsize
,
tsize
)
);
module
->
Reference
().
SetThickness
(
thickness
);
module
->
Reference
().
SetThickness
(
thickness
);
module
->
Value
().
SetOrientation
(
module
->
Reference
().
GetOrientation
()
);
module
->
Value
().
SetOrientation
(
module
->
Reference
().
GetOrientation
()
);
...
...
pcbnew/pcbplot.h
View file @
cb49ca5a
...
@@ -64,7 +64,7 @@ class BOARD;
...
@@ -64,7 +64,7 @@ class BOARD;
#define PLOT_MAX_SCALE 100.0
#define PLOT_MAX_SCALE 100.0
// Small drill marks (small pad holes) diameter value
// Small drill marks (small pad holes) diameter value
#define SMALL_DRILL
(int)
( 0.35 * IU_PER_MM )
#define SMALL_DRILL
KiROUND
( 0.35 * IU_PER_MM )
// A helper class to plot board items
// A helper class to plot board items
...
...
pcbnew/printout_controler.cpp
View file @
cb49ca5a
...
@@ -250,8 +250,8 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
...
@@ -250,8 +250,8 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
scalex
,
scaley
);
scalex
,
scaley
);
wxSize
PlotAreaSizeInUserUnits
;
wxSize
PlotAreaSizeInUserUnits
;
PlotAreaSizeInUserUnits
.
x
=
(
int
)
(
PlotAreaSizeInPixels
.
x
/
scalex
);
PlotAreaSizeInUserUnits
.
x
=
KiROUND
(
PlotAreaSizeInPixels
.
x
/
scalex
);
PlotAreaSizeInUserUnits
.
y
=
(
int
)
(
PlotAreaSizeInPixels
.
y
/
scaley
);
PlotAreaSizeInUserUnits
.
y
=
KiROUND
(
PlotAreaSizeInPixels
.
y
/
scaley
);
wxLogTrace
(
tracePrinting
,
wxT
(
"Scaled plot area in user units: x=%d, y=%d"
),
wxLogTrace
(
tracePrinting
,
wxT
(
"Scaled plot area in user units: x=%d, y=%d"
),
PlotAreaSizeInUserUnits
.
x
,
PlotAreaSizeInUserUnits
.
y
);
PlotAreaSizeInUserUnits
.
x
,
PlotAreaSizeInUserUnits
.
y
);
...
@@ -309,7 +309,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
...
@@ -309,7 +309,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
* is the y coordinate values from - PlotAreaSize.y to 0 */
* is the y coordinate values from - PlotAreaSize.y to 0 */
int
y_dc_offset
=
PlotAreaSizeInPixels
.
y
;
int
y_dc_offset
=
PlotAreaSizeInPixels
.
y
;
y_dc_offset
=
(
int
)
(
(
double
)
y_dc_offset
*
userscale
);
y_dc_offset
=
KiROUND
(
y_dc_offset
*
userscale
);
dc
->
SetDeviceOrigin
(
0
,
y_dc_offset
);
dc
->
SetDeviceOrigin
(
0
,
y_dc_offset
);
wxLogTrace
(
tracePrinting
,
wxT
(
"Device origin: x=%d, y=%d"
),
wxLogTrace
(
tracePrinting
,
wxT
(
"Device origin: x=%d, y=%d"
),
...
...
pcbnew/specctra_import.cpp
View file @
cb49ca5a
...
@@ -439,7 +439,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
...
@@ -439,7 +439,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
if
(
place
->
side
==
T_front
)
if
(
place
->
side
==
T_front
)
{
{
// convert from degrees to tenths of degrees used in KiCad.
// convert from degrees to tenths of degrees used in KiCad.
int
orientation
=
(
int
)
(
place
->
rotation
*
10.0
);
int
orientation
=
KiROUND
(
place
->
rotation
*
10.0
);
if
(
module
->
GetLayer
()
!=
LAYER_N_FRONT
)
if
(
module
->
GetLayer
()
!=
LAYER_N_FRONT
)
{
{
...
@@ -451,7 +451,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
...
@@ -451,7 +451,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
}
}
else
if
(
place
->
side
==
T_back
)
else
if
(
place
->
side
==
T_back
)
{
{
int
orientation
=
(
int
)
((
place
->
rotation
+
180.0
)
*
10.0
);
int
orientation
=
KiROUND
(
(
place
->
rotation
+
180.0
)
*
10.0
);
if
(
module
->
GetLayer
()
!=
LAYER_N_BACK
)
if
(
module
->
GetLayer
()
!=
LAYER_N_BACK
)
{
{
...
...
pcbnew/zones_convert_to_polygons_aux_functions.cpp
View file @
cb49ca5a
...
@@ -203,7 +203,7 @@ void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -203,7 +203,7 @@ void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
copperThickness
=
0
;
copperThickness
=
0
;
// Leave a small extra size to the copper area inside to pad
// Leave a small extra size to the copper area inside to pad
copperThickness
+=
(
int
)(
IU_PER_MM
*
0.04
);
copperThickness
+=
KiROUND
(
IU_PER_MM
*
0.04
);
startpoint
.
x
=
std
::
min
(
pad
->
GetSize
().
x
,
copperThickness
);
startpoint
.
x
=
std
::
min
(
pad
->
GetSize
().
x
,
copperThickness
);
startpoint
.
y
=
std
::
min
(
pad
->
GetSize
().
y
,
copperThickness
);
startpoint
.
y
=
std
::
min
(
pad
->
GetSize
().
y
,
copperThickness
);
...
@@ -216,7 +216,7 @@ void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
...
@@ -216,7 +216,7 @@ void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
int
fAngle
=
pad
->
GetOrientation
();
int
fAngle
=
pad
->
GetOrientation
();
if
(
pad
->
GetShape
()
==
PAD_CIRCLE
)
if
(
pad
->
GetShape
()
==
PAD_CIRCLE
)
{
{
endpoint
.
x
=
(
int
)
(
endpoint
.
x
*
aArcCorrection
);
endpoint
.
x
=
KiROUND
(
endpoint
.
x
*
aArcCorrection
);
endpoint
.
y
=
endpoint
.
x
;
endpoint
.
y
=
endpoint
.
x
;
fAngle
=
aRoundPadThermalRotation
;
fAngle
=
aRoundPadThermalRotation
;
}
}
...
...
polygon/PolyLine.cpp
View file @
cb49ca5a
...
@@ -111,7 +111,8 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
...
@@ -111,7 +111,8 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
ClipperLib
::
Polygon
&
polygon
=
normalized_polygons
[
ii
];
ClipperLib
::
Polygon
&
polygon
=
normalized_polygons
[
ii
];
cornerslist
.
clear
();
cornerslist
.
clear
();
for
(
unsigned
jj
=
0
;
jj
<
polygon
.
size
();
jj
++
)
for
(
unsigned
jj
=
0
;
jj
<
polygon
.
size
();
jj
++
)
cornerslist
.
push_back
(
KI_POLY_POINT
(
(
int
)
polygon
[
jj
].
X
,
(
int
)
polygon
[
jj
].
Y
)
);
cornerslist
.
push_back
(
KI_POLY_POINT
(
KiROUND
(
polygon
[
jj
].
X
),
KiROUND
(
polygon
[
jj
].
Y
)
)
);
mainpoly
.
set
(
cornerslist
.
begin
(),
cornerslist
.
end
()
);
mainpoly
.
set
(
cornerslist
.
begin
(),
cornerslist
.
end
()
);
all_contours
.
push_back
(
mainpoly
);
all_contours
.
push_back
(
mainpoly
);
}
}
...
@@ -137,7 +138,8 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
...
@@ -137,7 +138,8 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
ClipperLib
::
Polygon
&
polygon
=
normalized_polygons
[
ii
];
ClipperLib
::
Polygon
&
polygon
=
normalized_polygons
[
ii
];
cornerslist
.
clear
();
cornerslist
.
clear
();
for
(
unsigned
jj
=
0
;
jj
<
polygon
.
size
();
jj
++
)
for
(
unsigned
jj
=
0
;
jj
<
polygon
.
size
();
jj
++
)
cornerslist
.
push_back
(
KI_POLY_POINT
(
(
int
)
polygon
[
jj
].
X
,
(
int
)
polygon
[
jj
].
Y
)
);
cornerslist
.
push_back
(
KI_POLY_POINT
(
KiROUND
(
polygon
[
jj
].
X
),
KiROUND
(
polygon
[
jj
].
Y
)
)
);
bpl
::
set_points
(
poly_tmp
,
cornerslist
.
begin
(),
cornerslist
.
end
()
);
bpl
::
set_points
(
poly_tmp
,
cornerslist
.
begin
(),
cornerslist
.
end
()
);
polysholes
.
push_back
(
poly_tmp
);
polysholes
.
push_back
(
poly_tmp
);
}
}
...
@@ -367,27 +369,27 @@ CPolyLine* CPolyLine::Chamfer( unsigned int aDistance )
...
@@ -367,27 +369,27 @@ CPolyLine* CPolyLine::Chamfer( unsigned int aDistance )
yb
=
m_CornersList
[
index
+
1
].
y
-
y1
;
yb
=
m_CornersList
[
index
+
1
].
y
-
y1
;
}
}
unsigned
int
lena
=
(
unsigned
int
)
sqrt
(
(
double
)
(
xa
*
xa
+
ya
*
ya
)
);
unsigned
int
lena
=
KiROUND
(
hypot
(
xa
,
ya
)
);
unsigned
int
lenb
=
(
unsigned
int
)
sqrt
(
(
double
)
(
xb
*
xb
+
yb
*
yb
)
);
unsigned
int
lenb
=
KiROUND
(
hypot
(
xb
,
yb
)
);
unsigned
int
distance
=
aDistance
;
unsigned
int
distance
=
aDistance
;
// Chamfer one half of an edge at most
// Chamfer one half of an edge at most
if
(
0.5
*
lena
<
distance
)
if
(
0.5
*
lena
<
distance
)
distance
=
(
unsigned
int
)
(
0.5
*
(
double
)
lena
);
distance
=
int
(
0.5
*
lena
);
if
(
0.5
*
lenb
<
distance
)
if
(
0.5
*
lenb
<
distance
)
distance
=
(
unsigned
int
)
(
0.5
*
(
double
)
lenb
);
distance
=
int
(
0.5
*
lenb
);
nx
=
(
int
)
(
(
double
)
(
distance
*
xa
)
/
sqrt
(
(
double
)
(
xa
*
xa
+
ya
*
ya
)
)
);
nx
=
KiROUND
(
(
distance
*
xa
)
/
hypot
(
xa
,
ya
)
);
ny
=
(
int
)
(
(
double
)
(
distance
*
ya
)
/
sqrt
(
(
double
)
(
xa
*
xa
+
ya
*
ya
)
)
);
ny
=
KiROUND
(
(
distance
*
ya
)
/
hypot
(
xa
,
ya
)
);
if
(
index
==
startIndex
)
if
(
index
==
startIndex
)
newPoly
->
Start
(
GetLayer
(),
x1
+
nx
,
y1
+
ny
,
GetHatchStyle
()
);
newPoly
->
Start
(
GetLayer
(),
x1
+
nx
,
y1
+
ny
,
GetHatchStyle
()
);
else
else
newPoly
->
AppendCorner
(
x1
+
nx
,
y1
+
ny
);
newPoly
->
AppendCorner
(
x1
+
nx
,
y1
+
ny
);
nx
=
(
int
)
(
(
double
)
(
distance
*
xb
)
/
sqrt
(
(
double
)
(
xb
*
xb
+
yb
*
yb
)
)
);
nx
=
KiROUND
(
(
distance
*
xb
)
/
hypot
(
xb
,
yb
)
);
ny
=
(
int
)
(
(
double
)
(
distance
*
yb
)
/
sqrt
(
(
double
)
(
xb
*
xb
+
yb
*
yb
)
)
);
ny
=
KiROUND
(
(
distance
*
yb
)
/
hypot
(
xb
,
yb
)
);
newPoly
->
AppendCorner
(
x1
+
nx
,
y1
+
ny
);
newPoly
->
AppendCorner
(
x1
+
nx
,
y1
+
ny
);
}
}
...
@@ -447,8 +449,8 @@ CPolyLine* CPolyLine::Fillet( unsigned int aRadius, unsigned int aSegments )
...
@@ -447,8 +449,8 @@ CPolyLine* CPolyLine::Fillet( unsigned int aRadius, unsigned int aSegments )
yb
=
m_CornersList
[
index
+
1
].
y
-
y1
;
yb
=
m_CornersList
[
index
+
1
].
y
-
y1
;
}
}
double
lena
=
sqrt
(
(
double
)
(
xa
*
xa
+
ya
*
ya
)
);
double
lena
=
hypot
(
xa
,
ya
);
double
lenb
=
sqrt
(
(
double
)
(
xb
*
xb
+
yb
*
yb
)
);
double
lenb
=
hypot
(
xb
,
yb
);
double
cosine
=
(
xa
*
xb
+
ya
*
yb
)
/
(
lena
*
lenb
);
double
cosine
=
(
xa
*
xb
+
ya
*
yb
)
/
(
lena
*
lenb
);
double
radius
=
aRadius
;
double
radius
=
aRadius
;
...
@@ -500,19 +502,19 @@ CPolyLine* CPolyLine::Fillet( unsigned int aRadius, unsigned int aSegments )
...
@@ -500,19 +502,19 @@ CPolyLine* CPolyLine::Fillet( unsigned int aRadius, unsigned int aSegments )
if
(
xa
*
yb
-
ya
*
xb
<=
0
)
if
(
xa
*
yb
-
ya
*
xb
<=
0
)
deltaAngle
*=
-
1
;
deltaAngle
*=
-
1
;
nx
=
xc
+
xs
+
0.5
;
nx
=
xc
+
xs
;
ny
=
yc
+
ys
+
0.5
;
ny
=
yc
+
ys
;
if
(
index
==
startIndex
)
if
(
index
==
startIndex
)
newPoly
->
Start
(
GetLayer
(),
(
int
)
nx
,
(
int
)
ny
,
GetHatchStyle
()
);
newPoly
->
Start
(
GetLayer
(),
KiROUND
(
nx
),
KiROUND
(
ny
)
,
GetHatchStyle
()
);
else
else
newPoly
->
AppendCorner
(
(
int
)
nx
,
(
int
)
ny
);
newPoly
->
AppendCorner
(
KiROUND
(
nx
),
KiROUND
(
ny
)
);
for
(
unsigned
int
j
=
0
;
j
<
segments
;
j
++
)
for
(
unsigned
int
j
=
0
;
j
<
segments
;
j
++
)
{
{
nx
=
xc
+
cos
(
startAngle
+
(
j
+
1
)
*
deltaAngle
)
*
radius
+
0.5
;
nx
=
xc
+
cos
(
startAngle
+
(
j
+
1
)
*
deltaAngle
)
*
radius
;
ny
=
yc
-
sin
(
startAngle
+
(
j
+
1
)
*
deltaAngle
)
*
radius
+
0.5
;
ny
=
yc
-
sin
(
startAngle
+
(
j
+
1
)
*
deltaAngle
)
*
radius
;
newPoly
->
AppendCorner
(
(
int
)
nx
,
(
int
)
ny
);
newPoly
->
AppendCorner
(
KiROUND
(
nx
),
KiROUND
(
ny
)
);
}
}
}
}
...
@@ -791,7 +793,7 @@ void CPolyLine::Hatch()
...
@@ -791,7 +793,7 @@ void CPolyLine::Hatch()
else
else
spacing
=
m_hatchPitch
*
2
;
spacing
=
m_hatchPitch
*
2
;
// set the "leng
ht
" of hatch lines (the lenght on horizontal axis)
// set the "leng
th
" of hatch lines (the lenght on horizontal axis)
double
hatch_line_len
=
m_hatchPitch
;
double
hatch_line_len
=
m_hatchPitch
;
// To have a better look, give a slope depending on the layer
// To have a better look, give a slope depending on the layer
...
@@ -802,13 +804,13 @@ void CPolyLine::Hatch()
...
@@ -802,13 +804,13 @@ void CPolyLine::Hatch()
if
(
slope_flag
==
1
)
if
(
slope_flag
==
1
)
{
{
max_a
=
(
int
)
(
max_y
-
slope
*
min_x
);
max_a
=
KiROUND
(
max_y
-
slope
*
min_x
);
min_a
=
(
int
)
(
min_y
-
slope
*
max_x
);
min_a
=
KiROUND
(
min_y
-
slope
*
max_x
);
}
}
else
else
{
{
max_a
=
(
int
)
(
max_y
-
slope
*
max_x
);
max_a
=
KiROUND
(
max_y
-
slope
*
max_x
);
min_a
=
(
int
)
(
min_y
-
slope
*
min_x
);
min_a
=
KiROUND
(
min_y
-
slope
*
min_x
);
}
}
min_a
=
(
min_a
/
spacing
)
*
spacing
;
min_a
=
(
min_a
/
spacing
)
*
spacing
;
...
@@ -864,13 +866,13 @@ void CPolyLine::Hatch()
...
@@ -864,13 +866,13 @@ void CPolyLine::Hatch()
if
(
ok
)
if
(
ok
)
{
{
wxPoint
point
(
(
int
)
x
,
(
int
)
y
);
wxPoint
point
(
KiROUND
(
x
),
KiROUND
(
y
)
);
pointbuffer
.
push_back
(
point
);
pointbuffer
.
push_back
(
point
);
}
}
if
(
ok
==
2
)
if
(
ok
==
2
)
{
{
wxPoint
point
(
(
int
)
x2
,
(
int
)
y2
);
wxPoint
point
(
KiROUND
(
x2
),
KiROUND
(
y2
)
);
pointbuffer
.
push_back
(
point
);
pointbuffer
.
push_back
(
point
);
}
}
...
@@ -1036,7 +1038,7 @@ void CPolyLine::SetEndContour( int ic, bool end_contour )
...
@@ -1036,7 +1038,7 @@ void CPolyLine::SetEndContour( int ic, bool end_contour )
void
CPolyLine
::
AppendArc
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
xc
,
int
yc
,
int
num
)
void
CPolyLine
::
AppendArc
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
xc
,
int
yc
,
int
num
)
{
{
// get radius
// get radius
double
radius
=
hypot
(
(
double
)
(
xi
-
xc
),
(
double
)
(
yi
-
yc
)
);
double
radius
=
::
Distance
(
xi
,
yi
,
xf
,
yf
);
// get angles of start and finish
// get angles of start and finish
double
th_i
=
atan2
(
(
double
)
(
yi
-
yc
),
(
double
)
(
xi
-
xc
)
);
double
th_i
=
atan2
(
(
double
)
(
yi
-
yc
),
(
double
)
(
xi
-
xc
)
);
...
...
polygon/math_for_graphics.cpp
View file @
cb49ca5a
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include <cmath>
#include <cmath>
#include <float.h>
#include <float.h>
#include <limits.h>
#include <limits.h>
#include <common.h>
#include <fctsys.h>
#include <fctsys.h>
#include <PolyLine.h>
#include <PolyLine.h>
...
@@ -13,12 +13,6 @@
...
@@ -13,12 +13,6 @@
static
bool
InRange
(
double
x
,
double
xi
,
double
xf
);
static
bool
InRange
(
double
x
,
double
xi
,
double
xf
);
double
Distance
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
return
hypot
(
x1
-
x2
,
y1
-
y2
);
}
/* Function FindSegmentIntersections
/* Function FindSegmentIntersections
* find intersections between line segment (xi,yi) to (xf,yf)
* find intersections between line segment (xi,yi) to (xf,yf)
* and line segment (xi2,yi2) to (xf2,yf2)
* and line segment (xi2,yi2) to (xf2,yf2)
...
@@ -203,10 +197,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -203,10 +197,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
if
(
InRange
(
y1
,
y1i
,
y1f
)
&&
InRange
(
x1
,
x2i
,
x2f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
if
(
InRange
(
y1
,
y1i
,
y1f
)
&&
InRange
(
x1
,
x2i
,
x2f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
{
{
if
(
x
)
if
(
x
)
*
x
=
(
int
)
x1
;
*
x
=
KiROUND
(
x1
);
if
(
y
)
if
(
y
)
*
y
=
(
int
)
y1
;
*
y
=
KiROUND
(
y1
)
;
if
(
d
)
if
(
d
)
*
d
=
0.0
;
*
d
=
0.0
;
...
@@ -231,10 +225,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -231,10 +225,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
x1
,
x2i
,
x2f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
x1
,
x2i
,
x2f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
{
{
if
(
x
)
if
(
x
)
*
x
=
(
int
)
x1
;
*
x
=
KiROUND
(
x1
)
;
if
(
y
)
if
(
y
)
*
y
=
(
int
)
y1
;
*
y
=
KiROUND
(
y1
)
;
if
(
d
)
if
(
d
)
*
d
=
0.0
;
*
d
=
0.0
;
...
@@ -259,10 +253,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -259,10 +253,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
&&
InRange
(
y1
,
y2i
,
y2f
)
)
{
{
if
(
x
)
if
(
x
)
*
x
=
(
int
)
x1
;
*
x
=
KiROUND
(
x1
)
;
if
(
y
)
if
(
y
)
*
y
=
(
int
)
y1
;
*
y
=
KiROUND
(
y1
)
;
if
(
d
)
if
(
d
)
*
d
=
0.0
;
*
d
=
0.0
;
...
@@ -287,10 +281,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -287,10 +281,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
)
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
)
{
{
if
(
x
)
if
(
x
)
*
x
=
(
int
)
x1
;
*
x
=
KiROUND
(
x1
)
;
if
(
y
)
if
(
y
)
*
y
=
(
int
)
y1
;
*
y
=
KiROUND
(
y1
)
;
if
(
d
)
if
(
d
)
*
d
=
0.0
;
*
d
=
0.0
;
...
@@ -318,10 +312,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -318,10 +312,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
)
if
(
InRange
(
x1
,
x1i
,
x1f
)
&&
InRange
(
y1
,
y1i
,
y1f
)
)
{
{
if
(
x
)
if
(
x
)
*
x
=
(
int
)
x1
;
*
x
=
KiROUND
(
x1
)
;
if
(
y
)
if
(
y
)
*
y
=
(
int
)
y1
;
*
y
=
KiROUND
(
y1
)
;
if
(
d
)
if
(
d
)
*
d
=
0.0
;
*
d
=
0.0
;
...
@@ -365,10 +359,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
...
@@ -365,10 +359,10 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
}
}
if
(
x
)
if
(
x
)
*
x
=
(
int
)
xx
;
*
x
=
KiROUND
(
xx
)
;
if
(
y
)
if
(
y
)
*
y
=
(
int
)
yy
;
*
y
=
KiROUND
(
yy
)
;
if
(
d
)
if
(
d
)
*
d
=
dist
;
*
d
=
dist
;
...
@@ -405,7 +399,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int w1,
...
@@ -405,7 +399,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int w1,
double
dist
;
double
dist
;
TestForIntersectionOfStraightLineSegments
(
x1i
,
y1i
,
x1f
,
y1f
,
TestForIntersectionOfStraightLineSegments
(
x1i
,
y1i
,
x1f
,
y1f
,
x2i
,
y2i
,
x2f
,
y2f
,
&
xx
,
&
yy
,
&
dist
);
x2i
,
y2i
,
x2f
,
y2f
,
&
xx
,
&
yy
,
&
dist
);
int
d
=
(
int
)
dist
-
(
(
w1
+
w2
)
/
2
);
int
d
=
KiROUND
(
dist
-
(
w1
+
w2
)
/
2
);
if
(
d
<
0
)
if
(
d
<
0
)
d
=
0
;
d
=
0
;
...
...
polygon/math_for_graphics.h
View file @
cb49ca5a
...
@@ -60,8 +60,12 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
...
@@ -60,8 +60,12 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
* if b > DBL_MAX/10, assume vertical line at x = a
* if b > DBL_MAX/10, assume vertical line at x = a
* returns closest point on line in xpp, ypp
* returns closest point on line in xpp, ypp
*/
*/
double
GetPointToLineDistance
(
double
a
,
double
b
,
int
x
,
int
y
,
double
*
xp
=
NULL
,
double
*
yp
=
NULL
);
double
GetPointToLineDistance
(
double
a
,
double
b
,
int
x
,
int
y
,
double
*
xp
=
NULL
,
double
*
yp
=
NULL
);
double
Distance
(
double
x1
,
double
y1
,
double
x2
,
double
y2
);
inline
double
Distance
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
return
hypot
(
x1
-
x2
,
y1
-
y2
);
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment