2
/**************************************************************************
4
* Regina - A Normal Surface Theory Calculator *
5
* Computational Engine *
7
* Copyright (c) 1999-2013, Ben Burton *
8
* For further details contact Ben Burton (bab@debian.org). *
10
* This program is free software; you can redistribute it and/or *
11
* modify it under the terms of the GNU General Public License as *
12
* published by the Free Software Foundation; either version 2 of the *
13
* License, or (at your option) any later version. *
15
* As an exception, when this program is distributed through (i) the *
16
* App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or *
17
* (iii) Google Play by Google Inc., then that store may impose any *
18
* digital rights management, device limits and/or redistribution *
19
* restrictions that are required by its terms of service. *
21
* This program is distributed in the hope that it will be useful, but *
22
* WITHOUT ANY WARRANTY; without even the implied warranty of *
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
24
* General Public License for more details. *
26
* You should have received a copy of the GNU General Public *
27
* License along with this program; if not, write to the Free *
28
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
29
* MA 02110-1301, USA. *
31
**************************************************************************/
37
#include "foreign/recogniser.h"
38
#include "triangulation/ntriangulation.h"
43
// Anonymous routine to write to the given output stream.
45
// PRE: All preconditions for writeRecogniser() have already been
46
// tested, and are known to be met.
47
bool writeRecogniser(std::ostream& out, NTriangulation& tri) {
49
out << "triangulation" << std::endl;
51
// Write face gluings.
55
for (unsigned i = 0; i < tri.getNumberOfTriangles(); ++i) {
56
f = tri.getTriangle(i);
58
tet = f->getEmbedding(0).getTetrahedron();
59
vert = f->getEmbedding(0).getVertices();
60
out << 't' << (tri.tetrahedronIndex(tet) + 1)
61
<< '(' << (vert[0] + 1)
62
<< ',' << (vert[1] + 1)
63
<< ',' << (vert[2] + 1) << ") - ";
65
tet = f->getEmbedding(1).getTetrahedron();
66
vert = f->getEmbedding(1).getVertices();
67
out << 't' << (tri.tetrahedronIndex(tet) + 1)
68
<< '(' << (vert[0] + 1)
69
<< ',' << (vert[1] + 1)
70
<< ',' << (vert[2] + 1) << ')';
72
if (i != tri.getNumberOfTriangles() - 1)
78
out << "end" << std::endl;
84
bool writeRecogniser(const char* filename, NTriangulation& tri) {
88
if (tri.hasBoundaryTriangles())
91
// Write to file or stdout as appropriate.
92
if (filename && *filename) {
93
std::ofstream out(filename);
96
return writeRecogniser(out, tri);
98
return writeRecogniser(std::cout, tri);
102
} // namespace regina