From 68f1b03e44f733c21d4efc835bf084d034328d80 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Sat, 14 Dec 2019 11:55:30 -0800 Subject: [PATCH 01/19] Fix Doxygen errors, turn on Doxygen translation and up version of swig to 4.0.1 --- Bindings/Java/OpenSimJNI/CMakeLists.txt | 2 +- Bindings/Python/CMakeLists.txt | 1 + Bindings/SWIGSimTK/Rotation.h | 24 +++++++++++------------ Bindings/common.i | 26 +++++++++++++------------ Bindings/preliminaries.i | 2 +- OpenSim/Common/Property.h | 5 ++++- OpenSim/Simulation/StatesTrajectory.h | 1 - OpenSim/Tools/InverseKinematicsTool.h | 6 ++++-- appveyor.yml | 2 +- 9 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Bindings/Java/OpenSimJNI/CMakeLists.txt b/Bindings/Java/OpenSimJNI/CMakeLists.txt index 14f382d7e0..9e5dbf4b35 100644 --- a/Bindings/Java/OpenSimJNI/CMakeLists.txt +++ b/Bindings/Java/OpenSimJNI/CMakeLists.txt @@ -7,7 +7,7 @@ find_package(JNI 1.7 REQUIRED) function(OpenSimGenerateJavaWrapper NAME INPUT_INTERFACE_FILE OUTPUT_CXX_FILE OUTPUT_H_FILE) - set(_swig_common_args -c++ -java + set(_swig_common_args -c++ -java -doxygen -package ${OPENSIM_JAVA_WRAPPING_PACKAGE} -I${OpenSim_SOURCE_DIR} -I${OpenSim_SOURCE_DIR}/Bindings diff --git a/Bindings/Python/CMakeLists.txt b/Bindings/Python/CMakeLists.txt index 73a6a2ca2c..017041a65e 100644 --- a/Bindings/Python/CMakeLists.txt +++ b/Bindings/Python/CMakeLists.txt @@ -88,6 +88,7 @@ macro(OpenSimAddPythonModule) #-debug-tmused # Which typemaps were used? -v # verbose -o ${_output_cxx_file} + -doxygen -outdir "${CMAKE_CURRENT_BINARY_DIR}" ${_swig_common_args} DEPENDS ${_${OSIMSWIGPY_MODULE}_dependencies} diff --git a/Bindings/SWIGSimTK/Rotation.h b/Bindings/SWIGSimTK/Rotation.h index 0dbea6fe96..ad831a08d1 100644 --- a/Bindings/SWIGSimTK/Rotation.h +++ b/Bindings/SWIGSimTK/Rotation.h @@ -518,10 +518,10 @@ class Rotation_ : public Mat<3, 3, P> { /// Theory: calculate qdot=N_P(q)*w_PB using multiplyByBodyXYZ_N_P(). /// @see multiplyByBodyXYZ_N_P() static Vec3 convertAngVelInParentToBodyXYZDot - (const Vec2& cosxy, ///< cos(qx), cos(qy) - const Vec2& sinxy, ///< sin(qx), sin(qy) - P oocosy, ///< 1/cos(qy) - const Vec3& w_PB) ///< angular velocity of B in P, exp. in P + (const Vec2& cosxy, //< cos(qx), cos(qy) + const Vec2& sinxy, //< sin(qx), sin(qy) + P oocosy, //< 1/cos(qy) + const Vec3& w_PB) //< angular velocity of B in P, exp. in P { return multiplyByBodyXYZ_N_P(cosxy,sinxy,oocosy,w_PB); } @@ -538,11 +538,11 @@ class Rotation_ : public Mat<3, 3, P> { /// efficiently. The second term is just an acceleration remainder term /// quadratic in qdot. static Vec3 convertAngAccInParentToBodyXYZDotDot - (const Vec2& cosxy, ///< cos(qx), cos(qy) - const Vec2& sinxy, ///< sin(qx), sin(qy) - P oocosy, ///< 1/cos(qy) - const Vec3& qdot, ///< previously calculated BodyXYZDot - const Vec3& b_PB) ///< angular acceleration, a.k.a. wdot_PB + (const Vec2& cosxy, //< cos(qx), cos(qy) + const Vec2& sinxy, //< sin(qx), sin(qy) + P oocosy, //< 1/cos(qy) + const Vec3& qdot, //< previously calculated BodyXYZDot + const Vec3& b_PB) //< angular acceleration, a.k.a. wdot_PB { const P s1 = sinxy[1], c1 = cosxy[1]; const P q0 = qdot[0], q1 = qdot[1], q2 = qdot[2]; @@ -1088,14 +1088,14 @@ class InverseRotation_ : public Mat<3,3,P>::TransposeType { #endif Rotation_

& operator~() { return updInvert(); } //@} - +#ifndef SWIG /// Access individual rows and columns of this InverseRotation; no cost or /// copying since suitably-cast references to the actual data are returned. /// There are no writable versions of these methods since changing a single /// row or column would violate the contract that these are always legitimate /// rotation matrices. //@{ -#ifndef SWIG + const RowType& row( int i ) const { return reinterpret_cast(asMat33()[i]); } const ColType& col( int j ) const { return reinterpret_cast(asMat33()(j)); } const ColType& x() const { return col(0); } @@ -1111,8 +1111,8 @@ class InverseRotation_ : public Mat<3,3,P>::TransposeType { //@{ const BaseMat& asMat33() const { return *static_cast(this); } BaseMat toMat33() const { return asMat33(); } -#endif //@} +#endif }; #ifndef SWIG diff --git a/Bindings/common.i b/Bindings/common.i index 563915c9dc..033f0487a9 100644 --- a/Bindings/common.i +++ b/Bindings/common.i @@ -123,19 +123,19 @@ namespace OpenSim { %shared_ptr(OpenSim::DataTable_); %shared_ptr(OpenSim::DataTable_); %shared_ptr(OpenSim::DataTable_); -%shared_ptr(OpenSim::DataTable_>); +%shared_ptr(OpenSim::DataTable_ >); %shared_ptr(OpenSim::DataTable_); %shared_ptr(OpenSim::DataTable_); %shared_ptr(OpenSim::DataTable_); -%shared_ptr(OpenSim::DataTable_>); +%shared_ptr(OpenSim::DataTable_ >); %shared_ptr(OpenSim::TimeSeriesTable_); %shared_ptr(OpenSim::TimeSeriesTable_); %shared_ptr(OpenSim::TimeSeriesTable_); -%shared_ptr(OpenSim::TimeSeriesTable_>); +%shared_ptr(OpenSim::TimeSeriesTable_ >); %shared_ptr(OpenSim::TimeSeriesTable_); %shared_ptr(OpenSim::TimeSeriesTable_); %shared_ptr(OpenSim::TimeSeriesTable_); -%shared_ptr(OpenSim::TimeSeriesTable_>); +%shared_ptr(OpenSim::TimeSeriesTable_ >); %ignore OpenSim::AbstractDataTable::clone; %ignore OpenSim::AbstractDataTable::getTableMetaData; %ignore OpenSim::AbstractDataTable::updTableMetaData; @@ -145,7 +145,7 @@ namespace OpenSim { %ignore OpenSim::AbstractDataTable::setDependentsMetaData; %ignore OpenSim::AbstractDataTable::setColumnLabels( const std::initializer_list&); -%template(StdVectorMatrix) std::vector>; +%template(StdVectorMatrix) std::vector >; %extend OpenSim::AbstractDataTable { void setColumnLabels(const std::vector& columnLabels) { $self->setColumnLabels(columnLabels); @@ -334,28 +334,30 @@ DATATABLE_CLONE(double, SimTK::Rotation_) %template(DataTable) OpenSim::DataTable_; %template(DataTableVec3) OpenSim::DataTable_; %template(DataTableUnitVec3) OpenSim::DataTable_; -%template(DataTableQuaternion) OpenSim::DataTable_>; +%template(DataTableQuaternion) OpenSim::DataTable_ >; %template(DataTableVec6) OpenSim::DataTable_; %template(DataTableSpatialVec) OpenSim::DataTable_; %template(DataTableMat33) OpenSim::DataTable_; -%template(DataTableRotation) OpenSim::DataTable_>; +%template(DataTableRotation) OpenSim::DataTable_ >; %template(TimeSeriesTable) OpenSim::TimeSeriesTable_; %template(TimeSeriesTableVec3) OpenSim::TimeSeriesTable_; %template(TimeSeriesTableUnitVec3) OpenSim::TimeSeriesTable_; %template(TimeSeriesTableQuaternion) - OpenSim::TimeSeriesTable_>; + OpenSim::TimeSeriesTable_ >; %template(TimeSeriesTableVec6) OpenSim::TimeSeriesTable_; %template(TimeSeriesTableSpatialVec) OpenSim::TimeSeriesTable_; %template(TimeSeriesTableMat33) OpenSim::TimeSeriesTable_; -%template(TimeSeriesTableRotation) OpenSim::TimeSeriesTable_>; +%template(TimeSeriesTableRotation) OpenSim::TimeSeriesTable_ >; %include %template(StdVectorEvent) std::vector; +%shared_ptr(std::shared_ptr) %template(StdMapStringTimeSeriesTableVec3) std::map>>; + std::shared_ptr >; + %shared_ptr(OpenSim::DataAdapter) %shared_ptr(OpenSim::FileAdapter) %shared_ptr(OpenSim::DelimFileAdapter) @@ -372,9 +374,9 @@ DATATABLE_CLONE(double, SimTK::Rotation_) %shared_ptr(OpenSim::TRCFileAdapter) %shared_ptr(OpenSim::C3DFileAdapter) %template(StdMapStringDataAdapter) - std::map>; + std::map >; %template(StdMapStringAbstractDataTable) - std::map>; + std::map >; %include %include %include diff --git a/Bindings/preliminaries.i b/Bindings/preliminaries.i index 735fa2fd56..d24850a65a 100644 --- a/Bindings/preliminaries.i +++ b/Bindings/preliminaries.i @@ -9,5 +9,5 @@ %template(StdVectorDouble) std::vector; %template(StdVectorString) std::vector; -%include "std_map.i" +//%include "std_map.i" %include diff --git a/OpenSim/Common/Property.h b/OpenSim/Common/Property.h index 46205e5e8e..6abb7d9fef 100644 --- a/OpenSim/Common/Property.h +++ b/OpenSim/Common/Property.h @@ -576,7 +576,9 @@ class Property : public AbstractProperty { Property(Property&&) = default; Property& operator=(const Property&) = default; Property& operator=(Property&&) = default; - /** @cond **/ // Hide from Doxygen. +#ifndef SWIG + /** @cond **/ + // Hide from Doxygen. // This is the interface that SimpleProperty and ObjectProperty must // implement. // Base class verifies that 0 <= index < size(), and for append operations @@ -587,6 +589,7 @@ class Property : public AbstractProperty { virtual int appendValueVirtual(const T& value) = 0; virtual int adoptAndAppendValueVirtual(T* value) = 0; /** @endcond **/ +#endif }; diff --git a/OpenSim/Simulation/StatesTrajectory.h b/OpenSim/Simulation/StatesTrajectory.h index 82331704ac..7703a45a60 100644 --- a/OpenSim/Simulation/StatesTrajectory.h +++ b/OpenSim/Simulation/StatesTrajectory.h @@ -494,7 +494,6 @@ class OSIMSIMULATION_API StatesTrajectory { * default values for `allowMissingColumns` and `allowExtraColumns`. */ static StatesTrajectory createFromStatesStorage(const Model& model, const std::string& filepath); - /// @} }; } // namespace diff --git a/OpenSim/Tools/InverseKinematicsTool.h b/OpenSim/Tools/InverseKinematicsTool.h index 0f57dca83e..0143939236 100644 --- a/OpenSim/Tools/InverseKinematicsTool.h +++ b/OpenSim/Tools/InverseKinematicsTool.h @@ -165,15 +165,17 @@ OpenSim_DECLARE_CONCRETE_OBJECT(InverseKinematicsTool, Tool); // INTERFACE //-------------------------------------------------------------------------- bool run() override SWIG_DECLARE_EXCEPTION; - +#ifndef SWIG /** @cond **/ // hide from Doxygen +#endif // For testing/debugging it is necessary to know exactly what are the // MarkersReference (set of marker trajectories and their weights) and // CoordinateReferences that are being used by the InverseKinematicsSolver. void populateReferences(MarkersReference& markersReference, SimTK::Array_&coordinateReferences) const; +#ifndef SWIG /** @endcond **/ - +#endif //============================================================================= }; // END of class InverseKinematicsTool //============================================================================= diff --git a/appveyor.yml b/appveyor.yml index 9066bb6e77..934e176e40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -73,7 +73,7 @@ install: # Only install swig if it isn't present (as a result of AppVeyor's caching). # SWIG 3.0.8 is the minimum required version, but it does not yet exist in # Chocolatey. - - IF NOT EXIST C:\ProgramData\chocolatey\bin\swig.exe choco install swig --version 3.0.9 --yes --limit-output #> $null + - IF NOT EXIST C:\ProgramData\chocolatey\bin\swig.exe choco install swig --version 4.0.1 --yes --limit-output #> $null ## Install python-nose for python testing. - "%PYTHON_DIR%\\Scripts\\pip install nose" From b2b6994ce081a92d4edf3c430adb51b613ed9634 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Sat, 14 Dec 2019 18:33:31 -0800 Subject: [PATCH 02/19] Restore std_map.i --- Bindings/preliminaries.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bindings/preliminaries.i b/Bindings/preliminaries.i index d24850a65a..735fa2fd56 100644 --- a/Bindings/preliminaries.i +++ b/Bindings/preliminaries.i @@ -9,5 +9,5 @@ %template(StdVectorDouble) std::vector; %template(StdVectorString) std::vector; -//%include "std_map.i" +%include "std_map.i" %include From 565182b64fdc0db689a83aaaf9110edf318da62c Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Sun, 15 Dec 2019 18:31:10 -0800 Subject: [PATCH 03/19] Update appveyor.yml Try swig 4.0.0 if available on chocolatey --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 934e176e40..605d7fe693 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -73,7 +73,7 @@ install: # Only install swig if it isn't present (as a result of AppVeyor's caching). # SWIG 3.0.8 is the minimum required version, but it does not yet exist in # Chocolatey. - - IF NOT EXIST C:\ProgramData\chocolatey\bin\swig.exe choco install swig --version 4.0.1 --yes --limit-output #> $null + - IF NOT EXIST C:\ProgramData\chocolatey\bin\swig.exe choco install swig --version 4.0.0 --yes --limit-output #> $null ## Install python-nose for python testing. - "%PYTHON_DIR%\\Scripts\\pip install nose" From 3bcdbfff4098ed9a913b57229ca689dcf9c21361 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Sat, 27 Mar 2021 01:46:35 -0700 Subject: [PATCH 04/19] Move inner typedef of C3DFileAdapter::Tables outside class, and fix comments --- OpenSim/Actuators/ModelFactory.h | 2 -- OpenSim/Common/C3DFileAdapter.cpp | 4 ++-- OpenSim/Common/C3DFileAdapter.h | 7 ++++--- OpenSim/Moco/MocoStudyFactory.h | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/OpenSim/Actuators/ModelFactory.h b/OpenSim/Actuators/ModelFactory.h index b18c8ce2f9..c680841710 100644 --- a/OpenSim/Actuators/ModelFactory.h +++ b/OpenSim/Actuators/ModelFactory.h @@ -19,7 +19,6 @@ * -------------------------------------------------------------------------- */ #include "osimActuatorsDLL.h" - #include namespace OpenSim { @@ -91,7 +90,6 @@ class OSIMACTUATORS_API ModelFactory { double bound = SimTK::NaN, bool skipCoordinatesWithExistingActuators = true); - /// @} }; } // namespace OpenSim diff --git a/OpenSim/Common/C3DFileAdapter.cpp b/OpenSim/Common/C3DFileAdapter.cpp index 4aaf377e2c..d78c73fc2e 100644 --- a/OpenSim/Common/C3DFileAdapter.cpp +++ b/OpenSim/Common/C3DFileAdapter.cpp @@ -80,8 +80,8 @@ C3DFileAdapter::clone() const { return new C3DFileAdapter{*this}; } -void -C3DFileAdapter::write(const C3DFileAdapter::Tables& tables, +void C3DFileAdapter::write( + const TablesDictionary& tables, const std::string& fileName) { OPENSIM_THROW(Exception, "Writing C3D not supported yet."); } diff --git a/OpenSim/Common/C3DFileAdapter.h b/OpenSim/Common/C3DFileAdapter.h index f31cfc6050..5d36991ee8 100644 --- a/OpenSim/Common/C3DFileAdapter.h +++ b/OpenSim/Common/C3DFileAdapter.h @@ -30,6 +30,8 @@ namespace OpenSim { +typedef std::map> TablesDictionary; + /** C3DFileAdapter reads a C3D file into markers and forces tables of type TimeSeriesTableVec3. The markers table has each column labeled by its corresponding marker name. For the forces table, the data are grouped @@ -41,7 +43,6 @@ CenterOfPressure, or the PointOfWrenchApplication. */ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { public: typedef std::vector EventTable; - typedef std::map> Tables; /** Enumerated list of locations in which read in forces are expressed. %Measurement from force plates can be expressed by the C3DFileAdapter @@ -117,8 +118,8 @@ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { return _location; } - static - void write(const Tables& markerTable, const std::string& fileName); + static void write( + const TablesDictionary& markerTable, const std::string& fileName); /** Retrieve the TimeSeriesTableVec3 of Markers */ std::shared_ptr getMarkersTable(DataAdapter::OutputTables& tables) { std::shared_ptr& adt = tables.at("markers"); diff --git a/OpenSim/Moco/MocoStudyFactory.h b/OpenSim/Moco/MocoStudyFactory.h index 99b92f7479..fd854f5de7 100644 --- a/OpenSim/Moco/MocoStudyFactory.h +++ b/OpenSim/Moco/MocoStudyFactory.h @@ -32,8 +32,8 @@ class OSIMMOCO_API MocoStudyFactory { /// LinearTangentFinalSpeed. This function is intended for use in testing. /// This problem has an analytical solution, and /// is described in Section 2.4 of Bryson and Ho [1]. Bryson, A. E., Ho, - /// Y.‐C., Applied Optimal Control, Optimization, Estimation, and Control. - /// New York‐London‐Sydney‐Toronto. John Wiley & Sons. 1975. + /// Y.C., Applied Optimal Control, Optimization, Estimation, and Control. + /// New York London Sydney Toronto. John Wiley & Sons. 1975. static MocoStudy createLinearTangentSteeringStudy( double acceleration, double finalTime, double finalHeight); }; From c0df8aa9a74410a7592987b229d95aca9141c7e9 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Mon, 29 Mar 2021 10:05:10 -0700 Subject: [PATCH 05/19] Remove template StdMapStringTimeSeriesTableVec3 as unusable for now and swig-out call-site --- Bindings/common.i | 4 ++-- OpenSim/Common/C3DFileAdapter.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Bindings/common.i b/Bindings/common.i index bd24421245..39ad63ed7d 100644 --- a/Bindings/common.i +++ b/Bindings/common.i @@ -365,8 +365,8 @@ DATATABLE_CLONE(double, SimTK::Rotation_) %include %template(StdVectorEvent) std::vector; %shared_ptr(std::shared_ptr) -%template(StdMapStringTimeSeriesTableVec3) - std::map >; +//%template(StdMapStringTimeSeriesTableVec3) +// std::map >; //%template(StdMapStringTimeSeriesTableVec3Iterator) // std::map >::Iterator; diff --git a/OpenSim/Common/C3DFileAdapter.h b/OpenSim/Common/C3DFileAdapter.h index 5d36991ee8..7718fa2c43 100644 --- a/OpenSim/Common/C3DFileAdapter.h +++ b/OpenSim/Common/C3DFileAdapter.h @@ -117,9 +117,10 @@ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { ForceLocation getLocationForForceExpression() const { return _location; } - +#ifndef SWIG static void write( const TablesDictionary& markerTable, const std::string& fileName); +#endif /** Retrieve the TimeSeriesTableVec3 of Markers */ std::shared_ptr getMarkersTable(DataAdapter::OutputTables& tables) { std::shared_ptr& adt = tables.at("markers"); From 4742a2421086cc32f0f1e7242e2f7bfd824b1f52 Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Mon, 29 Mar 2021 10:15:42 -0700 Subject: [PATCH 06/19] Update continuous_integration.yml use 4.0.2 for ci --- .github/workflows/continuous_integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 0da626a3fb..f3e1439240 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -35,7 +35,7 @@ jobs: run: python -m pip install numpy - name: Install SWIG - run: choco install swig --version 3.0.12 --yes --limit-output + run: choco install swig --version 4.0.2 --yes --limit-output - name: Cache dependencies id: cache-dependencies @@ -175,8 +175,8 @@ jobs: if: steps.cache-swig.outputs.cache-hit != 'true' run: | mkdir ~/swig-source && cd ~/swig-source - wget https://github.com/swig/swig/archive/rel-3.0.12.tar.gz - tar xzf rel-3.0.12.tar.gz && cd swig-rel-3.0.12 + wget https://github.com/swig/swig/archive/rel-4.0.2.tar.gz + tar xzf rel-4.0.2.tar.gz && cd swig-rel-4.0.2 sh autogen.sh && ./configure --prefix=$HOME/swig --disable-ccache make && make -j4 install From 79b098a0671f3706f3e57ecaf372f508782eb174 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Fri, 2 Apr 2021 00:05:52 -0700 Subject: [PATCH 07/19] Add function templates to Model class to maintain backwards compatibility and account for changes in swig handling of function templates scoping --- Bindings/simulation.i | 56 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/Bindings/simulation.i b/Bindings/simulation.i index 6ba6669e79..ec138f186c 100644 --- a/Bindings/simulation.i +++ b/Bindings/simulation.i @@ -269,12 +269,42 @@ OpenSim::ModelComponentSet; %template(ActuatorList) OpenSim::ComponentList; %template(ActuatorIterator) OpenSim::ComponentListIterator; -%template(getFrameList) OpenSim::Model::getComponentList; -%template(getBodyList) OpenSim::Model::getComponentList; -%template(getMuscleList) OpenSim::Model::getComponentList; -%template(getModelComponentList) OpenSim::Model::getComponentList; -%template(getJointList) OpenSim::Model::getComponentList; -%template(getActuatorList) OpenSim::Model::getComponentList; +%template(Thelen2003MuscleList) + OpenSim::ComponentList; +%template(Thelen2003MuscleIterator) + OpenSim::ComponentListIterator; + +%template(Millard2012EquilibriumMuscleList) + OpenSim::ComponentList; +%template(Millard2012EquilibriumMuscleIterator) + OpenSim::ComponentListIterator; + +%extend OpenSim::Model { + OpenSim::ComponentList getFrameList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getBodyList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getMuscleList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getJointList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getActuatorList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getModelComponentList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getThelen2003MuscleList(){ + return $self->getComponentList(); + } + OpenSim::ComponentList getMillard2012EquilibriumMuscleList(){ + return $self->getComponentList(); + } +} %include %include @@ -289,20 +319,6 @@ OpenSim::ModelComponentSet; %include %include -%template(Thelen2003MuscleList) - OpenSim::ComponentList; -%template(Thelen2003MuscleIterator) - OpenSim::ComponentListIterator; - -%template(Millard2012EquilibriumMuscleList) - OpenSim::ComponentList; -%template(Millard2012EquilibriumMuscleIterator) - OpenSim::ComponentListIterator; - -%template(getThelen2003MuscleList) - OpenSim::Model::getComponentList; -%template(getMillard2012EquilibriumMuscleList) - OpenSim::Model::getComponentList; // Compensate for insufficient C++11 support in SWIG // ================================================= From 0dea39c3869e21c2b4a9ebb6787281978e2823f8 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Mon, 5 Apr 2021 10:42:51 -0700 Subject: [PATCH 08/19] Include doxygen in python module, tests run with python 3.9 but with some failures --- Bindings/Python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bindings/Python/CMakeLists.txt b/Bindings/Python/CMakeLists.txt index be28830635..c9d402f4ce 100644 --- a/Bindings/Python/CMakeLists.txt +++ b/Bindings/Python/CMakeLists.txt @@ -73,7 +73,7 @@ macro(OpenSimAddPythonModule) # We run swig once to get dependencies and then again to actually generate # the wrappers. This variable holds the parts of the swig command that # are shared between both invocations. - set(_swig_common_args -c++ -python + set(_swig_common_args -c++ -python -doxygen -I${OpenSim_SOURCE_DIR} -I${OpenSim_SOURCE_DIR}/Bindings/ -I${Simbody_INCLUDE_DIR} From 0c3402ecdf3785f5e4c9c5ae408579b7741a24b3 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Tue, 6 Apr 2021 23:39:27 -0700 Subject: [PATCH 09/19] Fix interface entry for shared_ptr of TimeSeriesTableVec3, restore internal typedef --- Bindings/common.i | 16 ++++++++-------- OpenSim/Common/C3DFileAdapter.cpp | 2 +- OpenSim/Common/C3DFileAdapter.h | 10 ++++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Bindings/common.i b/Bindings/common.i index 39ad63ed7d..059ae953ea 100644 --- a/Bindings/common.i +++ b/Bindings/common.i @@ -364,12 +364,8 @@ DATATABLE_CLONE(double, SimTK::Rotation_) %include %template(StdVectorEvent) std::vector; -%shared_ptr(std::shared_ptr) -//%template(StdMapStringTimeSeriesTableVec3) -// std::map >; -//%template(StdMapStringTimeSeriesTableVec3Iterator) -// std::map >::Iterator; +%shared_ptr(OpenSim::TimeSeriesTableVec3) + %shared_ptr(OpenSim::DataAdapter) %shared_ptr(OpenSim::FileAdapter) %shared_ptr(OpenSim::DelimFileAdapter) @@ -386,9 +382,13 @@ DATATABLE_CLONE(double, SimTK::Rotation_) %shared_ptr(OpenSim::TRCFileAdapter) %shared_ptr(OpenSim::C3DFileAdapter) %template(StdMapStringDataAdapter) - std::map>; + std::map >; %template(StdMapStringAbstractDataTable) - std::map>; + std::map >; +//%template(StdMapStringTimeSeriesTableVec3) +// std::map > >; + + %include %include %include diff --git a/OpenSim/Common/C3DFileAdapter.cpp b/OpenSim/Common/C3DFileAdapter.cpp index d78c73fc2e..bf8fe6afdc 100644 --- a/OpenSim/Common/C3DFileAdapter.cpp +++ b/OpenSim/Common/C3DFileAdapter.cpp @@ -81,7 +81,7 @@ C3DFileAdapter::clone() const { } void C3DFileAdapter::write( - const TablesDictionary& tables, + const C3DFileAdapter::Tables& tables, const std::string& fileName) { OPENSIM_THROW(Exception, "Writing C3D not supported yet."); } diff --git a/OpenSim/Common/C3DFileAdapter.h b/OpenSim/Common/C3DFileAdapter.h index 7718fa2c43..fed6fbd5ed 100644 --- a/OpenSim/Common/C3DFileAdapter.h +++ b/OpenSim/Common/C3DFileAdapter.h @@ -30,8 +30,6 @@ namespace OpenSim { -typedef std::map> TablesDictionary; - /** C3DFileAdapter reads a C3D file into markers and forces tables of type TimeSeriesTableVec3. The markers table has each column labeled by its corresponding marker name. For the forces table, the data are grouped @@ -43,6 +41,7 @@ CenterOfPressure, or the PointOfWrenchApplication. */ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { public: typedef std::vector EventTable; + typedef std::map> Tables; /** Enumerated list of locations in which read in forces are expressed. %Measurement from force plates can be expressed by the C3DFileAdapter @@ -117,15 +116,18 @@ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { ForceLocation getLocationForForceExpression() const { return _location; } + #ifndef SWIG - static void write( - const TablesDictionary& markerTable, const std::string& fileName); + static + void write(const Tables& markerTable, const std::string& fileName); #endif + /** Retrieve the TimeSeriesTableVec3 of Markers */ std::shared_ptr getMarkersTable(DataAdapter::OutputTables& tables) { std::shared_ptr& adt = tables.at("markers"); return std::dynamic_pointer_cast(adt); } + /** Retrieve the TimeSeriesTableVec3 of Forces */ std::shared_ptr getForcesTable(DataAdapter::OutputTables& tables) { std::shared_ptr& adt = tables.at("forces"); From 2581785a8b4c5007fcdab639bb0135916ca834db Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Wed, 7 Apr 2021 20:00:12 -0700 Subject: [PATCH 10/19] Update CMakeLists.txt Use 4.0.0 so as not to force bleeding edge swig --- Bindings/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bindings/CMakeLists.txt b/Bindings/CMakeLists.txt index 6f7599a75e..3cc4c10519 100644 --- a/Bindings/CMakeLists.txt +++ b/Bindings/CMakeLists.txt @@ -1,7 +1,7 @@ if(BUILD_PYTHON_WRAPPING OR BUILD_JAVA_WRAPPING) # We require 3.0.8 for the reason mentioned here (for Python 3): # https://github.com/tensorflow/tensorflow/issues/830 - find_package(SWIG 4.0.2 REQUIRED) + find_package(SWIG 4.0.0 REQUIRED) endif() # Flags are both Python and Java bindings will use. From f17e685d1f0bc2032cc051a4442230ff0131a31c Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Wed, 7 Apr 2021 20:02:47 -0700 Subject: [PATCH 11/19] Update CMakeLists.txt Remove stale comment referring to swig 3.0.9 --- Bindings/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Bindings/CMakeLists.txt b/Bindings/CMakeLists.txt index 3cc4c10519..7395f83908 100644 --- a/Bindings/CMakeLists.txt +++ b/Bindings/CMakeLists.txt @@ -1,6 +1,4 @@ if(BUILD_PYTHON_WRAPPING OR BUILD_JAVA_WRAPPING) - # We require 3.0.8 for the reason mentioned here (for Python 3): - # https://github.com/tensorflow/tensorflow/issues/830 find_package(SWIG 4.0.0 REQUIRED) endif() From 00c3d3cf30ec44dea3f1e54d6f4f5ce3a86c0d6b Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Wed, 7 Apr 2021 20:14:25 -0700 Subject: [PATCH 12/19] Update continuous_integration.yml Update SWIG acquisition script --- .github/workflows/continuous_integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index f3e1439240..b88ae34e18 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -35,7 +35,7 @@ jobs: run: python -m pip install numpy - name: Install SWIG - run: choco install swig --version 4.0.2 --yes --limit-output + run: choco install swig --version 4.0.0 --yes --limit-output - name: Cache dependencies id: cache-dependencies @@ -175,7 +175,7 @@ jobs: if: steps.cache-swig.outputs.cache-hit != 'true' run: | mkdir ~/swig-source && cd ~/swig-source - wget https://github.com/swig/swig/archive/rel-4.0.2.tar.gz + wget https://github.com/swig/swig/archive/refs/tags/rel-4.0.2.tar.gz tar xzf rel-4.0.2.tar.gz && cd swig-rel-4.0.2 sh autogen.sh && ./configure --prefix=$HOME/swig --disable-ccache make && make -j4 install From 863d3452916abb8616a5c45f4441f4bd4748057a Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Wed, 7 Apr 2021 23:02:29 -0700 Subject: [PATCH 13/19] Update continuous_integration.yml workaround caching swig --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index b88ae34e18..b64130292b 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -172,7 +172,7 @@ jobs: key: ${{ runner.os }}-swig - name: Install SWIG - if: steps.cache-swig.outputs.cache-hit != 'true' + # if: steps.cache-swig.outputs.cache-hit != 'true' run: | mkdir ~/swig-source && cd ~/swig-source wget https://github.com/swig/swig/archive/refs/tags/rel-4.0.2.tar.gz From 7f241e2e0c4e18de5bdd92c60e9312c7ef7e1f2c Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Thu, 8 Apr 2021 02:10:19 -0700 Subject: [PATCH 14/19] Update continuous_integration.yml try get source for swig on linux --- .github/workflows/continuous_integration.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index b64130292b..88479bbae8 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -300,8 +300,16 @@ jobs: - uses: actions/checkout@v1 - name: Install packages - run: sudo apt-get update && sudo apt-get install --yes build-essential libtool autoconf pkg-config gfortran libopenblas-dev liblapack-dev freeglut3-dev libxi-dev libxmu-dev doxygen python3 python3-dev python3-numpy python3-setuptools swig + run: sudo apt-get update && sudo apt-get install --yes build-essential libtool autoconf pkg-config gfortran libopenblas-dev liblapack-dev freeglut3-dev libxi-dev libxmu-dev doxygen python3 python3-dev python3-numpy python3-setuptools + - name: Install SWIG + # if: steps.cache-swig.outputs.cache-hit != 'true' + run: | + mkdir ~/swig-source && cd ~/swig-source + wget https://github.com/swig/swig/archive/refs/tags/rel-4.0.2.tar.gz + tar xzf rel-4.0.2.tar.gz && cd swig-rel-4.0.2 + sh autogen.sh && ./configure --prefix=$HOME/swig --disable-ccache + make && make -j4 install - name: Cache dependencies id: cache-dependencies uses: actions/cache@v1 From 9cd04d2bb2219eef67ba8c16180941cf53bd301a Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Thu, 8 Apr 2021 02:27:39 -0700 Subject: [PATCH 15/19] Update continuous_integration.yml swig location on linux --- .github/workflows/continuous_integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 88479bbae8..7e748ce296 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -341,6 +341,7 @@ jobs: OSIM_CMAKE_ARGS+=(-DOPENSIM_DEPENDENCIES_DIR=~/opensim_dependencies_install) OSIM_CMAKE_ARGS+=(-DOPENSIM_C3D_PARSER=ezc3d) OSIM_CMAKE_ARGS+=(-DBUILD_PYTHON_WRAPPING=on -DBUILD_JAVA_WRAPPING=on) + OSIM_CMAKE_ARGS+=(-DSWIG_DIR=~/swig) OSIM_CMAKE_ARGS+=(-DOPENSIM_INSTALL_UNIX_FHS=OFF) OSIM_CMAKE_ARGS+=(-DOPENSIM_DOXYGEN_USE_MATHJAX=off) # TODO: Update to simbody.github.io/latest From fa40e72f27539fb23df43523cf599704e06df937 Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Thu, 8 Apr 2021 10:55:51 -0700 Subject: [PATCH 16/19] Update continuous_integration.yml SWIG_DIR on linux --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 7e748ce296..ebbf27f489 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -341,7 +341,7 @@ jobs: OSIM_CMAKE_ARGS+=(-DOPENSIM_DEPENDENCIES_DIR=~/opensim_dependencies_install) OSIM_CMAKE_ARGS+=(-DOPENSIM_C3D_PARSER=ezc3d) OSIM_CMAKE_ARGS+=(-DBUILD_PYTHON_WRAPPING=on -DBUILD_JAVA_WRAPPING=on) - OSIM_CMAKE_ARGS+=(-DSWIG_DIR=~/swig) + OSIM_CMAKE_ARGS+=(-DSWIG_DIR=~/swig/share/swig) OSIM_CMAKE_ARGS+=(-DOPENSIM_INSTALL_UNIX_FHS=OFF) OSIM_CMAKE_ARGS+=(-DOPENSIM_DOXYGEN_USE_MATHJAX=off) # TODO: Update to simbody.github.io/latest From 7e8ffc9395f4aca584ef8b567df3acf8fdd46c70 Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Thu, 8 Apr 2021 11:05:03 -0700 Subject: [PATCH 17/19] Update continuous_integration.yml swig4.0 on linux --- .github/workflows/continuous_integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index ebbf27f489..f512d0b178 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -342,6 +342,7 @@ jobs: OSIM_CMAKE_ARGS+=(-DOPENSIM_C3D_PARSER=ezc3d) OSIM_CMAKE_ARGS+=(-DBUILD_PYTHON_WRAPPING=on -DBUILD_JAVA_WRAPPING=on) OSIM_CMAKE_ARGS+=(-DSWIG_DIR=~/swig/share/swig) + OSIM_CMAKE_ARGS+=(-DSWIG_EXECUTABLE=~/swig/bin/swig) OSIM_CMAKE_ARGS+=(-DOPENSIM_INSTALL_UNIX_FHS=OFF) OSIM_CMAKE_ARGS+=(-DOPENSIM_DOXYGEN_USE_MATHJAX=off) # TODO: Update to simbody.github.io/latest From 2599b48de4c8248773f4190cae3bbf3c691fb923 Mon Sep 17 00:00:00 2001 From: aymanhab Date: Sat, 10 Apr 2021 01:56:33 -0700 Subject: [PATCH 18/19] Force python 3.7 in ci on windows, osx --- .github/workflows/continuous_integration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index f512d0b178..b3a962bc1a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -31,6 +31,9 @@ jobs: echo "$env:GITHUB_WORKSPACE\\doxygen" >> $GITHUB_PATH - name: Install Python packages + uses: actions/setup-python@v2 + with: + python-version: '3.7' # Need numpy to use SWIG numpy typemaps. run: python -m pip install numpy @@ -157,7 +160,7 @@ jobs: - name: Install Homebrew packages # Save the gfortran version to a file so we can use it in the cache key. run: | - brew install cmake pkgconfig autoconf libtool automake wget pcre doxygen + brew install cmake pkgconfig autoconf libtool automake wget pcre doxygen python@3.7 brew reinstall gcc pip3 install numpy gfortran -v From 4008c9a7869838dfda7ecc19fc11b3d9248daace Mon Sep 17 00:00:00 2001 From: Ayman Habib Date: Sat, 10 Apr 2021 02:41:58 -0700 Subject: [PATCH 19/19] Update continuous_integration.yml fix syntax --- .github/workflows/continuous_integration.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index b3a962bc1a..c8242285ed 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -34,7 +34,9 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.7' - # Need numpy to use SWIG numpy typemaps. + + - name: Install numpy + #Need numpy to use SWIG numpy typemaps. run: python -m pip install numpy - name: Install SWIG