43template <
typename PixelType>
84 bool operator<(
const Candidate &other)
const
89 if (ShapeTile<PixelType>::compare_shape_only(other.flipped_tile, flipped_tile)) {
92 return flipped_tile < other.flipped_tile;
97 std::pair{
false,
false}, std::pair{
false,
true}, std::pair{
true,
false}, std::pair{
true,
true}};
99 std::vector<Candidate> candidates;
100 candidates.reserve(4);
102 for (
const auto &[h, v] : flips) {
103 candidates.push_back({tile.flip(h, v), h, v});
106 auto min_candidate = *std::min_element(candidates.begin(), candidates.end());
109 *
static_cast<ShapeTile<PixelType> *
>(
this) = min_candidate.flipped_tile;
110 h_flip_ = min_candidate.h_flip;
111 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.