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
3aa880de
Commit
3aa880de
authored
Jun 29, 2014
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pcb_parser for new board, coding standards
parent
06bf0821
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
39 deletions
+60
-39
connect.cpp
pcbnew/connect.cpp
+20
-5
pcb_parser.cpp
pcbnew/pcb_parser.cpp
+40
-34
No files found.
pcbnew/connect.cpp
View file @
3aa880de
...
@@ -245,12 +245,13 @@ static bool sortConnectedPointByXthenYCoordinates( const CONNECTED_POINT & aRef,
...
@@ -245,12 +245,13 @@ static bool sortConnectedPointByXthenYCoordinates( const CONNECTED_POINT & aRef,
return
aRef
.
GetPoint
().
x
<
aTst
.
GetPoint
().
x
;
return
aRef
.
GetPoint
().
x
<
aTst
.
GetPoint
().
x
;
}
}
void
CONNECTIONS
::
BuildTracksCandidatesList
(
TRACK
*
aBegin
,
TRACK
*
aEnd
)
void
CONNECTIONS
::
BuildTracksCandidatesList
(
TRACK
*
aBegin
,
TRACK
*
aEnd
)
{
{
m_candidates
.
clear
();
m_candidates
.
clear
();
m_firstTrack
=
m_lastTrack
=
aBegin
;
m_firstTrack
=
m_lastTrack
=
aBegin
;
unsigned
ii
=
0
;
unsigned
ii
=
0
;
// Count candidates ( i.e. end points )
// Count candidates ( i.e. end points )
for
(
const
TRACK
*
track
=
aBegin
;
track
;
track
=
track
->
Next
()
)
for
(
const
TRACK
*
track
=
aBegin
;
track
;
track
=
track
->
Next
()
)
{
{
...
@@ -260,14 +261,17 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
...
@@ -260,14 +261,17 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
ii
+=
2
;
ii
+=
2
;
m_lastTrack
=
track
;
m_lastTrack
=
track
;
if
(
track
==
aEnd
)
if
(
track
==
aEnd
)
break
;
break
;
}
}
// Build candidate list
// Build candidate list
m_candidates
.
reserve
(
ii
);
m_candidates
.
reserve
(
ii
);
for
(
TRACK
*
track
=
aBegin
;
track
;
track
=
track
->
Next
()
)
for
(
TRACK
*
track
=
aBegin
;
track
;
track
=
track
->
Next
()
)
{
{
CONNECTED_POINT
candidate
(
track
,
track
->
GetStart
());
CONNECTED_POINT
candidate
(
track
,
track
->
GetStart
()
);
m_candidates
.
push_back
(
candidate
);
m_candidates
.
push_back
(
candidate
);
if
(
track
->
Type
()
!=
PCB_VIA_T
)
if
(
track
->
Type
()
!=
PCB_VIA_T
)
{
{
...
@@ -285,6 +289,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
...
@@ -285,6 +289,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
sort
(
m_candidates
.
begin
(),
m_candidates
.
end
(),
sortConnectedPointByXthenYCoordinates
);
sort
(
m_candidates
.
begin
(),
m_candidates
.
end
(),
sortConnectedPointByXthenYCoordinates
);
}
}
/* Populates .m_connected with tracks/vias connected to aTrack
/* Populates .m_connected with tracks/vias connected to aTrack
* param aTrack = track or via to use as reference
* param aTrack = track or via to use as reference
* For calculation time reason, an exhaustive search cannot be made
* For calculation time reason, an exhaustive search cannot be made
...
@@ -294,7 +299,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
...
@@ -294,7 +299,7 @@ void CONNECTIONS::BuildTracksCandidatesList( TRACK * aBegin, TRACK * aEnd)
* because with this constraint we can make a fast search in track list
* because with this constraint we can make a fast search in track list
* m_candidates is expected to be populated by the track candidates ends list
* m_candidates is expected to be populated by the track candidates ends list
*/
*/
int
CONNECTIONS
::
SearchConnectedTracks
(
const
TRACK
*
aTrack
)
int
CONNECTIONS
::
SearchConnectedTracks
(
const
TRACK
*
aTrack
)
{
{
int
count
=
0
;
int
count
=
0
;
m_connected
.
clear
();
m_connected
.
clear
();
...
@@ -308,7 +313,9 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
...
@@ -308,7 +313,9 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
int
dist_max
=
aTrack
->
GetWidth
()
/
2
;
int
dist_max
=
aTrack
->
GetWidth
()
/
2
;
static
std
::
vector
<
CONNECTED_POINT
*>
tracks_candidates
;
static
std
::
vector
<
CONNECTED_POINT
*>
tracks_candidates
;
#endif
#endif
wxPoint
position
=
aTrack
->
GetStart
();
wxPoint
position
=
aTrack
->
GetStart
();
for
(
int
kk
=
0
;
kk
<
2
;
kk
++
)
for
(
int
kk
=
0
;
kk
<
2
;
kk
++
)
{
{
#ifndef USE_EXTENDED_SEARCH
#ifndef USE_EXTENDED_SEARCH
...
@@ -321,8 +328,10 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
...
@@ -321,8 +328,10 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
{
{
if
(
m_candidates
[
ii
].
GetTrack
()
==
aTrack
)
if
(
m_candidates
[
ii
].
GetTrack
()
==
aTrack
)
continue
;
continue
;
if
(
m_candidates
[
ii
].
GetPoint
()
!=
position
)
if
(
m_candidates
[
ii
].
GetPoint
()
!=
position
)
break
;
break
;
if
(
(
m_candidates
[
ii
].
GetTrack
()
->
GetLayerSet
()
&
layerMask
).
any
()
)
if
(
(
m_candidates
[
ii
].
GetTrack
()
->
GetLayerSet
()
&
layerMask
).
any
()
)
m_connected
.
push_back
(
m_candidates
[
ii
].
GetTrack
()
);
m_connected
.
push_back
(
m_candidates
[
ii
].
GetTrack
()
);
}
}
...
@@ -332,18 +341,23 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
...
@@ -332,18 +341,23 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
{
{
if
(
m_candidates
[
ii
].
GetTrack
()
==
aTrack
)
if
(
m_candidates
[
ii
].
GetTrack
()
==
aTrack
)
continue
;
continue
;
if
(
m_candidates
[
ii
].
GetPoint
()
!=
position
)
if
(
m_candidates
[
ii
].
GetPoint
()
!=
position
)
break
;
break
;
if
(
(
m_candidates
[
ii
].
GetTrack
()
->
GetLayerSet
()
&
layerMask
).
any
()
)
if
(
(
m_candidates
[
ii
].
GetTrack
()
->
GetLayerSet
()
&
layerMask
).
any
()
)
m_connected
.
push_back
(
m_candidates
[
ii
].
GetTrack
()
);
m_connected
.
push_back
(
m_candidates
[
ii
].
GetTrack
()
);
}
}
}
}
#else
#else
tracks_candidates
.
clear
();
tracks_candidates
.
clear
();
CollectItemsNearTo
(
tracks_candidates
,
position
,
dist_max
);
CollectItemsNearTo
(
tracks_candidates
,
position
,
dist_max
);
for
(
unsigned
ii
=
0
;
ii
<
tracks_candidates
.
size
();
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
tracks_candidates
.
size
();
ii
++
)
{
{
TRACK
*
ctrack
=
tracks_candidates
[
ii
]
->
GetTrack
();
TRACK
*
ctrack
=
tracks_candidates
[
ii
]
->
GetTrack
();
if
(
!
(
ctrack
->
GetLayerSet
()
&
layerMask
).
any
()
)
if
(
!
(
ctrack
->
GetLayerSet
()
&
layerMask
).
any
()
)
continue
;
continue
;
...
@@ -354,6 +368,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
...
@@ -354,6 +368,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack )
// We have a good candidate: calculate the actual distance
// We have a good candidate: calculate the actual distance
// between ends, which should be <= dist max.
// between ends, which should be <= dist max.
wxPoint
delta
=
tracks_candidates
[
ii
]
->
GetPoint
()
-
position
;
wxPoint
delta
=
tracks_candidates
[
ii
]
->
GetPoint
()
-
position
;
int
dist
=
KiROUND
(
EuclideanNorm
(
delta
)
);
int
dist
=
KiROUND
(
EuclideanNorm
(
delta
)
);
if
(
dist
>
dist_max
)
if
(
dist
>
dist_max
)
...
...
pcbnew/pcb_parser.cpp
View file @
3aa880de
...
@@ -734,6 +734,7 @@ void PCB_PARSER::parseLayer( LAYER* aLayer ) throw( IO_ERROR, PARSE_ERROR )
...
@@ -734,6 +734,7 @@ void PCB_PARSER::parseLayer( LAYER* aLayer ) throw( IO_ERROR, PARSE_ERROR )
}
}
void
PCB_PARSER
::
parseLayers
()
throw
(
IO_ERROR
,
PARSE_ERROR
)
void
PCB_PARSER
::
parseLayers
()
throw
(
IO_ERROR
,
PARSE_ERROR
)
{
{
wxCHECK_RET
(
CurTok
()
==
T_layers
,
wxCHECK_RET
(
CurTok
()
==
T_layers
,
...
@@ -752,19 +753,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
...
@@ -752,19 +753,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
parseLayer
(
&
layer
);
parseLayer
(
&
layer
);
if
(
layer
.
m_type
!=
LT_UNDEFINED
)
// it's a copper layer
if
(
layer
.
m_type
==
LT_UNDEFINED
)
// it's a non-copper layer
{
break
;
cu
.
push_back
(
layer
);
//DBG( printf( "cop m_visible:%s\n", cu.back().m_visible ? "true" : "false" );)
cu
.
push_back
(
layer
);
// it's copper
}
}
else
// all non-copper are fixed names, simply look up LAYER_ID.
{
// All Cu layers are parsed, but not the non-cu layers here.
// This is an edge triggered one shot if( test ) that happens on
// the first non copper layer, which follow all the Cu layers.
// The original *.kicad_pcb file format and the inverted
// This is the feature that the original *.kicad_pcb file format and
// Cu stack format both have all the Cu layers first, so use this
// the inverted Cu stack format had in common and is therefore a trick
// trick to handle either. The layer number in the (layers ..)
// used to handle either. The layer number in the (layers ..)
// s-expression element are ignored.
// s-expression element are ignored.
if
(
cu
.
size
()
)
if
(
cu
.
size
()
)
{
{
...
@@ -793,10 +792,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
...
@@ -793,10 +792,17 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
}
}
copperLayerCount
=
cu
.
size
();
copperLayerCount
=
cu
.
size
();
cu
.
clear
();
// this marks the list as "one time processed".
}
}
if
(
token
!=
T_RIGHT
)
{
// read any non-copper layers
for
(
token
=
NextTok
();
token
!=
T_RIGHT
;
token
=
NextTok
()
)
{
LAYER
layer
;
parseLayer
(
&
layer
);
LAYER_ID_MAP
::
const_iterator
it
=
m_layerIndices
.
find
(
UTF8
(
layer
.
m_name
)
);
LAYER_ID_MAP
::
const_iterator
it
=
m_layerIndices
.
find
(
UTF8
(
layer
.
m_name
)
);
if
(
it
==
m_layerIndices
.
end
()
)
if
(
it
==
m_layerIndices
.
end
()
)
...
...
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