// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include "../../common/Reflection.h" #include "gemmi/symmetry.hpp" struct HKLKey { int h = 0; int k = 0; int l = 0; bool plus = true; bool operator<(const HKLKey &o) const { return std::tie(h, k, l, plus) < std::tie(o.h, o.k, o.l, o.plus); } bool operator==(const HKLKey &o) const { return h == o.h && k == o.k && l == o.l && plus == o.plus; } [[nodiscard]] uint64_t pack() const; // The key pack() made, back. [[nodiscard]] static HKLKey unpack(uint64_t packed); }; class HKLKeyGenerator { bool merge_friedel; gemmi::SpaceGroup sg; gemmi::GroupOps ops; gemmi::ReciprocalAsu asu; public: HKLKeyGenerator(bool merge_friedel, const gemmi::SpaceGroup &sg); HKLKey operator()(const Reflection &r) const; HKLKey operator()(const MergedReflection &r) const; HKLKey operator()(int32_t h, int32_t k, int32_t l) const; bool IsSystematicallyAbsent(int32_t h, int32_t k, int32_t l) const; bool IsSystematicallyAbsent(const Reflection &r) const; }; HKLKey CanonicalHKL(const Reflection &r, bool merge_friedel, const std::optional &sg); HKLKey CanonicalHKL(const MergedReflection &r, bool merge_friedel, const std::optional &sg); HKLKey CanonicalHKL(int32_t h, int32_t k, int32_t l, bool merge_friedel, const std::optional &sg); bool AcceptReflection(const Reflection &r, std::optional d_min_limit, std::optional d_max_limit); bool AcceptReflection(const Reflection &r, double d_min_limit, double d_max_limit);