Skip to content

Commit a71323d

Browse files
committed
Update progress bar.
1 parent 4911f66 commit a71323d

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ v0.2.3
66
* Advancing front method [Zhao et al. 2007] is implemented.
77
* Change dev-env manager to Poetry.
88
* Add a method to compute principal curvatures (and thier directions) [Rusinkiewicz 2004].
9-
* Add a method of context-based coherent surface completion [Harary et al. 2014].
9+
* Add a method of context-based coherent surface completion [Harary et al. 2016].
1010
* Add own print function to support both C++/Python standard outputs.
1111

1212
v0.2.2

examples/cpp/example_hole_fill.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int main(int argc, char **argv) {
4949
// Context-based coherent surface completion [Harary and Tal 2016]
5050
{
5151
tms::Mesh mesh(argv[1]);
52-
tms::holeFillContextCoherent(mesh);
52+
tms::holeFillContextCoherent(mesh, 300);
5353

5454
const std::string outfile =
5555
(dirpath / fs::path((basename + "_fill_context_coherent" + extension).c_str())).string();

src/tinymesh/core/progress.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define PROGRESS_H
77

88
#include <iostream>
9+
#include <iomanip>
910
#include <string>
1011
#include <chrono>
1112
#include <sstream>
@@ -46,10 +47,23 @@ class ProgressBar {
4647
const int r_min = (int)(rest_time / 1000.0) / 60;
4748
const int r_sec = (int)(rest_time / 1000.0) % 60;
4849

50+
std::string it_text = "";
4951
const int steps_per_sec = (int)(1000.0 / time_msec_per_step);
50-
std::ostringstream oss;
51-
oss << steps_per_sec;
52-
const std::string it_text = steps_per_sec < 1000 ? oss.str() : "1000+";
52+
if (steps_per_sec > 0) {
53+
std::ostringstream oss;
54+
if (steps_per_sec < 1000) {
55+
oss << steps_per_sec;
56+
} else {
57+
oss << "1000+";
58+
}
59+
oss << "it/s";
60+
it_text = oss.str();
61+
} else {
62+
std::ostringstream oss;
63+
oss << std::setprecision(2);
64+
oss << time_msec_per_step / 1000.0 << "s/it";
65+
it_text = oss.str();
66+
}
5367

5468
const int tick = (int)(m_width * m_step / m_total);
5569
std::string pbar = std::string(tick, '=');
@@ -63,7 +77,7 @@ class ProgressBar {
6377
if (!m_description.empty()) {
6478
Print("%s ", m_description.c_str());
6579
}
66-
Print("[%3d%%]|%s| %d/%d [%02d:%02d<%02d:%02d, %sit/s]", (int)percent, pbar.c_str(), m_step, m_total, n_min,
80+
Print("[%3d%%]|%s| %d/%d [%02d:%02d<%02d:%02d, %s]", (int)percent, pbar.c_str(), m_step, m_total, n_min,
6781
n_sec, r_min, r_sec, it_text.c_str());
6882
}
6983

0 commit comments

Comments
 (0)