| Directory: | ./ |
|---|---|
| File: | include/pinocchio/bindings/python/collision/fcl/transform.hpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 24 | 24 | 100.0% |
| Branches: | 14 | 24 | 58.3% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #ifndef __pinocchio_python_collision_fcl_transform_hpp__ | ||
| 6 | #define __pinocchio_python_collision_fcl_transform_hpp__ | ||
| 7 | |||
| 8 | #include "pinocchio/spatial/se3.hpp" | ||
| 9 | #include <hpp/fcl/math/transform.h> | ||
| 10 | |||
| 11 | namespace boost | ||
| 12 | { | ||
| 13 | namespace python | ||
| 14 | { | ||
| 15 | namespace converter | ||
| 16 | { | ||
| 17 | |||
| 18 | template<typename Scalar, int Options> | ||
| 19 | struct implicit<::hpp::fcl::Transform3f, ::pinocchio::SE3Tpl<Scalar, Options>> | ||
| 20 | { | ||
| 21 | typedef ::hpp::fcl::Transform3f Source; | ||
| 22 | typedef ::pinocchio::SE3Tpl<Scalar, Options> Target; | ||
| 23 | |||
| 24 | 53 | static void * convertible(PyObject * obj) | |
| 25 | { | ||
| 26 | // Find a converter which can produce a Source instance from | ||
| 27 | // obj. The user has told us that Source can be converted to | ||
| 28 | // Target, and instantiating construct() below, ensures that | ||
| 29 | // at compile-time. | ||
| 30 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 52 times.
|
53 | return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters) ? obj |
| 31 | 53 | : 0; | |
| 32 | } | ||
| 33 | |||
| 34 | 1 | static void construct(PyObject * obj, rvalue_from_python_stage1_data * data) | |
| 35 | { | ||
| 36 | 1 | void * storage = | |
| 37 | reinterpret_cast<rvalue_from_python_storage<Target> *>(reinterpret_cast<void *>(data)) | ||
| 38 | ->storage.bytes; | ||
| 39 | |||
| 40 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | arg_from_python<Source> get_source(obj); |
| 41 | 1 | bool convertible = get_source.convertible(); | |
| 42 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | BOOST_VERIFY(convertible); |
| 43 | |||
| 44 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const Source & t = get_source(); |
| 45 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | new (storage) Target(t.getRotation(), t.getTranslation()); |
| 46 | |||
| 47 | // record successful construction | ||
| 48 | 1 | data->convertible = storage; | |
| 49 | 1 | } | |
| 50 | }; | ||
| 51 | |||
| 52 | template<typename Scalar, int Options> | ||
| 53 | struct implicit<::pinocchio::SE3Tpl<Scalar, Options>, ::hpp::fcl::Transform3f> | ||
| 54 | { | ||
| 55 | typedef ::pinocchio::SE3Tpl<Scalar, Options> Source; | ||
| 56 | typedef ::hpp::fcl::Transform3f Target; | ||
| 57 | |||
| 58 | 27 | static void * convertible(PyObject * obj) | |
| 59 | { | ||
| 60 | // Find a converter which can produce a Source instance from | ||
| 61 | // obj. The user has told us that Source can be converted to | ||
| 62 | // Target, and instantiating construct() below, ensures that | ||
| 63 | // at compile-time. | ||
| 64 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 26 times.
|
27 | return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters) ? obj |
| 65 | 27 | : 0; | |
| 66 | } | ||
| 67 | |||
| 68 | 1 | static void construct(PyObject * obj, rvalue_from_python_stage1_data * data) | |
| 69 | { | ||
| 70 | 1 | void * storage = | |
| 71 | reinterpret_cast<rvalue_from_python_storage<Target> *>(reinterpret_cast<void *>(data)) | ||
| 72 | ->storage.bytes; | ||
| 73 | |||
| 74 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | arg_from_python<Source> get_source(obj); |
| 75 | 1 | bool convertible = get_source.convertible(); | |
| 76 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | BOOST_VERIFY(convertible); |
| 77 | |||
| 78 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const Source & M = get_source(); |
| 79 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | new (storage) Target(M.rotation(), M.translation()); |
| 80 | |||
| 81 | // record successful construction | ||
| 82 | 1 | data->convertible = storage; | |
| 83 | 1 | } | |
| 84 | }; | ||
| 85 | |||
| 86 | } // namespace converter | ||
| 87 | } // namespace python | ||
| 88 | } // namespace boost | ||
| 89 | |||
| 90 | #endif // ifndef __pinocchio_python_collision_fcl_transform_hpp__ | ||
| 91 |