-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
713 lines (651 loc) · 22.8 KB
/
Copy pathmain.cpp
File metadata and controls
713 lines (651 loc) · 22.8 KB
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
#include <ColourFactory.h>
#include <Mesh.h>
#include <libSculptVersion.h>
#include <QCommandLineParser>
#include <QDir>
#include <QElapsedTimer>
#include <QFileInfo>
#include <QGuiApplication>
#include <QJsonDocument>
#include <QTextCursor>
#include <QTextDocument>
#include "Document.h"
#include "FileResult.h"
#include "MeshChecker.h"
#include "globals.h"
static Verbosity verbosity{Mute};
static bool genReport{};
static QStringList suffixes{"nethers", "stl", "obj", "3mf"};
static bool ok = true;
static int flags = CheckNothing;
static int fileCount = 0;
static int failCount = 0;
static bool failOnly = false;
static enum { None, Record, Compare } recordMode{None};
static int summaryResult[64] = {};
static int diffSum[64] = {};
static constexpr int NO_VERBOSITY_LEVELS = 4;
static QString rootFolder;
static bool verboseFail = false;
QTextStream out (stdout);
static QFile markdown;
static QTextStream md (&markdown);
static QJsonObject recording;
static QJsonObject recordingFiles;
static QString folderFilter;
static QStringList fileList;
static const int levels[NO_VERBOSITY_LEVELS] = {
Mute,
FileName,
FileName | Summary,
FileName | Summary | Details,
};
static bool markFiles{};
static bool markIslands{};
static bool viewerHyperlinks{};
static void generateFileList ()
{
for (auto it = recordingFiles.begin (); it != recordingFiles.end (); it++)
{
fileList.push_back (it.key ());
}
}
static QString diffNo (int no)
{
static const QLocale locale;
if (no < 0)
{
return locale.toString (no);
}
return QStringLiteral ("+") + locale.toString (no);
}
static int check2idx (Checks check)
{
int idx = -1;
auto t = (unsigned int)check;
while (t)
{
t >>= 1;
idx++;
}
return idx;
}
static void record (const FileResult& result)
{
switch (recordMode)
{
case None:
break;
case Record:
{
QJsonObject file;
QJsonObject o;
for (const auto& result : result.m_checkResults)
{
o.insert (MeshChecker::checkName (result.m_check), result.m_badCount);
}
file.insert (QStringLiteral ("checks"), o);
file.insert (QStringLiteral ("pass"), result.m_pass);
recordingFiles.insert (result.m_path, file);
}
break;
case Compare:
{
const QFileInfo fi (result.m_path);
if (fi.lastModified ().secsTo (QDateTime::currentDateTime ()) > 40 * 60)
{
qDebug ().noquote ().nospace () << "Out of date file? \"" << result.m_path << "\"";
}
bool changes = false;
auto file = recordingFiles.value (result.m_path).toObject ();
if (file.isEmpty ())
{
out << "\n" << result.m_path << " - NEW FILE - " << (result.m_pass ? "PASS" : "FAIL") << '\n';
//return;
}
auto o = file.value (QStringLiteral ("checks")).toObject ();
for (const auto& result : result.m_checkResults)
{
if (result.m_badCount == -1)
{
continue;
}
auto old = o.value (MeshChecker::checkName (result.m_check)).toDouble ();
auto diff = result.m_badCount - old;
diffSum[check2idx (result.m_check)] += diff;
if (result.m_badCount != old)
{
changes = true;
}
}
changes |= (result.m_pass != file.value (QStringLiteral ("pass")).toBool ());
if (changes)
{
out << '\n' << result.m_path;
if (result.m_pass != file.value (QStringLiteral ("pass")).toBool ())
{
out << " " << (file.value (QStringLiteral ("pass")).toBool () ? "PASS" : "FAIL") << " -> " << (result.m_pass ? "PASS" : "FAIL");
}
out << "\n";
for (const auto& result : result.m_checkResults)
{
if (result.m_badCount == -1)
{
continue;
}
auto name = MeshChecker::checkName (result.m_check);
auto old = o.value (name).toInt ();
auto diff = result.m_badCount - old;
if (diff != 0)
{
out << " " << name << QString (padding - name.length (), QChar ('.')) << ": " << old << " -> " << result.m_badCount << " " << diffNo (diff) << '\n';
}
}
}
}
break;
}
}
static void reportMd (const FileResult& result)
{
if (result.m_pass && failOnly)
{
return;
}
auto path = result.m_path;
if (path.startsWith (rootFolder))
{
path = path.mid (rootFolder.length ());
if (path.startsWith (QStringLiteral ("/")))
{
path = QStringLiteral ("./") + path.mid (1);
}
}
md << "## " << path << (result.m_pass ? " - PASS\n" : " - FAIL\n");
if (result.m_pass && verboseFail)
{
return;
}
if ((verbosity & Details))
{
for (const auto& res : result.m_checkResults)
{
if (res.m_check == CheckInfo /*|| res.m_check == CheckShortEdges*/)
{
auto report = res.m_report.trimmed ();
report = report.mid (4).trimmed ();
md << " " << report << "\n";
}
}
}
if (verbosity & Summary || (!result.m_pass && verboseFail))
{
md << "|Check|Result|\n|---|---|\n";
for (const auto& res : result.m_checkResults)
{
if (res.m_check == CheckInfo || res.m_check == CheckShortEdges)
{
continue;
}
switch (res.m_badCount)
{
case -1:
md << "|" << res.m_report.split ('\n').constFirst () << "||\n";
break;
case 0:
md << "|" << res.name () << "|None|\n";
break;
default:
md << "|" << res.name () << "|" << QString::number (res.m_badCount) << "|\n";
break;
}
}
md << '\n';
}
}
static void reportBasic (const FileResult& result)
{
if (result.m_pass && failOnly)
{
return;
}
if (verbosity > FileName)
{
out << result.m_path << (result.m_pass ? " - PASS\n" : " - FAIL\n");
}
for (const auto& res : result.m_checkResults)
{
if (verbosity & Details)
{
out << res.m_report;
}
else if (verbosity & Summary)
{
out << res.m_report.split ('\n').constFirst () << '\n';
}
}
if (verbosity & Summary)
{
out << " SUMMARY:\n";
}
QLocale const locale;
for (const auto& res : result.m_checkResults)
{
if (verbosity & Summary)
{
if (res.m_badCount > -1)
{
auto name = res.name ();
out << " " << name + QString (padding - name.length (), QChar ('.')) << QStringLiteral (": ") + locale.toString (res.m_badCount) + QStringLiteral ("\n");
}
}
}
out.flush ();
}
static void callback (Checks check, const MeshPtr& mesh, const TrianglePtr& t1, const TrianglePtr& t2)
{
Q_UNUSED (check)
Q_UNUSED (mesh)
static auto cf = ColourFactory::instance ();
static auto col = cf->colour (1.0, 0.0, 1.0);
static auto colours = cf->stockColours ();
static int idx;
Q_ASSERT (t1->id () | t2->id ());
t1->setColour (colours.at (idx));
idx = (idx + 1) % colours.count ();
t2->setColour (colours.at (idx));
idx = (idx + 1) % colours.count ();
}
static bool processFile (const QString& path)
{
fileList.removeAll (path);
fileCount++;
Triangle::resetID (); // May need to mutex this if we multi thread
auto mesh = Document::readMesh (path);
if (!mesh)
{
qDebug ().nospace ().noquote () << "Unable to open: \"" << path << "\"\n";
failCount++;
return false;
}
MeshChecker checker (mesh, path);
if (markFiles)
{
mesh->removeColour ();
checker.setCallback (callback);
}
checker.setCheckFlags (flags);
MeshChecker::setViewerHyperlinks (viewerHyperlinks);
const auto res = checker.check ();
for (const auto& c : res.m_checkResults)
{
if (c.m_badCount > 0)
{
summaryResult[check2idx (c.m_check)] += c.m_badCount;
}
}
if (genReport)
{
reportMd (res);
}
else
{
reportBasic (res);
}
record (res);
if (!res.m_pass)
{
failCount++;
}
ok &= res.m_pass;
out.flush ();
if (markIslands)
{
mesh->removeColour ();
auto cols = ColourFactory::instance ()->stockColours ();
int colIdx = 0;
auto hes = HalfEdges::create (mesh);
auto holes = hes->holes ();
for (const auto& hole : std::as_const (holes))
{
if (hole->isIsland ())
{
hole->colourHole (cols.at (colIdx++));
colIdx %= cols.size ();
}
}
}
if (markFiles || markIslands)
{
const QFileInfo fi (path);
auto fname = fi.canonicalPath () + QStringLiteral ("/") + fi.baseName () + QStringLiteral (".nethers");
//qDebug () << path;
Document::write (mesh, path);
}
return res.m_pass;
}
static void files (const QString& path)
{
QFileInfo const inf (path);
if (inf.isFile () && suffixes.contains (inf.suffix ()) && inf.path ().endsWith (folderFilter))
{
processFile (path);
}
else if (inf.isDir ())
{
QDir const d (path);
auto entries = d.entryInfoList (QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
for (const auto& e : std::as_const (entries))
{
files (e.absoluteFilePath ());
}
}
}
static void rootFiles (const QString& path)
{
QFileInfo const inf (path);
if (!inf.exists ())
{
qDebug ().nospace ().noquote () << path << " does not exist";
}
if (inf.isDir ())
{
rootFolder = inf.absoluteFilePath ();
}
else
{
rootFolder = inf.absolutePath ();
}
files (path);
}
static void summarise ()
{
out << QStringLiteral ("\n Overall Summary: %1 failed out of %2 (%3% passed)\n").arg (failCount).arg (fileCount).arg (100 * (fileCount - failCount) / fileCount);
int t = 1;
int idx = 0;
QLocale const locale;
do
{
if (t & flags)
{
auto check = (Checks)(flags & t);
auto r = summaryResult[check2idx (check)];
if (r >= 0)
{
const auto name = MeshChecker::checkName (check);
out << " " << name << QString (padding - name.length (), QChar ('.')) << ": " << locale.toString (summaryResult[check2idx (check)]) << "\n";
}
}
t <<= 1;
idx++;
} while (idx < 64);
}
static void summariseMd ()
{
md << "# Overall Summary:\n";
md << QStringLiteral ("\n%1 failed out of %2 (%3% passed)").arg (failCount).arg (fileCount).arg (100 * (fileCount - failCount) / fileCount) << "\n";
if (!(verbosity & Summary) && !(failCount > 0 && verboseFail))
{
return;
}
md << "\n|Check|Result|\n";
md << "|---|---|\n";
int t = 1;
int idx = 0;
QLocale const locale;
do
{
if (t & flags)
{
auto check = (Checks)(flags & t);
auto r = summaryResult[check2idx (check)];
if (r >= 0 || (failCount > 0 && verboseFail))
{
const auto name = MeshChecker::checkName (check);
const auto badCount = summaryResult[check2idx (check)];
if (badCount == 0)
{
md << "|" << name << "|None|\n";
}
else
{
md << "|" << name << "|" << locale.toString (summaryResult[check2idx (check)]) << "|\n";
}
}
}
t <<= 1;
idx++;
} while (idx < 64);
}
int main (int argc, char** argv)
{
QGuiApplication const a (argc, argv);
#ifdef QT_DEBUG
QDir dir;
dir.mkpath (QStringLiteral ("/tmp/3d"));
#endif
QCoreApplication::setApplicationName (QStringLiteral ("MeshChecker"));
QCoreApplication::setApplicationVersion (QStringLiteral (VERSION) + QStringLiteral (" (libSculpt ") + libSculptVersion () + QStringLiteral (")"));
QCoreApplication::setOrganizationName (QStringLiteral ("Netherwood Industries"));
QCommandLineParser parser;
parser.setApplicationDescription (QStringLiteral ("Check mesh for errors.\nNB, for 3mf files, only checks the main model (there can be more). Use 3mfsplitter app to work around this limitation."));
parser.addHelpOption ();
parser.addVersionOption ();
parser.addPositionalArgument (QStringLiteral ("<mesh>"), QStringLiteral ("3D file to examine (STL, 3MF or OBJ)."));
parser.addOption (QCommandLineOption (QStringLiteral ("verbose"), QStringLiteral ("Show details of errors, 0 = mute, 1 = file name, 2 = + summary, 3 = + details."), QStringLiteral ("verbosity"), QStringLiteral ("1")));
//parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("multi-thread") << QStringLiteral ("mt"), QStringLiteral ("Multi threaded execution (experimental).")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("fail-only") << QStringLiteral ("f"), QStringLiteral ("Only print names of incorrect files.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("all") << QStringLiteral ("a"), QStringLiteral ("Run all checks.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("default") << QStringLiteral ("d"), QStringLiteral ("Run default checks.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("cmpDefault"), QStringLiteral ("Run default checks for comparisons.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("critical") << QStringLiteral ("c"), QStringLiteral ("Only do critical checks.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("stl"), QStringLiteral ("STL files only.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("3mf"), QStringLiteral ("3MF files only.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("nethers"), QStringLiteral ("nethers files only.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("report"), QStringLiteral ("Generate a report in Mark Down format."), QStringLiteral ("file")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("verbose-fail"), QStringLiteral ("Generate a summery or detailed report only for failed mesh files.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("compare"), QStringLiteral ("Compare with last recorded run."), QStringLiteral ("JSON file")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("record"), QStringLiteral ("Record results in file for use with compare."), QStringLiteral ("JSON file")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("folderFilter") << QStringLiteral ("ff"), QStringLiteral ("Only look in subfolders with given name."), QStringLiteral ("folder name")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("mark"), QStringLiteral ("Mark bad triangles with colour and save file as .nether type.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("mark-islands"), QStringLiteral ("Mark islands with colours and save file as .nether type.")));
parser.addOption (QCommandLineOption (QStringList () << QStringLiteral ("hyperlinks"), QStringLiteral ("Produce markdown text with hyperlinks")));
//parser.setSingleDashWordOptionMode (QCommandLineParser::ParseAsLongOptions);
const auto& checkList = MeshChecker::checkList ();
for (const auto& check : checkList)
{
parser.addOption (QCommandLineOption (QStringList () << MeshChecker::optionName (check.first), MeshChecker::description (check.first) + '.'));
}
parser.process (a);
markFiles = parser.isSet (QStringLiteral ("mark"));
markIslands = parser.isSet (QStringLiteral ("mark-islands"));
viewerHyperlinks = parser.isSet ("hyperlinks");
if (parser.isSet (QStringLiteral ("compare")))
{
if (parser.isSet (QStringLiteral ("record")))
{
qDebug ().nospace ().noquote () << "Only --record or --compare allowed, not both";
return 106;
}
QFile in (parser.value (QStringLiteral ("compare")));
in.open (QFile::ReadOnly);
if (!in.isOpen ())
{
qDebug ().nospace ().noquote () << "Unable to open \"" << parser.value (QStringLiteral ("compare")) << "\"";
return 105;
}
recordMode = Compare;
recording = QJsonDocument::fromJson (in.readAll ()).object ();
if (recording.isEmpty ())
{
qDebug ().nospace ().noquote () << "Unable t open: \"" << in.fileName () << "\"";
exit (100);
}
recordingFiles = recording.value (QStringLiteral ("files")).toObject ();
generateFileList ();
}
if (parser.isSet (QStringLiteral ("record")))
{
if (parser.isSet (QStringLiteral ("compare")))
{
qDebug ().nospace ().noquote () << "Only --record or --compare allowed, not both";
return 106;
}
recordMode = Record;
recording.insert (QStringLiteral ("version"), qApp->applicationVersion ());
}
folderFilter = parser.value (QStringLiteral ("ff"));
verboseFail = parser.isSet (QStringLiteral ("verbose-fail"));
if (parser.isSet (QStringLiteral ("stl")) || parser.isSet (QStringLiteral ("3mf")) || parser.isSet (QStringLiteral ("nethers")))
{
suffixes.clear ();
}
if (parser.isSet (QStringLiteral ("stl")))
{
suffixes += QStringLiteral ("stl");
}
if (parser.isSet (QStringLiteral ("3mf")))
{
suffixes += QStringLiteral ("3mf");
}
if (parser.isSet (QStringLiteral ("nethers")))
{
suffixes += QStringLiteral ("nethers");
}
if (parser.isSet (QStringLiteral ("all")))
{
flags = All;
}
if (parser.isSet (QStringLiteral ("default")))
{
flags = Default;
}
if (parser.isSet (QStringLiteral ("cmpDefault")))
{
flags = CmpDefault;
}
else if (parser.isSet (QStringLiteral ("critical")))
{
flags = Critical;
}
for (const auto& check : checkList)
{
if (parser.isSet (MeshChecker::optionName (check.first)))
{
flags |= check.first;
}
}
if (flags == 0)
{
flags = Default;
}
// if (parser.isSet (QStringLiteral ("mt")))
// {
// flags |= MultiThread;
// }
failOnly = parser.isSet (QStringLiteral ("f"));
verbosity = (Verbosity)levels[std::min (parser.value (QStringLiteral ("verbose")).toInt (), NO_VERBOSITY_LEVELS - 1)];
genReport = parser.isSet (QStringLiteral ("report"));
if (genReport)
{
markdown.setFileName (parser.value (QStringLiteral ("report")));
markdown.open (QFile::WriteOnly);
if (!markdown.isOpen ())
{
qDebug () << "Unable to open report output file: " << parser.value (QStringLiteral ("report"));
return 100;
}
md << "# Mesh Check report\n";
md << "Version: " << +VERSION << "\n\n";
if (failOnly)
{
md << "Reporting only failed files.\n\n";
}
md << "Running checks:\n";
int t = 1;
do
{
if (t & flags)
{
auto check = (Checks)(flags & t);
md << "* " << MeshChecker::checkName (check) << " - " << MeshChecker::description (check) << "\n";
}
t <<= 1;
} while (t);
md << "\n";
}
if (parser.positionalArguments ().isEmpty ())
{
qDebug ().nospace ().noquote () << "Missing argument";
parser.showHelp (100);
}
QElapsedTimer et;
et.start ();
for (const auto& f : parser.positionalArguments ())
{
rootFiles (f);
}
if (genReport)
{
summariseMd ();
}
if ((verbosity & Summary) && fileCount > 1)
{
summarise ();
}
if (recordMode == Record)
{
recording.insert (QStringLiteral ("fileCount"), fileCount);
recording.insert (QStringLiteral ("fails"), failCount);
recording.insert (QStringLiteral ("files"), recordingFiles);
QFile out (parser.value (QStringLiteral ("record")));
out.open (QFile::WriteOnly);
if (!out.isOpen ())
{
qDebug ().nospace ().noquote () << "Unable to open \"" << parser.value (QStringLiteral ("record")) << "\"";
return 105;
}
const QJsonDocument doc (recording);
out.write (doc.toJson ());
}
if (recordMode == Compare)
{
for (const auto& file : std::as_const (fileList))
{
out << "Missing file: \"" << file << "\"\n";
}
out << QStringLiteral ("\nOverall changes: files: %1 (%2), fails: %3 (%4)\n")
.arg (fileCount)
.arg (diffNo (fileCount - recording.value (QStringLiteral ("fileCount")).toInt ()))
.arg (failCount)
.arg (diffNo (failCount - recording.value (QStringLiteral ("fails")).toInt ()));
int t = 1;
int idx = 0;
do
{
if (t & flags)
{
auto check = (Checks)(flags & t);
const auto name = MeshChecker::checkName (check);
int const idx = check2idx (check);
auto r = diffSum[check2idx (check)];
if (r != 0)
{
out << " " << name << QString (padding - name.length (), QChar ('.')) << ": " << summaryResult[idx] - diffSum[idx] << " -> " << summaryResult[idx] << " (" << diffNo (diffSum[idx]) << ")\n";
}
else
{
out << " " << name << QString (padding - name.length (), QChar ('.')) << ": " << summaryResult[idx] << "\n";
}
}
t <<= 1;
idx++;
} while (idx < 64);
}
if (verbosity != Mute)
{
QLocale const locale;
out << "\n" << QGuiApplication::applicationName () << " took " << locale.toString ((double)et.nsecsElapsed () / 1000000000.0) << " seconds" << '\n';
}
return (ok ? 0 : 100);
}