Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
989e54a3
Commit
989e54a3
authored
Sep 25, 2016
by
Jakob Schöttl
Browse files
Extract method to prefilter dyn elemns
parent
e6c4c74c
Changes
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/control/TargetController.java
View file @
989e54a3
...
...
@@ -42,17 +42,8 @@ public class TargetController {
if
(
this
.
target
.
isTargetPedestrian
())
{
return
;
}
final
double
reachedDistance
=
target
.
getAttributes
().
getDeletionDistance
();
final
Rectangle2D
bounds
=
target
.
getShape
().
getBounds2D
();
final
VPoint
center
=
new
VPoint
(
bounds
.
getCenterX
(),
bounds
.
getCenterY
());
final
double
radius
=
Math
.
max
(
bounds
.
getHeight
(),
bounds
.
getWidth
())
+
reachedDistance
;
final
Collection
<
DynamicElement
>
elementsInRange
=
new
LinkedList
<>();
elementsInRange
.
addAll
(
getObjectsInCircle
(
Pedestrian
.
class
,
center
,
radius
));
elementsInRange
.
addAll
(
getObjectsInCircle
(
Car
.
class
,
center
,
radius
));
for
(
DynamicElement
element
:
elementsInRange
)
{
for
(
DynamicElement
element
:
getPrefilteredDynamicElements
())
{
final
Agent
agent
;
if
(
element
instanceof
Agent
)
{
...
...
@@ -100,6 +91,20 @@ public class TargetController {
}
}
private
Collection
<
DynamicElement
>
getPrefilteredDynamicElements
()
{
final
double
reachedDistance
=
target
.
getAttributes
().
getDeletionDistance
();
final
Rectangle2D
bounds
=
target
.
getShape
().
getBounds2D
();
final
VPoint
center
=
new
VPoint
(
bounds
.
getCenterX
(),
bounds
.
getCenterY
());
final
double
radius
=
Math
.
max
(
bounds
.
getHeight
(),
bounds
.
getWidth
())
+
reachedDistance
;
final
Collection
<
DynamicElement
>
elementsInRange
=
new
LinkedList
<>();
elementsInRange
.
addAll
(
getObjectsInCircle
(
Pedestrian
.
class
,
center
,
radius
));
elementsInRange
.
addAll
(
getObjectsInCircle
(
Car
.
class
,
center
,
radius
));
return
elementsInRange
;
}
private
<
T
extends
DynamicElement
>
List
<
T
>
getObjectsInCircle
(
final
Class
<
T
>
clazz
,
final
VPoint
center
,
final
double
radius
)
{
return
topography
.
getSpatialMap
(
clazz
).
getObjects
(
center
,
radius
);
}
...
...
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