Skip to content

Commit 285d14a

Browse files
authored
Merge pull request #61 from pariterre/CInterfaceSavior
CInterfaceSavior
2 parents 45f496a + 55f3249 commit 285d14a

File tree

11 files changed

+100
-60
lines changed

11 files changed

+100
-60
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ script:
6060
- cd build
6161
# Perform tests on all platform, but only perform code coverage on Linux
6262
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
63-
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=/c/tools/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLE=OFF -DMODULE_ACTUATORS=ON -DMODULE_MUSCLES=ON -DBINDER_PYTHON3=ON -DBINDER_C=ON ..;
63+
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=/c/tools/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLE=ON -DMODULE_ACTUATORS=ON -DMODULE_MUSCLES=ON -DBINDER_PYTHON3=ON -DBINDER_C=ON ..;
6464
cmake --build ./ --config Release;
6565
else
6666
cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=$HOME/miniconda/ -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLE=ON -DMODULE_ACTUATORS=ON -DMODULE_MUSCLES=ON -DBINDER_C=ON ..;
@@ -72,13 +72,14 @@ script:
7272
cd test\\Release;
7373
xcopy ..\\models .\\models\\;
7474
xcopy ..\\models\\meshFiles .\\models\\meshFiles\\;
75-
xcopy ..\\binding\\c\\Release\\biorbd_tests_binding_c.exe;
7675
./biorbd_tests.exe;
7776
else
7877
cd test;
7978
./biorbd_tests;
8079
fi
8180
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
81+
xcopy ..\\binding\\c\\Release\\biorbd_tests_binding_c.exe;
82+
xcopy ..\\..\\binding\\c\\Release\\*.dll;
8283
./biorbd_tests_binding_c.exe;
8384
else
8485
cd binding/c;

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ set (CMAKE_CXX_STANDARD 11)
55
# Set some variables
66
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/modules)
77

8-
# Set a default build type to 'Release' if none was specified
8+
# Because of Eigen, it is not possible to compile biorbd as a dynamic library
99
if (WIN32)
10-
SET(BUILD_SHARED_LIBS FALSE CACHE BOOL "Choose if the static library should be build" FORCE)
10+
SET(BUILD_SHARED_LIBS FALSE CACHE BOOL "Choose if the dynamic library should be build" FORCE)
1111
else()
12-
SET(BUILD_SHARED_LIBS TRUE CACHE BOOL "Choose if the static library should be build" FORCE)
12+
SET(BUILD_SHARED_LIBS TRUE CACHE BOOL "Choose if the dynamic library should be build")
1313
endif()
14+
# Set a default build type to 'Release' if none was specified
1415
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1516
MESSAGE(STATUS "Setting build type to 'Release' as none was specified.")
16-
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
17+
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
1718
# Set the possible values of build type for cmake-gui
1819
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
1920
ENDIF()

binding/c/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ cmake_minimum_required(VERSION 3.8)
55

66
set(C_BINDING_PATH ${CMAKE_SOURCE_DIR}/binding/c)
77

8+
SET(BUILD_SHARED_LIBS_C TRUE CACHE BOOL "Choose if the static library should be build")
9+
810
# Get the file to compile
911
set(C_FILE ${C_BINDING_PATH}/${MASTER_PROJECT_NAME}_c.cpp)
10-
if (BUILD_SHARED_LIBS)
12+
if (BUILD_SHARED_LIBS_C)
1113
add_library(${PROJECT_NAME} SHARED ${C_FILE})
1214
else()
1315
add_library(${PROJECT_NAME} STATIC ${C_FILE})

binding/c/biorbd_c.h

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
#include "BiorbdModel.h"
66
#include "biorbdConfig.h"
7+
#ifdef _WIN32
8+
#define BIORBD_API_C __declspec(dllexport)
9+
#else
10+
#define BIORBD_API_C
11+
#endif
712

