From d44e8b641674478f1e542703eeedbe153c68bc9a Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 6 Oct 2022 10:59:57 +0200 Subject: [PATCH] tes:: mirror command added --- arbitrile.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/arbitrile.cpp b/arbitrile.cpp index 97abba90..467c900f 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -71,6 +71,8 @@ struct shape { bool apeirogonal; /** connections repeat `repeat_value` times */ int repeat_value; + /** 0 if the no mirror symmetries are declared; otherwise, edge i is the mirror of edge gmod(symmetric_value-i, size()). Make sure symmetric_value != 0, e.g., by adding size() */ + int symmetric_value; /** if a tile/edge combination may be connected to edges j1 and j2 of this, j1-j2 must be divisible by cycle_length */ int cycle_length; /** list of valences of vertices in the tesfile convention */ @@ -350,16 +352,25 @@ EX void load_tile(exp_parser& ep, arbi_tiling& c, bool unit) { cc.id = isize(c.shapes) - 1; cc.orig_id = cc.id; cc.is_mirrored = false; + cc.symmetric_value = 0; cc.flags = 0; cc.repeat_value = 1; + bool is_symmetric = false; while(ep.next() != ')') { cld dist = 1; ep.skip_white(); + if(ep.eat("|")) { + cc.symmetric_value = ep.iparse(); + is_symmetric = true; + ep.force_eat(")"); + break; + } if(ep.eat("*")) { ld frep = ep.rparse(0); if(isinf(frep)) { cc.apeirogonal = true; set_flag(ginf[gArbitrary].flags, qIDEAL, true); + if(ep.eat(",") && ep.eat("|")) is_symmetric = true, cc.symmetric_value = ep.iparse(); ep.force_eat(")"); break; } @@ -379,6 +390,11 @@ EX void load_tile(exp_parser& ep, arbi_tiling& c, bool unit) { cc.ideal_markers.push_back(cc.ideal_markers[j]); } ep.skip_white(); + if(ep.eat(",")) { + ep.force_eat("|"); + cc.symmetric_value = ep.iparse(); + is_symmetric = true; + } if(ep.eat(")")) { if(repeat_from == 0) cc.repeat_value = rep; break; @@ -420,6 +436,7 @@ EX void load_tile(exp_parser& ep, arbi_tiling& c, bool unit) { throw; } int n = cc.size(); + if(is_symmetric) cc.symmetric_value += n; cc.connections.resize(n); for(int i=0; i mirrored_id(s, -1); for(int i=0; i= s) sh[i].is_mirrored = true; } - for(int i=s; i= s); co.mirror = false; - if(mirr) { - co.sid += s; + if(mirr && mirrored_id[co.sid] == -1) { + co.eid = gmod(sh[co.sid].symmetric_value - co.eid, isize(sh[co.sid].angles)); + } + else if(mirr) { + co.sid = mirrored_id[co.sid]; co.eid = isize(sh[co.sid].angles) - 1 - co.eid; if(sh[co.sid].apeirogonal) co.eid = gmod(co.eid - 2, isize(sh[co.sid].angles)); @@ -761,7 +786,7 @@ EX void check_football_colorability(arbi_tiling& c) { for(auto&sh: c.shapes) sh.football_type = 3; } -EX void add_connection(arbi_tiling& c, int ai, int as, int bi, int bs, int m) { +EX void add_connection_sub(arbi_tiling& c, int ai, int as, int bi, int bs, int m) { int as0 = as, bs0 = bs; auto& ash = c.shapes[ai]; auto& bsh = c.shapes[bi]; @@ -777,6 +802,25 @@ EX void add_connection(arbi_tiling& c, int ai, int as, int bi, int bs, int m) { while(bs != bs0); } +EX void add_connection(arbi_tiling& c, int ai, int as, int bi, int bs, int m) { + auto& ash = c.shapes[ai]; + auto& bsh = c.shapes[bi]; + add_connection_sub(c, ai, as, bi, bs, m); + int as1, bs1; + if(ash.symmetric_value) { + as1 = gmod(ash.symmetric_value - as, ash.size()); + println(hlog, tie(ai, as), " also is ", tie(ai, as1), " since symmetric is ", ash.symmetric_value, "/", ash.size(), " A"); + add_connection_sub(c, ai, as1, bi, bs, !m); + } + if(bsh.symmetric_value) { + bs1 = gmod(bsh.symmetric_value - bs, bsh.size()); + println(hlog, tie(bi, bs), " also is ", tie(bi, bs1), " since symmetric is ", bsh.symmetric_value, "/", bsh.size(), " B"); + add_connection_sub(c, ai, as, bi, bs1, !m); + } + if(ash.symmetric_value && bsh.symmetric_value) + add_connection_sub(c, ai, as1, bi, bs1, m); + } + EX void set_defaults(arb::arbi_tiling& c, bool keep_sliders, string fname) { c.order++; c.name = unnamed;