├── CMake └── FindQt5_ROOT_PATH.cmake ├── CMakeLists.txt ├── Code ├── CMakeLists.txt ├── btkBase │ ├── btkNode_pyq.cpp │ ├── btkNode_pyq.h │ └── btk_python_init_btkBase.cpp ├── btkIO │ └── btk_python_init_btkIO.cpp ├── btkModel │ └── btk_python_init_btkModel.cpp ├── btkPythonBinding.cpp ├── btkPythonModule.cpp └── btkTrial │ └── btk_python_init_btkTrial.cpp ├── LICENSE ├── README.md ├── Testing ├── Base │ └── NodeTest.py ├── CMakeLists.txt ├── _TDD.py.in ├── _TDDBase.py └── _TDDConfigure.py.in └── btkPythonBinding.h /CMake/FindQt5_ROOT_PATH.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Qt5 2 | # Once done this will define 3 | # 4 | # Qt5_ROOT_PATH: Root path for the CMake folder included in Qt5 5 | # Qt5_CMAKE_PATH: Root path for the CMake folder included in Qt5 6 | # Qt5_FOUND: Simple flag to indicate if Qt5 was found or not 7 | # 8 | # Note: This only attempt to add the path in the variable CMAKE_PREFIX_PATH 9 | # to be able to use after the CMake scripts provided by Qt5. 10 | # 11 | # Copyright (c) 2009-2013 Arnaud Barré 12 | # Redistribution and use is allowed according to the terms of the BSD license. 13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file 14 | 15 | IF(Qt5_ROOT_PATH) 16 | # In cache already 17 | SET(Qt5_FIND_QUIETLY TRUE) 18 | ENDIF(Qt5_ROOT_PATH) 19 | 20 | IF(APPLE) 21 | FILE(GLOB Qt5_PATHS_A "/Developer/Qt5*") 22 | FILE(GLOB Qt5_PATHS_B "/Developer/Qt/5*") 23 | FILE(GLOB Qt5_PATHS_C "$ENV{HOME}/Qt/5*") 24 | FILE(GLOB Qt5_PATHS_D "$ENV{HOME}/Developer/Qt/5*") 25 | SET(Qt_PATH_SUFFIXES "clang_64") 26 | SET(Qt_QMAKE "qmake") 27 | ELSEIF(WIN32) 28 | FILE(GLOB Qt5_PATHS_A "C:/Qt/Qt5*/*") 29 | SET(Qt_PATH_SUFFIXES "msvc2010_opengl") 30 | SET(Qt_QMAKE "qmake.exe") 31 | ENDIF(APPLE) 32 | 33 | FIND_PATH(Qt5_ROOT_PATH NAMES bin/${Qt_QMAKE} 34 | PATH_SUFFIXES ${Qt_PATH_SUFFIXES} 35 | NO_DEFAULT_PATH 36 | HINTS 37 | ${Qt5_PATHS_A} 38 | ${Qt5_PATHS_B} 39 | ${Qt5_PATHS_C} 40 | ${Qt5_PATHS_D} 41 | ) 42 | 43 | IF(Qt5_ROOT_PATH) 44 | SET(Qt5_FOUND 1) 45 | ENDIF(Qt5_ROOT_PATH) 46 | 47 | SET (Qt5_CMAKE_PATH "${Qt5_ROOT_PATH}/lib/cmake") 48 | INCLUDE(FindPackageHandleStandardArgs) 49 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt5 DEFAULT_MSG Qt5_ROOT_PATH) 50 | 51 | LIST(FIND CMAKE_PREFIX_PATH ${Qt5_CMAKE_PATH} _Qt5_PATH_INDEX) 52 | IF(_Qt5_PATH_INDEX EQUAL -1) 53 | SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${Qt5_CMAKE_PATH}) 54 | ENDIF(_Qt5_PATH_INDEX EQUAL -1) 55 | MARK_AS_ADVANCED(Qt5_ROOT_PATH CMAKE_PREFIX_PATH) -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) 2 | 3 | # BTKPython: Python binding for the C++ library Biomechanical ToolKit 4 | PROJECT(BTKPython) 5 | 6 | # BTKPython version number. 7 | SET(BTKPython_VERSION_MAJOR 1) 8 | SET(BTKPython_VERSION_MINOR 0) 9 | SET(BTKPython_VERSION_PATCH 0) 10 | SET(BTKPython_VERSION "${BTKPython_VERSION_MAJOR}.${BTKPython_VERSION_MINOR}.${BTKPython_VERSION_PATCH}") 11 | SET(BTKPython_VERSION_STRING ${BTKPython_VERSION}) 12 | # The major.minor is enough to distinguish available features of the toolkit. Moreover, 13 | # this variable is used to create lib/share/include folders where the patch number does 14 | # not need to be included. 15 | SET(BTKPython_LIBRARY_VERSION_STRING "${BTKPython_VERSION_MAJOR}.${BTKPython_VERSION_MINOR}") 16 | 17 | # ------------------------------------------------------------------------ 18 | # CMAKE GENERAL CONFIGURATION 19 | # ------------------------------------------------------------------------ 20 | 21 | SET(CMAKE_INCLUDE_CURRENT_DIR ON) 22 | SET(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) 23 | SET(CMAKE_CXX_STANDARD 11) 24 | SET(CMAKE_CXX_STANDARD_REQUIRED ON) 25 | 26 | IF((CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) 27 | SET(CMAKE_CXX_FLAGS "-stdlib=libc++") 28 | # CMake 3.1 complains it does not know how to set the compile flag to enable C++11 with (Apple) Clang 29 | SET(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") 30 | SET(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") 31 | ELSEIF((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND MSVC) 32 | # CMake 3.1 complains it does not know how to set the compile flag to enable C++11 with MSVC 33 | SET(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") 34 | SET(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "") 35 | # CXX Flag details 36 | # - EHsc: enable exception handling for C++ object 37 | # - D_SCL_SECURE_NO_WARNINGS: disable function call with unsafe parameters warning 38 | SET(CMAKE_CXX_FLAGS "/EHsc -D_SCL_SECURE_NO_WARNINGS") 39 | ENDIF() 40 | 41 | SET(BTKPython_CMAKE_MODULE_PATH "${BTKPython_SOURCE_DIR}/CMake") 42 | SET(CMAKE_MODULE_PATH "${BTKPython_CMAKE_MODULE_PATH}") 43 | 44 | # ------------------------------------------------------------------------ 45 | # COMPILATION INSTRUCTIONS 46 | # ------------------------------------------------------------------------ 47 | 48 | # Using the configuration "Always full RPATH" 49 | # from http://www.cmake.org/Wiki/CMake_RPATH_handling 50 | # -------------------------- 51 | # use, i.e. don't skip the full RPATH for the build tree 52 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) 53 | # when building, don't use the install RPATH already 54 | # (but later on when installing) 55 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 56 | # the RPATH to be used when installing 57 | SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/btk-${BTKPython_LIBRARY_VERSION_STRING}") 58 | # add the automatically determined parts of the RPATH 59 | # which point to directories outside the build tree to the install RPATH 60 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 61 | 62 | # Output directories. 63 | SET(LIBRARY_OUTPUT_PATH ${BTKPython_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.") 64 | SET(BTKPython_LIBRARY_PATH "${LIBRARY_OUTPUT_PATH}") 65 | SET(EXECUTABLE_OUTPUT_PATH ${BTKPython_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.") 66 | SET(BTKPython_EXECUTABLE_PATH "${EXECUTABLE_OUTPUT_PATH}") 67 | 68 | # Load some CMake macros. 69 | INCLUDE(GenerateExportHeader) 70 | INCLUDE(CMakePackageConfigHelpers) 71 | 72 | # By default BTK is compiled in Release mode 73 | IF(NOT CMAKE_BUILD_TYPE) 74 | MESSAGE(STATUS "Setting build type to 'Release' as none was specified.") 75 | SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) 76 | # Set the possible values of build type for cmake-gui 77 | SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 78 | ENDIF() 79 | 80 | # BTK build configuration option (SHARED by default). 81 | OPTION(BUILD_SHARED_LIBS "Build BTK with shared libraries." ON) 82 | SET(BTKPython_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) 83 | IF(WIN32) 84 | IF(BUILD_SHARED_LIBS) 85 | SET(BTKPython_LIBS_BUILD_TYPE "SHARED") 86 | ELSE(BUILD_SHARED_LIBS) 87 | SET(BTKPython_LIBS_BUILD_TYPE "STATIC") 88 | ENDIF(BUILD_SHARED_LIBS) 89 | ENDIF() 90 | 91 | IF(WIN32) 92 | SET(BTKPython_LIBRARY_PREFIX "btk") 93 | ELSE() 94 | SET(BTKPython_LIBRARY_PREFIX "libbtk") 95 | ENDIF() 96 | SET(BTKPython_LIBRARY_PROPERTIES 97 | VERSION "${BTKPython_VERSION_MAJOR}.${BTKPython_VERSION_MINOR}.${BTKPython_VERSION_PATCH}" 98 | SOVERSION "${BTKPython_VERSION_MAJOR}.${BTKPython_VERSION_MINOR}" 99 | PREFIX "${BTKPython_LIBRARY_PREFIX}" 100 | DEBUG_POSTFIX _debug) 101 | 102 | # ------------------------------------------------------------------------ 103 | # PROJECT'S SUBDIRECTORIES 104 | # ------------------------------------------------------------------------ 105 | 106 | # Code 107 | ADD_SUBDIRECTORY(Code) 108 | 109 | # TDD (Test-driven development) code 110 | OPTION(BUILD_TESTING "Build BTK unit and regression tests." OFF) 111 | IF(BUILD_TESTING) 112 | ENABLE_TESTING() 113 | ADD_SUBDIRECTORY(Testing) 114 | ENDIF(BUILD_TESTING) -------------------------------------------------------------------------------- /Code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(CMAKE_AUTOMOC ON) 2 | SET(CMAKE_INCLUDE_CURRENT_DIR ON) 3 | 4 | FIND_PACKAGE(BTK REQUIRED) 5 | FIND_PACKAGE(PythonLibs REQUIRED) 6 | FIND_PACKAGE(PythonQt REQUIRED) 7 | FIND_PACKAGE(Qt5_ROOT_PATH REQUIRED) 8 | FIND_PACKAGE(Qt5 5.4 COMPONENTS Core REQUIRED) 9 | 10 | # --------------------------------------------------------------------------- # 11 | # Library 12 | # --------------------------------------------------------------------------- # 13 | 14 | INCLUDE_DIRECTORIES( 15 | ${PYTHON_INCLUDE_PATH} 16 | ${PythonQt_INCLUDE_DIRS} 17 | ) 18 | 19 | SET(btkPythonBinding_SRCS 20 | btkPythonBinding.cpp 21 | # btkBase 22 | btkBase/btk_python_init_btkBase.cpp 23 | btkBase/btkNode_pyq.cpp 24 | # btkIO 25 | btkIO/btk_python_init_btkIO.cpp 26 | # btkModel 27 | btkModel/btk_python_init_btkModel.cpp 28 | # btkTrial 29 | btkTrial/btk_python_init_btkTrial.cpp 30 | ) 31 | 32 | ADD_LIBRARY(Python SHARED ${btkPythonBinding_SRCS}) 33 | 34 | TARGET_INCLUDE_DIRECTORIES(Python PUBLIC 35 | $ 36 | $ 37 | $ 38 | $ 39 | $ 40 | # $ # FIXME : Installation path? 41 | ) 42 | 43 | GENERATE_EXPORT_HEADER(Python 44 | BASE_NAME BTK_PYTHON 45 | EXPORT_FILE_NAME btkPythonExport.h) 46 | 47 | SET_TARGET_PROPERTIES(Python PROPERTIES ${BTKPython_LIBRARY_PROPERTIES}) 48 | IF (NOT ${BTKPython_BUILD_SHARED_LIBS}) 49 | SET_TARGET_PROPERTIES(Python PROPERTIES COMPILE_FLAGS -DBTK_PYTHON_STATIC_DEFINE) 50 | ENDIF() 51 | 52 | TARGET_LINK_LIBRARIES(Python BTK::Base Qt5::Core ${PythonQt_LIBRARIES}) 53 | 54 | # --------------------------------------------------------------------------- # 55 | # Module 56 | # --------------------------------------------------------------------------- # 57 | 58 | SET(btkPythonModule_SRCS 59 | btkPythonModule.cpp 60 | ) 61 | 62 | ADD_LIBRARY(_btk MODULE ${btkPythonModule_SRCS}) 63 | SET_TARGET_PROPERTIES(_btk PROPERTIES 64 | LINKER_LANGUAGE C 65 | PREFIX "") 66 | 67 | TARGET_LINK_LIBRARIES(_btk Python) -------------------------------------------------------------------------------- /Code/btkBase/btkNode_pyq.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "btkNode_pyq.h" 37 | 38 | PythonQtShell_btkNode::PythonQtShell_btkNode(const QString& name, btkNode* parent) 39 | : btkNode(name.toStdString(),parent), _wrapper(nullptr) 40 | {}; 41 | 42 | PythonQtShell_btkNode::~PythonQtShell_btkNode() 43 | { 44 | PythonQtPrivate* priv = PythonQt::priv(); 45 | if (priv) 46 | priv->shellClassDeleted(this); 47 | }; 48 | 49 | // -------------------------------------------------------------------------- // 50 | 51 | btkNode* PythonQtWrapper_btkNode::new_btkNode(const QString& name, btkNode* parent) 52 | { 53 | return new PythonQtShell_btkNode(name,parent); 54 | }; 55 | 56 | void PythonQtWrapper_btkNode::delete_btkNode(btkNode* obj) 57 | { 58 | delete obj; 59 | }; 60 | 61 | QString PythonQtWrapper_btkNode::name(btkNode* obj) const 62 | { 63 | return QString::fromStdString(obj->name()); 64 | }; -------------------------------------------------------------------------------- /Code/btkBase/btkNode_pyq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #ifndef __btkNode_pyq_h 37 | #define __btkNode_pyq_h 38 | 39 | #include "btkNode.h" 40 | 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | using btkNode = btk::Node; 47 | 48 | class PythonQtShell_btkNode : public btkNode 49 | { 50 | public: 51 | PythonQtShell_btkNode(const QString& name, btkNode* parent); 52 | ~PythonQtShell_btkNode(); 53 | 54 | PythonQtInstanceWrapper* _wrapper; 55 | }; 56 | 57 | class PythonQtWrapper_btkNode : public QObject 58 | { 59 | Q_OBJECT 60 | 61 | public slots: 62 | btkNode* new_btkNode(const QString& name, btkNode* parent = nullptr); 63 | void delete_btkNode(btkNode* obj); 64 | 65 | QString name(btkNode* obj) const; 66 | }; 67 | 68 | #endif // __btkNode_pyq_h -------------------------------------------------------------------------------- /Code/btkBase/btk_python_init_btkBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include 37 | 38 | #include "btkNode_pyq.h" 39 | 40 | void btk_python_init_btkBase() 41 | { 42 | PythonQt::priv()->registerCPPClass("btkNode", "", "btkBase", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, 0, 0); 43 | }; -------------------------------------------------------------------------------- /Code/btkIO/btk_python_init_btkIO.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | void btk_python_init_btkIO() 37 | { 38 | 39 | }; -------------------------------------------------------------------------------- /Code/btkModel/btk_python_init_btkModel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | void btk_python_init_btkModel() 37 | { 38 | 39 | }; -------------------------------------------------------------------------------- /Code/btkPythonBinding.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "btkPythonBinding.h" 37 | 38 | void btk_python_init_btkBase(); 39 | void btk_python_init_btkIO(); 40 | void btk_python_init_btkModel(); 41 | void btk_python_init_btkTrial(); 42 | 43 | void btk_python_binding_init() 44 | { 45 | btk_python_init_btkBase(); 46 | btk_python_init_btkIO(); 47 | btk_python_init_btkModel(); 48 | btk_python_init_btkTrial(); 49 | }; -------------------------------------------------------------------------------- /Code/btkPythonModule.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "btkPythonBinding.h" 37 | 38 | #include 39 | 40 | PyMODINIT_FUNC init_btk(void) 41 | { 42 | PythonQt::init(PythonQt::PythonAlreadyInitialized,"_btk"); 43 | btk_python_binding_init(); 44 | } -------------------------------------------------------------------------------- /Code/btkTrial/btk_python_init_btkTrial.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | void btk_python_init_btkTrial() 37 | { 38 | 39 | }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Biomechanical ToolKit 2 | Copyright (c) 2009-2015, Arnaud Barré 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | * Redistributions of source code must retain the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials 15 | provided with the distribution. 16 | * Neither the name(s) of the copyright holders nor the names 17 | of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written 19 | permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #BTKPython# 2 | 3 | ##Introduction## 4 | 5 | This is the [Python](http://www.python.org) binding for the C++ library [Biomechanical ToolKit](https://github.com/Biomechanical-ToolKit/BTKCore/). 6 | 7 | This project is split in two parts: 8 | - A shared library containing all the C++ wrapped objects; 9 | - A Python module using the shared library. 10 | 11 | The latter can be used directly in a Python interpreter, while the goal of the former is to be used within a standalone application offering a PythonQt-based console to interact with `btk*` objects. 12 | 13 | Internally, the binding is managed by [PythonQt](http://pythonqt.sourceforge.net). 14 | 15 | ##License## 16 | 17 | BTK use the generous open-source New BSD license. Yes, you can use BTK in commercial products. The complete text of the copyright is presented below: 18 | 19 | ``` 20 | The Biomechanical ToolKit 21 | Copyright (c) 2009-2015, Arnaud Barré 22 | All rights reserved. 23 | 24 | Redistribution and use in source and binary forms, with or without 25 | modification, are permitted provided that the following conditions 26 | are met: 27 | 28 | * Redistributions of source code must retain the above 29 | copyright notice, this list of conditions and the following 30 | disclaimer. 31 | * Redistributions in binary form must reproduce the above 32 | copyright notice, this list of conditions and the following 33 | disclaimer in the documentation and/or other materials 34 | provided with the distribution. 35 | * Neither the name(s) of the copyright holders nor the names 36 | of its contributors may be used to endorse or promote products 37 | derived from this software without specific prior written 38 | permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 43 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 44 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 45 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 46 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 48 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 50 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 51 | POSSIBILITY OF SUCH DAMAGE. 52 | ``` 53 | -------------------------------------------------------------------------------- /Testing/Base/NodeTest.py: -------------------------------------------------------------------------------- 1 | from _btk import btkBase 2 | import unittest 3 | 4 | class NodeTest(unittest.TestCase): 5 | def test_Constructor(self): 6 | test = btkBase.btkNode('test') 7 | self.assertEqual(test.name(), 'test') -------------------------------------------------------------------------------- /Testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(PythonInterp REQUIRED) 2 | 3 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/_TDD.py.in ${BTKPython_EXECUTABLE_PATH}/TDD.py) 4 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/_TDDConfigure.py.in ${CMAKE_CURRENT_BINARY_DIR}/_TDDConfigure.py) 5 | 6 | ADD_TEST(NAME "TDD_Python" WORKING_DIRECTORY ${BTKPython_EXECUTABLE_PATH} COMMAND ${PYTHON_EXECUTABLE} "TDD.py") -------------------------------------------------------------------------------- /Testing/_TDD.py.in: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import unittest 4 | 5 | def import_module(path, recursive=False): 6 | sys.path.append(path) 7 | if recursive: 8 | directory = os.listdir(path) 9 | for filename in directory: 10 | f = path+os.sep+filename 11 | if os.path.isdir(f): 12 | import_module(f,recursive) 13 | 14 | def clean_pyc(path): 15 | directory = os.listdir(path) 16 | for filename in directory: 17 | f = path+os.sep+filename 18 | if filename[-3:] == 'pyc': 19 | os.remove(f) 20 | elif os.path.isdir(f): 21 | clean_pyc(f) 22 | 23 | import_module('${BTKPython_BINARY_DIR}/Testing') # _TDDConfigure.py 24 | import_module('${BTKPython_SOURCE_DIR}/Testing', True) # All of the unit tests 25 | 26 | import _TDDBase 27 | 28 | if __name__ == '__main__': 29 | out = True 30 | result = unittest.TextTestRunner().run(_TDDBase.suite()) 31 | out &= result.wasSuccessful() 32 | # result = unittest.TextTestRunner().run(_TDDIO.suite()) 33 | # out &= result.wasSuccessful() 34 | clean_pyc('${BTKPython_SOURCE_DIR}/Testing') 35 | if out: 36 | sys.exit(0) 37 | else: 38 | sys.exit(1) -------------------------------------------------------------------------------- /Testing/_TDDBase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import NodeTest 4 | 5 | def suite(): 6 | suite = unittest.TestSuite() 7 | suite.addTest(unittest.makeSuite(NodeTest.NodeTest)) 8 | return suite -------------------------------------------------------------------------------- /Testing/_TDDConfigure.py.in: -------------------------------------------------------------------------------- 1 | TDD_FilePathIN = '${BTK_TESTING_DATA_PATH}/Input/' 2 | TDD_FilePathOUT = '${BTK_BINARY_DIR}/Testing/Data/Output/' -------------------------------------------------------------------------------- /btkPythonBinding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Biomechanical ToolKit 3 | * Copyright (c) 2009-2015, Arnaud Barré 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials 16 | * provided with the distribution. 17 | * * Neither the name(s) of the copyright holders nor the names 18 | * of its contributors may be used to endorse or promote products 19 | * derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #ifndef __btkPythonBinding_h 37 | #define __btkPythonBinding_h 38 | 39 | #include "btkPythonExport.h" 40 | 41 | BTK_PYTHON_EXPORT void btk_python_binding_init(); 42 | 43 | #endif // __btkPythonBinding_h --------------------------------------------------------------------------------