tes:: refactored find_connection
This commit is contained in:
parent
d8da9639d0
commit
60d0d15dab
|
@ -1377,6 +1377,28 @@ EX transmatrix get_adj(arbi_tiling& c, int t, int dl) {
|
||||||
return get_adj(c, t, dl, co.sid, co.eid, co.mirror);
|
return get_adj(c, t, dl, co.sid, co.eid, co.mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns if F describes the same tile as T, taking possible symmetries into account. Paramater co is the expected edge (co.sid tells us the tile type); if yes, co may be adjusted */
|
||||||
|
EX bool find_connection(const transmatrix& T, const transmatrix& F, connection_t& co) {
|
||||||
|
|
||||||
|
if(!same_point_may_warn(tC0(F), tC0(T))) return false;
|
||||||
|
|
||||||
|
auto& xsh = current.shapes[co.sid];
|
||||||
|
int n = isize(xsh.connections);
|
||||||
|
for(int oth = 0; oth < n; oth++) {
|
||||||
|
int oth1 = gmod(oth+1, n);
|
||||||
|
int eid1 = gmod(co.eid+1, n);
|
||||||
|
if(same_point_may_warn(F * xsh.vertices[oth], T * xsh.vertices[co.eid]) && same_point_may_warn(F * xsh.vertices[oth1], T * xsh.vertices[eid1])) {
|
||||||
|
co.eid = oth;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(same_point_may_warn(F * xsh.vertices[oth], T * xsh.vertices[eid1]) && same_point_may_warn(F * xsh.vertices[oth1], T * xsh.vertices[co.eid])) {
|
||||||
|
co.eid = oth; co.mirror = !co.mirror;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct hrmap_arbi : hrmap {
|
struct hrmap_arbi : hrmap {
|
||||||
heptagon *origin;
|
heptagon *origin;
|
||||||
heptagon *getOrigin() override { return origin; }
|
heptagon *getOrigin() override { return origin; }
|
||||||
|
@ -1433,8 +1455,6 @@ struct hrmap_arbi : hrmap {
|
||||||
|
|
||||||
auto& co = sh.connections[d];
|
auto& co = sh.connections[d];
|
||||||
|
|
||||||
auto& xsh = current.shapes[co.sid];
|
|
||||||
|
|
||||||
if(cgflags & qAFFINE) {
|
if(cgflags & qAFFINE) {
|
||||||
set<heptagon*> visited;
|
set<heptagon*> visited;
|
||||||
|
|
||||||
|
@ -1492,24 +1512,14 @@ struct hrmap_arbi : hrmap {
|
||||||
alt = (heptagon*) s;
|
alt = (heptagon*) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& p2: altmap[alt]) if(id_of(p2.first) == co.sid && same_point_may_warn(tC0(p2.second), tC0(T))) {
|
for(auto& p2: altmap[alt]) if(id_of(p2.first) == co.sid) {
|
||||||
for(int oth=0; oth < p2.first->type; oth++) {
|
connection_t co1 = co;
|
||||||
int oth1 = gmod(oth+1, p2.first->type);
|
if(find_connection(T, p2.second, co1)) {
|
||||||
int eid1 = gmod(co.eid+1, p2.first->type);
|
if(p2.first->move(co1.eid)) {
|
||||||
if(same_point_may_warn(p2.second * xsh.vertices[oth], T * xsh.vertices[co.eid]) && same_point_may_warn(p2.second * xsh.vertices[oth1], T * xsh.vertices[eid1])) {
|
throw hr_exception("already connected!");
|
||||||
if(p2.first->move(oth)) {
|
|
||||||
throw hr_exception("already connected!");
|
|
||||||
}
|
|
||||||
h->c.connect(d, p2.first, oth%p2.first->type, co.mirror);
|
|
||||||
return p2.first;
|
|
||||||
}
|
|
||||||
if(same_point_may_warn(p2.second * xsh.vertices[oth], T * xsh.vertices[eid1]) && same_point_may_warn(p2.second * xsh.vertices[oth1], T * xsh.vertices[co.eid])) {
|
|
||||||
if(p2.first->move(oth)) {
|
|
||||||
throw hr_exception("already connected!");
|
|
||||||
}
|
|
||||||
h->c.connect(d, p2.first, oth%p2.first->type, co.mirror^1);
|
|
||||||
return p2.first;
|
|
||||||
}
|
}
|
||||||
|
h->c.connect(d, p2.first, co1.eid, co1.mirror);
|
||||||
|
return p2.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue