Skip to content

Commit

Permalink
core: Move sources from bindings to core part
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Nov 8, 2024
1 parent cfe610d commit 750bd0e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
37 changes: 5 additions & 32 deletions include/pinocchio/bindings/python/parsers/python.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,12 @@
#ifndef __pinocchio_python_parser_python_hpp__
#define __pinocchio_python_parser_python_hpp__

#include "pinocchio/multibody/model.hpp"
#include "pinocchio/macros.hpp"

#include <boost/python.hpp>
// clang-format off
PINOCCHIO_PRAGMA_DEPRECATED_HEADER(pinocchio/bindings/python/parsers/python.hpp, pinocchio/parsers/python.hpp)
// clang-format on

#if defined _WIN32
#ifdef pinocchio_pywrap_EXPORTS
#define PINOCCHIO_PYWRAP_DLLAPI __declspec(dllexport)
#else
#define PINOCCHIO_PYWRAP_DLLAPI __declspec(dllimport)
#endif // pinocchio_pywrap_EXPORTS
#else
#define PINOCCHIO_PYWRAP_DLLAPI
#endif // _WIN32

namespace pinocchio
{
namespace python
{
/// \brief Load a model from a Python script.
///
/// This function raises a Python error in case of incistency in the Python code.
///
/// \input filename The full path to the model file.
/// \input var_name Name of the Python variable which contains the model in the script.
///
/// \returns The model constructed by the Python script.
///
// TODO: look inside the context of Python and find an occurence of object Model
PINOCCHIO_PYWRAP_DLLAPI
Model buildModel(const std::string & filename, const std::string & var_name = "model");

} // namespace python

} // namespace pinocchio
#include "pinocchio/parsers/python.hpp"

#endif // ifndef __pinocchio_python_parser_python_hpp__
24 changes: 23 additions & 1 deletion include/pinocchio/parsers/python.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
#ifndef __pinocchio_parser_python_hpp__
#define __pinocchio_parser_python_hpp__

#include "pinocchio/bindings/python/parsers/python.hpp"
#include "pinocchio/python_parser/config.hpp"
#include "pinocchio/multibody/model.hpp"

namespace pinocchio
{
namespace python
{
/// \brief Load a model from a Python script.
///
/// This function raises a Python error in case of inconsistency in the Python code.
///
/// \input filename The full path to the model file.
/// \input var_name Name of the Python variable which contains the model in the script.
///
/// \returns The model constructed by the Python script.
///
// TODO: look inside the context of Python and find an occurence of object Model
PINOCCHIO_PYTHON_PARSER_DLLAPI
Model buildModel(const std::string & filename, const std::string & var_name = "model");

} // namespace python

} // namespace pinocchio

#endif // ifndef __pinocchio_parser_python_hpp__
2 changes: 1 addition & 1 deletion sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ set(${PROJECT_NAME}_PYTHON_PARSER_PUBLIC_HEADERS
${PROJECT_SOURCE_DIR}/include/pinocchio/parsers/python.hpp)

set(${PROJECT_NAME}_PYTHON_PARSER_SOURCES
${PROJECT_SOURCE_DIR}/bindings/python/parsers/python/model.cpp)
${PROJECT_SOURCE_DIR}/src/parsers/python/model.cpp)

set(${PROJECT_NAME}_EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/extra/reachable-workspace.cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Copyright (c) 2016-2023 CNRS INRIA
//

#include "pinocchio/bindings/python/parsers/python.hpp"
#include "pinocchio/parsers/python.hpp"

#include <boost/version.hpp>
#include <boost/algorithm/string/predicate.hpp>

#include <boost/python.hpp>

// Boost 1.58
#if BOOST_VERSION / 100 % 1000 == 58
#include <fstream>
Expand Down
2 changes: 1 addition & 1 deletion unittest/python_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "pinocchio/multibody/model.hpp"
#include "pinocchio/multibody/data.hpp"
#include "pinocchio/bindings/python/parsers/python.hpp"
#include "pinocchio/parsers/python.hpp"

#include <boost/test/unit_test.hpp>

Expand Down

0 comments on commit 750bd0e

Please sign in to comment.