-
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
…889)
- Loading branch information
1 parent
3cde6f1
commit 68eda8e
Showing
13 changed files
with
346 additions
and
66 deletions.
There are no files selected for viewing
38 changes: 33 additions & 5 deletions
38
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 |
---|---|---|
@@ -1,22 +1,50 @@ | ||
#include "ModelWarperConfiguration.h" | ||
|
||
#include <OpenSim/Common/Component.h> | ||
#include <oscar/Utils/HashHelpers.h> | ||
|
||
#include <filesystem> | ||
#include <sstream> | ||
#include <string_view> | ||
#include <unordered_set> | ||
#include <utility> | ||
|
||
osc::mow::ModelWarperConfiguration::ModelWarperConfiguration() | ||
{ | ||
constructProperties(); | ||
constructProperties(); | ||
} | ||
|
||
osc::mow::ModelWarperConfiguration::ModelWarperConfiguration(const std::filesystem::path& filePath) : | ||
OpenSim::Component{filePath.string()} | ||
OpenSim::Component{filePath.string()} | ||
{ | ||
constructProperties(); | ||
updateFromXMLDocument(); | ||
constructProperties(); | ||
updateFromXMLDocument(); | ||
} | ||
|
||
void osc::mow::ModelWarperConfiguration::constructProperties() | ||
{} | ||
|
||
void osc::mow::ModelWarperConfiguration::extendFinalizeFromProperties() | ||
{ | ||
// TODO | ||
if (getProperty_components().empty()) { | ||
return; // BODGE: the OpenSim API throws if you call `getComponentList` on an | ||
} | ||
|
||
// note: it's ok to have the same `StrategyTarget` if the `ComponentStrategy` applies | ||
// to a different type of component | ||
// | ||
// (e.g. if a station warper targets "*", that will capture different components from | ||
// a offset frame warper that targets "*") | ||
using SetElement = std::pair<const std::type_info*, std::string_view>; | ||
std::unordered_set<SetElement, Hasher<SetElement>> allStrategyTargets; | ||
for (const auto& warpingStrategy : getComponentList<ComponentWarpingStrategy>()) { | ||
const std::type_info& targetType = warpingStrategy.getTargetComponentTypeInfo(); | ||
for (int i = 0; i < warpingStrategy.getProperty_StrategyTargets().size(); ++i) { | ||
if (not allStrategyTargets.emplace(&targetType, warpingStrategy.get_StrategyTargets(i)).second) { | ||
std::stringstream ss; | ||
ss << warpingStrategy.get_StrategyTargets(i) << ": duplicate strategy target detected in '" << warpingStrategy.getName() << "': this will confuse the engine and should be resolved"; | ||
OPENSIM_THROW_FRMOBJ(OpenSim::Exception, std::move(ss).str()); | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.