7 #ifndef GRAPHGEN_PIXEL_SET_H_
8 #define GRAPHGEN_PIXEL_SET_H_
18 #include "yaml-cpp/yaml.h"
30 pixel(std::string name, std::vector<int> coords) :
name_{ std::move(name) },
coords_{ std::move(coords) } {}
42 assert(rhs.
size() ==
coords_.size() &&
"Something wrong with pixel's coordinates");
43 for (
size_t i = 0; i <
coords_.size(); ++i) {
56 YAML::Node pixel_node;
57 pixel_node[
"name"] =
name_;
60 pixel_node[
"coords"].push_back(std::to_string(c));
67 name_ = node[
"name"].as<std::string>();
68 for (
unsigned i = 0; i < node[
"coords"].size(); ++i) {
69 coords_.push_back(node[
"coords"][i].as<int>());
77 static int ChebyshevDistance(
const pixel& p1,
const pixel& p2)
81 for (
size_t i = 0; i < p1.
size(); ++i) {
82 max = std::max(max, abs(p1[i] - p2[i]));
100 for (
size_t i = 0; i <
pixels_.front().
size(); ++i)
105 assert(shifts.size() ==
shifts_.size() &&
"'shifts' vector size cannot be changed");
139 for (
const auto& p :
pixels_) {
140 ps_node[
"pixels"].push_back(p.Serialize());
143 for (
const auto& s :
shifts_) {
144 ps_node[
"shifts"].push_back(
static_cast<int>(s));
150 for (
unsigned i = 0; i < node[
"shifts"].size(); ++i) {
151 shifts_.push_back(node[
"shifts"][i].as<int>());
154 for (
unsigned i = 0; i < node[
"pixels"].size(); ++i) {
bool operator()(const pixel &p) const
find_pixel(std::string name)
auto & operator[](const std::string &s) const
pixel_set(const YAML::Node &ps_node)
void SetShifts(std::vector< uint8_t > shifts)
auto & operator[](const std::string &s)
std::vector< pixel > pixels_
pixel_set(std::initializer_list< pixel > il, std::vector< uint8_t > shifts)
pixel_set(std::initializer_list< pixel > il)
void Deserialize(const YAML::Node &node)
auto & operator[](size_t i)
std::vector< uint8_t > shifts_
YAML::Node Serialize() const
auto & operator[](size_t i) const
pixel(std::string name, std::vector< int > coords)
auto & operator[](size_t i) const
std::vector< int > coords_
pixel(const YAML::Node &node)
bool operator==(const pixel &rhs) const
auto & operator[](size_t i)
YAML::Node Serialize() const
void Deserialize(const YAML::Node &node)