Skip to content

Commit

Permalink
Fix SWIG wrapping of vehicle transmission classes
Browse files Browse the repository at this point in the history
(cherry picked from commit 5c7b0e0)
  • Loading branch information
rserban committed May 20, 2024
1 parent 525fc53 commit 9f8e44f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
7 changes: 3 additions & 4 deletions src/chrono_swig/interface/vehicle/ChEngine.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "chrono_vehicle/ChPowertrainAssembly.h" // Testing
%}

%include "chrono_vehicle/ChPart.h"
%include "chrono_vehicle/ChEngine.h"
// Include ChPowertrainAssembly - test
%include "chrono_vehicle/ChPowertrainAssembly.h"
%include "../../../chrono_vehicle/ChPart.h"
%include "../../../chrono_vehicle/ChEngine.h"
%include "../../../chrono_vehicle/ChPowertrainAssembly.h"
12 changes: 8 additions & 4 deletions src/chrono_swig/interface/vehicle/ChModuleVehicle.i
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ Before adding a shared_ptr, mark as shared ptr all its inheritance tree in the m
%shared_ptr(chrono::vehicle::ChEngineShafts)

%shared_ptr(chrono::vehicle::ChTransmission)
%shared_ptr(chrono::vehicle::ChAutomaticTransmission)
%shared_ptr(chrono::vehicle::ChManualTransmission)

// Expose for both python and csharp
%shared_ptr(chrono::vehicle::ChVehicleVisualSystem)
Expand Down Expand Up @@ -323,7 +321,7 @@ Before adding a shared_ptr, mark as shared ptr all its inheritance tree in the m
%template(ChAxleList) std::vector<std::shared_ptr<chrono::vehicle::ChAxle> > ;


#ifdef SWIGPYTHON
#ifdef SWIGPYTHON // --------------------------------------------------------------------- PYTHON

#ifdef CHRONO_IRRLICHT
#define ChApiIrr
Expand All @@ -332,7 +330,7 @@ Before adding a shared_ptr, mark as shared ptr all its inheritance tree in the m
%include "chrono_swig/interface/vehicle/ChVehicleVisualSystemIrrlicht.i"
#endif

#endif // ----- end PYTHON
#endif // ----------------------------------------------------------------- end PYTHON

// TODO:
//%include "rapidjson.i"
Expand Down Expand Up @@ -471,6 +469,12 @@ Before adding a shared_ptr, mark as shared ptr all its inheritance tree in the m
%DefSharedPtrDynamicCast(chrono::vehicle,ChTransmission, ChManualTransmissionShafts)
%DefSharedPtrDynamicCast(chrono::vehicle,ChTransmission, ManualTransmissionShafts)

%DefSharedPtrDynamicCast(chrono::vehicle, ChTransmission, ChAutomaticTransmission);
%DefSharedPtrDynamicCast(chrono::vehicle, ChAutomaticTransmission, ChAutomaticTransmissionSimpleMap);
%DefSharedPtrDynamicCast(chrono::vehicle, ChAutomaticTransmission, ChAutomaticTransmissionShafts);
%DefSharedPtrDynamicCast(chrono::vehicle, ChTransmission, ChManualTransmission);
%DefSharedPtrDynamicCast(chrono::vehicle, ChManualTransmission, ChManualTransmissionShafts);

%DefSharedPtrDynamicCast(chrono::vehicle,ChDriveline, ChDrivelineWV)
%DefSharedPtrDynamicCast(chrono::vehicle,ChDriveline, ChShaftsDriveline2WD)
%DefSharedPtrDynamicCast(chrono::vehicle,ChDriveline, ChShaftsDriveline4WD)
Expand Down
18 changes: 3 additions & 15 deletions src/chrono_swig/interface/vehicle/ChPowertrain.i
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "chrono_vehicle/powertrain/EngineSimpleMap.h"
#include "chrono_vehicle/powertrain/EngineShafts.h"

#include "chrono_vehicle/ChTransmission.h"

