gtsam 4.2.0
gtsam
DotWriter.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010-2021, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
19#pragma once
20
22#include <gtsam/base/Vector.h>
23#include <gtsam/inference/Key.h>
24
25#include <iosfwd>
26#include <map>
27#include <set>
28
29namespace gtsam {
30
35struct GTSAM_EXPORT DotWriter {
42
47 std::map<Key, Vector2> variablePositions;
48
54 std::map<char, double> positionHints;
55
57 std::set<Key> boxes;
58
63 std::map<size_t, Vector2> factorPositions;
64
65 explicit DotWriter(double figureWidthInches = 5,
66 double figureHeightInches = 5,
67 bool plotFactorPoints = true,
68 bool connectKeysToFactor = true, bool binaryEdges = false)
69 : figureWidthInches(figureWidthInches),
70 figureHeightInches(figureHeightInches),
71 plotFactorPoints(plotFactorPoints),
72 connectKeysToFactor(connectKeysToFactor),
73 binaryEdges(binaryEdges) {}
74
76 void graphPreamble(std::ostream* os) const;
77
79 void digraphPreamble(std::ostream* os) const;
80
82 void drawVariable(Key key, const KeyFormatter& keyFormatter,
83 const boost::optional<Vector2>& position,
84 std::ostream* os) const;
85
87 static void DrawFactor(size_t i, const boost::optional<Vector2>& position,
88 std::ostream* os);
89
91 boost::optional<Vector2> variablePos(Key key) const;
92
94 void processFactor(size_t i, const KeyVector& keys,
95 const KeyFormatter& keyFormatter,
96 const boost::optional<Vector2>& position,
97 std::ostream* os) const;
98};
99
100} // namespace gtsam
A thin wrapper around std::vector that uses a custom allocator.
typedef and functions to augment Eigen's VectorXd
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:100
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
DotWriter is a helper class for writing graphviz .dot files.
Definition: DotWriter.h:35
double figureWidthInches
The figure width on paper in inches.
Definition: DotWriter.h:36
bool plotFactorPoints
Plots each factor as a dot between the variables.
Definition: DotWriter.h:38
bool connectKeysToFactor
Draw a line from each key within a factor to the dot of the factor.
Definition: DotWriter.h:39
std::map< Key, Vector2 > variablePositions
Variable positions can be optionally specified and will be included in the dot file with a "!...
Definition: DotWriter.h:47
bool binaryEdges
just use non-dotted edges for binary factors
Definition: DotWriter.h:41
std::map< char, double > positionHints
The position hints allow one to use symbol character and index to specify position.
Definition: DotWriter.h:54
std::set< Key > boxes
A set of keys that will be displayed as a box.
Definition: DotWriter.h:57
std::map< size_t, Vector2 > factorPositions
Factor positions can be optionally specified and will be included in the dot file with a "!...
Definition: DotWriter.h:63
double figureHeightInches
The figure height on paper in inches.
Definition: DotWriter.h:37