Skip to content

Commit

Permalink
Rule of five; more code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbianco committed Aug 30, 2023
1 parent ce3b0c4 commit c383f64
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions OpenSim/Actuators/ModelFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ void ModelFactory::replaceMusclesWithPathActuators(OpenSim::Model &model) {
model.addForce(actu);

// Copy the muscle's path.
AbstractPath& path = musc.updPath();
if (auto* pGeometryPath = dynamic_cast<GeometryPath*>(&path)) {
if (auto* pGeometryPath = musc.tryUpdPath<GeometryPath>()) {
GeometryPath& thisGeometryPath = actu->initGeometryPath();

// For the connectee names in the PathPoints to be correct, we must
Expand Down
6 changes: 5 additions & 1 deletion OpenSim/Simulation/Model/AbstractPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ AbstractPath::~AbstractPath() noexcept = default;

AbstractPath& AbstractPath::operator=(const AbstractPath&) = default;

AbstractPath::AbstractPath(AbstractPath&& other) noexcept = default;

AbstractPath& AbstractPath::operator=(AbstractPath&& other) noexcept = default;

// DEFAULTED METHODS
const SimTK::Vec3& AbstractPath::getDefaultColor() const
{
Expand All @@ -61,4 +65,4 @@ void AbstractPath::setPreScaleLength(const SimTK::State&,
double preScaleLength)
{
_preScaleLength = preScaleLength;
}
}
7 changes: 5 additions & 2 deletions OpenSim/Simulation/Model/AbstractPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(AbstractPath, ModelComponent);
// METHODS
//=============================================================================
AbstractPath();
AbstractPath(const AbstractPath&);
~AbstractPath() noexcept;


AbstractPath(const AbstractPath&);
AbstractPath& operator=(const AbstractPath&);

AbstractPath(AbstractPath&& other) noexcept;
AbstractPath& operator=(AbstractPath&& other) noexcept;

// INTERFACE METHODS
//
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/Blankevoort1991Ligament.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ OpenSim_DECLARE_CONCRETE_OBJECT(Blankevoort1991Ligament, Force)
double linear_stiffness, double slack_length);

// Path
bool hasPath() const override { return true;};
bool hasPath() const override { return true; };

AbstractPath& updPath() { return upd_path(); }
const AbstractPath& getPath() const { return get_path(); }
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/Ligament.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ OpenSim_DECLARE_CONCRETE_OBJECT(Ligament, Force);
//--------------------------------------------------------------------------
// PATH
//--------------------------------------------------------------------------
bool hasPath() const override { return true;};
bool hasPath() const override { return true; };

AbstractPath& updPath() { return upd_path(); }
const AbstractPath& getPath() const { return get_path(); }
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Simulation/Model/Muscle.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Muscle, PathActuator);

/** Potential energy stored by the muscle */
double computePotentialEnergy(const SimTK::State& state) const override;

/** Override PathActuator virtual to calculate a preferred color for the
muscle path based on activation. **/
SimTK::Vec3 computePathColor(const SimTK::State& state) const override;
Expand All @@ -440,7 +440,7 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Muscle, PathActuator);
void extendAddToSystem(SimTK::MultibodySystem& system) const override;
void extendSetPropertiesFromState(const SimTK::State &s) override;
void extendInitStateFromProperties(SimTK::State& state) const override;

// Update the display geometry attached to the muscle
virtual void updateGeometry(const SimTK::State& s);
// End of Interfaces imposed by parent classes.
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/PathActuator.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OSIMSIMULATION_API PathActuator : public ScalarActuator {
// GET AND SET
//--------------------------------------------------------------------------
// Path
bool hasPath() const override { return true;};
bool hasPath() const override { return true; };

AbstractPath& updPath() { return upd_path(); }
const AbstractPath& getPath() const { return get_path(); }
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Simulation/Model/PathSpring.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ OpenSim_DECLARE_CONCRETE_OBJECT(PathSpring, Force);
void setDissipation(double dissipation);

/** get/set the path object */
bool hasPath() const override { return true;};
bool hasPath() const override { return true; };

AbstractPath& updPath() { return upd_path(); }
const AbstractPath& getPath() const { return get_path(); }
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Tests/Wrapping/testWrapCylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ namespace {
// Trigger computing the wrapping path (realizing the state will not).
model.getComponent<PathSpring>("spring").getLength(state);
const WrapResult wrapResult = model.getComponent<PathSpring>("spring")
.getPath<GeometryPath>()
.getGeometryPath()
.getWrapSet()
.get("pathwrap")
.getPreviousWrap();
Expand Down

0 comments on commit c383f64

Please sign in to comment.