diff --git a/archimedean.cpp b/archimedean.cpp index 3a24d4a4..6287d8a7 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -529,17 +529,8 @@ struct hrmap_archimedean : hrmap { dynamicval curmap(currentmap, this); int id = DUAL ? current.N * 2 : 0;; int N0 = isize(current.adjacent[id]); - origin = tailored_alloc (N0); + origin = init_heptagon(N0); origin->s = hsOrigin; - origin->emeraldval = 0; - origin->zebraval = 0; - origin->fiftyval = 0; - origin->fieldval = 0; - origin->rval0 = origin->rval1 = 0; - origin->cdata = NULL; - origin->alt = NULL; - origin->c7 = NULL; - origin->distance = 0; parent_index_of(origin) = DUAL ? 1 : 0; id_of(origin) = id; @@ -549,14 +540,9 @@ struct hrmap_archimedean : hrmap { if(hyperbolic) { dynamicval g(geometry, gNormal); - alt = tailored_alloc (S7); + alt = init_heptagon(S7); alt->s = hsOrigin; - alt->emeraldval = 0; - alt->zebraval = 0; - alt->distance = 0; - alt->c7 = NULL; alt->alt = alt; - alt->cdata = NULL; current_altmap = newAltMap(alt); } diff --git a/asonov.cpp b/asonov.cpp index 6b27450b..b4564682 100644 --- a/asonov.cpp +++ b/asonov.cpp @@ -176,15 +176,12 @@ struct hrmap_asonov : hrmap { heptagon *get_at(coord c) { auto& h = at[c]; if(h) return h; - h = tailored_alloc (S7); + h = init_heptagon(S7); h->c7 = newCell(S7, h); coords[h] = c; - h->dm4 = 0; h->distance = c[2]; h->zebraval = c[0]; h->emeraldval = c[1]; - h->cdata = NULL; - h->alt = NULL; return h; } diff --git a/bigstuff.cpp b/bigstuff.cpp index 0528ed35..12c52d85 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -291,16 +291,11 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special if(!polarb50(c)) return NULL; } - heptagon *alt = tailored_alloc (h->type); + heptagon *alt = init_heptagon(h->type); allmaps.push_back(newAltMap(alt)); //printf("new alt {%p}\n", hr::voidp(alt)); alt->s = firststate; - alt->emeraldval = 0; - alt->zebraval = 0; - alt->distance = 0; - alt->fieldval = 0; if(hybri) alt->fieldval = hybrid::get_where(centerover).second; - alt->c7 = NULL; alt->alt = alt; #if MAXMDIM >= 4 if(reg3::in_rule()) { diff --git a/cell.cpp b/cell.cpp index e97e859f..8bb3c3d7 100644 --- a/cell.cpp +++ b/cell.cpp @@ -178,17 +178,11 @@ EX hrmap *newAltMap(heptagon *o) { EX heptagon* hyperbolic_origin() { int odegree = geometry == gBinaryTiling ? 6 : S7; - heptagon *origin = tailored_alloc (odegree); + heptagon *origin = init_heptagon(odegree); heptagon& h = *origin; h.s = hsOrigin; h.emeraldval = a46 ? 0 : 98; h.zebraval = 40; - h.fiftyval = 0; - h.fieldval = 0; - h.rval0 = h.rval1 = 0; - h.cdata = NULL; - h.alt = NULL; - h.distance = 0; #if CAP_IRR if(IRREGULAR) irr::link_start(origin); else diff --git a/crystal.cpp b/crystal.cpp index deead13f..1cc745c6 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -506,9 +506,7 @@ struct hrmap_crystal : hrmap_standard { heptagon *get_heptagon_at(coord c, int deg) { if(heptagon_at.count(c)) return heptagon_at[c]; heptagon*& h = heptagon_at[c]; - h = tailored_alloc (deg); - h->alt = NULL; - h->cdata = NULL; + h = init_heptagon(deg); h->c7 = newCell(deg, h); /* in {6,4} we need emeraldval for some patterns, including (bitruncated) football and (bitruncated) three-color */ @@ -519,7 +517,6 @@ struct hrmap_crystal : hrmap_standard { h->emeraldval ^= ((c[2] & 2) << 1); if(c[0] & 2) h->emeraldval ^= 1; - h->distance = 0; if(ginf[gCrystal].vertex == 3) h->fiftyval = fiftyrule(c); for(int i=0; idistance += abs(c[i]); diff --git a/euclid.cpp b/euclid.cpp index 9c67057a..d7e71d31 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -180,7 +180,7 @@ EX namespace euc { if(spacemap.count(at)) return spacemap[at]; else { - auto h = tailored_alloc (S7); + auto h = init_heptagon(S7); if(!IRREGULAR) h->c7 = newCell(S7, h); #if CAP_IRR @@ -197,9 +197,6 @@ EX namespace euc { } } #endif - h->distance = 0; - h->cdata = NULL; - h->alt = NULL; if(S7 != 14) h->zebraval = gmod(at[0] + at[1] * 2 + at[2] * 4, 5); else diff --git a/heptagon.cpp b/heptagon.cpp index ca3581c1..5c1ae021 100644 --- a/heptagon.cpp +++ b/heptagon.cpp @@ -76,6 +76,21 @@ EX heptagon *buildHeptagon1(heptagon *h, heptagon *parent, int d, hstate s, int h->cdata = NULL; return h; } + +heptagon *init_heptagon(int type) { + heptagon *h = tailored_alloc (d); + h->emeraldval = 0; + h->zebraval = 0; + h->fiftyval = 0; + h->fieldval = 0; + h->rval0 = origin->rval1 = 0; + h->cdata = NULL; + h->alt = NULL; + h->c7 = NULL; + h->distance = 0; + h->dm4 = 0; + return h; + } heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fixdistance = COMPUTE) { heptagon *h = buildHeptagon1(tailored_alloc (S7), parent, d, s, pard); diff --git a/inforder.cpp b/inforder.cpp index c22e3f5f..4abe524f 100644 --- a/inforder.cpp +++ b/inforder.cpp @@ -24,13 +24,11 @@ EX namespace inforder { heptagon *create_step(heptagon *h, int direction) { int deg = h->type; if(mixed()) deg = 7 - deg; - auto h1 = tailored_alloc (deg); + auto h1 = init_heptagon(deg); bool par = h->s == hsA && direction == 0; h->c.connect(direction, h1, par ? 1 + hrand(2) : 0, false); - h1->alt = NULL; h1->s = hsA; - h1->cdata = NULL; h1->distance = h->distance + (par ? -1 : 1); h1->c7 = newCell(deg, h1); diff --git a/kite.cpp b/kite.cpp index 215b6181..b6d16fe2 100644 --- a/kite.cpp +++ b/kite.cpp @@ -157,18 +157,11 @@ struct hrmap_kite : hrmap { } heptagon *newtile(pshape s, int dist) { - heptagon *h = tailored_alloc (8); + heptagon *h = init_heptagon(8); h->s = hstate(s); h->dm4 = h->distance = dist; if(bt::in() || dist == 0) h->c7 = newCell(euclid ? 4 : s == pKite ? 12 : 10, h); - else - h->c7 = NULL; - h->zebraval = 0; - h->emeraldval = 0; - h->fieldval = 0; - h->cdata = NULL; - h->alt = NULL; return h; } diff --git a/nonisotropic.cpp b/nonisotropic.cpp index d747d721..f4902492 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -246,16 +246,12 @@ EX namespace sn { heptagon *get_at(heptagon *x, heptagon *y) { auto& h = at[make_pair(x, y)]; if(h) return h; - h = tailored_alloc (S7); + h = init_heptagon(S7); h->c7 = newCell(S7, h); coords[h] = make_pair(x, y); h->distance = x->distance; - h->dm4 = 0; h->zebraval = x->emeraldval; h->emeraldval = y->emeraldval; - h->fieldval = 0; - h->cdata = NULL; - h->alt = NULL; return h; } @@ -266,27 +262,17 @@ EX namespace sn { if(true) { dynamicval g(geometry, gBinary4); - alt = tailored_alloc (S7); + alt = init_heptagon(S7); alt->s = hsOrigin; alt->alt = alt; - alt->cdata = NULL; - alt->c7 = NULL; - alt->zebraval = 0; - alt->distance = 0; - alt->emeraldval = 0; binary_map = bt::new_alt_map(alt); } if(nih) { dynamicval g(geometry, gTernary); - alt3 = tailored_alloc (S7); + alt3 = init_heptagon(S7); alt3->s = hsOrigin; alt3->alt = alt3; - alt3->cdata = NULL; - alt3->c7 = NULL; - alt3->zebraval = 0; - alt3->distance = 0; - alt3->emeraldval = 0; ternary_map = bt::new_alt_map(alt3); } else { @@ -886,15 +872,12 @@ EX namespace nilv { heptagon *get_at(mvec c) { auto& h = at[c]; if(h) return h; - h = tailored_alloc (S7); + h = init_heptagon(S7); h->c7 = newCell(S7, h); coords[h] = c; - h->dm4 = 0; h->zebraval = c[0]; h->emeraldval = c[1]; h->fieldval = c[2]; - h->cdata = NULL; - h->alt = NULL; return h; } diff --git a/quotient.cpp b/quotient.cpp index 84e0499e..d4020bc7 100644 --- a/quotient.cpp +++ b/quotient.cpp @@ -353,25 +353,16 @@ struct hrmap_quotient : hrmap_standard { // printf("all cells = %d\n", TOT*(S7+S3)/S3); if(!TOT) exit(1); allh.resize(TOT); - for(int i=0; i (S7); + for(int i=0; ialt = base.origin; for(int i=0; ialt = NULL; - } if(true) { h->s = hsOrigin; - h->emeraldval = 0; - h->zebraval = 0; - h->fiftyval = 0; h->fieldval = S7*i; - h->rval0 = h->rval1 = 0; h->cdata = NULL; - h->distance = 0; if(!IRREGULAR) h->c7 = newCell(S7, h); - else h->c7 = NULL; } for(int j=0; j (S7); + allh[a] = init_heptagon(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); } } @@ -616,15 +614,9 @@ EX namespace reg3 { } hrmap_reg3() { - origin = tailored_alloc (S7); + origin = init_heptagon(S7); heptagon& h = *origin; h.s = hsOrigin; - h.cdata = NULL; - h.alt = NULL; - h.distance = 0; - h.fiftyval = 0; - h.fieldval = 0; - h.emeraldval = 0; h.c7 = newCell(S7, origin); if(sphere) spherecells.push_back(h.c7); worst_error1 = 0, worst_error2 = 0; @@ -657,14 +649,9 @@ EX namespace reg3 { if(hyperbolic) { dynamicval g(geometry, gBinary3); bt::build_tmatrix(); - alt = tailored_alloc (S7); + alt = init_heptagon(S7); alt->s = hsOrigin; - alt->emeraldval = 0; - alt->zebraval = 0; - alt->distance = 0; alt->alt = alt; - alt->cdata = NULL; - alt->c7 = NULL; binary_map = bt::new_alt_map(alt); T = xpush(.01241) * spin(1.4117) * xpush(0.1241) * cspin(0, 2, 1.1249) * xpush(0.07) * Id; } @@ -834,11 +821,9 @@ EX namespace reg3 { } println(hlog, "found d2 = ", d2); } - heptagon *created = tailored_alloc (S7); + heptagon *created = init_heptagon(S7); created->c7 = newCell(S7, created); if(sphere) spherecells.push_back(created->c7); - created->alt = NULL; - created->cdata = NULL; #if CAP_FIELD if(quotient_map) { created->emeraldval = fv; @@ -1048,16 +1033,10 @@ EX namespace reg3 { load_ruleset(get_rule_filename()); - origin = tailored_alloc (S7); + origin = init_heptagon(S7); heptagon& h = *origin; h.s = hsOrigin; - h.cdata = NULL; - h.alt = NULL; - h.distance = 0; - h.zebraval = 0; - h.fieldval = 0; h.fiftyval = root[0]; - h.c7 = NULL; h.c7 = newCell(S7, origin); int opos = 0; @@ -1183,13 +1162,9 @@ EX namespace reg3 { } if(id1 != -1) { - res = tailored_alloc (S7); + res = init_heptagon(S7); if(parent->c7) res->c7 = newCell(S7, res); - else - res->c7 = nullptr; - res->alt = nullptr; - res->cdata = nullptr; res->fieldval = fv; res->distance = parent->distance + 1; res->fiftyval = id1; @@ -1198,10 +1173,8 @@ EX namespace reg3 { } else if(other[pos] == ('A' + d) && other[pos+1] == ',') { - res = tailored_alloc (S7); - res->c7 = nullptr; + res = init_heptagon(S7); res->alt = parent->alt; - res->cdata = nullptr; res->fieldval = fv; res->distance = parent->distance - 1; vector possible; diff --git a/sphere.cpp b/sphere.cpp index 9100b190..8d254ec6 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -27,14 +27,11 @@ struct hrmap_spherical : hrmap_standard { hrmap_spherical() { for(int i=0; i (S7)); + heptagon& h = *(dodecahedron[i] = init_heptagon(S7)); h.s = hsOrigin; h.emeraldval = i; h.zebraval = i; h.fiftyval = i; - h.rval0 = h.rval1 = 0; - h.alt = NULL; - h.cdata = NULL; h.c.fullclear(); h.fieldval = i; if(!IRREGULAR) h.c7 = newCell(S7, &h);