OpenSim Moco  0.4.0
Public Member Functions | List of all members
OpenSim::ModelProcessor Class Reference

Description

This class describes a workflow for processing a Model using ModelOperators.

The user must provide a source model via either the model property or the filepath property. In C++, one can easily chain together the operators in a processor using the C++ pipe operator:

ModelProcessor proc = ModelProcessor("model.osim") | ModOpAddReserves();
Examples:
example2DWalking.cpp, exampleMocoInverse.cpp, and exampleMocoTrack.cpp.
Inheritance diagram for OpenSim::ModelProcessor:

#include <Moco/Moco/ModelProcessor.h>

Public Member Functions

 OpenSim_DECLARE_PROPERTY (filepath, std::string, "File path to a Model (.osim).")
 
 OpenSim_DECLARE_LIST_PROPERTY (operators, ModelOperator, "Operators to apply to the source Model of this processor.")
 
 ModelProcessor ()
 This constructor is only for use when reading (deserializing) from an XML file. More...
 
 ModelProcessor (Model model)
 Use a Model object as the source model. More...
 
 ModelProcessor (std::string filepath)
 Use the filepath of a .osim file to obtain the source model. More...
 
Model * setModel (std::unique_ptr< Model > model)
 Set the base model. More...
 
const Model & getModel () const
 Obtain the base model, if one was provided via the model property or setModel(). More...
 
Model & updModel ()
 Obtain a mutable reference to the base model, if one was provided via the model property or setModel(). More...
 
Model process (const std::string &relativeToDirectory={}) const
 Process and obtain the model. More...
 
ModelProcessorappend (const ModelOperator &op)
 Append an operation to the end of the operations in this processor.
 
ModelProcessoroperator| (const ModelOperator &right)
 This operator allows one to write the following code in C++: More...
 

Constructor & Destructor Documentation

◆ ModelProcessor() [1/3]

OpenSim::ModelProcessor::ModelProcessor ( )
inline

This constructor is only for use when reading (deserializing) from an XML file.

◆ ModelProcessor() [2/3]

OpenSim::ModelProcessor::ModelProcessor ( Model  model)
inline

Use a Model object as the source model.

Since this constructor is not explicit, you can provide a Model to any function that takes a ModelProcessor (in C++).

◆ ModelProcessor() [3/3]

OpenSim::ModelProcessor::ModelProcessor ( std::string  filepath)
inline

Use the filepath of a .osim file to obtain the source model.

Since this constructor is not explicit, you can provide a string filepath any function that takes a ModelProcessor (in C++).

Member Function Documentation

◆ getModel()

const Model& OpenSim::ModelProcessor::getModel ( ) const
inline

Obtain the base model, if one was provided via the model property or setModel().

This ignores base models specified via the filepath property.

◆ operator|()

ModelProcessor& OpenSim::ModelProcessor::operator| ( const ModelOperator right)
inline

This operator allows one to write the following code in C++:

ModelProcessor proc = ModelProcessor("model.osim") | ModOpAddReserves();

◆ process()

Model OpenSim::ModelProcessor::process ( const std::string &  relativeToDirectory = {}) const
inline

Process and obtain the model.

If the base model is specified via the filepath property, the filepath will be evaluated relative to relativeToDirectory, if provided.

Examples:
example2DWalking.cpp, and exampleMocoTrack.cpp.

◆ setModel()

Model* OpenSim::ModelProcessor::setModel ( std::unique_ptr< Model >  model)
inline

Set the base model.

This returns a raw pointer equal to the pointer provided.

◆ updModel()

Model& OpenSim::ModelProcessor::updModel ( )
inline

Obtain a mutable reference to the base model, if one was provided via the model property or setModel().

This ignores base models specified via the filepath property.


The documentation for this class was generated from the following file: