FG print(): fix empty lines on nullptr; avoid endl

release/4.3a0
Jose Luis Blanco-Claraco 2022-01-12 11:00:24 +01:00
parent 6244910896
commit b79c59acd5
No known key found for this signature in database
GPG Key ID: D443304FBD70A641
1 changed files with 9 additions and 3 deletions

View File

@ -54,9 +54,14 @@ void NonlinearFactorGraph::print(const std::string& str, const KeyFormatter& key
for (size_t i = 0; i < factors_.size(); i++) {
stringstream ss;
ss << "Factor " << i << ": ";
if (factors_[i] != nullptr) factors_[i]->print(ss.str(), keyFormatter);
cout << endl;
if (factors_[i] != nullptr) {
factors_[i]->print(ss.str(), keyFormatter);
cout << "\n";
} else {
cout << ss.str() << "nullptr\n";
}
}
std::cout.flush();
}
/* ************************************************************************* */
@ -80,8 +85,9 @@ void NonlinearFactorGraph::printErrors(const Values& values, const std::string&
factor->print(ss.str(), keyFormatter);
cout << "error = " << errorValue << "\n";
}
cout << endl; // only one "endl" at end might be faster, \n for each factor
cout << "\n";
}
std::cout.flush();
}
/* ************************************************************************* */