File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,33 +137,4 @@ class NeighborhoodSearch
137137 }
138138 return result;
139139 }
140-
141- std::vector<Value*> GetNeighboringAgentsPtr (Point pos, double radius) const
142- {
143- std::vector<Value*> result{};
144- result.reserve (128 );
145-
146- const auto posIdx = getIndex (pos);
147- const auto offset = static_cast <int32_t >(std::ceil (radius / _cellSize));
148- const int32_t xMin = posIdx.idx - offset;
149- const int32_t xMax = posIdx.idx + offset;
150- const int32_t yMin = posIdx.idy - offset;
151- const int32_t yMax = posIdx.idy + offset;
152-
153- const auto radiusSquared = radius * radius;
154-
155- for (int32_t x = xMin; x <= xMax; ++x) {
156- for (int32_t y = yMin; y <= yMax; ++y) {
157- auto it = _grid.find ({x, y});
158- if (it != _grid.cend ()) {
159- for (const auto & item : it->second ) {
160- if (DistanceSquared (item->pos , pos) <= radiusSquared) {
161- result.emplace_back (const_cast <Value*>(item));
162- }
163- }
164- }
165- }
166- }
167- return result;
168- }
169140};
Original file line number Diff line number Diff line change @@ -244,6 +244,7 @@ GenericAgent::ID Simulation::AddAgent(GenericAgent agent)
244244 _stageManager.HandleNewAgent (agent.stageId );
245245 _agents.emplace_back (std::move (agent));
246246 _neighborhoodSearch.AddAgent (_agents.back ());
247+
247248 auto v = IteratorPair (std::prev (std::end (_agents)), std::end (_agents));
248249 _stategicalDecisionSystem.Run (_journeys, v, _stageManager);
249250 _tacticalDecisionSystem.Run (*_routingEngine, v);
@@ -357,6 +358,7 @@ std::vector<GenericAgent::ID> Simulation::AgentsInPolygon(const std::vector<Poin
357358 throw SimulationError (" Polygon needs to be simple and convex" );
358359 }
359360 const auto [p, dist] = poly.ContainingCircle ();
361+
360362 const auto candidates = _neighborhoodSearch.GetNeighboringAgents (p, dist);
361363 std::vector<GenericAgent::ID> result{};
362364 result.reserve (candidates.size ());
You can’t perform that action at this time.
0 commit comments