41template <
typename PixelType>
78 bool operator<(
const Candidate &other)
const
83 if (ShapeTile<PixelType>::compare_shape_only(other.flipped_tile, flipped_tile)) {
86 return flipped_tile < other.flipped_tile;
91 std::pair{
false,
false}, std::pair{
false,
true}, std::pair{
true,
false}, std::pair{
true,
true}};
93 std::vector<Candidate> candidates;
94 candidates.reserve(4);
96 for (
const auto &[h, v] : flips) {
97 candidates.push_back({tile.flip(h, v), h, v});
100 auto min_candidate = *std::min_element(candidates.begin(), candidates.end());
103 *
static_cast<ShapeTile<PixelType> *
>(
this) = min_candidate.flipped_tile;
104 h_flip_ = min_candidate.h_flip;
105 v_flip_ = min_candidate.v_flip;
A ShapeTile representation that stores the canonical (lexicographically minimal) orientation among al...
bool h_flip() const
Returns the horizontal flip flag.
bool v_flip() const
Returns the vertical flip flag.
CanonicalShapeTile(const ShapeTile< PixelType > &tile)
Constructs a CanonicalShapeTile by finding the canonical orientation of the input tile.
auto operator<=>(const CanonicalShapeTile &other) const =default
Three-way comparison operator that compares all fields.
An 8x8 tile backed by mask-based storage that maps shape regions to pixel values.