#include "chrono_vehicle/powertrain/ChAutomaticTransmissionSimpleMap.h"
#include "chrono_vehicle/powertrain/ChAutomaticTransmissionShafts.h"
#include "chrono_vehicle/powertrain/AutomaticTransmissionSimpleMap.h"
Expand All @@ -40,14 +42,6 @@
%shared_ptr(chrono::vehicle::EngineSimpleMap)
%shared_ptr(chrono::vehicle::EngineShafts)

%shared_ptr(chrono::vehicle::ChAutomaticTransmissionSimpleMap)
%shared_ptr(chrono::vehicle::ChAutomaticTransmissionShafts)
%shared_ptr(chrono::vehicle::AutomaticTransmissionSimpleMap)
%shared_ptr(chrono::vehicle::AutomaticTransmissionShafts)
%shared_ptr(chrono::vehicle::ChManualTransmissionShafts)
%shared_ptr(chrono::vehicle::ManualTransmissionShafts)


%import "../../../chrono_vehicle/ChPart.h"

#ifdef SWIGCSHARP
Expand All @@ -61,17 +55,11 @@
// Parse the header file to generate wrappers
%include "../../../chrono_vehicle/ChPowertrainAssembly.h"


%include "../../../chrono_vehicle/powertrain/ChEngineSimple.h"
%include "../../../chrono_vehicle/powertrain/ChEngineSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/ChEngineShafts.h"
%include "../../../chrono_vehicle/powertrain/EngineSimple.h"
%include "../../../chrono_vehicle/powertrain/EngineSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/EngineShafts.h"

%include "../../../chrono_vehicle/powertrain/ChAutomaticTransmissionSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/ChAutomaticTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/AutomaticTransmissionSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/AutomaticTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/ChManualTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/ManualTransmissionShafts.h"

30 changes: 23 additions & 7 deletions src/chrono_swig/interface/vehicle/ChTransmission.i
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@

%csmethodmodifiers chrono::vehicle::ChTransmission::GetType "public virtual new"

#endif // --------------------------------------------------------------------- CSHARP

#endif // ----------------------------------------------------------------- end CSHARP

%{
#include "chrono_vehicle/ChPart.h"
#include "chrono_vehicle/ChTransmission.h"
//#include "chrono_vehicle/ChPowertrainAssembly.h" // Included for testing
#include "chrono_vehicle/powertrain/ChAutomaticTransmissionSimpleMap.h"
#include "chrono_vehicle/powertrain/AutomaticTransmissionSimpleMap.h"
#include "chrono_vehicle/powertrain/ChAutomaticTransmissionShafts.h"
#include "chrono_vehicle/powertrain/AutomaticTransmissionShafts.h"
#include "chrono_vehicle/powertrain/ChManualTransmissionShafts.h"
#include "chrono_vehicle/powertrain/ManualTransmissionShafts.h"
%}

%shared_ptr(chrono::vehicle::ChAutomaticTransmission)
%shared_ptr(chrono::vehicle::ChManualTransmission)
%shared_ptr(chrono::vehicle::ChAutomaticTransmissionSimpleMap)
%shared_ptr(chrono::vehicle::AutomaticTransmissionSimpleMap)
%shared_ptr(chrono::vehicle::ChAutomaticTransmissionShafts)
%shared_ptr(chrono::vehicle::AutomaticTransmissionShafts)
%shared_ptr(chrono::vehicle::ChManualTransmissionShafts)
%shared_ptr(chrono::vehicle::ManualTransmissionShafts)

%include "chrono_vehicle/ChPart.h"
%include "chrono_vehicle/ChTransmission.h"
// Include ChPowertrainAssembly if necessary
//%include "chrono_vehicle/ChPowertrainAssembly.h"
%include "../../../chrono_vehicle/ChPart.h"
%include "../../../chrono_vehicle/ChTransmission.h"
%include "../../../chrono_vehicle/powertrain/ChAutomaticTransmissionSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/AutomaticTransmissionSimpleMap.h"
%include "../../../chrono_vehicle/powertrain/ChAutomaticTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/AutomaticTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/ChManualTransmissionShafts.h"
%include "../../../chrono_vehicle/powertrain/ManualTransmissionShafts.h"

0 comments on commit 9f8e44f

Please sign in to comment.