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
|
################################
#
# Sample Python Script
#
# Illustrates the traversal and manipulation of an entire packet tree.
#
# See the file "tree.session" for the results of running this script.
#
################################
# Recreate the original SnapPea census of cusped hyperbolic manifolds
# triangulated by at most 5 tetrahedra.
#
# Since we are building a packet tree, we need to use PacketOfTriangulation3,
# not the plain type Triangulation3 (which is not a packet type).
census = Container()
for i in range(415):
mfd = SnapPeaCensusManifold(SnapPeaCensusManifold.SEC_5, i)
census.append(make_packet(mfd.construct(), mfd.name()))
# The triangulations are now all children of the "census" container.
# Remove all triangulations with more than two tetrahedra.
#
# Since we are deleting children, we step through the children manually
# instead of just iterating over children().
tri = census.firstChild()
while tri != None:
next = tri.nextSibling()
if tri.size() > 2:
tri.makeOrphan()
tri = next
# Print the homology of each remaining triangulation.
# This time we are not adding or removing children, so we can just iterate.
for tri in census.children():
print(tri.label() + ":", tri.homology())
|