Commit 1bb0b034 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

HexModel: remove double-getNeighbors method

parent 3a846b0f
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -112,32 +112,6 @@ std::set<Pixel::Index> HexagonalPixelDetectorModel::getNeighbors(const Pixel::In
    return neighbors;
}

std::set<Pixel::Index> HexagonalPixelDetectorModel::getNeighbors(const Pixel::Index& idx,
                                                                 const Pixel::Index& last_idx,
                                                                 const size_t distance) const {
    std::set<Pixel::Index> neighbors;

    auto x_lower = std::min(idx.x(), last_idx.x()) - static_cast<int>(distance);
    auto x_higher = std::max(idx.x(), last_idx.x()) + static_cast<int>(distance);
    auto y_lower = std::min(idx.y(), last_idx.y()) - static_cast<int>(distance);
    auto y_higher = std::max(idx.y(), last_idx.y()) + static_cast<int>(distance);

    for(int x = x_lower; x <= x_higher; x++) {
        for(int y = y_lower; y <= y_higher; y++) {
            // Remove indices outside the pixel grid
            if(isWithinPixelGrid(x, y)) {
                // "cut off" the corners of the rectangle around the indices in question to make it a "prolonged"
                // hexagon
                if(std::abs(x - idx.x() + y - idx.y()) <= static_cast<int>(distance) ||
                   std::abs(x - last_idx.x() + y - last_idx.y()) <= static_cast<int>(distance)) {
                    neighbors.insert({x, y});
                }
            }
        }
    }
    return neighbors;
}

bool HexagonalPixelDetectorModel::areNeighbors(const Pixel::Index& seed,
                                               const Pixel::Index& entrant,
                                               const size_t distance) const {
+0 −12
Original line number Diff line number Diff line
@@ -99,18 +99,6 @@ namespace allpix {
         */
        std::set<Pixel::Index> getNeighbors(const Pixel::Index& idx, const size_t distance) const override;

        /**
         * @brief Return a set containing all pixels neighboring the two given pixels with a configurable maximum distance
         * @param idx       Index of the first pixel in question
         * @param last_idx  Index of the second pixel in question
         * @param distance  Distance for pixels to be considered neighbors
         * @return Set of neighboring pixel indices, including the two initial pixels
         *
         * @note The returned set should always also include the initial pixel indices the neighbors are calculated for
         */
        std::set<Pixel::Index>
        getNeighbors(const Pixel::Index& idx, const Pixel::Index& last_idx, const size_t distance) const override;

        /**
         * @brief Check if two pixel indices are neighbors to each other
         * @param  seed    Initial pixel index