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
Hide 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 @@
...
@@ -4,6 +4,7 @@
#ifndef CLASS_DRAWSEGMENT_H
#ifndef CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
#include "polyline.h"
class
DRAWSEGMENT
:
public
BOARD_ITEM
class
DRAWSEGMENT
:
public
BOARD_ITEM
{
{
...
@@ -15,8 +16,8 @@ public:
...
@@ -15,8 +16,8 @@ public:
int
m_Shape
;
// Shape: line, Circle, Arc
int
m_Shape
;
// Shape: line, Circle, Arc
int
m_Type
;
// Used in complex associations ( Dimensions.. )
int
m_Type
;
// Used in complex associations ( Dimensions.. )
int
m_Angle
;
// Used only for Arcs: Arc angle in 1/10 deg
int
m_Angle
;
// Used only for Arcs: Arc angle in 1/10 deg
wxPoint
m_BezierC1
;
// Bezier Control Point 1
wxPoint
m_BezierC1
;
// Bezier Control Point 1
wxPoint
m_BezierC2
;
// Bezier Control Point 1
wxPoint
m_BezierC2
;
// Bezier Control Point 1
std
::
vector
<
wxPoint
>
m_BezierPoints
;
std
::
vector
<
wxPoint
>
m_BezierPoints
;
public
:
public
:
...
@@ -42,13 +43,13 @@ public:
...
@@ -42,13 +43,13 @@ public:
* Function GetStart
* Function GetStart
* returns the starting point of the graphic
* returns the starting point of the graphic
*/
*/
wxPoint
GetStart
()
const
;
wxPoint
GetStart
()
const
;
/**
/**
* Function GetEnd
* Function GetEnd
* returns the ending point of the graphic
* returns the ending point of the graphic
*/
*/
wxPoint
GetEnd
()
const
;
wxPoint
GetEnd
()
const
;
/**
/**
* Function Save
* Function Save
...
@@ -56,15 +57,15 @@ public:
...
@@ -56,15 +57,15 @@ public:
* @param aFile The FILE to write to.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
* @return bool - true if success writing else false.
*/
*/
bool
Save
(
FILE
*
aFile
)
const
;
bool
Save
(
FILE
*
aFile
)
const
;
bool
ReadDrawSegmentDescr
(
FILE
*
File
,
int
*
LineNum
);
bool
ReadDrawSegmentDescr
(
FILE
*
File
,
int
*
LineNum
);
void
Copy
(
DRAWSEGMENT
*
source
);
void
Copy
(
DRAWSEGMENT
*
source
);
void
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
void
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
int
aDrawMode
,
const
wxPoint
&
offset
=
ZeroOffset
);
int
aDrawMode
,
const
wxPoint
&
offset
=
ZeroOffset
);
/**
/**
* Function DisplayInfo
* Function DisplayInfo
...
@@ -73,7 +74,7 @@ public:
...
@@ -73,7 +74,7 @@ public:
* Is virtual from EDA_BaseStruct.
* Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information.
* @param frame A WinEDA_BasePcbFrame in which to print status information.
*/
*/
virtual
void
DisplayInfo
(
WinEDA_DrawFrame
*
frame
);
virtual
void
DisplayInfo
(
WinEDA_DrawFrame
*
frame
);
/**
/**
...
@@ -82,7 +83,7 @@ public:
...
@@ -82,7 +83,7 @@ public:
* @param ref_pos A wxPoint to test
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
* @return bool - true if a hit, else false
*/
*/
bool
HitTest
(
const
wxPoint
&
ref_pos
);
bool
HitTest
(
const
wxPoint
&
ref_pos
);
/**
/**
* Function HitTest (overlayed)
* Function HitTest (overlayed)
...
@@ -91,7 +92,7 @@ public:
...
@@ -91,7 +92,7 @@ public:
* @param refPos the given EDA_Rect to test
* @param refPos the given EDA_Rect to test
* @return bool - true if a hit, else false
* @return bool - true if a hit, else false
*/
*/
bool
HitTest
(
EDA_Rect
&
refArea
);
bool
HitTest
(
EDA_Rect
&
refArea
);
/**
/**
* Function GetClass
* Function GetClass
...
@@ -116,36 +117,56 @@ public:
...
@@ -116,36 +117,56 @@ public:
return
hypot
(
delta
.
x
,
delta
.
y
);
return
hypot
(
delta
.
x
,
delta
.
y
);
}
}
/**
/**
* Function Move
* Function Move
* move this object.
* move this object.
* @param const wxPoint& aMoveVector - the move vector for 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_Start
+=
aMoveVector
;
m_End
+=
aMoveVector
;
m_End
+=
aMoveVector
;
}
}
/**
/**
* Function Rotate
* Function Rotate
* Rotate this object.
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
* @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
* Function Flip
* Flip this object, i.e. change the board side for this object
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
* @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)
#if defined(DEBUG)
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
#endif
#endif
};
};
...
...
pcbnew/class_pad.h
View file @
f2f4cd53
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
class
Pcb3D_GLCanvas
;
class
Pcb3D_GLCanvas
;
#include "pad_shapes.h"
#include "pad_shapes.h"
#include "polyline.h"
/* Default layers used for pads, according to the pad type.
/* Default layers used for pads, according to the pad type.
* this is default values only, they can be changed for a given pad
* this is default values only, they can be changed for a given pad
...
@@ -141,7 +142,7 @@ public:
...
@@ -141,7 +142,7 @@ public:
m_Pos
=
aPos
;
m_Pos
=
aPos
;
}
}
/** function Transform
Pad
WithClearanceToPolygon
/** function Transform
Shape
WithClearanceToPolygon
* Convert the pad shape to a closed polygon
* Convert the pad shape to a closed polygon
* Used in filling zones calculations
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* Circles and arcs are approximated by segments
...
@@ -152,7 +153,7 @@ public:
...
@@ -152,7 +153,7 @@ public:
* clearance when the circle is approxiamted by segment bigger or equal
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
* 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
);
int
aClearanceValue
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
/**
/**
...
...
pcbnew/class_pcb_text.h
View file @
f2f4cd53
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#define CLASS_PCB_TEXT_H
#define CLASS_PCB_TEXT_H
#include "base_struct.h"
#include "base_struct.h"
#include "polyline.h"
class
TEXTE_PCB
:
public
BOARD_ITEM
,
public
EDA_TextStruct
class
TEXTE_PCB
:
public
BOARD_ITEM
,
public
EDA_TextStruct
{
{
...
@@ -110,6 +111,23 @@ public:
...
@@ -110,6 +111,23 @@ public:
return
wxT
(
"PTEXT"
);
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)
#if defined(DEBUG)
/**
/**
* Function Show
* Function Show
...
...
pcbnew/class_track.h
View file @
f2f4cd53
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#define CLASS_TRACK_H
#define CLASS_TRACK_H
#include "base_struct.h"
#include "base_struct.h"
#include "polyline.h"
// Via attributes (m_Shape parmeter)
// Via attributes (m_Shape parmeter)
...
@@ -148,7 +149,7 @@ public:
...
@@ -148,7 +149,7 @@ public:
/* divers */
/* divers */
int
Shape
()
const
{
return
m_Shape
&
0xFF
;
}
int
Shape
()
const
{
return
m_Shape
&
0xFF
;
}
/** Function Transform
Track
WithClearanceToPolygon
/** Function Transform
Shape
WithClearanceToPolygon
* Convert the track shape to a closed polygon
* Convert the track shape to a closed polygon
* Used in filling zones calculations
* Used in filling zones calculations
* Circles (vias) and arcs (ends of tracks) are approximated by segments
* Circles (vias) and arcs (ends of tracks) are approximated by segments
...
@@ -159,7 +160,7 @@ public:
...
@@ -159,7 +160,7 @@ public:
* clearance when the circle is approxiamted by segment bigger or equal
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
* 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
aClearanceValue
,
int
aCircleToSegmentsCount
,
int
aCircleToSegmentsCount
,
double
aCorrectionFactor
);
double
aCorrectionFactor
);
...
...
pcbnew/debug_kbool_key_file_fct.cpp
View file @
f2f4cd53
...
@@ -14,9 +14,15 @@
...
@@ -14,9 +14,15 @@
#if defined (CREATE_KBOOL_KEY_FILES) || (CREATE_KBOOL_KEY_FILES_FIRST_PASS)
#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
FILE
*
kdebugFile
;
static
char
sDate_Time
[
256
];
static
char
sDate_Time
[
256
];
static
vector
<
kfcoord
>
s_EntityCoordinates
;
void
CreateKeyFile
()
void
CreateKeyFile
()
{
{
...
@@ -48,6 +54,8 @@ void CreateKeyFile()
...
@@ -48,6 +54,8 @@ void CreateKeyFile()
{
{
wxMessageBox
(
wxT
(
"CreateKeyFile() cannot create output file"
)
);
wxMessageBox
(
wxT
(
"CreateKeyFile() cannot create output file"
)
);
}
}
s_EntityCoordinates
.
clear
();
}
}
...
@@ -58,11 +66,11 @@ void CloseKeyFile()
...
@@ -58,11 +66,11 @@ void CloseKeyFile()
fprintf
(
kdebugFile
,
"
\n
ENDLIB;
\n
"
);
fprintf
(
kdebugFile
,
"
\n
ENDLIB;
\n
"
);
fclose
(
kdebugFile
);
fclose
(
kdebugFile
);
}
}
s_EntityCoordinates
.
clear
();
}
}
const
char
*
sCurrEntityName
=
NULL
;
const
char
*
sCurrEntityName
=
NULL
;
static
int
s_count
;
void
OpenKeyFileEntity
(
const
char
*
aName
)
void
OpenKeyFileEntity
(
const
char
*
aName
)
{
{
...
@@ -74,7 +82,7 @@ void OpenKeyFileEntity( const char* aName )
...
@@ -74,7 +82,7 @@ void OpenKeyFileEntity( const char* aName )
fprintf
(
kdebugFile
,
"STRNAME %s;
\n
"
,
aName
);
fprintf
(
kdebugFile
,
"STRNAME %s;
\n
"
,
aName
);
}
}
sCurrEntityName
=
aName
;
sCurrEntityName
=
aName
;
s_
count
=
0
;
s_
EntityCoordinates
.
clear
()
;
}
}
...
@@ -84,20 +92,45 @@ void CloseKeyFileEntity()
...
@@ -84,20 +92,45 @@ void CloseKeyFileEntity()
fprintf
(
kdebugFile
,
"
\n
ENDSTR %s;
\n
"
,
sCurrEntityName
);
fprintf
(
kdebugFile
,
"
\n
ENDSTR %s;
\n
"
,
sCurrEntityName
);
}
}
/* start a polygon entity in key file
void
StartKeyFilePolygon
(
int
aCornersCount
,
int
aLayer
)
*/
void
StartKeyFilePolygon
(
int
aLayer
)
{
{
s_EntityCoordinates
.
clear
();
fprintf
(
kdebugFile
,
"
\n
BOUNDARY; LAYER %d; DATATYPE 0;
\n
"
,
aLayer
);
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
)
kfcoord
coord
;
fprintf
(
kdebugFile
,
"
\n
"
);
coord
.
x
=
aXcoord
;
fprintf
(
kdebugFile
,
"
\n
ENDEL;
\n
"
);
coord
.
y
=
aYcoord
;
s_count
=
0
;
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
)
void
CopyPolygonsFromFilledPolysListToKeyFile
(
ZONE_CONTAINER
*
aZone
,
int
aLayer
)
...
@@ -106,30 +139,15 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
...
@@ -106,30 +139,15 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
return
;
return
;
unsigned
corners_count
=
aZone
->
m_FilledPolysList
.
size
();
unsigned
corners_count
=
aZone
->
m_FilledPolysList
.
size
();
int
count
=
0
;
unsigned
ic
=
0
;
unsigned
ic
=
0
;
CPolyPt
*
corner
;
while
(
ic
<
corners_count
)
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:
// write polygon:
StartKeyFilePolygon
(
count
+
1
,
aLayer
);
StartKeyFilePolygon
(
aLayer
);
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
int
startpointX
=
corner
->
x
;
int
startpointY
=
corner
->
y
;
for
(
;
ic
<
corners_count
;
ic
++
)
for
(
;
ic
<
corners_count
;
ic
++
)
{
{
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
CPolyPt
*
corner
=
&
aZone
->
m_FilledPolysList
[
ic
];
AddKeyFilePointXY
(
corner
->
x
,
corner
->
y
);
AddKeyFilePointXY
(
corner
->
x
,
corner
->
y
);
if
(
corner
->
end_contour
)
if
(
corner
->
end_contour
)
{
{
...
@@ -137,21 +155,8 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
...
@@ -137,21 +155,8 @@ void CopyPolygonsFromFilledPolysListToKeyFile( ZONE_CONTAINER* aZone, int aLayer
break
;
break
;
}
}
}
}
// Close polygon:
EndKeyFilePolygon
();
AddKeyFilePointXY
(
startpointX
,
startpointY
);
EndKeyFileElement
();
}
}
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
)
{
if
(
s_count
>=
2
)
{
s_count
=
0
;
fprintf
(
kdebugFile
,
"
\n
"
);
}
}
fprintf
(
kdebugFile
,
" X %d; Y %d;"
,
aXcoord
,
aYcoord
);
s_count
++
;
}
}
#endif
#endif
pcbnew/debug_kbool_key_file_fct.h
View file @
f2f4cd53
...
@@ -38,9 +38,9 @@ void CloseKeyFileEntity();
...
@@ -38,9 +38,9 @@ void CloseKeyFileEntity();
/* polygon creations:
/* polygon creations:
*/
*/
void
CopyPolygonsFromFilledPolysListToKeyFile
(
ZONE_CONTAINER
*
aZone
,
int
aLayer
);
void
CopyPolygonsFromFilledPolysListToKeyFile
(
ZONE_CONTAINER
*
aZone
,
int
aLayer
);
void
StartKeyFilePolygon
(
int
aCornersCount
,
int
aLayer
);
void
StartKeyFilePolygon
(
int
aLayer
);
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
);
void
AddKeyFilePointXY
(
int
aXcoord
,
int
aYcoord
);
void
EndKeyFile
Element
();
void
EndKeyFile
Polygon
();
#endif // CREATE_KBOOL_KEY_FILES
#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