-
Notifications
You must be signed in to change notification settings - Fork 331
Add test case to exercise ScaleTool as in GUI operation. #1903
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
base: main
Are you sure you want to change the base?
Changes from all commits
cd05c1b
5ba64fa
7157117
ba5e52c
95b82d4
2c0f3f5
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import org.opensim.modeling.*; | ||
import java.io.IOException; | ||
|
||
class TestModelScaling { | ||
public static void main(String[] args) { | ||
|
||
try { | ||
ScaleTool scaleTool = null; | ||
// Live current model in GUI would be used for unscaledModel | ||
Model unscaledModel = new Model("gait2354_simbody.osim"); | ||
// Exercise "loadsettings" from file" | ||
try { | ||
scaleTool = new ScaleTool("subject01_Setup_Scale.xml"); | ||
} catch (IOException ex) { | ||
System.exit(-1); | ||
} | ||
System.out.println("ScaleTool created!"); | ||
// Populate the tabs of Scale factors and measurements | ||
MarkerSet extraMarkerSet = new MarkerSet(unscaledModel, "gait2354_Scale_MarkerSet.xml"); | ||
System.out.println("Extra MarkerSet created!"); | ||
unscaledModel.updateMarkerSet(extraMarkerSet); | ||
System.out.println("Extra MarkerSet added to model!"); | ||
OpenSimContext context = new OpenSimContext(unscaledModel.initSystem(), unscaledModel); | ||
MeasurementSet measurementSet = scaleTool.getModelScaler().getMeasurementSet(); | ||
System.out.println("MeasurementSet created!"); | ||
MarkerData measurementTrial = new MarkerData("subject01_static.trc"); | ||
System.out.println("MarkerData for static trial loaded!"); | ||
double scaleFactor = context.computeMeasurementScaleFactor(scaleTool.getModelScaler(), unscaledModel, | ||
measurementTrial, measurementSet.get(0)); | ||
System.out.println("Measurement computed !"); | ||
// When we run the tool we create a copy of the unscaled model and scale in place using the | ||
// calls below which exercise the "run" button | ||
Model processedModel = new Model(unscaledModel); | ||
processedModel.setName(scaleTool.getName()); | ||
OpenSimContext processedContext = new OpenSimContext(processedModel.initSystem(), processedModel); | ||
processedContext.processModelScale(scaleTool.getModelScaler(), | ||
processedModel, "", scaleTool.getSubjectMass()); | ||
processedContext.processModelMarkerPlacer(scaleTool.getMarkerPlacer(), processedModel, ""); | ||
System.out.println("Test finished!"); | ||
} | ||
catch (IOException ex){ | ||
System.exit(-1); | ||
} | ||
System.gc(); | ||
} | ||
} | ||
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. Can we remove Model::replaceMarkerSet() (see #1780) and deleteUnusedMarkers() since they appear to be unused by the GUI? 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. MarkerPlacer::processModel uses deleteUnusedMarkers(), it's not used by the GUI directly. replaceMarkerSet is not called by the GUI anymore and can be removed. |
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 comment does not describe what is happening below.