Skip to content

Commit

Permalink
fix load issue with scale tool (#3110)
Browse files Browse the repository at this point in the history
* fix load issue scale tool load issue if model or marker set file is given as an absolute path, and the tool was created from a setup file. update error message to better reflect possible issues.

* update CHANGELOG
  • Loading branch information
carmichaelong authored Nov 30, 2021
1 parent 8ad4017 commit bdd5fad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This is not a comprehensive list of changes but rather a hand-curated collection
v4.4
====
- Updated ezc3d to version 1.4.6 which better manage the events defined in a c3d file.
- Fixed an issue that could happen sometimes with ScaleTool where loading the model file or marker set file could fail if the file was given as an absolute path (Issue #3109, PR #3110)

v4.3
====
Expand Down
8 changes: 6 additions & 2 deletions OpenSim/Tools/GenericModelMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,17 @@ Model* GenericModelMaker::processModel(const string& aPathToSubject) const

try
{
model = new Model(aPathToSubject + _fileName);
std::string modelPath =
SimTK::Pathname::getAbsolutePathnameUsingSpecifiedWorkingDirectory(aPathToSubject, _fileName);
model = new Model(modelPath);
model->initSystem();

if (!_markerSetFileNameProp.getValueIsDefault() && _markerSetFileName !="Unassigned") {
log_info("Loading marker set from '{}'.",
aPathToSubject + _markerSetFileName);
MarkerSet *markerSet = new MarkerSet(aPathToSubject + _markerSetFileName);
std::string markerSetPath =
SimTK::Pathname::getAbsolutePathnameUsingSpecifiedWorkingDirectory(aPathToSubject, _markerSetFileName);
MarkerSet *markerSet = new MarkerSet(markerSetPath);
model->updateMarkerSet(*markerSet);
}
}
Expand Down
7 changes: 5 additions & 2 deletions OpenSim/Tools/ScaleTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ Model* ScaleTool::createModel() const
Model *model = getGenericModelMaker().processModel(_pathToSubject);
if (!model)
{
log_error("Unable to load generic model at path {}.",
_pathToSubject);
// processModel() attempts to load both the model and market set
// file. _pathToSubject might be misleading of model path was
// given as an aboslute path in the setup file, so it was
// removed from this error message.
log_error("Unable to load the generic model or marker set file.");
return 0;
}
else {
Expand Down

0 comments on commit bdd5fad

Please sign in to comment.