From 7e2e4928e9d2b434ff60b6ce6604bea1cac68357 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 6 Jan 2020 21:23:17 +0100 Subject: [PATCH] factored hrmap_quotient3::initialize --- reg3.cpp | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/reg3.cpp b/reg3.cpp index 503e2b5c..d1328a25 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -226,6 +226,7 @@ EX namespace reg3 { struct hrmap_quotient3 : hrmap { vector allh; vector> tmatrices; + vector acells; transmatrix adj(heptagon *h, int d) { return tmatrices[h->fieldval][d]; } @@ -233,9 +234,26 @@ EX namespace reg3 { void draw() override; transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override; + + void initialize(int cell_count); + vector& allcells() override { return acells; } }; #endif + void hrmap_quotient3::initialize(int cell_count) { + allh.resize(cell_count); + acells.clear(); + tmatrices.resize(cell_count); + for(int a=0; a (S7); + allh[a]->c7 = newCell(S7, allh[a]); + allh[a]->fieldval = a; + allh[a]->zebraval = 0; + allh[a]->alt = NULL; + acells.push_back(allh[a]->c7); + } + } + void hrmap_quotient3::draw() { sphereflip = Id; @@ -289,15 +307,7 @@ EX namespace reg3 { hrmap_from_crystal() { generate(); - allh.resize(256); - tmatrices.resize(256); - for(int a=0; a<256; a++) { - allh[a] = tailored_alloc (S7); - allh[a]->c7 = newCell(S7, allh[a]); - allh[a]->fieldval = a; - allh[a]->zebraval = 0; - allh[a]->alt = NULL; - } + initialize(256); if(1) { auto m = crystal::new_map(); dynamicval cm(currentmap, m); @@ -316,7 +326,6 @@ EX namespace reg3 { }; struct hrmap_field3 : hrmap_quotient3 { - vector acells; int mgmul(std::initializer_list v) { int a = 0; @@ -474,19 +483,9 @@ EX namespace reg3 { DEBB(DF_FIELD, ("building allh...")); int cells = N / perm_group; - allh.resize(cells); - for(int i=0; i (S7); - allh[i]->c7 = newCell(S7, allh[i]); - allh[i]->fieldval = i; - allh[i]->zebraval = 0; - allh[i]->alt = NULL; - acells.push_back(allh[i]->c7); - } - - DEBB(DF_FIELD, ("finding tmatrices...")); - tmatrices.resize(cells); + initialize(cells); + DEBB(DF_FIELD, ("finding tmatrices...")); for(int i=0; i& allcells() override { return acells; } - vector get_vertices(cell* c) override { return vertices_only; } @@ -694,15 +691,7 @@ EX namespace reg3 { hrmap_seifert_cover() { if(periods.empty()) build_reps(); - allh.resize(125); - tmatrices.resize(125); - for(int a=0; a<125; a++) { - allh[a] = tailored_alloc (S7); - allh[a]->c7 = newCell(S7, allh[a]); - allh[a]->fieldval = a; - allh[a]->zebraval = 0; - allh[a]->alt = NULL; - } + initialize(125); for(int a=0; a<125; a++) { tmatrices[a].resize(12); for(int b=0; b<12; b++) {