-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General check for null pointer in saveGraph #503
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,42 +205,49 @@ void NonlinearFactorGraph::saveGraph(std::ostream &stm, const Values& values, | |
// Create factors and variable connections | ||
for(size_t i = 0; i < size(); ++i) { | ||
const NonlinearFactor::shared_ptr& factor = at(i); | ||
if(formatting.plotFactorPoints) { | ||
// If null pointer, move on to the next | ||
if (!factor) { | ||
continue; | ||
} | ||
|
||
if (formatting.plotFactorPoints) { | ||
const KeyVector& keys = factor->keys(); | ||
if (formatting.binaryEdges && keys.size()==2) { | ||
stm << " var" << keys[0] << "--" << "var" << keys[1] << ";\n"; | ||
if (formatting.binaryEdges && keys.size() == 2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting changes |
||
stm << " var" << keys[0] << "--" | ||
<< "var" << keys[1] << ";\n"; | ||
} else { | ||
// Make each factor a dot | ||
stm << " factor" << i << "[label=\"\", shape=point"; | ||
{ | ||
map<size_t, Point2>::const_iterator pos = formatting.factorPositions.find(i); | ||
if(pos != formatting.factorPositions.end()) | ||
stm << ", pos=\"" << formatting.scale*(pos->second.x() - minX) << "," | ||
<< formatting.scale*(pos->second.y() - minY) << "!\""; | ||
map<size_t, Point2>::const_iterator pos = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting changes. |
||
formatting.factorPositions.find(i); | ||
if (pos != formatting.factorPositions.end()) | ||
stm << ", pos=\"" << formatting.scale * (pos->second.x() - minX) | ||
<< "," << formatting.scale * (pos->second.y() - minY) | ||
<< "!\""; | ||
} | ||
stm << "];\n"; | ||
|
||
// Make factor-variable connections | ||
if(formatting.connectKeysToFactor && factor) { | ||
for(Key key: *factor) { | ||
stm << " var" << key << "--" << "factor" << i << ";\n"; | ||
if (formatting.connectKeysToFactor && factor) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just formatting. |
||
for (Key key : *factor) { | ||
stm << " var" << key << "--" | ||
<< "factor" << i << ";\n"; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
if(factor) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this check since I added a generic check at the beginning. |
||
Key k; | ||
bool firstTime = true; | ||
for(Key key: *this->at(i)) { | ||
if(firstTime) { | ||
k = key; | ||
firstTime = false; | ||
continue; | ||
} | ||
stm << " var" << key << "--" << "var" << k << ";\n"; | ||
} else { | ||
Key k; | ||
bool firstTime = true; | ||
for (Key key : *this->at(i)) { | ||
if (firstTime) { | ||
k = key; | ||
firstTime = false; | ||
continue; | ||
} | ||
stm << " var" << key << "--" | ||
<< "var" << k << ";\n"; | ||
k = key; | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is the main fix.