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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
/**************************************************************************
* *
* Regina - A Normal Surface Theory Calculator *
* Computational Engine *
* *
* Copyright (c) 1999-2008, 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. *
* *
* 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, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
**************************************************************************/
/* end stub */
#include <list>
#include <sstream>
#include "packet/ncontainer.h"
#include "surfaces/nnormalsurface.h"
#include "triangulation/nisomorphism.h"
#include "triangulation/ntriangulation.h"
namespace regina {
unsigned long NTriangulation::splitIntoComponents(NPacket* componentParent,
bool setLabels) {
// Knock off the empty triangulation first.
if (tetrahedra.empty())
return 0;
if (! componentParent)
componentParent = this;
// We clone the triangulation, create new empty component
// triangulations and then sort the tetrahedra into the new
// components.
unsigned long nTets = tetrahedra.size();
// Begin by cloning the triangulation.
NTetrahedron** newTets = new NTetrahedron*[nTets];
NTetrahedron *tet, *adjTet;
unsigned long tetPos, adjPos;
NPerm adjPerm;
int face;
for (tetPos = 0; tetPos < nTets; tetPos++)
newTets[tetPos] = new NTetrahedron(
tetrahedra[tetPos]->getDescription());
for (tetPos = 0; tetPos < nTets; tetPos++) {
tet = tetrahedra[tetPos];
for (face = 0; face < 4; face++) {
adjTet = tet->getAdjacentTetrahedron(face);
if (adjTet) {
adjPos = tetrahedronIndex(adjTet);
adjPerm = tet->getAdjacentTetrahedronGluing(face);
if (adjPos > tetPos ||
(adjPos == tetPos && adjPerm[face] > face))
newTets[tetPos]->joinTo(face, newTets[adjPos], adjPerm);
}
}
}
// Now create the new component triangulations.
// We will need a skeleton at this point -- use getNumberOfComponents()
// to force a skeletal recalculation if it has not already been done.
NTriangulation** newTris = new NTriangulation*[getNumberOfComponents()];
unsigned long whichComp = 0;
for (ComponentIterator it = components.begin(); it != components.end();
it++) {
newTris[whichComp] = new NTriangulation();
componentParent->insertChildLast(newTris[whichComp]);
if (setLabels) {
std::ostringstream label;
label << getPacketLabel() << " - Cmpt #" << (whichComp + 1);
newTris[whichComp]->setPacketLabel(makeUniqueLabel(label.str()));
}
whichComp++;
}
// At this point whichComp == components.size().
// Sort the new tetrahedra into component triangulations.
// Note that component index lookup is faster than tetrahedron index
// lookup.
for (tetPos = 0; tetPos < nTets; tetPos++)
newTris[componentIndex(tetrahedra[tetPos]->getComponent())]->
addTetrahedron(newTets[tetPos]);
// And clean up.
delete[] newTets;
delete[] newTris;
return whichComp;
}
unsigned long NTriangulation::connectedSumDecomposition(NPacket* primeParent,
bool setLabels) {
// Precondition checks.
if (! (isValid() && isClosed() && isOrientable() && isConnected()))
return 0;
if (! primeParent)
primeParent = this;
// Make a working copy, simplify and record the initial homology.
NTriangulation* working = new NTriangulation(*this);
working->intelligentSimplify();
unsigned long initZ, initZ2, initZ3;
{
const NAbelianGroup& homology = working->getHomologyH1();
initZ = homology.getRank();
initZ2 = homology.getTorsionRank(2);
initZ3 = homology.getTorsionRank(3);
}
// Start crushing normal spheres.
NContainer toProcess;
toProcess.insertChildLast(working);
std::list<NTriangulation*> primeComponents;
unsigned long whichComp = 0;
NTriangulation* processing;
NTriangulation* crushed;
NNormalSurface* sphere;
while ((processing = static_cast<NTriangulation*>(
toProcess.getFirstTreeChild()))) {
// INV: Our triangulation is the connected sum of all the
// children of toProcess, all the elements of primeComponents
// and possibly some copies of S2xS1, RP3 and/or L(3,1).
// Work with the last child.
processing->makeOrphan();
// Find a normal 2-sphere to crush.
sphere = NNormalSurface::findNonTrivialSphere(processing);
if (sphere) {
crushed = sphere->crush();
delete sphere;
delete processing;
crushed->intelligentSimplify();
// Insert each component of the crushed triangulation back
// into the list to process.
if (crushed->getNumberOfComponents() == 0)
delete crushed;
else if (crushed->getNumberOfComponents() == 1)
toProcess.insertChildLast(crushed);
else {
crushed->splitIntoComponents(&toProcess, false);
delete crushed;
}
} else {
// We have no non-trivial normal 2-spheres!
// The triangulation is 0-efficient (and prime).
// Is it a 3-sphere?
if (processing->getNumberOfVertices() > 1) {
// Proposition 5.1 of Jaco & Rubinstein's 0-efficiency
// paper: If a closed orientable triangulation T is
// 0-efficient then either T has one vertex or T is a
// 3-sphere with precisely two vertices.
//
// It follows then that this is a 3-sphere.
// Toss it away.
delete sphere;
delete processing;
} else {
// Now we have a one-vertex prime 0-efficient triangulation.
// We have to look for an almost normal sphere.
//
// From the proof of Proposition 5.12 in Jaco & Rubinstein's
// 0-efficiency paper, we see that we can restrict our
// search to octagonal almost normal surfaces.
// Furthermore, from Casson's proof (directly following
// Proposition 5.12), we see that we can restrict this
// search further to vertex octagonal almost normal surfaces.
sphere = NNormalSurface::findVtxOctAlmostNormalSphere(
processing);
if (sphere) {
// It's a 3-sphere. Toss this component away.
delete sphere;
delete processing;
} else {
// It's a non-trivial prime component!
primeComponents.push_back(processing);
}
}
}
}
// Run a final homology check and put back our missing S2xS1, RP3
// and L(3,1) terms.
unsigned long finalZ = 0, finalZ2 = 0, finalZ3 = 0;
for (std::list<NTriangulation*>::iterator it = primeComponents.begin();
it != primeComponents.end(); it++) {
const NAbelianGroup& homology = (*it)->getHomologyH1();
finalZ += homology.getRank();
finalZ2 += homology.getTorsionRank(2);
finalZ3 += homology.getTorsionRank(3);
}
while (finalZ++ < initZ) {
working = new NTriangulation();
working->insertLayeredLensSpace(0, 1);
primeComponents.push_back(working);
}
while (finalZ2++ < initZ2) {
working = new NTriangulation();
working->insertLayeredLensSpace(2, 1);
primeComponents.push_back(working);
}
while (finalZ3++ < initZ3) {
working = new NTriangulation();
working->insertLayeredLensSpace(3, 1);
primeComponents.push_back(working);
}
// All done!
for (std::list<NTriangulation*>::iterator it = primeComponents.begin();
it != primeComponents.end(); it++) {
primeParent->insertChildLast(*it);
if (setLabels) {
std::ostringstream label;
label << getPacketLabel() << " - Summand #" << (whichComp + 1);
(*it)->setPacketLabel(makeUniqueLabel(label.str()));
}
whichComp++;
}
return whichComp;
}
bool NTriangulation::isThreeSphere() const {
if (threeSphere.known())
return threeSphere.value();
// Basic property checks.
if (! (isValid() && isClosed() && isOrientable() && isConnected())) {
threeSphere = false;
return false;
}
// Check homology.
// Better simplify first, which means we need a clone.
NTriangulation* working = new NTriangulation(*this);
working->intelligentSimplify();
if (! working->getHomologyH1().isTrivial()) {
threeSphere = false;
delete working;
return false;
}
// Time for some more heavy machinery. On to normal surfaces.
NContainer toProcess;
toProcess.insertChildLast(working);
NTriangulation* processing;
NTriangulation* crushed;
NNormalSurface* sphere;
while ((processing = static_cast<NTriangulation*>(
toProcess.getLastTreeChild()))) {
// INV: Our triangulation is the connected sum of all the
// children of toProcess. Each of these children has trivial
// homology (and therefore we have no S2xS1 / RP3 / L(3,1)
// summands to worry about).
// Work with the last child.
processing->makeOrphan();
// Find a normal 2-sphere to crush.
sphere = NNormalSurface::findNonTrivialSphere(processing);
if (sphere) {
crushed = sphere->crush();
delete sphere;
delete processing;
crushed->intelligentSimplify();
// Insert each component of the crushed triangulation in the
// list to process.
if (crushed->getNumberOfComponents() == 0)
delete crushed;
else if (crushed->getNumberOfComponents() == 1)
toProcess.insertChildLast(crushed);
else {
crushed->splitIntoComponents(&toProcess, false);
delete crushed;
}
} else {
// We have no non-trivial normal 2-spheres!
// The triangulation is 0-efficient.
// We can now test directly whether we have a 3-sphere.
if (processing->getNumberOfVertices() > 1) {
// Proposition 5.1 of Jaco & Rubinstein's 0-efficiency
// paper: If a closed orientable triangulation T is
// 0-efficient then either T has one vertex or T is a
// 3-sphere with precisely two vertices.
//
// It follows then that this is a 3-sphere.
// Toss it away.
delete sphere;
delete processing;
} else {
// Now we have a one-vertex 0-efficient triangulation.
// We have to look for an almost normal sphere.
//
// From the proof of Proposition 5.12 in Jaco & Rubinstein's
// 0-efficiency paper, we see that we can restrict our
// search to octagonal almost normal surfaces.
// Furthermore, from Casson's proof (directly following
// Proposition 5.12), we see that we can restrict this
// search further to vertex octagonal almost normal surfaces.
sphere = NNormalSurface::findVtxOctAlmostNormalSphere(
processing);
if (sphere) {
// It's a 3-sphere. Toss this component away.
delete sphere;
delete processing;
} else {
// It's not a 3-sphere. We're done!
threeSphere = false;
delete processing;
return false;
}
}
}
}
// Our triangulation is the connected sum of 0 components!
threeSphere = true;
return true;
}
bool NTriangulation::knowsThreeSphere() const {
if (threeSphere.known())
return true;
// Run some very fast prelimiary tests before we give up and say no.
if (! (isValid() && isClosed() && isOrientable() && isConnected())) {
threeSphere = false;
return true;
}
// More work is required.
return false;
}
NPacket* NTriangulation::makeZeroEfficient() {
// Extract a connected sum decomposition.
NContainer* connSum = new NContainer();
connSum->setPacketLabel(getPacketLabel() + " - Decomposition");
unsigned long ans = connectedSumDecomposition(connSum, true);
if (ans > 1) {
// Composite!
return connSum;
} else if (ans == 1) {
// Prime.
NTriangulation* newTri = dynamic_cast<NTriangulation*>(
connSum->getLastTreeChild());
if (! isIsomorphicTo(*newTri).get()) {
removeAllTetrahedra();
insertTriangulation(*newTri);
}
delete connSum;
return 0;
} else {
// 3-sphere.
if (getNumberOfTetrahedra() > 1) {
removeAllTetrahedra();
insertLayeredLensSpace(1,0);
}
delete connSum;
return 0;
}
}
} // namespace regina
|