-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…894)
- Loading branch information
1 parent
0234941
commit 5cbd1ee
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/OpenSimCreator/Documents/ModelWarper/ModelWarperConfiguration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "ModelWarperConfiguration.h" | ||
|
||
#include <OpenSim/Common/Component.h> | ||
|
||
#include <filesystem> | ||
|
||
osc::mow::ModelWarperConfiguration::ModelWarperConfiguration() | ||
{ | ||
constructProperties(); | ||
} | ||
|
||
osc::mow::ModelWarperConfiguration::ModelWarperConfiguration(const std::filesystem::path& filePath) : | ||
OpenSim::Component{filePath.string()} | ||
{ | ||
constructProperties(); | ||
updateFromXMLDocument(); | ||
} | ||
|
||
void osc::mow::ModelWarperConfiguration::constructProperties() | ||
{ | ||
// TODO | ||
} |
89 changes: 89 additions & 0 deletions
89
src/OpenSimCreator/Documents/ModelWarper/ModelWarperConfiguration.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#pragma once | ||
|
||
#include <OpenSim/Common/Component.h> | ||
|
||
#include <filesystem> | ||
|
||
namespace osc::mow | ||
{ | ||
// abstract interface to a component that is capable of warping `n` other | ||
// components (`StrategyTargets`) during a model warp | ||
class ComponentWarpingStrategy : public OpenSim::Component { | ||
protected: | ||
ComponentWarpingStrategy() = default; | ||
ComponentWarpingStrategy(const ComponentWarpingStrategy&) = default; | ||
ComponentWarpingStrategy(ComponentWarpingStrategy&&) noexcept = default; | ||
ComponentWarpingStrategy& operator=(const ComponentWarpingStrategy&) = default; | ||
ComponentWarpingStrategy& operator=(ComponentWarpingStrategy&&) noexcept = default; | ||
public: | ||
~ComponentWarpingStrategy() noexcept override = default; | ||
|
||
// StrategyTargets | ||
private: | ||
}; | ||
|
||
// abstract interface to a component that is capable of warping `n` | ||
// `OpenSim::PhysicalOffsetFrame`s during a model warp | ||
class OffsetFrameWarpingStrategy : public ComponentWarpingStrategy {}; | ||
|
||
// concrete implementation of an `OffsetFrameWarpingStrategy` in which | ||
// only the `translation` property of the offset frame is warped but the | ||
// rotation is left as-is | ||
class ThinPlateSplineOnlyTranslationOffsetFrameWarpingStrategy final : public OffsetFrameWarpingStrategy { | ||
public: | ||
// PointSources | ||
private: | ||
}; | ||
|
||
// concrete implementation of an `OffsetFrameWarpingStrategy` in which the | ||
// implementation should produce a halting error rather than continuing with | ||
// the model warp | ||
class ProduceErrorOffsetFrameWarpingStrategy final : public OffsetFrameWarpingStrategy { | ||
}; | ||
|
||
// concrete implementation of an `OffsetFrameWarpingStrategy` in which the | ||
// implementation should use a least-squares fit of the correspondences between | ||
// source/destination landmarks (`PointsToFit`) to compute the resulting offset | ||
// frame's `translation` and `rotation` | ||
class LeastSquaresOffsetFrameWarpingStrategy final : public OffsetFrameWarpingStrategy { | ||
public: | ||
// PointsToFit | ||
}; | ||
|
||
// abstract interface to a component that is capable of warping `n` | ||
// `OpenSim::Station`s during a model warp | ||
class StationWarpingStrategy : public OpenSim::Component {}; | ||
|
||
// concrete implementation of a `StationWarpingStrategy` that uses the Thin-Plate | ||
// Spline (TPS) algorithm to fit correspondences between mesh landmarks (`MeshSources`) | ||
class ThinPlateSplineStationWarpingStrategy final : public StationWarpingStrategy { | ||
// MeshSources | ||
}; | ||
|
||
// TODO: | ||
// MuscleParameterWarpingStrategies | ||
// MuscleParameterWarpingStrategy | ||
// some_scaling_param | ||
// IdentityMuscleParameterWarpingStrategy | ||
// | ||
// MeshWarpingStrategies | ||
// ThinPlateSplineMeshWarpingStrategy | ||
// | ||
// WrapSurfaceWarpingStrategies | ||
// WrapSurfaceWarpingStrategy | ||
// LeastSquaresProjectionWrapSurfaceWarpingStrategy? | ||
|
||
// top-level model warping configuration file | ||
class ModelWarperConfiguration final : public OpenSim::Component { | ||
OpenSim_DECLARE_CONCRETE_OBJECT(ModelWarperConfiguration, OpenSim::Component); | ||
public: | ||
// constructs a blank (default) configuration object | ||
ModelWarperConfiguration(); | ||
|
||
// constructs a `ModelWarperConfiguration` by loading its properties from an XML file | ||
// at the given filesystem location | ||
explicit ModelWarperConfiguration(const std::filesystem::path& filePath); | ||
private: | ||
void constructProperties(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/TestOpenSimCreator/Documents/ModelWarper/TestModelWarperConfiguration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <OpenSimCreator/Documents/ModelWarper/ModelWarperConfiguration.h> | ||
|
||
#include <TestOpenSimCreator/TestOpenSimCreatorConfig.h> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <filesystem> | ||
|
||
using namespace osc; | ||
using namespace osc::mow; | ||
|
||
namespace | ||
{ | ||
std::filesystem::path GetFixturePath(const std::filesystem::path& subpath) | ||
{ | ||
return std::filesystem::weakly_canonical(std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / subpath); | ||
} | ||
} | ||
|
||
TEST(ModelWarperConfiguration, CanDefaultConstruct) | ||
{ | ||
[[maybe_unused]] ModelWarperConfiguration configuration; | ||
} | ||
|
||
TEST(ModelWarperConfiguration, CanSaveDefaultConstructedToXMLFile) | ||
{ | ||
ModelWarperConfiguration configuration; | ||
configuration.print(R"(C:\Users\adamk\Desktop\somefile.xml)"); | ||
} | ||
|
||
TEST(ModelWarperConfiguration, LoadingNonExistentFileThrows) | ||
{ | ||
ASSERT_ANY_THROW({ [[maybe_unused]] ModelWarperConfiguration configuration{GetFixturePath("doesnt_exist")}; }); | ||
} | ||
|
||
TEST(ModelWarperConfiguration, LoadingMalformedFileThrows) | ||
{ | ||
ModelWarperConfiguration configuration{GetFixturePath("Document/ModelWarper/ModelWarperConfiguration/malformed.xml")}; | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
.../TestOpenSimCreator/resources/Document/ModelWarper/ModelWarperConfiguration/malformed.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this isn't valid XML |