print variants for KeyList, KeyVector
parent
9395bb0913
commit
2649b0fd7a
4
gtsam.h
4
gtsam.h
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue