From b6bf0911f355b2fcce94f2ebabcba6be8743636b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 9 Jul 2021 10:10:13 +0200 Subject: [PATCH] refactored master_relative as virtual function --- cell.cpp | 3 ++- geometry2.cpp | 15 +++++++++------ reg3.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cell.cpp b/cell.cpp index fd9361d2..36b6a997 100644 --- a/cell.cpp +++ b/cell.cpp @@ -66,7 +66,7 @@ struct hrmap { virtual int shvid(cell *c) { return 0; } virtual int full_shvid(cell *c) { return shvid(c); } virtual hyperpoint get_corner(cell *c, int cid, ld cf=3) { return C0; } - + virtual transmatrix master_relative(cell *c, bool get_inverse = false) { return Id; } virtual int wall_offset(cell *c); }; @@ -87,6 +87,7 @@ struct hrmap_standard : hrmap { void find_cell_connection(cell *c, int d) override; virtual int shvid(cell *c) override; virtual hyperpoint get_corner(cell *c, int cid, ld cf) override; + virtual transmatrix master_relative(cell *c, bool get_inverse) override; }; void clearfrom(heptagon*); diff --git a/geometry2.cpp b/geometry2.cpp index 0335a21b..8b324b13 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -52,7 +52,7 @@ EX transmatrix relative_matrix_recursive(heptagon *h2, heptagon *h1) { return gm * where; } -EX transmatrix master_relative(cell *c, bool get_inverse IS(false)) { +transmatrix hrmap_standard::master_relative(cell *c, bool get_inverse) { if(0) ; #if CAP_IRR else if(IRREGULAR) { @@ -109,18 +109,21 @@ transmatrix hrmap_standard::adj(heptagon *h, int d) { return T; } -transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) { - +EX transmatrix relative_matrix_via_masters(cell *c2, cell *c1, const hyperpoint& hint) { heptagon *h1 = c1->master; - transmatrix gm = master_relative(c1, true); + transmatrix gm = currentmap->master_relative(c1, true); heptagon *h2 = c2->master; - transmatrix where = master_relative(c2); + transmatrix where = currentmap->master_relative(c2); - transmatrix U = relative_matrix(h2, h1, hint); + transmatrix U = currentmap->relative_matrix(h2, h1, hint); return gm * U * where; } +transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) { + return relative_matrix_via_masters(c2, c1, hint); + } + transmatrix hrmap_standard::relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { transmatrix gm = Id, where = Id; diff --git a/reg3.cpp b/reg3.cpp index 59f178bb..c68dd192 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -657,6 +657,12 @@ EX namespace reg3 { int id = local_id[c].second; return cgi.subshapes[id].vertices_only_local; } + + transmatrix master_relative(cell *c, bool get_inverse) { + int id = local_id[c].second; + auto& ss = cgi.subshapes[id]; + return get_inverse ? ss.from_cellcenter : ss.to_cellcenter; + } void make_subconnections();