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
e126042b
Commit
e126042b
authored
Dec 29, 2007
by
raburton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set eol-style native on new files
parent
5eda8a52
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
4471 additions
and
4471 deletions
+4471
-4471
PolyLine.cpp
polygon/PolyLine.cpp
+1888
-1888
PolyLine.h
polygon/PolyLine.h
+177
-177
PolyLine2Kicad.h
polygon/PolyLine2Kicad.h
+94
-94
cdisplaylist_stuff.cpp
polygon/cdisplaylist_stuff.cpp
+85
-85
freepcbDisplayList.h
polygon/freepcbDisplayList.h
+269
-269
freepcb_ids.h
polygon/freepcb_ids.h
+118
-118
math_for_graphics.cpp
polygon/math_for_graphics.cpp
+1736
-1736
math_for_graphics.h
polygon/math_for_graphics.h
+104
-104
No files found.
polygon/PolyLine.cpp
View file @
e126042b
This diff is collapsed.
Click to expand it.
polygon/PolyLine.h
View file @
e126042b
This diff is collapsed.
Click to expand it.
polygon/PolyLine2Kicad.h
View file @
e126042b
// PolyLine.h ... definition of CPolyLine class
//
// A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles
// There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of
// each contour.
//
// When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper.
//
// If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE2KICAD_H
#define POLYLINE2KICAD_H
#define PCBU_PER_MIL 10
#define MAX_LAYERS 32
#define NM_PER_MIL 10 // 25400
// pad shapes
enum
{
PAD_NONE
=
0
,
PAD_ROUND
,
PAD_SQUARE
,
PAD_RECT
,
PAD_RRECT
,
PAD_OVAL
,
PAD_OCTAGON
};
/*
enum
{
// visible layers
LAY_SELECTION = 0,
LAY_BACKGND,
LAY_VISIBLE_GRID,
LAY_HILITE,
LAY_DRC_ERROR,
LAY_BOARD_OUTLINE,
LAY_RAT_LINE,
LAY_SILK_TOP,
LAY_SILK_BOTTOM,
LAY_SM_TOP,
LAY_SM_BOTTOM,
LAY_PAD_THRU,
LAY_TOP_COPPER,
LAY_BOTTOM_COPPER,
// invisible layers
LAY_MASK_TOP = -100,
LAY_MASK_BOTTOM = -101,
LAY_PASTE_TOP = -102,
LAY_PASTE_BOTTOM = -103
};
*/
#define LAY_SELECTION 0
#define LAY_TOP_COPPER 0
#define CDC wxDC
class
wxDC
;
#if 0
class dl_element;
class CDisplayList {
public:
void Set_visible(void*, int) {};
int Get_x(void) { return 0;};
int Get_y(void) { return 0;};
void StopDragging(void) {};
void CancelHighLight(void) {};
void StartDraggingLineVertex(...) {};
void Add() {};
};
#endif
class
CRect
{
public
:
int
left
,
right
,
top
,
bottom
;
};
class
CPoint
{
public
:
int
x
,
y
;
public
:
CPoint
(
void
)
{
x
=
y
=
0
;};
CPoint
(
int
i
,
int
j
)
{
x
=
i
;
y
=
j
;};
};
#endif // #ifndef POLYLINE2KICAD_H
// PolyLine.h ... definition of CPolyLine class
//
// A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles
// There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of
// each contour.
//
// When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper.
//
// If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE2KICAD_H
#define POLYLINE2KICAD_H
#define PCBU_PER_MIL 10
#define MAX_LAYERS 32
#define NM_PER_MIL 10 // 25400
// pad shapes
enum
{
PAD_NONE
=
0
,
PAD_ROUND
,
PAD_SQUARE
,
PAD_RECT
,
PAD_RRECT
,
PAD_OVAL
,
PAD_OCTAGON
};
/*
enum
{
// visible layers
LAY_SELECTION = 0,
LAY_BACKGND,
LAY_VISIBLE_GRID,
LAY_HILITE,
LAY_DRC_ERROR,
LAY_BOARD_OUTLINE,
LAY_RAT_LINE,
LAY_SILK_TOP,
LAY_SILK_BOTTOM,
LAY_SM_TOP,
LAY_SM_BOTTOM,
LAY_PAD_THRU,
LAY_TOP_COPPER,
LAY_BOTTOM_COPPER,
// invisible layers
LAY_MASK_TOP = -100,
LAY_MASK_BOTTOM = -101,
LAY_PASTE_TOP = -102,
LAY_PASTE_BOTTOM = -103
};
*/
#define LAY_SELECTION 0
#define LAY_TOP_COPPER 0
#define CDC wxDC
class
wxDC
;
#if 0
class dl_element;
class CDisplayList {
public:
void Set_visible(void*, int) {};
int Get_x(void) { return 0;};
int Get_y(void) { return 0;};
void StopDragging(void) {};
void CancelHighLight(void) {};
void StartDraggingLineVertex(...) {};
void Add() {};
};
#endif
class
CRect
{
public
:
int
left
,
right
,
top
,
bottom
;
};
class
CPoint
{
public
:
int
x
,
y
;
public
:
CPoint
(
void
)
{
x
=
y
=
0
;};
CPoint
(
int
i
,
int
j
)
{
x
=
i
;
y
=
j
;};
};
#endif // #ifndef POLYLINE2KICAD_H
polygon/cdisplaylist_stuff.cpp
View file @
e126042b
/* stuff for class CDisplayList */
#include "PolyLine.h"
dl_element
*
CDisplayList
::
Add
(
id
id
,
void
*
ptr
,
int
glayer
,
int
gtype
,
int
visible
,
int
w
,
int
holew
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
xo
,
int
yo
,
int
radius
,
int
orig_layer
)
{
return
NULL
;
}
dl_element
*
CDisplayList
::
AddSelector
(
id
id
,
void
*
ptr
,
int
glayer
,
int
gtype
,
int
visible
,
int
w
,
int
holew
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
xo
,
int
yo
,
int
radius
)
{
return
NULL
;
}
void
CDisplayList
::
Set_visible
(
dl_element
*
el
,
int
visible
)
{
}
int
CDisplayList
::
StopDragging
()
{
return
0
;
}
int
CDisplayList
::
CancelHighLight
()
{
return
0
;
}
void
CDisplayList
::
Set_id
(
dl_element
*
el
,
id
*
id
)
{
}
id
CDisplayList
::
Remove
(
dl_element
*
element
)
{
return
0
;
}
int
CDisplayList
::
Get_w
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_x
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_y
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_xf
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_yf
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
HighLight
(
int
gtype
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
w
,
int
orig_layer
)
{
return
0
;
}
int
CDisplayList
::
StartDraggingLineVertex
(
CDC
*
pDC
,
int
x
,
int
y
,
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
layer1
,
int
layer2
,
int
w1
,
int
w2
,
int
style1
,
int
style2
,
int
layer_no_via
,
int
via_w
,
int
via_holew
,
int
dir
,
int
crosshair
)
{
return
0
;
}
int
CDisplayList
::
StartDraggingArc
(
CDC
*
pDC
,
int
style
,
int
x
,
int
y
,
int
xi
,
int
yi
,
int
layer
,
int
w
,
int
crosshair
)
{
return
0
;
}
/* stuff for class CDisplayList */
#include "PolyLine.h"
dl_element
*
CDisplayList
::
Add
(
id
id
,
void
*
ptr
,
int
glayer
,
int
gtype
,
int
visible
,
int
w
,
int
holew
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
xo
,
int
yo
,
int
radius
,
int
orig_layer
)
{
return
NULL
;
}
dl_element
*
CDisplayList
::
AddSelector
(
id
id
,
void
*
ptr
,
int
glayer
,
int
gtype
,
int
visible
,
int
w
,
int
holew
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
xo
,
int
yo
,
int
radius
)
{
return
NULL
;
}
void
CDisplayList
::
Set_visible
(
dl_element
*
el
,
int
visible
)
{
}
int
CDisplayList
::
StopDragging
()
{
return
0
;
}
int
CDisplayList
::
CancelHighLight
()
{
return
0
;
}
void
CDisplayList
::
Set_id
(
dl_element
*
el
,
id
*
id
)
{
}
id
CDisplayList
::
Remove
(
dl_element
*
element
)
{
return
0
;
}
int
CDisplayList
::
Get_w
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_x
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_y
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_xf
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
Get_yf
(
dl_element
*
el
)
{
return
0
;
}
int
CDisplayList
::
HighLight
(
int
gtype
,
int
x
,
int
y
,
int
xf
,
int
yf
,
int
w
,
int
orig_layer
)
{
return
0
;
}
int
CDisplayList
::
StartDraggingLineVertex
(
CDC
*
pDC
,
int
x
,
int
y
,
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
layer1
,
int
layer2
,
int
w1
,
int
w2
,
int
style1
,
int
style2
,
int
layer_no_via
,
int
via_w
,
int
via_holew
,
int
dir
,
int
crosshair
)
{
return
0
;
}
int
CDisplayList
::
StartDraggingArc
(
CDC
*
pDC
,
int
style
,
int
x
,
int
y
,
int
xi
,
int
yi
,
int
layer
,
int
w
,
int
crosshair
)
{
return
0
;
}
polygon/freepcbDisplayList.h
View file @
e126042b
This diff is collapsed.
Click to expand it.
polygon/freepcb_ids.h
View file @
e126042b
// definition of ID structure used by FreePCB
//
#pragma once
// struct id : this structure is used to identify PCB design elements
// such as instances of parts or nets, and their subelements
// Each element will have its own id.
// An id is attached to each item of the Display List so that it can
// be linked back to the PCB design element which drew it.
// These are mainly used to identify items selected by clicking the mouse
//
// In general:
// id.type = type of PCB element (e.g. part, net, text)
// id.st = subelement type (e.g. part pad, net connection)
// id.i = subelement index (zero-based)
// id.sst = subelement of subelement (e.g. net connection segment)
// id.ii = subsubelement index (zero-based)
//
// For example, the id for segment 0 of connection 4 of net 12 would be
// id = { ID_NET, 12, ID_CONNECT, 4, ID_SEG, 0 };
//
//
class
id
{
public
:
// constructor
id
(
int
qt
=
0
,
int
qst
=
0
,
int
qis
=
0
,
int
qsst
=
0
,
int
qiis
=
0
)
{
type
=
qt
;
st
=
qst
;
i
=
qis
;
sst
=
qsst
;
ii
=
qiis
;
}
// operators
friend
int
operator
==
(
id
id1
,
id
id2
)
{
return
(
id1
.
type
==
id2
.
type
&&
id1
.
st
==
id2
.
st
&&
id1
.
sst
==
id2
.
sst
&&
id1
.
i
==
id2
.
i
&&
id1
.
ii
==
id2
.
ii
);
}
// member functions
void
Clear
()
{
type
=
0
;
st
=
0
;
i
=
0
;
sst
=
0
;
ii
=
0
;
}
void
Set
(
int
qt
,
int
qst
=
0
,
int
qis
=
0
,
int
qsst
=
0
,
int
qiis
=
0
)
{
type
=
qt
;
st
=
qst
;
i
=
qis
;
sst
=
qsst
;
ii
=
qiis
;
}
// member variables
unsigned
int
type
;
// type of element
unsigned
int
st
;
// type of subelement
unsigned
int
i
;
// index of subelement
unsigned
int
sst
;
// type of subsubelement
unsigned
int
ii
;
// index of subsubelement
};
// these are constants used in ids
// root types
enum
{
ID_NONE
=
0
,
// an undefined type or st (or an error)
ID_BOARD
,
// board outline
ID_PART
,
// part
ID_NET
,
// net
ID_TEXT
,
// free-standing text
ID_DRC
,
// DRC error
ID_SM_CUTOUT
,
// cutout for solder mask
ID_MULTI
// if multiple selections
};
// subtypes of ID_PART
enum
{
ID_PAD
=
1
,
// pad_stack in a part
ID_SEL_PAD
,
// selection rectangle for pad_stack in a part
ID_OUTLINE
,
// part outline
ID_REF_TXT
,
// text showing ref num for part
ID_ORIG
,
// part origin
ID_SEL_RECT
,
// selection rectangle for part
ID_SEL_REF_TXT
// selection rectangle for ref text
};
// subtypes of ID_TEXT
enum
{
ID_SEL_TXT
=
1
,
// selection rectangle
ID_STROKE
// stroke for text
};
// subtypes of ID_NET
enum
{
ID_ENTIRE_NET
=
0
,
ID_CONNECT
,
// connection
ID_AREA
// copper area
};
// subtypes of ID_BOARD
enum
{
ID_BOARD_OUTLINE
=
1
,
};
// subsubtypes of ID_NET.ID_CONNECT
enum
{
ID_ENTIRE_CONNECT
=
0
,
ID_SEG
,
ID_SEL_SEG
,
ID_VERTEX
,
ID_SEL_VERTEX
,
ID_VIA
};
// subsubtypes of ID_NET.ID_AREA, ID_BOARD.ID_BOARD_OUTLINE, ID_SM_CUTOUT
enum
{
ID_SIDE
=
1
,
ID_SEL_SIDE
,
ID_SEL_CORNER
,
ID_HATCH
,
ID_PIN_X
,
// only used by ID_AREA
ID_STUB_X
// only used by ID_AREA
};
// subtypes of ID_DRC
// for subsubtypes, use types in DesignRules.h
enum
{
ID_DRE
=
1
,
ID_SEL_DRE
};
// definition of ID structure used by FreePCB
//
#pragma once
// struct id : this structure is used to identify PCB design elements
// such as instances of parts or nets, and their subelements
// Each element will have its own id.
// An id is attached to each item of the Display List so that it can
// be linked back to the PCB design element which drew it.
// These are mainly used to identify items selected by clicking the mouse
//
// In general:
// id.type = type of PCB element (e.g. part, net, text)
// id.st = subelement type (e.g. part pad, net connection)
// id.i = subelement index (zero-based)
// id.sst = subelement of subelement (e.g. net connection segment)
// id.ii = subsubelement index (zero-based)
//
// For example, the id for segment 0 of connection 4 of net 12 would be
// id = { ID_NET, 12, ID_CONNECT, 4, ID_SEG, 0 };
//
//
class
id
{
public
:
// constructor
id
(
int
qt
=
0
,
int
qst
=
0
,
int
qis
=
0
,
int
qsst
=
0
,
int
qiis
=
0
)
{
type
=
qt
;
st
=
qst
;
i
=
qis
;
sst
=
qsst
;
ii
=
qiis
;
}
// operators
friend
int
operator
==
(
id
id1
,
id
id2
)
{
return
(
id1
.
type
==
id2
.
type
&&
id1
.
st
==
id2
.
st
&&
id1
.
sst
==
id2
.
sst
&&
id1
.
i
==
id2
.
i
&&
id1
.
ii
==
id2
.
ii
);
}
// member functions
void
Clear
()
{
type
=
0
;
st
=
0
;
i
=
0
;
sst
=
0
;
ii
=
0
;
}
void
Set
(
int
qt
,
int
qst
=
0
,
int
qis
=
0
,
int
qsst
=
0
,
int
qiis
=
0
)
{
type
=
qt
;
st
=
qst
;
i
=
qis
;
sst
=
qsst
;
ii
=
qiis
;
}
// member variables
unsigned
int
type
;
// type of element
unsigned
int
st
;
// type of subelement
unsigned
int
i
;
// index of subelement
unsigned
int
sst
;
// type of subsubelement
unsigned
int
ii
;
// index of subsubelement
};
// these are constants used in ids
// root types
enum
{
ID_NONE
=
0
,
// an undefined type or st (or an error)
ID_BOARD
,
// board outline
ID_PART
,
// part
ID_NET
,
// net
ID_TEXT
,
// free-standing text
ID_DRC
,
// DRC error
ID_SM_CUTOUT
,
// cutout for solder mask
ID_MULTI
// if multiple selections
};
// subtypes of ID_PART
enum
{
ID_PAD
=
1
,
// pad_stack in a part
ID_SEL_PAD
,
// selection rectangle for pad_stack in a part
ID_OUTLINE
,
// part outline
ID_REF_TXT
,
// text showing ref num for part
ID_ORIG
,
// part origin
ID_SEL_RECT
,
// selection rectangle for part
ID_SEL_REF_TXT
// selection rectangle for ref text
};
// subtypes of ID_TEXT
enum
{
ID_SEL_TXT
=
1
,
// selection rectangle
ID_STROKE
// stroke for text
};
// subtypes of ID_NET
enum
{
ID_ENTIRE_NET
=
0
,
ID_CONNECT
,
// connection
ID_AREA
// copper area
};
// subtypes of ID_BOARD
enum
{
ID_BOARD_OUTLINE
=
1
,
};
// subsubtypes of ID_NET.ID_CONNECT
enum
{
ID_ENTIRE_CONNECT
=
0
,
ID_SEG
,
ID_SEL_SEG
,
ID_VERTEX
,
ID_SEL_VERTEX
,
ID_VIA
};
// subsubtypes of ID_NET.ID_AREA, ID_BOARD.ID_BOARD_OUTLINE, ID_SM_CUTOUT
enum
{
ID_SIDE
=
1
,
ID_SEL_SIDE
,
ID_SEL_CORNER
,
ID_HATCH
,
ID_PIN_X
,
// only used by ID_AREA
ID_STUB_X
// only used by ID_AREA
};
// subtypes of ID_DRC
// for subsubtypes, use types in DesignRules.h
enum
{
ID_DRE
=
1
,
ID_SEL_DRE
};
polygon/math_for_graphics.cpp
View file @
e126042b
This diff is collapsed.
Click to expand it.
polygon/math_for_graphics.h
View file @
e126042b
// math stuff for graphics, from FreePCB
typedef
struct
PointTag
{
double
X
,
Y
;
}
Point
;
typedef
struct
EllipseTag
{
Point
Center
;
/* ellipse center */
// double MaxRad,MinRad; /* major and minor axis */
// double Phi; /* major axis rotation */
double
xrad
,
yrad
;
// radii on x and y
double
theta1
,
theta2
;
// start and end angle for arc
}
EllipseKH
;
const
CPoint
zero
(
0
,
0
);
class
my_circle
{
public
:
my_circle
(){};
my_circle
(
int
xx
,
int
yy
,
int
rr
)
{
x
=
xx
;
y
=
yy
;
r
=
rr
;
};
int
x
,
y
,
r
;
};
class
my_rect
{
public
:
my_rect
(){};
my_rect
(
int
xi
,
int
yi
,
int
xf
,
int
yf
)
{
xlo
=
min
(
xi
,
xf
);
xhi
=
max
(
xi
,
xf
);
ylo
=
min
(
yi
,
yf
);
yhi
=
max
(
yi
,
yf
);
};
int
xlo
,
ylo
,
xhi
,
yhi
;
};
class
my_seg
{
public
:
my_seg
(){};
my_seg
(
int
xxi
,
int
yyi
,
int
xxf
,
int
yyf
)
{
xi
=
xxi
;
yi
=
yyi
;
xf
=
xxf
;
yf
=
yyf
;
};
int
xi
,
yi
,
xf
,
yf
;
};
// math stuff for graphics
BOOL
Quadratic
(
double
a
,
double
b
,
double
c
,
double
*
x1
,
double
*
x2
);
void
DrawArc
(
CDC
*
pDC
,
int
shape
,
int
xxi
,
int
yyi
,
int
xxf
,
int
yyf
,
BOOL
bMeta
=
FALSE
);
void
RotatePoint
(
CPoint
*
p
,
int
angle
,
CPoint
org
);
void
RotateRect
(
CRect
*
r
,
int
angle
,
CPoint
org
);
int
TestLineHit
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
x
,
int
y
,
double
dist
);
int
FindLineIntersection
(
double
a
,
double
b
,
double
c
,
double
d
,
double
*
x
,
double
*
y
);
int
FindLineSegmentIntersection
(
double
a
,
double
b
,
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
style
,
double
*
x1
,
double
*
y1
,
double
*
x2
,
double
*
y2
,
double
*
dist
=
NULL
);
int
FindSegmentIntersections
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
style
,
int
xi2
,
int
yi2
,
int
xf2
,
int
yf2
,
int
style2
,
double
x
[]
=
NULL
,
double
y
[]
=
NULL
);
BOOL
FindLineEllipseIntersections
(
double
a
,
double
b
,
double
c
,
double
d
,
double
*
x1
,
double
*
x2
);
BOOL
FindVerticalLineEllipseIntersections
(
double
a
,
double
b
,
double
x
,
double
*
y1
,
double
*
y2
);
BOOL
TestForIntersectionOfStraightLineSegments
(
int
x1i
,
int
y1i
,
int
x1f
,
int
y1f
,
int
x2i
,
int
y2i
,
int
x2f
,
int
y2f
,
int
*
x
=
NULL
,
int
*
y
=
NULL
,
double
*
dist
=
NULL
);
void
GetPadElements
(
int
type
,
int
x
,
int
y
,
int
wid
,
int
len
,
int
radius
,
int
angle
,
int
*
nr
,
my_rect
r
[],
int
*
nc
,
my_circle
c
[],
int
*
ns
,
my_seg
s
[]
);
int
GetClearanceBetweenPads
(
int
type1
,
int
x1
,
int
y1
,
int
w1
,
int
l1
,
int
r1
,
int
angle1
,
int
type2
,
int
x2
,
int
y2
,
int
w2
,
int
l2
,
int
r2
,
int
angle2
);
int
GetClearanceBetweenSegmentAndPad
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
w
,
int
type
,
int
x
,
int
y
,
int
wid
,
int
len
,
int
radius
,
int
angle
);
int
GetClearanceBetweenSegments
(
int
x1i
,
int
y1i
,
int
x1f
,
int
y1f
,
int
style1
,
int
w1
,
int
x2i
,
int
y2i
,
int
x2f
,
int
y2f
,
int
style2
,
int
w2
,
int
max_cl
,
int
*
x
,
int
*
y
);
/** Function GetPointToLineSegmentDistance
* Get distance between line segment and point
* @param x,y = point
* @param xi,yi and xf,yf = the end-points of the line segment
* @return the distance
*/
double
GetPointToLineSegmentDistance
(
int
x
,
int
y
,
int
xi
,
int
yi
,
int
xf
,
int
yf
);
double
GetPointToLineDistance
(
double
a
,
double
b
,
int
x
,
int
y
,
double
*
xp
=
NULL
,
double
*
yp
=
NULL
);
BOOL
InRange
(
double
x
,
double
xi
,
double
xf
);
double
Distance
(
int
x1
,
int
y1
,
int
x2
,
int
y2
);
int
GetArcIntersections
(
EllipseKH
*
el1
,
EllipseKH
*
el2
,
double
*
x1
=
NULL
,
double
*
y1
=
NULL
,
double
*
x2
=
NULL
,
double
*
y2
=
NULL
);
CPoint
GetInflectionPoint
(
CPoint
pi
,
CPoint
pf
,
int
mode
);
// quicksort (2-way or 3-way)
void
quickSort
(
int
numbers
[],
int
index
[],
int
array_size
);
void
q_sort
(
int
numbers
[],
int
index
[],
int
left
,
int
right
);
void
q_sort_3way
(
int
a
[],
int
b
[],
int
left
,
int
right
);
// math stuff for graphics, from FreePCB
typedef
struct
PointTag
{
double
X
,
Y
;
}
Point
;
typedef
struct
EllipseTag
{
Point
Center
;
/* ellipse center */
// double MaxRad,MinRad; /* major and minor axis */
// double Phi; /* major axis rotation */
double
xrad
,
yrad
;
// radii on x and y
double
theta1
,
theta2
;
// start and end angle for arc
}
EllipseKH
;
const
CPoint
zero
(
0
,
0
);
class
my_circle
{
public
:
my_circle
(){};
my_circle
(
int
xx
,
int
yy
,
int
rr
)
{
x
=
xx
;
y
=
yy
;
r
=
rr
;
};
int
x
,
y
,
r
;
};
class
my_rect
{
public
:
my_rect
(){};
my_rect
(
int
xi
,
int
yi
,
int
xf
,
int
yf
)
{
xlo
=
min
(
xi
,
xf
);
xhi
=
max
(
xi
,
xf
);
ylo
=
min
(
yi
,
yf
);
yhi
=
max
(
yi
,
yf
);
};
int
xlo
,
ylo
,
xhi
,
yhi
;
};
class
my_seg
{
public
:
my_seg
(){};
my_seg
(
int
xxi
,
int
yyi
,
int
xxf
,
int
yyf
)
{
xi
=
xxi
;
yi
=
yyi
;
xf
=
xxf
;
yf
=
yyf
;
};
int
xi
,
yi
,
xf
,
yf
;
};
// math stuff for graphics
BOOL
Quadratic
(
double
a
,
double
b
,
double
c
,
double
*
x1
,
double
*
x2
);
void
DrawArc
(
CDC
*
pDC
,
int
shape
,
int
xxi
,
int
yyi
,
int
xxf
,
int
yyf
,
BOOL
bMeta
=
FALSE
);
void
RotatePoint
(
CPoint
*
p
,
int
angle
,
CPoint
org
);
void
RotateRect
(
CRect
*
r
,
int
angle
,
CPoint
org
);
int
TestLineHit
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
x
,
int
y
,
double
dist
);
int
FindLineIntersection
(
double
a
,
double
b
,
double
c
,
double
d
,
double
*
x
,
double
*
y
);
int
FindLineSegmentIntersection
(
double
a
,
double
b
,
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
style
,
double
*
x1
,
double
*
y1
,
double
*
x2
,
double
*
y2
,
double
*
dist
=
NULL
);
int
FindSegmentIntersections
(
int
xi
,
int
yi
,
int
xf
,
int
yf
,
int
style
,
int
xi2
,
int
yi2
,
int
xf2
,
int
yf2
,
int
style2
,
double
x
[]
=
NULL
,
double
y
[]
=
NULL
);
BOOL
FindLineEllipseIntersections
(
double
a
,
double
b
,
double
c
,
double
d
,
double
*
x1
,
double
*
x2
);
BOOL
FindVerticalLineEllipseIntersections
(
double
a
,
double
b
,
double
x
,
double
*
y1
,
double
*
y2
);
BOOL
TestForIntersectionOfStraightLineSegments
(
int
x1i
,
int
y1i
,
int
x1f
,
int
y1f
,
int
x2i
,
int
y2i
,
int
x2f
,
int
y2f
,
int
*
x
=
NULL
,
int
*
y
=
NULL
,
double
*
dist
=
NULL
);
void
GetPadElements
(
int
type
,
int
x
,
int
y
,
int
wid
,
int
len
,
int
radius
,
int
angle
,
int
*
nr
,
my_rect
r
[],
int
*
nc
,
my_circle
c
[],
int
*
ns
,
my_seg
s
[]
);
int
GetClearanceBetweenPads
(
int
type1
,
int
x1
,
int
y1
,
int
w1
,
int
l1
,
int
r1
,
int
angle1
,
int
type2
,
int
x2
,
int
y2
,
int
w2
,
int
l2
,
int
r2
,
int
angle2
);
int
GetClearanceBetweenSegmentAndPad
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
w
,
int
type
,
int
x
,
int
y
,
int
wid
,
int
len
,
int
radius
,
int
angle
);
int
GetClearanceBetweenSegments
(
int
x1i
,
int
y1i
,
int
x1f
,
int
y1f
,
int
style1
,
int
w1
,
int
x2i
,
int
y2i
,
int
x2f
,
int
y2f
,
int
style2
,
int
w2
,
int
max_cl
,
int
*
x
,
int
*
y
);
/** Function GetPointToLineSegmentDistance
* Get distance between line segment and point
* @param x,y = point
* @param xi,yi and xf,yf = the end-points of the line segment
* @return the distance
*/
double
GetPointToLineSegmentDistance
(
int
x
,
int
y
,
int
xi
,
int
yi
,
int
xf
,
int
yf
);
double
GetPointToLineDistance
(
double
a
,
double
b
,
int
x
,
int
y
,
double
*
xp
=
NULL
,
double
*
yp
=
NULL
);
BOOL
InRange
(
double
x
,
double
xi
,
double
xf
);
double
Distance
(
int
x1
,
int
y1
,
int
x2
,
int
y2
);
int
GetArcIntersections
(
EllipseKH
*
el1
,
EllipseKH
*
el2
,
double
*
x1
=
NULL
,
double
*
y1
=
NULL
,
double
*
x2
=
NULL
,
double
*
y2
=
NULL
);
CPoint
GetInflectionPoint
(
CPoint
pi
,
CPoint
pf
,
int
mode
);
// quicksort (2-way or 3-way)
void
quickSort
(
int
numbers
[],
int
index
[],
int
array_size
);
void
q_sort
(
int
numbers
[],
int
index
[],
int
left
,
int
right
);
void
q_sort_3way
(
int
a
[],
int
b
[],
int
left
,
int
right
);
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