Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions utils/retriangulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ enum {
FLAVOUR_KNOT = 100
} flavour = FLAVOUR_NONE;
bool internalSig = false;
bool exhaustive = false;

template <int dim>
void process(const regina::Triangulation<dim>& tri) {
unsigned long nSolns = 0;
unsigned long total = 0;
bool nonMinimal = false;
std::string simpler;

tri.retriangulate(argHeight, argThreads, nullptr /* tracker */,
[&nSolns, &nonMinimal, &simpler, &tri](
[&total, &nSolns, &nonMinimal, &simpler, &tri](
const std::string& sig, const regina::Triangulation<dim>& t) {
++total;
if (t.size() > tri.size())
return false;

Expand All @@ -71,7 +74,8 @@ void process(const regina::Triangulation<dim>& tri) {
if (t.size() < tri.size()) {
nonMinimal = true;
simpler = sig;
return true;
if (!exhaustive)
return true;
}

++nSolns;
Expand All @@ -86,7 +90,8 @@ void process(const regina::Triangulation<dim>& tri) {
if (t.size() < tri.size()) {
nonMinimal = true;
simpler = std::move(classic);
return true;
if (!exhaustive)
return true;
}

++nSolns;
Expand All @@ -97,8 +102,10 @@ void process(const regina::Triangulation<dim>& tri) {
if (nonMinimal) {
std::cerr << "Triangulation is non-minimal!" << std::endl;
std::cerr << "Smaller triangulation: " << simpler << std::endl;
} else
std::cerr << "Found " << nSolns << " triangulation(s)." << std::endl;
}
if (!nonMinimal || exhaustive)
std::cerr << "Found " << nSolns << " triangulation(s)." << std::endl;
std::cerr << "Considered " << total << " triangulations." << std::endl;
}

void process(const regina::Link& knot) {
Expand Down Expand Up @@ -141,21 +148,23 @@ R"help(Usage: retriangulate <isosig>
-4, --dim4 Input is a 4-manifold signature
-k, --knot Input is a knot signature
-a, --anysig Output does not need to use classic signature(s)
-e, --exhaustive Do not stop when encountering smaller signature
-v, --version Show which version of Regina is being used.
--help Show this help message
)help";
}

int main(int argc, char* argv[]) {
// Parse the command-line arguments.
const char* shortOpt = ":h:t:34kav";
const char* shortOpt = ":h:t:34kave";
struct option longOpt[] = {
{ "height", required_argument, nullptr, 'h' },
{ "threads", required_argument, nullptr, 't' },
{ "dim3", no_argument, nullptr, '3' },
{ "dim4", no_argument, nullptr, '4' },
{ "knot", no_argument, nullptr, 'k' },
{ "anysig", no_argument, nullptr, 'a' },
{ "exhaustive", no_argument, nullptr, 'e' },
{ "version", no_argument, nullptr, 'v' },
{ "help", no_argument, nullptr, '_' },
{ nullptr, 0, nullptr, 0 }
Expand Down Expand Up @@ -213,6 +222,9 @@ int main(int argc, char* argv[]) {
case 'a':
internalSig = true;
break;
case 'e' :
exhaustive = true;
break;
case 'v':
// If other arguments were passed, just silently ignore them
// for now. Ideally we would give an error in this scenario.
Expand Down