813
namespace biorbd {
914
namespace rigidbody {
@@ -15,63 +20,63 @@ class KalmanReconsIMU;
1520
}
1621
extern "C" {
1722
// Create a pointer on a model
18-
BIORBD_API biorbd::Model* c_biorbdModel(
23+
BIORBD_API_C biorbd::Model* c_biorbdModel(
1924
const char* pathToModel);
20-
BIORBD_API void c_deleteBiorbdModel(
25+
BIORBD_API_C void c_deleteBiorbdModel(
2126
biorbd::Model*);
22-
BIORBD_API void c_writeBiorbdModel(
27+
BIORBD_API_C void c_writeBiorbdModel(
2328
biorbd::Model*, const char * path);
2429

2530

2631
// Joints functions
27-
BIORBD_API void c_boneRotationSequence( // Return the angle sequence of a bone named segName
32+
BIORBD_API_C void c_boneRotationSequence( // Return the angle sequence of a bone named segName
2833
biorbd::Model* m,
2934
const char* segName,
3035
char* seq);
31-
BIORBD_API void c_localJCS( // Return the LCS for segment of index i in parent coordinate system
36+
BIORBD_API_C void c_localJCS( // Return the LCS for segment of index i in parent coordinate system
3237
biorbd::Model* m,
3338
int i,
3439
double* RtOut);
35-
BIORBD_API void c_globalJCS(
40+
BIORBD_API_C void c_globalJCS(
3641
biorbd::Model*,
3742
const double* Q,
3843
double* jcs);
39-
BIORBD_API void c_inverseDynamics(
44+
BIORBD_API_C void c_inverseDynamics(
4045
biorbd::Model* model,
4146
const double* q,
4247
const double* qdot,
4348
const double* qddot,
4449
double* tau);
45-
BIORBD_API void c_massMatrix(
50+
BIORBD_API_C void c_massMatrix(
4651
biorbd::Model* model,
4752
const double* q,
4853
double* massMatrix);
4954

5055

5156
// dof functions
52-
BIORBD_API int c_nQ(
57+
BIORBD_API_C int c_nQ(
5358
biorbd::Model* model);
54-
BIORBD_API int c_nQDot(
59+
BIORBD_API_C int c_nQDot(
5560
biorbd::Model* model);
56-
BIORBD_API int c_nQDDot(
61+
BIORBD_API_C int c_nQDDot(
5762
biorbd::Model* model);
58-
BIORBD_API int c_nGeneralizedTorque(
63+
BIORBD_API_C int c_nGeneralizedTorque(
5964
biorbd::Model* model);
6065

6166

6267
// Markers functions
63-
BIORBD_API int c_nMarkers(
68+
BIORBD_API_C int c_nMarkers(
6469
biorbd::Model* model);
65-
BIORBD_API void c_markersInLocal(
70+
BIORBD_API_C void c_markersInLocal(
6671
biorbd::Model* model,
6772
double* markPos);
68-
BIORBD_API void c_markers(
73+
BIORBD_API_C void c_markers(
6974
biorbd::Model* model,
7075
const double* Q,
7176
double* markPos,
7277
bool removeAxis = true,
7378
bool updateKin = true);
74-
BIORBD_API void c_addMarker(
79+
BIORBD_API_C void c_addMarker(
7580
biorbd::Model *model,
7681
const double *markPos,
7782
const char* name = "",
@@ -81,9 +86,9 @@ extern "C" {
8186
const char* axesToRemove = "");
8287

8388
// IMUs functions
84-
BIORBD_API int c_nIMUs(
89+
BIORBD_API_C int c_nIMUs(
8590
biorbd::Model*);
86-
BIORBD_API void c_addIMU(
91+
BIORBD_API_C void c_addIMU(
8792
biorbd::Model *model,
8893
const double *imuRT,
8994
const char* name = "",
@@ -93,15 +98,15 @@ extern "C" {
9398

9499
// Kalman IMU
95100
#ifndef SKIP_KALMAN
96-
BIORBD_API biorbd::rigidbody::KalmanReconsIMU* c_BiorbdKalmanReconsIMU(
101+
BIORBD_API_C biorbd::rigidbody::KalmanReconsIMU* c_BiorbdKalmanReconsIMU(
97102
biorbd::Model*,
98103
double* QinitialGuess = nullptr,
99104
double freq = 100,
100105
double noiseF = 5e-3,
101106
double errorF = 1e-10);
102-
BIORBD_API void c_deleteBiorbdKalmanReconsIMU(
107+
BIORBD_API_C void c_deleteBiorbdKalmanReconsIMU(
103108
biorbd::rigidbody::KalmanReconsIMU*);
104-
BIORBD_API void c_BiorbdKalmanReconsIMUstep(
109+
BIORBD_API_C void c_BiorbdKalmanReconsIMUstep(
105110
biorbd::Model*,
106111
biorbd::rigidbody::KalmanReconsIMU*,
107112
double* imu,
@@ -111,19 +116,19 @@ extern "C" {
111116
#endif
112117

113118
// Math functions
114-
BIORBD_API void c_matrixMultiplication(
119+
BIORBD_API_C void c_matrixMultiplication(
115120
const double* M1,
116121
const double* M2,
117122
double* Mout);
118-
BIORBD_API void c_meanRT(
123+
BIORBD_API_C void c_meanRT(
119124
const double *imuRT,
120125
unsigned int nFrame,
121126
double* imuRT_mean);
122-
BIORBD_API void c_projectJCSinParentBaseCoordinate(
127+
BIORBD_API_C void c_projectJCSinParentBaseCoordinate(
123128
const double* parent,
124129
const double* jcs,
125130
double * out);
126-
BIORBD_API void c_transformMatrixToCardan(
131+
BIORBD_API_C void c_transformMatrixToCardan(
127132
const double* M,
128133
const char* sequence,
129134
double* cardanOut);

include/ModelReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BIORBD_API Reader
3838
std::vector<std::vector<biorbd::utils::Node3d>> &force, // Linear forces (x,y,z)
3939
std::vector<std::vector<biorbd::utils::Node3d>> &moment, // Moments (x,y,z)
4040
std::vector<std::vector<biorbd::utils::Node3d>> &cop); // Center of pressure (x,y,z)
41-
static std::vector<std::vector<RigidBodyDynamics::Math::SpatialVector>> readViconForceFile(const biorbd::utils::String &path);
41+
static std::vector<std::vector<RigidBodyDynamics::Math::SpatialVector>> readViconForceFile(const utils::Path &path);
4242
// Read a marker file CSV formated
4343
static std::vector<std::vector<biorbd::utils::Node3d>> readViconMarkerFile(
4444
const biorbd::utils::Path &path,

src/Actuators/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ set(SRC_LIST_MODULE
1313
)
1414

1515
# Create the library
16-
if (BUILD_SHARED_LIBS)
17-
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
18-
else()
16+
if (WIN32)
1917
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
18+
else()
19+
if (BUILD_SHARED_LIBS)
20+
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
21+
else()
22+
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
23+
endif()
2024
endif()
2125

2226
# Add the dependencies for insuring build order

src/ModelReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,9 @@ void biorbd::Reader::readViconForceFile(
11961196
}
11971197
}
11981198

1199-
std::vector<std::vector<RigidBodyDynamics::Math::SpatialVector>> biorbd::Reader::readViconForceFile(const biorbd::utils::String &path){
1199+
std::vector<std::vector<RigidBodyDynamics::Math::SpatialVector>>
1200+
biorbd::Reader::readViconForceFile(
1201+
const biorbd::utils::Path &path) {
12001202
// Lire le fichier
12011203
std::vector<std::vector<unsigned int>> frame;
12021204
std::vector<unsigned int> frequency;// Acquisition frequency

src/Muscles/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ if (NOT SKIP_STATIC_OPTIM)
4141
endif()
4242

4343
# Create the library
44-
if (BUILD_SHARED_LIBS)
45-
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
46-
else()
44+
if (WIN32)
4745
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
46+
else()
47+
if (BUILD_SHARED_LIBS)
48+
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
49+
else()
50+
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
51+
endif()
4852
endif()
4953

5054
# Add the dependencies for insuring build order

src/RigidBody/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ if (NOT SKIP_KALMAN)
2727
endif()
2828

2929
# Create the library
30-
if (BUILD_SHARED_LIBS)
31-
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
32-
else()
30+
if (WIN32)
3331
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
32+
else()
33+
if (BUILD_SHARED_LIBS)
34+
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
35+
else()
36+
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
37+
endif()
3438
endif()
3539

3640
# Add the dependencies for insuring build order

src/Utils/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ set(SRC_LIST_MODULE
2222
)
2323

2424
# Create the library
25-
if (BUILD_SHARED_LIBS)
26-
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
27-
else()
25+
if (WIN32)
2826
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
27+
else()
28+
if (BUILD_SHARED_LIBS)
29+
add_library(${PROJECT_NAME} SHARED ${SRC_LIST_MODULE})
30+
else()
31+
add_library(${PROJECT_NAME} STATIC ${SRC_LIST_MODULE})
32+
endif()
2933
endif()
3034

3135
# Add the include

0 commit comments

Comments
 (0)