print variants for KeyList, KeyVector

release/4.3a0
dellaert 2014-05-06 13:21:49 -04:00
parent 9395bb0913
commit 2649b0fd7a
4 changed files with 974 additions and 937 deletions

1862
.cproject

File diff suppressed because it is too large Load Diff

View File

@ -1551,6 +1551,10 @@ char symbolChr(size_t key);
size_t symbolIndex(size_t key);
// Default keyformatter
void printKeyList (const gtsam::KeyList& keys);
void printKeyList (const gtsam::KeyList& keys, string s);
void printKeyVector(const gtsam::KeyVector& keys);
void printKeyVector(const gtsam::KeyVector& keys, string s);
void printKeySet (const gtsam::KeySet& keys);
void printKeySet (const gtsam::KeySet& keys, string s);

View File

@ -27,14 +27,13 @@
namespace gtsam {
/* ************************************************************************* */
std::string _multirobotKeyFormatter(gtsam::Key key) {
std::string _multirobotKeyFormatter(Key key) {
const LabeledSymbol asLabeledSymbol(key);
if (asLabeledSymbol.chr() > 0 && asLabeledSymbol.label() > 0)
return (std::string) asLabeledSymbol;
const gtsam::Symbol asSymbol(key);
const Symbol asSymbol(key);
if (asLabeledSymbol.chr() > 0)
return (std::string) asSymbol;
else
@ -42,16 +41,34 @@ std::string _multirobotKeyFormatter(gtsam::Key key) {
}
/* ************************************************************************* */
void printKeySet(const gtsam::KeySet& keys, const std::string& s, const KeyFormatter& keyFormatter) {
template<class CONTAINER>
static void print(const CONTAINER& keys, const std::string& s,
const KeyFormatter& keyFormatter) {
std::cout << s << " ";
if (keys.empty())
std::cout << "(none)" << std::endl;
else {
BOOST_FOREACH(const gtsam::Key& key, keys)
BOOST_FOREACH(const Key& key, keys)
std::cout << keyFormatter(key) << " ";
std::cout << std::endl;
}
}
/* ************************************************************************* */
void printKeyList(const KeyList& keys, const std::string& s,
const KeyFormatter& keyFormatter) {
print(keys, s, keyFormatter);
}
/* ************************************************************************* */
void printKeyVector(const KeyVector& keys, const std::string& s,
const KeyFormatter& keyFormatter) {
print(keys, s, keyFormatter);
}
/* ************************************************************************* */
void printKeySet(const KeySet& keys, const std::string& s,
const KeyFormatter& keyFormatter) {
print(keys, s, keyFormatter);
}
/* ************************************************************************* */
} // \namespace gtsam

View File

@ -46,6 +46,14 @@ namespace gtsam {
typedef FastSet<Key> KeySet;
typedef FastMap<Key,int> KeyGroupMap;
/// Utility function to print sets of keys with optional prefix
GTSAM_EXPORT void printKeyList(const KeyList& keys, const std::string& s = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
/// Utility function to print sets of keys with optional prefix
GTSAM_EXPORT void printKeyVector(const KeyVector& keys, const std::string& s = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
/// Utility function to print sets of keys with optional prefix
GTSAM_EXPORT void printKeySet(const KeySet& keys, const std::string& s = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter);