Skip to content

Commit

Permalink
Fix 'Output Window' progress printing for Maya 2018+.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cattermole committed Jun 22, 2020
1 parent 951e9a5 commit bcf212a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
18 changes: 11 additions & 7 deletions src/core/bundleAdjust_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <maya/MFnCamera.h>
#include <maya/MComputation.h>
#include <maya/MProfiler.h>
#include <maya/MStreamUtils.h>

// Local
#include <core/bundleAdjust_base.h>
Expand Down Expand Up @@ -867,18 +868,21 @@ void print_details(

if (verbose == false) {
if (solverResult.success) {
std::cerr << "Solver returned SUCCESS | ";
MStreamUtils::stdErrorStream() << "Solver returned SUCCESS | ";
} else {
std::cerr << "Solver returned FAILURE | ";
MStreamUtils::stdErrorStream() << "Solver returned FAILURE | ";
}
fprintf(
stderr,
"error avg %8.4f min %8.4f max %8.4f iterations %03u\n",

char formatBuffer[128];
sprintf(
formatBuffer,
"error avg %8.4f min %8.4f max %8.4f iterations %03u",
solverResult.errorAvg,
solverResult.errorMin,
solverResult.errorMax,
solverResult.iterations);
fflush(stderr);
MStreamUtils::stdErrorStream() << std::string(formatBuffer)
<< std::endl;
}

// Add all the data into the output string from the Maya command.
Expand Down Expand Up @@ -1273,7 +1277,7 @@ bool solve(SolverOptions &solverOptions,
}
std::string pad_chars(num, '=');

std::cerr << tmp_string << " " << pad_chars << std::endl;
MStreamUtils::stdErrorStream() << tmp_string << " " << pad_chars << std::endl;
}

// MComputation helper.
Expand Down
21 changes: 12 additions & 9 deletions src/core/bundleAdjust_solveFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include <maya/MComputation.h>
#include <maya/MProfiler.h>
#include <maya/MGlobal.h>
#include <maya/MStreamUtils.h>

// Solver Utilities
#include <mayaUtils.h>
Expand Down Expand Up @@ -689,12 +690,12 @@ void incrementNormalIteration(SolverData *ud,
++ud->iterNum;
// We're not using INFO macro because we don't want a
// new-line created.
std::cerr << "Eval ";
std::cerr << std::right << std::setfill ('0') << std::setw(4)
<< ud->funcEvalNum;
std::cerr << " | Normal ";
std::cerr << std::right << std::setfill ('0') << std::setw(4)
<< ud->iterNum;
MStreamUtils::stdErrorStream() << "Eval ";
MStreamUtils::stdErrorStream() << std::right << std::setfill ('0') << std::setw(4)
<< ud->funcEvalNum;
MStreamUtils::stdErrorStream() << " | Normal ";
MStreamUtils::stdErrorStream() << std::right << std::setfill ('0') << std::setw(4)
<< ud->iterNum;
if (debugIsOpen) {
debugFile << std::endl
<< "iteration normal: " << ud->iterNum
Expand Down Expand Up @@ -1060,12 +1061,14 @@ int solveFunc(int numberOfParameters,
ud->timer.funcBenchTicks.stop();

if (ud->isNormalCall) {
fprintf(
stderr,
" | error avg %8.4f min %8.4f max %8.4f\n",
char formatBuffer[128];
sprintf(
formatBuffer,
" | error avg %8.4f min %8.4f max %8.4f",
error_avg,
error_min,
error_max);
MStreamUtils::stdErrorStream() << std::string(formatBuffer) << std::endl;
} else {
if (ud->verbose) {
if (!ud->doCalcJacobian) {
Expand Down

0 comments on commit bcf212a

Please sign in to comment.