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
f2f4cd53
Commit
f2f4cd53
authored
Nov 16, 2009
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework on zones (continued):try to fix a filling problem with kbool: cleanup code
parent
537d4861
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
872 additions
and
678 deletions
+872
-678
board_items_to_polygon_shape_transform.cpp
pcbnew/board_items_to_polygon_shape_transform.cpp
+629
-60
class_drawsegment.h
pcbnew/class_drawsegment.h
+38
-17
class_pad.h
pcbnew/class_pad.h
+3
-2
class_pcb_text.h
pcbnew/class_pcb_text.h
+18
-0
class_track.h
pcbnew/class_track.h
+3
-2
debug_kbool_key_file_fct.cpp
pcbnew/debug_kbool_key_file_fct.cpp
+49
-44
debug_kbool_key_file_fct.h
pcbnew/debug_kbool_key_file_fct.h
+2
-2
zones_convert_brd_items_to_polygons.cpp
pcbnew/zones_convert_brd_items_to_polygons.cpp
+130
-551
No files found.
pcbnew/board_items_to_polygon_shape_transform.cpp
View file @
f2f4cd53
This diff is collapsed.
Click to expand it.
pcbnew/class_drawsegment.h
View file @
f2f4cd53
...
...
@@ -4,6 +4,7 @@
#ifndef CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
#include "polyline.h"
class
DRAWSEGMENT
:
public
BOARD_ITEM
{
...
...
@@ -116,36 +117,56 @@ public:
return
hypot
(
delta
.
x
,
delta
.
y
);
}
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual
void
Move
(
const
wxPoint
&
aMoveVector
)
virtual
void
Move
(
const
wxPoint
&
aMoveVector
)
{
m_Start
+=
aMoveVector
;
m_End
+=
aMoveVector
;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual
void
Rotate
(
const
wxPoint
&
aRotCentre
,
int
aAngle
);
virtual
void
Rotate
(
const
wxPoint
&
aRotCentre
,
int
aAngle
);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual
void
Flip
(
const
wxPoint
&
aCentre
);
virtual
void
Flip
(
const
wxPoint
&
aCentre
);
/** Function TransformShapeWithClearanceToPolygon
* Convert the track shape to a closed polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* @param aCornerBuffer = a buffer to store the polygon
* @param aClearanceValue = the clearance around the pad
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void
TransformShapeWithClearanceToPolygon
(
std
::
vector
<
CPolyPt
>&
aCornerBuffer
,
int
aClearanceValue
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
#if defined(DEBUG)
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
#endif
#endif
};
...
...
pcbnew/class_pad.h
View file @
f2f4cd53
...
...
@@ -5,6 +5,7 @@
class
Pcb3D_GLCanvas
;
#include "pad_shapes.h"
#include "polyline.h"
/* Default layers used for pads, according to the pad type.
* this is default values only, they can be changed for a given pad
...
...
@@ -141,7 +142,7 @@ public:
m_Pos
=
aPos
;
}
/** function Transform
Pad
WithClearanceToPolygon
/** function Transform
Shape
WithClearanceToPolygon
* Convert the pad shape to a closed polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
...
...
@@ -152,7 +153,7 @@ public:
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void
Transform
PadWithClearanceToPolygon
(
std
::
vector
<
wxPoin
t
>&
aCornerBuffer
,
void
Transform
ShapeWithClearanceToPolygon
(
std
::
vector
<
CPolyP
t
>&
aCornerBuffer
,
int
aClearanceValue
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
/**
...
...
pcbnew/class_pcb_text.h
View file @
f2f4cd53
...
...
@@ -5,6 +5,7 @@
#define CLASS_PCB_TEXT_H
#include "base_struct.h"
#include "polyline.h"
class
TEXTE_PCB
:
public
BOARD_ITEM
,
public
EDA_TextStruct
{
...
...
@@ -110,6 +111,23 @@ public:
return
wxT
(
"PTEXT"
);
}
/** Function TransformShapeWithClearanceToPolygon
* Convert the track shape to a closed polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* @param aCornerBuffer = a buffer to store the polygon
* @param aClearanceValue = the clearance around the pad
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void
TransformShapeWithClearanceToPolygon
(
std
::
vector
<
CPolyPt
>&
aCornerBuffer
,
int
aClearanceValue
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
#if defined(DEBUG)
/**
* Function Show
...
...
pcbnew/class_track.h
View file @
f2f4cd53
...
...
@@ -6,6 +6,7 @@
#define CLASS_TRACK_H
#include "base_struct.h"
#include "polyline.h"
// Via attributes (m_Shape parmeter)
...
...
@@ -148,7 +149,7 @@ public:
/* divers */
int
Shape
()
const
{
return
m_Shape
&
0xFF
;
}
/** Function Transform
Track
WithClearanceToPolygon
/** Function Transform
Shape
WithClearanceToPolygon
* Convert the track shape to a closed polygon
* Used in filling zones calculations
* Circles (vias) and arcs (ends of tracks) are approximated by segments
...
...
@@ -159,7 +160,7 @@ public:
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void
Transform
TrackWithClearanceToPolygon
(
std
::
vector
<
wxPoin
t
>&
aCornerBuffer
,
void
Transform
ShapeWithClearanceToPolygon
(
std
::
vector
<
CPolyP
t
>&
aCornerBuffer
,
int
aClearanceValue
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
...
...
pcbnew/debug_kbool_key_file_fct.cpp
View file @
f2f4cd53
...
...
@@ -14,9 +14,15 @@
#if defined (CREATE_KBOOL_KEY_FILES) || (CREATE_KBOOL_KEY_FILES_FIRST_PASS)
// Helper class to handle a coordinate
struct
kfcoord
{
int
x
,
y
;
};
static
FILE
*
kdebugFile
;
static
char
sDate_Time
[
256
];
static
vector
<
kfcoord
>
s_EntityCoordinates
;
void
CreateKeyFile
()
{
...
...
@@ -48,6 +54,8 @@ void CreateKeyFile()
{
wxMessageBox
(
wxT
(
"CreateKeyFile() cannot create output file"
)
);
}
s_EntityCoordinates
.
clear
();
}
...
...
@@ -58,11 +66,11 @@ void CloseKeyFile()
fprintf
(
kdebugFile
,
"
\n
ENDLIB;
\n
"
);
fclose
(
kdebugFile
);
}
s_EntityCoordinates
.
clear
();
}
const
char
*
sCurrEntityName
=
NULL
;
static
int
s_count
;
void
OpenKeyFileEntity
(
const
char
*
aName
)
{
...
...
@@ -74,7 +82,7 @@ void OpenKeyFileEntity( const char* aName )
fprintf
(
kdebugFile
,
"STRNAME %s;
\n
"
,
aName
);
}
sCurrEntityName
=
aName
;
s_
count
=
0
;
s_
EntityCoordinates
.
clear
()
;
}
...
...
@@ -84,20 +92,45 @@ void CloseKeyFileEntity()
fprintf
(
kdebugFile
,
"
\n
ENDSTR %s;
\n
"
,
sCurrEntityName
);
}
void
StartKeyFilePolygon
(
int
aCornersCount
,
int
aLayer
)
/* start a polygon entity in key file
*/
void
StartKeyFilePolygon
(
int
aLayer
)
{
s_EntityCoordinates
.
clear
();
fprintf
(
kdebugFile
,
"
\n
BOUNDARY; LAYER %d; DATATYPE 0;
\n
"
,
aLayer
);
fprintf
(
kdebugFile
,
" XY %d;
\n
"
,
aCornersCount
);
s_count
=
0
;
}
void
EndKeyFileElement
()
/* add a polygon corner to the current polygon entity in key file
*/
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
)
{
if
(
s_count
==
1
)
fprintf
(
kdebugFile
,
"
\n
"
);
fprintf
(
kdebugFile
,
"
\n
ENDEL;
\n
"
);
s_count
=
0
;
kfcoord
coord
;
coord
.
x
=
aXcoord
;
coord
.
y
=
aYcoord
;
s_EntityCoordinates
.
push_back
(
coord
);
}
/* Close a polygon entity in key file
* write the entire polygon data to the file
*/
void
EndKeyFilePolygon
()
{
// Polygon must be closed: test for that and close it if needed
if
(
s_EntityCoordinates
.
size
()
)
{
if
(
s_EntityCoordinates
.
back
().
x
!=
s_EntityCoordinates
[
0
].
x
||
s_EntityCoordinates
.
back
().
y
!=
s_EntityCoordinates
[
0
].
y
)
s_EntityCoordinates
.
push_back
(
s_EntityCoordinates
[
0
]
);
}
fprintf
(
kdebugFile
,
" XY %d;
\n
"
,
s_EntityCoordinates
.
size
()
);
for
(
unsigned
ii
=
0
;
ii
<
s_EntityCoordinates
.
size
();
ii
++
)
fprintf
(
kdebugFile
,
" X %d; Y %d;
\n
"
,
s_EntityCoordinates
[
ii
].
x
,
s_EntityCoordinates
[
ii
].
y
);
fprintf
(
kdebugFile
,
"ENDEL;
\n
"
);
s_EntityCoordinates
.
clear
();
}
void
CopyPolygonsFromFilledPolysListToKeyFile
(
ZONE_CONTAINER
*
aZone
,
int
aLayer
)
...
...
@@ -106,30 +139,15 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
return
;
unsigned
corners_count
=
aZone
->
m_FilledPolysList
.
size
();
int
count
=
0
;
unsigned
ic
=
0
;
CPolyPt
*
corner
;
while
(
ic
<
corners_count
)
{
// Count corners:
count
=
0
;
for
(
unsigned
ii
=
ic
;
ii
<
corners_count
;
ii
++
)
{
corner
=
&
aZone
->
m_FilledPolysList
[
ii
];
count
++
;
if
(
corner
->
end_contour
)
break
;
}
// write corners:
StartKeyFilePolygon
(
count
+
1
,
aLayer
);
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
int
startpointX
=
corner
->
x
;
int
startpointY
=
corner
->
y
;
// write polygon:
StartKeyFilePolygon
(
aLayer
);
for
(
;
ic
<
corners_count
;
ic
++
)
{
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
CPolyPt
*
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
AddKeyFilePointXY
(
corner
->
x
,
corner
->
y
);
if
(
corner
->
end_contour
)
{
...
...
@@ -137,21 +155,8 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
break
;
}
}
// Close polygon:
AddKeyFilePointXY
(
startpointX
,
startpointY
);
EndKeyFileElement
();
}
}
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
)
{
if
(
s_count
>=
2
)
{
s_count
=
0
;
fprintf
(
kdebugFile
,
"
\n
"
);
EndKeyFilePolygon
();
}
fprintf
(
kdebugFile
,
" X %d; Y %d;"
,
aXcoord
,
aYcoord
);
s_count
++
;
}
#endif
pcbnew/debug_kbool_key_file_fct.h
View file @
f2f4cd53
...
...
@@ -38,9 +38,9 @@ void CloseKeyFileEntity();
/* polygon creations:
*/
void
CopyPolygonsFromFilledPolysListToKeyFile
(
ZONE_CONTAINER
*
aZone
,
int
aLayer
);
void
StartKeyFilePolygon
(
int
aCornersCount
,
int
aLayer
);
void
StartKeyFilePolygon
(
int
aLayer
);
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
);
void
EndKeyFile
Element
();
void
EndKeyFile
Polygon
();
#endif // CREATE_KBOOL_KEY_FILES
...
...
pcbnew/zones_convert_brd_items_to_polygons.cpp
View file @
f2f4cd53
This diff is collapsed.
Click to expand it.
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