Skip to content

Commit

Permalink
Changed statistics output
Browse files Browse the repository at this point in the history
Statistics and progress bars are only printed if the `-s` or
`--statistics` parameter is present.
  • Loading branch information
Pseudomanifold committed Sep 1, 2010
1 parent 9b61e1c commit b1ccfbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 9 additions & 8 deletions mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,9 @@ void mesh::prune(const std::set<size_t>& remove_faces, const std::set<size_t>& r

void mesh::print_progress(std::string message, size_t cur_pos, size_t max_pos)
{
if(!print_statistics)
return;

size_t percentage = (cur_pos*100)/max_pos;
static size_t last;

Expand Down Expand Up @@ -1350,24 +1353,19 @@ void mesh::subdivide( short algorithm,
size_t num_edges = E.size();
size_t num_faces = F.size();

std::string algorithm_name;

// Choose algorithm (if this is _not_ done via pointers, the for-loop
// would have to be duplicated or the algorithm check would have to be
// made for each iteration.
void (mesh::*subdivision_algorithm)() = NULL;
switch(algorithm)
{
case ALG_CATMULL_CLARK:
algorithm_name = "CC";
subdivision_algorithm = &mesh::subdivide_catmull_clark;
break;
case ALG_DOO_SABIN:
algorithm_name = "DS";
subdivision_algorithm = &mesh::subdivide_doo_sabin;
break;
case ALG_LOOP:
algorithm_name = "L";
subdivision_algorithm = &mesh::subdivide_loop;
break;
default:
Expand All @@ -1378,11 +1376,14 @@ void mesh::subdivide( short algorithm,
size_t width = static_cast<unsigned int>(log10(steps))*2;
for(size_t i = 0; i < steps; i++)
{
std::cerr << algorithm_name << " [" << std::setw(width) << i << "]\n";
if(print_statistics)
std::cerr << "[" << std::setw(width) << i << "]\n";

(this->*subdivision_algorithm)();
std::cerr << "\n";
}

if(print_statistics)
std::cerr << "\n";
}
clock_t end = clock();

if(print_statistics)
Expand Down
4 changes: 4 additions & 0 deletions psalm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ int main(int argc, char* argv[])
scene_mesh.set_bspline_weights_usage();
break;

case 's':
scene_mesh.set_statistics_output();
break;

case 'h':
case '?':
show_usage();
Expand Down

0 comments on commit b1ccfbb

Please sign in to comment.