| 615 | } |
| 616 | |
| 617 | bool DescriptionEditService::isCellPresent(Occupancy const& cellPosBySlot, SpaceCalculator const& spaceCalculator, RealVector2D const& posToCheck, float distance) |
| 618 | { |
| 619 | auto intPos = toIntVector2D(posToCheck); |
| 620 | |
| 621 | auto getMatchingSlots = [&cellPosBySlot](IntVector2D const& intPos) { |
| 622 | auto findResult = cellPosBySlot.find(intPos); |
| 623 | if (findResult != cellPosBySlot.end()) { |
| 624 | return findResult->second; |
| 625 | } |
| 626 | return std::vector<RealVector2D>{}; |
| 627 | }; |
| 628 | |
| 629 | auto isOccupied = [&](std::vector<RealVector2D> const& cellPositions) { |
| 630 | for (auto const& cellPos : cellPositions) { |
| 631 | auto otherPos = spaceCalculator.getCorrectedPosition(cellPos); |
| 632 | if (Math::length(posToCheck - otherPos) < distance) { |
| 633 | return true; |
| 634 | } |
| 635 | } |
| 636 | return false; |
| 637 | }; |
| 638 | |
| 639 | auto distanceInt = toInt(ceilf(distance)); |
| 640 | for (int dx = -distanceInt; dx <= distanceInt; ++dx) { |
| 641 | for (int dy = -distanceInt; dy <= distanceInt; ++dy) { |
| 642 | if (isOccupied(getMatchingSlots({intPos.x + dx, intPos.y + dy}))) { |
| 643 | return true; |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | return false; |
| 648 | } |
| 649 | |
| 650 | uint64_t DescriptionEditService::getId(CellOrParticleDescription const& entity) |
| 651 | { |
nothing calls this directly
no test coverage detected