rewritten shvid using OOP

This commit is contained in:
Zeno Rogue 2021-06-12 23:34:50 +02:00
parent 8d18946450
commit 42fc2c44a7
8 changed files with 44 additions and 27 deletions

View File

@ -801,6 +801,10 @@ struct hrmap_arbi : hrmap {
transmatrix adj(cell *c, int dir) override { return adj(c->master, dir); }
ld spin_angle(cell *c, int d) override { return SPIN_NOT_AVAILABLE; }
int shvid(cell *c) override {
return id_of(c->master);
}
};
EX hrmap *new_map() { return new hrmap_arbi; }

View File

@ -780,6 +780,13 @@ struct hrmap_archimedean : hrmap {
}
else hrmap::find_cell_connection(c, d);
}
int shvid(cell *c) override {
auto& ac = arcm::current;
int id = arcm::id_of(c->master);
if(ac.regular && id>=2 && id < 2*ac.N) id &= 1;
return id;
}
};
EX hrmap *new_map() { return new hrmap_archimedean; }

View File

@ -431,6 +431,15 @@ EX namespace bt {
}
}
int shvid(cell *c) override {
if(geometry == gBinaryTiling)
return c->type-6;
else if(geometry == gBinary4 || geometry == gTernary)
return c->master->zebraval;
else
return 0;
}
int updir_at(heptagon *h) {
if(geometry != gBinaryTiling) return updir();
else if(type_of(h) == 6) return bd_down;

View File

@ -61,6 +61,7 @@ struct hrmap {
virtual double spacedist(cell *c, int i) { return hdist0(tC0(adj(c, i))); }
virtual void find_cell_connection(cell *c, int d);
virtual int shvid(cell *c) { return 0; }
};
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
@ -78,6 +79,7 @@ struct hrmap_standard : hrmap {
ld spin_angle(cell *c, int d) override;
double spacedist(cell *c, int i) override;
void find_cell_connection(cell *c, int d) override;
virtual int shvid(cell *c);
};
void clearfrom(heptagon*);
@ -216,9 +218,6 @@ void hrmap_standard::find_cell_connection(cell *c, int d) {
}
hybrid::link();
}
else if(INVERSE) {
gp::inverse_move(c, d);
}
#endif
else if(PURE) {
hrmap::find_cell_connection(c, d);

View File

@ -848,7 +848,7 @@ EX namespace gp {
cgi.extra_vertices();
}
int get_plainshape_id(cell *c) {
EX int get_plainshape_id(cell *c) {
int siid, sidir;
cell *c1 = c;
auto f = [&] {
@ -924,36 +924,18 @@ EX void set_floor(const transmatrix& spin, hpcshape& sh) {
}
EX int shvid(cell *c) {
if(hybri) {
cell *c1 = hybrid::get_where(c).first;
return PIU( shvid(c1) );
}
else if(GOLDBERG_INV)
return currentmap->shvid(c);
}
int hrmap_standard::shvid(cell *c) {
if(GOLDBERG)
return gp::get_plainshape_id(c);
#if CAP_IRR
else if(IRREGULAR)
return irr::cellindex[c];
#endif
#if CAP_ARCM
else if(arcm::in()) {
auto& ac = arcm::current;
int id = arcm::id_of(c->master);
if(ac.regular && id>=2 && id < 2*ac.N) id &= 1;
return id;
}
#endif
else if(arb::in())
return arb::id_of(c->master);
else if(geosupport_football() == 2)
return pseudohept(c);
#if CAP_BT
else if(geometry == gBinaryTiling)
return c->type-6;
else if(kite::in())
return kite::getshape(c->master);
else if(geometry == gBinary4 || geometry == gTernary)
return c->master->zebraval;
#endif
else if(inforder::mixed()) {
int t = c->type;
static vector<bool> computed;

View File

@ -1273,6 +1273,13 @@ EX namespace gp {
}
}
void find_cell_connection(cell *c, int d) override {
inverse_move(c, d);
}
int shvid(cell *c) override {
return gp::get_plainshape_id(c);
}
};
EX hrmap* new_inverse() { return new hrmap_inverse; }

View File

@ -152,6 +152,10 @@ struct hrmap_kite : hrmap {
kite::find_cell_connection(c, d);
}
int shvid(cell *c) override {
return kite::getshape(c->master);
}
heptagon *newtile(pshape s, int dist) {
heptagon *h = tailored_alloc<heptagon> (8);
h->s = hstate(s);

View File

@ -1275,6 +1275,11 @@ EX namespace hybrid {
void find_cell_connection(cell *c, int d) override {
hybrid::find_cell_connection(c, d);
}
int shvid(cell *c) override {
cell *c1 = hybrid::get_where(c).first;
return PIU( shvid(c1) );
}
virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); }
virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); }