File: nsnappeacensustri.cpp

package info (click to toggle)
regina-normal 4.5-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 16,824 kB
  • ctags: 7,862
  • sloc: cpp: 63,296; ansic: 12,913; sh: 10,556; perl: 3,294; makefile: 947; python: 188
file content (241 lines) | stat: -rw-r--r-- 9,583 bytes parent folder | download
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

/**************************************************************************
 *                                                                        *
 *  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 "algebra/nabeliangroup.h"
#include "manifold/nsnappeacensusmfd.h"
#include "subcomplex/nsnappeacensustri.h"
#include "triangulation/ncomponent.h"
#include "triangulation/nedge.h"
#include "triangulation/nface.h"
#include "triangulation/nvertex.h"

namespace regina {

const char NSnapPeaCensusTri::SEC_5 = 'm';
const char NSnapPeaCensusTri::SEC_6_OR = 's';
const char NSnapPeaCensusTri::SEC_6_NOR = 'x';
const char NSnapPeaCensusTri::SEC_7_OR = 'v';
const char NSnapPeaCensusTri::SEC_7_NOR = 'y';

NSnapPeaCensusTri* NSnapPeaCensusTri::isSmallSnapPeaCensusTri(
        const NComponent* comp) {
    // Currently this routine can recognise SnapPea triangulations
    // m000 -- m004 as well as m129.

    // Since the triangulations are so small we can use census results
    // (from a census of all small valid ideal triangulations) to recognise
    // the triangulations by properties alone.

    // Before we do any further checks, make sure the number of
    // tetrahedra is within the supported range.

    if (comp->getNumberOfTetrahedra() > 4)
        return 0;

    // Start with property checks to see if it has a chance of being
    // in the SnapPea census at all.  The component must not be
    // closed, every edge must be valid and every vertex link must be
    // either a torus or a Klein bottle.  Note that this implies
    // that there are no boundary faces.

    if (comp->isClosed())
        return 0;

    unsigned long nVertices = comp->getNumberOfVertices();
    unsigned long nEdges = comp->getNumberOfEdges();
    unsigned long i;
    int link;
    for (i = 0; i < nVertices; i++) {
        link = comp->getVertex(i)->getLink();
        if (link != NVertex::TORUS && link != NVertex::KLEIN_BOTTLE)
            return 0;
    }
    for (i = 0; i < nEdges; i++)
        if (! comp->getEdge(i)->isValid())
            return 0;

    // Now search for specific triangulations.

    if (comp->getNumberOfTetrahedra() == 1) {
        // At this point it must be m000, since there are no others
        // that fit these constraints.  But test orientability
        // anyway just to be safe.
        if (comp->isOrientable())
            return 0;
        return new NSnapPeaCensusTri(SEC_5, 0);
    } else if (comp->getNumberOfTetrahedra() == 2) {
        if (comp->isOrientable()) {
            // Orientable.  Looking for m003 or m004.
            if (comp->getNumberOfVertices() != 1)
                return 0;
            if (comp->getNumberOfEdges() != 2)
                return 0;
            if (comp->getEdge(0)->getNumberOfEmbeddings() != 6 ||
                    comp->getEdge(1)->getNumberOfEmbeddings() != 6)
                return 0;

            // Now we know it's either m003 or m004.  We distinguish
            // between them by face types, since all of m003's faces
            // are Mobius bands and all of m004's faces are horns.
            if (comp->getFace(0)->getType() == NFace::MOBIUS)
                return new NSnapPeaCensusTri(SEC_5, 3);
            else
                return new NSnapPeaCensusTri(SEC_5, 4);
        } else {
            // Non-orientable.  Looking for m001 or m002.
            if (comp->getNumberOfVertices() == 1) {
                // Looking for m001.
                if (comp->getNumberOfEdges() != 2)
                    return 0;
                if (! ((comp->getEdge(0)->getNumberOfEmbeddings() == 4 &&
                        comp->getEdge(1)->getNumberOfEmbeddings() == 8) ||
                       (comp->getEdge(0)->getNumberOfEmbeddings() == 8 &&
                        comp->getEdge(1)->getNumberOfEmbeddings() == 4)))
                    return 0;
                // Census says it's m001 if no face forms a dunce hat.
                for (int i = 0; i < 4; i++)
                    if (comp->getFace(i)->getType() == NFace::DUNCEHAT)
                        return 0;
                return new NSnapPeaCensusTri(SEC_5, 1);
            } else if (comp->getNumberOfVertices() == 2) {
                // Looking for m002.
                if (comp->getNumberOfEdges() != 2)
                    return 0;
                if (comp->getEdge(0)->getNumberOfEmbeddings() != 6 ||
                        comp->getEdge(1)->getNumberOfEmbeddings() != 6)
                    return 0;
                // Census says it's m002 if some face forms a dunce hat.
                for (int i = 0; i < 4; i++)
                    if (comp->getFace(i)->getType() == NFace::DUNCEHAT)
                        return new NSnapPeaCensusTri(SEC_5, 2);
                return 0;
            }
        }
    } else if (comp->getNumberOfTetrahedra() == 4) {
        if (comp->isOrientable()) {
            // Search for the Whitehead link complement.
            // Note that this could be done with a smaller set of tests
            // since some can be deduced from others, but these tests
            // aren't terribly expensive anyway.
            if (comp->getNumberOfVertices() != 2)
                return 0;
            if (comp->getNumberOfEdges() != 4)
                return 0;
            if (comp->getVertex(0)->getLink() != NVertex::TORUS)
                return 0;
            if (comp->getVertex(1)->getLink() != NVertex::TORUS)
                return 0;
            if (comp->getVertex(0)->getNumberOfEmbeddings() != 8)
                return 0;
            if (comp->getVertex(1)->getNumberOfEmbeddings() != 8)
                return 0;
            // Census says it's the Whitehead link if some edge has
            // degree 8.
            for (int i = 0; i < 4; i++)
                if (comp->getEdge(i)->getNumberOfEmbeddings() == 8)
                    return new NSnapPeaCensusTri(SEC_5, 129);
            return 0;
        }
    }

    // Not recognised after all.
    return 0;
}

NManifold* NSnapPeaCensusTri::getManifold() const {
    return new NSnapPeaCensusManifold(section, index);
}

NAbelianGroup* NSnapPeaCensusTri::getHomologyH1() const {
    // Hard-code the smallest cases.
    if (section == SEC_5) {
        if (index == 0 || index == 4) {
            NAbelianGroup* ans = new NAbelianGroup();
            ans->addRank();
            return ans;
        }
        if (index == 1 || index == 2) {
            NAbelianGroup* ans = new NAbelianGroup();
            ans->addRank();
            ans->addTorsionElement(2);
            return ans;
        }
        if (index == 3) {
            NAbelianGroup* ans = new NAbelianGroup();
            ans->addRank();
            ans->addTorsionElement(5);
            return ans;
        }
        if (index == 129) {
            // Whitehead link complement.
            NAbelianGroup* ans = new NAbelianGroup();
            ans->addRank(2);
            return ans;
        }
    }

    // Leave it as an unknown.
    return 0;
}

std::ostream& NSnapPeaCensusTri::writeName(std::ostream& out) const {
    out << "SnapPea " << section;

    // Pad the index with leading zeroes.
    // All sections are written with three-digit indices, except for
    // 7-tetrahedron orientable which uses four-digit indices.
    if (section == SEC_7_OR && index < 1000)
        out << '0';
    if (index < 100)
        out << '0';
    if (index < 10)
        out << '0';
    out << index;

    return out;
}

std::ostream& NSnapPeaCensusTri::writeTeXName(std::ostream& out) const {
    out << section << "_{";

    // Pad the index with leading zeroes.
    // All sections are written with three-digit indices, except for
    // 7-tetrahedron orientable which uses four-digit indices.
    if (section == SEC_7_OR && index < 1000)
        out << '0';
    if (index < 100)
        out << '0';
    if (index < 10)
        out << '0';
    out << index << '}';

    return out;
}

} // namespace regina