switch formatter and writer arguments
parent
501a6dbd3b
commit
c27cd7a2e8
|
|
@ -133,7 +133,9 @@ class DiscreteBayesTree {
|
|||
|
||||
#include <gtsam/inference/DotWriter.h>
|
||||
class DotWriter {
|
||||
DotWriter();
|
||||
DotWriter(double figureWidthInches = 5, double figureHeightInches = 5,
|
||||
bool plotFactorPoints = true, bool connectKeysToFactor = true,
|
||||
bool binaryEdges = true);
|
||||
};
|
||||
|
||||
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
||||
|
|
@ -153,13 +155,13 @@ class DiscreteFactorGraph {
|
|||
void print(string s = "") const;
|
||||
bool equals(const gtsam::DiscreteFactorGraph& fg, double tol = 1e-9) const;
|
||||
|
||||
string dot(const gtsam::DotWriter& dotWriter = gtsam::DotWriter(),
|
||||
const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
void saveGraph(string s,
|
||||
const gtsam::DotWriter& dotWriter = gtsam::DotWriter(),
|
||||
const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
string dot(
|
||||
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter,
|
||||
const gtsam::DotWriter& dotWriter = gtsam::DotWriter()) const;
|
||||
void saveGraph(
|
||||
string s,
|
||||
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter,
|
||||
const gtsam::DotWriter& dotWriter = gtsam::DotWriter()) const;
|
||||
|
||||
gtsam::DecisionTreeFactor product() const;
|
||||
double operator()(const gtsam::DiscreteValues& values) const;
|
||||
|
|
|
|||
|
|
@ -35,12 +35,15 @@ struct GTSAM_EXPORT DotWriter {
|
|||
///< the dot of the factor
|
||||
bool binaryEdges; ///< just use non-dotted edges for binary factors
|
||||
|
||||
DotWriter()
|
||||
: figureWidthInches(5),
|
||||
figureHeightInches(5),
|
||||
plotFactorPoints(true),
|
||||
connectKeysToFactor(true),
|
||||
binaryEdges(true) {}
|
||||
explicit DotWriter(double figureWidthInches = 5,
|
||||
double figureHeightInches = 5,
|
||||
bool plotFactorPoints = true,
|
||||
bool connectKeysToFactor = true, bool binaryEdges = true)
|
||||
: figureWidthInches(figureWidthInches),
|
||||
figureHeightInches(figureHeightInches),
|
||||
plotFactorPoints(plotFactorPoints),
|
||||
connectKeysToFactor(connectKeysToFactor),
|
||||
binaryEdges(binaryEdges) {}
|
||||
|
||||
/// Write out preamble, including size.
|
||||
void writePreamble(std::ostream* os) const;
|
||||
|
|
|
|||
|
|
@ -128,8 +128,9 @@ FactorIndices FactorGraph<FACTOR>::add_factors(const CONTAINER& factors,
|
|||
|
||||
/* ************************************************************************* */
|
||||
template <class FACTOR>
|
||||
void FactorGraph<FACTOR>::dot(std::ostream& os, const DotWriter& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
void FactorGraph<FACTOR>::dot(std::ostream& os,
|
||||
const KeyFormatter& keyFormatter,
|
||||
const DotWriter& writer) const {
|
||||
writer.writePreamble(&os);
|
||||
|
||||
// Create nodes for each variable in the graph
|
||||
|
|
@ -153,20 +154,20 @@ void FactorGraph<FACTOR>::dot(std::ostream& os, const DotWriter& writer,
|
|||
|
||||
/* ************************************************************************* */
|
||||
template <class FACTOR>
|
||||
std::string FactorGraph<FACTOR>::dot(const DotWriter& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
std::string FactorGraph<FACTOR>::dot(const KeyFormatter& keyFormatter,
|
||||
const DotWriter& writer) const {
|
||||
std::stringstream ss;
|
||||
dot(ss, writer, keyFormatter);
|
||||
dot(ss, keyFormatter, writer);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template <class FACTOR>
|
||||
void FactorGraph<FACTOR>::saveGraph(const std::string& filename,
|
||||
const DotWriter& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
const KeyFormatter& keyFormatter,
|
||||
const DotWriter& writer) const {
|
||||
std::ofstream of(filename.c_str());
|
||||
dot(of, writer, keyFormatter);
|
||||
dot(of, keyFormatter, writer);
|
||||
of.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -378,17 +378,18 @@ class FactorGraph {
|
|||
/// @{
|
||||
|
||||
/// Output to graphviz format, stream version.
|
||||
void dot(std::ostream& os, const DotWriter& writer = DotWriter(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
void dot(std::ostream& os,
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const DotWriter& writer = DotWriter()) const;
|
||||
|
||||
/// Output to graphviz format string.
|
||||
std::string dot(const DotWriter& writer = DotWriter(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
std::string dot(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const DotWriter& writer = DotWriter()) const;
|
||||
|
||||
/// output to file with graphviz format.
|
||||
void saveGraph(const std::string& filename,
|
||||
const DotWriter& writer = DotWriter(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const DotWriter& writer = DotWriter()) const;
|
||||
|
||||
/// @}
|
||||
/// @name Advanced Interface
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <gtsam/linear/linearExceptions.h>
|
||||
#include <gtsam/linear/VectorValues.h>
|
||||
#include <gtsam/inference/Ordering.h>
|
||||
#include <gtsam/inference/DotWriter.h>
|
||||
#include <gtsam/inference/FactorGraph-inst.h>
|
||||
#include <gtsam/config.h> // for GTSAM_USE_TBB
|
||||
|
||||
|
|
@ -92,8 +91,8 @@ bool NonlinearFactorGraph::equals(const NonlinearFactorGraph& other, double tol)
|
|||
|
||||
/* ************************************************************************* */
|
||||
void NonlinearFactorGraph::dot(std::ostream& os, const Values& values,
|
||||
const GraphvizFormatting& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
const KeyFormatter& keyFormatter,
|
||||
const GraphvizFormatting& writer) const {
|
||||
writer.writePreamble(&os);
|
||||
|
||||
// Find bounds (imperative)
|
||||
|
|
@ -139,21 +138,21 @@ void NonlinearFactorGraph::dot(std::ostream& os, const Values& values,
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
std::string NonlinearFactorGraph::dot(
|
||||
const Values& values, const GraphvizFormatting& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
std::string NonlinearFactorGraph::dot(const Values& values,
|
||||
const KeyFormatter& keyFormatter,
|
||||
const GraphvizFormatting& writer) const {
|
||||
std::stringstream ss;
|
||||
dot(ss, values, writer, keyFormatter);
|
||||
dot(ss, values, keyFormatter, writer);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void NonlinearFactorGraph::saveGraph(
|
||||
const std::string& filename, const Values& values,
|
||||
const GraphvizFormatting& writer,
|
||||
const KeyFormatter& keyFormatter) const {
|
||||
void NonlinearFactorGraph::saveGraph(const std::string& filename,
|
||||
const Values& values,
|
||||
const KeyFormatter& keyFormatter,
|
||||
const GraphvizFormatting& writer) const {
|
||||
std::ofstream of(filename);
|
||||
dot(of, values, writer, keyFormatter);
|
||||
dot(of, values, keyFormatter, writer);
|
||||
of.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,23 +213,22 @@ namespace gtsam {
|
|||
using FactorGraph::saveGraph;
|
||||
|
||||
/// Output to graphviz format, stream version, with Values/extra options.
|
||||
void dot(
|
||||
std::ostream& os, const Values& values,
|
||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
void dot(std::ostream& os, const Values& values,
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const GraphvizFormatting& graphvizFormatting =
|
||||
GraphvizFormatting()) const;
|
||||
|
||||
/// Output to graphviz format string, with Values/extra options.
|
||||
std::string dot(
|
||||
const Values& values,
|
||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
std::string dot(const Values& values,
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const GraphvizFormatting& graphvizFormatting =
|
||||
GraphvizFormatting()) const;
|
||||
|
||||
/// output to file with graphviz format, with Values/extra options.
|
||||
void saveGraph(
|
||||
const std::string& filename, const Values& values,
|
||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
||||
|
||||
void saveGraph(const std::string& filename, const Values& values,
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||
const GraphvizFormatting& graphvizFormatting =
|
||||
GraphvizFormatting()) const;
|
||||
/// @}
|
||||
|
||||
private:
|
||||
|
|
@ -267,7 +266,14 @@ namespace gtsam {
|
|||
std::ostream& os, const Values& values = Values(),
|
||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||
dot(os, values, graphvizFormatting, keyFormatter);
|
||||
dot(os, values, keyFormatter, graphvizFormatting);
|
||||
}
|
||||
/** \deprecated */
|
||||
void GTSAM_DEPRECATED saveGraph(
|
||||
const std::string& filename, const Values& values,
|
||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||
saveGraph(filename, values, keyFormatter, graphvizFormatting);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,12 @@ class NonlinearFactorGraph {
|
|||
// enabling serialization functionality
|
||||
void serialize() const;
|
||||
|
||||
void saveGraph(const string& s) const;
|
||||
string dot(
|
||||
const gtsam::Values& values,
|
||||
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter);
|
||||
void saveGraph(const string& s, const gtsam::Values& values,
|
||||
const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
};
|
||||
|
||||
#include <gtsam/nonlinear/NonlinearFactor.h>
|
||||
|
|
@ -782,6 +787,12 @@ class ISAM2 {
|
|||
|
||||
void printStats() const;
|
||||
gtsam::VectorValues gradientAtZero() const;
|
||||
|
||||
string dot(const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
void saveGraph(string s,
|
||||
const gtsam::KeyFormatter& keyFormatter =
|
||||
gtsam::DefaultKeyFormatter) const;
|
||||
};
|
||||
|
||||
#include <gtsam/nonlinear/NonlinearISAM.h>
|
||||
|
|
|
|||
Loading…
Reference in New Issue