GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: python/gjk.cc Lines: 54 54 100.0 %
Date: 2024-02-09 12:57:42 Branches: 52 104 50.0 %

Line Branch Exec Source
1
//
2
// Software License Agreement (BSD License)
3
//
4
//  Copyright (c) 2020 CNRS-LAAS
5
//  Author: Joseph Mirabel
6
//  All rights reserved.
7
//
8
//  Redistribution and use in source and binary forms, with or without
9
//  modification, are permitted provided that the following conditions
10
//  are met:
11
//
12
//   * Redistributions of source code must retain the above copyright
13
//     notice, this list of conditions and the following disclaimer.
14
//   * Redistributions in binary form must reproduce the above
15
//     copyright notice, this list of conditions and the following
16
//     disclaimer in the documentation and/or other materials provided
17
//     with the distribution.
18
//   * Neither the name of CNRS-LAAS. nor the names of its
19
//     contributors may be used to endorse or promote products derived
20
//     from this software without specific prior written 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
#include <eigenpy/eigenpy.hpp>
36
37
#include "fcl.hh"
38
39
#include <hpp/fcl/fwd.hh>
40
#include <hpp/fcl/narrowphase/gjk.h>
41
42
#ifdef HPP_FCL_HAS_DOXYGEN_AUTODOC
43
#include "doxygen_autodoc/functions.h"
44
#include "doxygen_autodoc/hpp/fcl/narrowphase/gjk.h"
45
#endif
46
47
using namespace boost::python;
48
using namespace hpp::fcl;
49
using hpp::fcl::details::EPA;
50
using hpp::fcl::details::GJK;
51
using hpp::fcl::details::MinkowskiDiff;
52
53
5
void exposeGJK() {
54
5
  if (!eigenpy::register_symbolic_link_to_registered_type<GJK::Status>()) {
55
10
    enum_<GJK::Status>("GJKStatus")
56
5
        .value("Valid", GJK::Valid)
57
5
        .value("Inside", GJK::Inside)
58
5
        .value("Failed", GJK::Failed)
59
5
        .export_values();
60
  }
61
62
5
  if (!eigenpy::register_symbolic_link_to_registered_type<MinkowskiDiff>()) {
63
10
    class_<MinkowskiDiff>("MinkowskiDiff", doxygen::class_doc<MinkowskiDiff>(),
64
                          no_init)
65
5
        .def(doxygen::visitor::init<MinkowskiDiff>())
66
        .def("set",
67
             static_cast<void (MinkowskiDiff::*)(
68
                 const ShapeBase*, const ShapeBase*)>(&MinkowskiDiff::set),
69
5
             doxygen::member_func_doc(
70
                 static_cast<void (MinkowskiDiff::*)(
71
10
                     const ShapeBase*, const ShapeBase*)>(&MinkowskiDiff::set)))
72
        .def("set",
73
             static_cast<void (MinkowskiDiff::*)(
74
                 const ShapeBase*, const ShapeBase*, const Transform3f& tf0,
75
                 const Transform3f& tf1)>(&MinkowskiDiff::set),
76
5
             doxygen::member_func_doc(
77
                 static_cast<void (MinkowskiDiff::*)(
78
                     const ShapeBase*, const ShapeBase*, const Transform3f& tf0,
79
5
                     const Transform3f& tf1)>(&MinkowskiDiff::set)))
80

5
        .DEF_CLASS_FUNC(MinkowskiDiff, support0)
81

5
        .DEF_CLASS_FUNC(MinkowskiDiff, support1)
82

5
        .DEF_CLASS_FUNC(MinkowskiDiff, support)
83
5
        .DEF_RW_CLASS_ATTRIB(MinkowskiDiff, inflation)
84
5
        .DEF_RW_CLASS_ATTRIB(MinkowskiDiff, normalize_support_direction);
85
  }
86
87
5
  if (!eigenpy::register_symbolic_link_to_registered_type<GJKVariant>()) {
88
10
    enum_<GJKVariant>("GJKVariant")
89
5
        .value("DefaultGJK", GJKVariant::DefaultGJK)
90
5
        .value("NesterovAcceleration", GJKVariant::NesterovAcceleration)
91
5
        .export_values();
92
  }
93
94
5
  if (!eigenpy::register_symbolic_link_to_registered_type<
95
5
          GJKConvergenceCriterion>()) {
96
10
    enum_<GJKConvergenceCriterion>("GJKConvergenceCriterion")
97
5
        .value("VDB", GJKConvergenceCriterion::VDB)
98
5
        .value("DualityGap", GJKConvergenceCriterion::DualityGap)
99
5
        .value("Hybrid", GJKConvergenceCriterion::Hybrid)
100
5
        .export_values();
101
  }
102
103
5
  if (!eigenpy::register_symbolic_link_to_registered_type<
104
5
          GJKConvergenceCriterionType>()) {
105
10
    enum_<GJKConvergenceCriterionType>("GJKConvergenceCriterionType")
106
5
        .value("Absolute", GJKConvergenceCriterionType::Absolute)
107
5
        .value("Relative", GJKConvergenceCriterionType::Relative)
108
5
        .export_values();
109
  }
110
111
5
  if (!eigenpy::register_symbolic_link_to_registered_type<GJK>()) {
112
10
    class_<GJK>("GJK", doxygen::class_doc<GJK>(), no_init)
113
5
        .def(doxygen::visitor::init<GJK, unsigned int, FCL_REAL>())
114
5
        .DEF_RW_CLASS_ATTRIB(GJK, distance)
115
5
        .DEF_RW_CLASS_ATTRIB(GJK, ray)
116
5
        .DEF_RW_CLASS_ATTRIB(GJK, support_hint)
117
5
        .DEF_RW_CLASS_ATTRIB(GJK, gjk_variant)
118
5
        .DEF_RW_CLASS_ATTRIB(GJK, convergence_criterion)
119
5
        .DEF_RW_CLASS_ATTRIB(GJK, convergence_criterion_type)
120

5
        .DEF_CLASS_FUNC(GJK, evaluate)
121

5
        .DEF_CLASS_FUNC(GJK, hasClosestPoints)
122

5
        .DEF_CLASS_FUNC(GJK, hasPenetrationInformation)
123

5
        .DEF_CLASS_FUNC(GJK, getClosestPoints)
124

5
        .DEF_CLASS_FUNC(GJK, setDistanceEarlyBreak)
125

5
        .DEF_CLASS_FUNC(GJK, getGuessFromSimplex)
126

5
        .DEF_CLASS_FUNC(GJK, getIterations);
127
  }
128
5
}