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
630a3fb1
Commit
630a3fb1
authored
Jan 31, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Safer RN_NET::GetNodes()
parent
7f3bf1be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
26 deletions
+35
-26
ratsnest_data.cpp
pcbnew/ratsnest_data.cpp
+35
-26
No files found.
pcbnew/ratsnest_data.cpp
View file @
630a3fb1
...
@@ -548,15 +548,17 @@ const RN_NODE_PTR RN_NET::GetClosestNode( const RN_NODE_PTR& aNode ) const
...
@@ -548,15 +548,17 @@ const RN_NODE_PTR RN_NET::GetClosestNode( const RN_NODE_PTR& aNode ) const
for
(
it
=
nodes
.
begin
(),
itEnd
=
nodes
.
end
();
it
!=
itEnd
;
++
it
)
for
(
it
=
nodes
.
begin
(),
itEnd
=
nodes
.
end
();
it
!=
itEnd
;
++
it
)
{
{
RN_NODE_PTR
node
=
*
it
;
// Obviously the distance between node and itself is the shortest,
// Obviously the distance between node and itself is the shortest,
// that's why we have to skip it
// that's why we have to skip it
if
(
*
it
!=
aNode
)
if
(
node
!=
aNode
)
{
{
unsigned
int
distance
=
getDistance
(
*
it
,
aNode
);
unsigned
int
distance
=
getDistance
(
node
,
aNode
);
if
(
distance
<
minDistance
)
if
(
distance
<
minDistance
)
{
{
minDistance
=
distance
;
minDistance
=
distance
;
closest
=
*
it
;
closest
=
node
;
}
}
}
}
}
}
...
@@ -650,34 +652,41 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
...
@@ -650,34 +652,41 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
{
{
std
::
list
<
RN_NODE_PTR
>
nodes
;
std
::
list
<
RN_NODE_PTR
>
nodes
;
switch
(
aItem
->
Type
()
)
try
{
case
PCB_PAD_T
:
{
const
D_PAD
*
pad
=
static_cast
<
const
D_PAD
*>
(
aItem
);
nodes
.
push_back
(
m_pads
.
at
(
pad
)
);
}
break
;
case
PCB_VIA_T
:
{
{
const
SEGVIA
*
via
=
static_cast
<
const
SEGVIA
*>
(
aItem
);
switch
(
aItem
->
Type
()
)
nodes
.
push_back
(
m_vias
.
at
(
via
)
);
{
}
case
PCB_PAD_T
:
break
;
{
const
D_PAD
*
pad
=
static_cast
<
const
D_PAD
*>
(
aItem
);
nodes
.
push_back
(
m_pads
.
at
(
pad
)
);
}
break
;
case
PCB_TRACE_T
:
case
PCB_VIA_T
:
{
{
const
TRACK
*
track
=
static_cast
<
const
TRACK
*>
(
aItem
);
const
SEGVIA
*
via
=
static_cast
<
const
SEGVIA
*>
(
aItem
);
RN_EDGE_PTR
edge
=
m_tracks
.
at
(
track
);
nodes
.
push_back
(
m_vias
.
at
(
via
)
);
}
break
;
nodes
.
push_back
(
edge
->
getSourceNode
()
);
case
PCB_TRACE_T
:
nodes
.
push_back
(
edge
->
getTargetNode
()
);
{
}
const
TRACK
*
track
=
static_cast
<
const
TRACK
*>
(
aItem
);
break
;
RN_EDGE_PTR
edge
=
m_tracks
.
at
(
track
)
;
default
:
nodes
.
push_back
(
edge
->
getSourceNode
()
);
nodes
.
push_back
(
edge
->
getTargetNode
()
);
}
break
;
break
;
default
:
break
;
}
}
catch
(
...
)
{
return
nodes
;
}
}
return
nodes
;
return
nodes
;
...
...
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