1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
/**************************************************************************
* *
* Regina - A Normal Surface Theory Calculator *
* Computational Engine *
* *
* Copyright (c) 1999-2025, Ben Burton *
* For further details contact Ben Burton (bab@debian.org). *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* As an exception, when this program is distributed through (i) the *
* App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or *
* (iii) Google Play by Google Inc., then that store may impose any *
* digital rights management, device limits and/or redistribution *
* restrictions that are required by its terms of service. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
#include "maths/matrix2.h"
#include "subcomplex/satannulus.h"
#include "triangulation/dim3.h"
namespace regina {
int SatAnnulus::meetsBoundary() const {
int ans = 0;
if (! tet[0]->adjacentTetrahedron(roles[0][3]))
++ans;
if (! tet[1]->adjacentTetrahedron(roles[1][3]))
++ans;
return ans;
}
void SatAnnulus::switchSides() {
for (int which = 0; which < 2; which++) {
int face = roles[which][3];
roles[which] = tet[which]->adjacentGluing(face) *
roles[which];
tet[which] = tet[which]->adjacentTetrahedron(face);
}
}
std::tuple<bool, bool, bool> SatAnnulus::isAdjacent(const SatAnnulus& other)
const {
if (other.meetsBoundary())
return { false, false, false };
// See what is actually attached to the given annulus.
SatAnnulus opposite(other);
opposite.switchSides();
if (opposite.tet[0] == tet[0] && opposite.tet[1] == tet[1]) {
// Could be a match without horizontal reflection.
if (opposite.roles[0] == roles[0] && opposite.roles[1] == roles[1]) {
// Perfect match.
return { true, false, false };
}
if (opposite.roles[0] == roles[0] * Perm<4>(0, 1) &&
opposite.roles[1] == roles[1] * Perm<4>(0, 1)) {
// Match with vertical reflection.
return { true, true, false };
}
}
if (opposite.tet[0] == tet[1] && opposite.tet[1] == tet[0]) {
// Could be a match with horizontal reflection.
if (opposite.roles[0] == roles[1] * Perm<4>(0, 1) &&
opposite.roles[1] == roles[0] * Perm<4>(0, 1)) {
// Match with horizontal reflection.
return { true, false, true };
}
if (opposite.roles[0] == roles[1] && opposite.roles[1] == roles[0]) {
// Match with both reflections.
return { true, true, true };
}
}
// No match.
return { false, false, false };
}
bool SatAnnulus::isJoined(const SatAnnulus& other, Matrix2& matching) const {
if (other.meetsBoundary())
return false;
// See what is actually attached to the given annulus.
SatAnnulus opposite(other);
opposite.switchSides();
bool swapTriangles;
Perm<4> roleMap; // Maps this 0/1/2 roles -> opposite 0/1/2 roles.
if (opposite.tet[0] == tet[0] &&
opposite.tet[1] == tet[1] &&
opposite.roles[0][3] == roles[0][3] &&
opposite.roles[1][3] == roles[1][3]) {
swapTriangles = false;
roleMap = opposite.roles[0].inverse() * roles[0];
if (roleMap != opposite.roles[1].inverse() * roles[1])
return false;
} else if (opposite.tet[0] == tet[1] &&
opposite.tet[1] == tet[0] &&
opposite.roles[0][3] == roles[1][3] &&
opposite.roles[1][3] == roles[0][3]) {
swapTriangles = true;
roleMap = opposite.roles[1].inverse() * roles[0];
if (roleMap != opposite.roles[0].inverse() * roles[1])
return false;
} else
return false;
// It's a match. We just need to work out the matching matrix.
if (roleMap == Perm<4>(0, 1, 2, 3)) {
matching = Matrix2(1, 0, 0, 1);
} else if (roleMap == Perm<4>(1, 2, 0, 3)) {
matching = Matrix2(-1, 1, -1, 0);
} else if (roleMap == Perm<4>(2, 0, 1, 3)) {
matching = Matrix2(0, -1, 1, -1);
} else if (roleMap == Perm<4>(0, 2, 1, 3)) {
matching = Matrix2(0, 1, 1, 0);
} else if (roleMap == Perm<4>(2, 1, 0, 3)) {
matching = Matrix2(1, -1, 0, -1);
} else if (roleMap == Perm<4>(1, 0, 2, 3)) {
matching = Matrix2(-1, 0, -1, 1);
}
if (swapTriangles)
matching.negate();
return true;
}
bool SatAnnulus::isTwoSidedTorus() const {
// Check that the edges are identified in opposite pairs and that we
// have no duplicates.
Edge<3>* e01 = tet[0]->edge(Edge<3>::edgeNumber[roles[0][0]][roles[0][1]]);
Edge<3>* e02 = tet[0]->edge(Edge<3>::edgeNumber[roles[0][0]][roles[0][2]]);
Edge<3>* e12 = tet[0]->edge(Edge<3>::edgeNumber[roles[0][1]][roles[0][2]]);
if (e01 != tet[1]->edge(Edge<3>::edgeNumber[roles[1][0]][roles[1][1]]))
return false;
if (e02 != tet[1]->edge(Edge<3>::edgeNumber[roles[1][0]][roles[1][2]]))
return false;
if (e12 != tet[1]->edge(Edge<3>::edgeNumber[roles[1][1]][roles[1][2]]))
return false;
if (e01 == e02 || e02 == e12 || e12 == e01)
return false;
// Verify that edges are consistently oriented, and that the
// orientations of the edge links indicate a two-sided torus.
Perm<4> map0, map1;
int a, b, x, y;
for (int i = 0; i < 3; i++) {
// Examine edges corresponding to annulus markings a & b.
// We also set x & y as the complement of {a,b} in {0,1,2,3}.
switch (i) {
case 0: a = 0; b = 1; x = 2; y = 3; break;
case 1: a = 0; b = 2; x = 1; y = 3; break;
case 2: a = 1; b = 2; x = 0; y = 3; break;
}
// Get mappings from tetrahedron edge roles to annulus vertex roles.
map0 = roles[0].inverse() * tet[0]->edgeMapping(
Edge<3>::edgeNumber[roles[0][a]][roles[0][b]]);
map1 = roles[1].inverse() * tet[1]->edgeMapping(
Edge<3>::edgeNumber[roles[1][a]][roles[1][b]]);
// We should have {a,b} -> {a,b} and {x,y} -> {x,y} for each map.
// Make sure that the two annulus edges are oriented in the same way
// (i.e., (a,b) <-> (b,a)), and that the edge link runs in opposite
// directions through the annulus on each side (i.e., (x,y) <-> (y,x)).
if (map0 != Perm<4>(a, b) * Perm<4>(x, y) * map1)
return false;
}
// No unpleasantries.
return true;
}
void SatAnnulus::transform(const Triangulation<3>& /* originalTri */,
const Isomorphism<3>& iso, const Triangulation<3>& newTri) {
for (int which = 0; which < 2; which++) {
size_t tetID = tet[which]->index();
tet[which] = newTri.tetrahedron(iso.tetImage(tetID));
roles[which] = iso.facePerm(tetID) * roles[which];
}
}
void SatAnnulus::attachLST(Tetrahedron<3>* t0, Perm<4> r0,
Tetrahedron<3>* t1, Perm<4> r1, long alpha, long beta) {
// Save ourselves headaches later.
if (alpha == 0)
throw InvalidArgument("SatAnnulus::attachLST() requires alpha "
"to be non-zero");
// The coprimality condition is checked by insertLayeredSolidTorus().
// The conditions on the two boundary faces (being unglued and unlocked)
// are checked within Simplex::join().
// Normalise to alpha positive.
if (alpha < 0) {
alpha = -alpha;
beta = -beta;
}
// Pull out the degenerate case.
if (alpha == 2 && beta == 1) {
t0->join(r0[3], t1, r1 * Perm<4>(0, 1) * r0.inverse());
return;
}
// Insert a real layered solid torus. How we do this depends on
// relative signs and orderings.
long diag = alpha - beta;
// Our six possibilities are:
//
// 0 <= -diag < alpha <= beta:
// 0 < alpha <= -diag < beta:
// 0 < diag <= beta < alpha:
// 0 <= beta < diag <= alpha:
// 0 < -beta <= alpha < diag
// 0 < alpha < -beta < diag
// We can give the vertices of the tetrahedra "cut labels" as
// follows (where the LST has parameters 0 <= cuts0 <= cuts1 <= cuts2):
//
// cuts0
// *-------*
// |2 1 / |
// | / 0|
// cuts1 | / | cuts1
// |0 / |
// | / 1 2|
// *-------*
// cuts0
long cuts0, cuts1;
Perm<4> cutsToRoles; // Maps cut labels to annulus vertex roles.
if (alpha <= beta) {
if (-diag < alpha) {
// 0 <= -diag < alpha <= beta:
cuts0 = -diag;
cuts1 = alpha;
cutsToRoles = Perm<4>(0, 2, 1, 3);
} else {
// 0 < alpha <= -diag < beta:
cuts0 = alpha;
cuts1 = -diag;
cutsToRoles = Perm<4>(2, 0, 1, 3);
}
} else if (0 <= beta) {
if (diag <= beta) {
// 0 < diag <= beta < alpha:
cuts0 = diag;
cuts1 = beta;
cutsToRoles = Perm<4>(0, 1, 2, 3);
} else {
// 0 <= beta < diag <= alpha:
cuts0 = beta;
cuts1 = diag;
cutsToRoles = Perm<4>(1, 0, 2, 3);
}
} else {
if (-beta <= alpha) {
// 0 < -beta <= alpha < diag
cuts0 = -beta;
cuts1 = alpha;
cutsToRoles = Perm<4>(1, 2, 0, 3);
} else {
// 0 < alpha < -beta < diag
cuts0 = alpha;
cuts1 = -beta;
cutsToRoles = Perm<4>(2, 1, 0, 3);
}
}
Tetrahedron<3>* lst = t0->triangulation().insertLayeredSolidTorus(
cuts0, cuts1);
// The boundary of the new LST sits differently for the special
// cases (0,1,1) and (1,1,2); see the insertLayeredSolidTorus()
// documentation for details.
if (cuts1 == 1) {
lst->join(3, t0, r0 * cutsToRoles * Perm<4>(1, 2, 0, 3));
lst->join(2, t1, r1 * cutsToRoles * Perm<4>(2, 1, 3, 0));
} else {
lst->join(3, t0, r0 * cutsToRoles * Perm<4>(0, 1, 2, 3));
lst->join(2, t1, r1 * cutsToRoles * Perm<4>(1, 0, 3, 2));
}
}
} // namespace regina
|