distance.cc
Go to the documentation of this file.
1 //
2 // Software License Agreement (BSD License)
3 //
4 // Copyright (c) 2019 CNRS-LAAS INRIA
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 "coal.hh"
38 
41 #include "coal/fwd.hh"
42 #include "coal/distance.h"
44 
45 #include "deprecation.hh"
47 
48 #include "serializable.hh"
49 
50 #ifdef COAL_HAS_DOXYGEN_AUTODOC
51 #include "doxygen_autodoc/functions.h"
52 #include "doxygen_autodoc/coal/collision_data.h"
53 #endif
54 
55 using namespace boost::python;
56 using namespace coal;
57 using namespace coal::python;
58 
59 namespace dv = doxygen::visitor;
60 
62  static Vec3s getNearestPoint1(const DistanceResult& res) {
63  return res.nearest_points[0];
64  }
65  static Vec3s getNearestPoint2(const DistanceResult& res) {
66  return res.nearest_points[1];
67  }
68 };
69 
73  if (!eigenpy::register_symbolic_link_to_registered_type<DistanceRequest>()) {
74  class_<DistanceRequest, bases<QueryRequest> >(
75  "DistanceRequest", doxygen::class_doc<DistanceRequest>(),
76  init<optional<bool, CoalScalar, CoalScalar> >(
77  (arg("self"), arg("enable_nearest_points"), arg("rel_err"),
78  arg("abs_err")),
79  "Constructor"))
80  .add_property(
81  "enable_nearest_points",
82  bp::make_function(
83  +[](DistanceRequest& self) -> bool {
84  return self.enable_nearest_points;
85  },
87  "enable_nearest_points has been marked as deprecated. "
88  "Nearest points are always computed when computing "
89  "distance. They are the points of the shapes that achieve "
90  "a distance of "
91  "DistanceResult::min_distance.\n"
92  "Use `enable_signed_distance` if you want to compute a "
93  "signed minimum "
94  "distance (and thus its corresponding nearest points).")),
95  bp::make_function(
96  +[](DistanceRequest& self, const bool value) -> void {
97  self.enable_nearest_points = value;
98  },
100  "enable_nearest_points has been marked as deprecated. "
101  "Nearest points are always computed when computing "
102  "distance. They are the points of the shapes that achieve "
103  "a distance of "
104  "DistanceResult::min_distance.\n"
105  "Use `enable_signed_distance` if you want to compute a "
106  "signed minimum "
107  "distance (and thus its corresponding nearest points).")),
108  doxygen::class_attrib_doc<DistanceRequest>("enable_nearest_points"))
109  .DEF_RW_CLASS_ATTRIB(DistanceRequest, enable_signed_distance)
110  .DEF_RW_CLASS_ATTRIB(DistanceRequest, rel_err)
111  .DEF_RW_CLASS_ATTRIB(DistanceRequest, abs_err)
113  }
115 
117  std::vector<DistanceRequest> >()) {
118  class_<std::vector<DistanceRequest> >("StdVec_DistanceRequest")
119  .def(vector_indexing_suite<std::vector<DistanceRequest> >());
120  }
121 
122  if (!eigenpy::register_symbolic_link_to_registered_type<DistanceResult>()) {
123  class_<DistanceResult, bases<QueryResult> >(
124  "DistanceResult", doxygen::class_doc<DistanceResult>(), no_init)
125  .def(dv::init<DistanceResult>())
126  .DEF_RW_CLASS_ATTRIB(DistanceResult, min_distance)
127  .DEF_RW_CLASS_ATTRIB(DistanceResult, normal)
128  //.def_readwrite ("nearest_points", &DistanceResult::nearest_points)
129  .def("getNearestPoint1", &DistanceResultWrapper::getNearestPoint1,
130  doxygen::class_attrib_doc<DistanceResult>("nearest_points"))
131  .def("getNearestPoint2", &DistanceResultWrapper::getNearestPoint2,
132  doxygen::class_attrib_doc<DistanceResult>("nearest_points"))
133  .DEF_RO_CLASS_ATTRIB(DistanceResult, nearest_points)
134  .DEF_RO_CLASS_ATTRIB(DistanceResult, o1)
135  .DEF_RO_CLASS_ATTRIB(DistanceResult, o2)
136  .DEF_RW_CLASS_ATTRIB(DistanceResult, b1)
137  .DEF_RW_CLASS_ATTRIB(DistanceResult, b2)
138 
139  .def("clear", &DistanceResult::clear,
140  doxygen::member_func_doc(&DistanceResult::clear))
142  }
143 
145  std::vector<DistanceResult> >()) {
146  class_<std::vector<DistanceResult> >("StdVec_DistanceResult")
147  .def(vector_indexing_suite<std::vector<DistanceResult> >());
148  }
149 
150  doxygen::def(
151  "distance",
152  static_cast<CoalScalar (*)(const CollisionObject*, const CollisionObject*,
153  const DistanceRequest&, DistanceResult&)>(
154  &distance));
155  doxygen::def(
156  "distance",
157  static_cast<CoalScalar (*)(const CollisionGeometry*, const Transform3s&,
158  const CollisionGeometry*, const Transform3s&,
159  const DistanceRequest&, DistanceResult&)>(
160  &distance));
161 
162  class_<ComputeDistance>("ComputeDistance",
163  doxygen::class_doc<ComputeDistance>(), no_init)
164  .def(dv::init<ComputeDistance, const CollisionGeometry*,
165  const CollisionGeometry*>())
166  .def("__call__",
167  static_cast<CoalScalar (ComputeDistance::*)(
168  const Transform3s&, const Transform3s&, const DistanceRequest&,
169  DistanceResult&) const>(&ComputeDistance::operator()));
170 }
boost::python
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
DistanceResultWrapper::getNearestPoint2
static Vec3s getNearestPoint2(const DistanceResult &res)
Definition: distance.cc:65
coal.hh
eigenpy.hpp
COAL_COMPILER_DIAGNOSTIC_PUSH
#define COAL_COMPILER_DIAGNOSTIC_PUSH
Definition: include/coal/fwd.hh:120
eigenpy::register_symbolic_link_to_registered_type
bool register_symbolic_link_to_registered_type()
exposeDistanceAPI
void exposeDistanceAPI()
Definition: distance.cc:70
distance
double distance(const std::vector< Transform3s > &tf, const BVHModel< BV > &m1, const BVHModel< BV > &m2, bool verbose)
Definition: benchmark.cpp:93
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
doxygen::visitor
Definition: doxygen-boost.hh:12
DistanceResultWrapper::getNearestPoint1
static Vec3s getNearestPoint1(const DistanceResult &res)
Definition: distance.cc:62
doxygen::def
void def(const char *name, Func func)
Definition: doxygen-boost.hh:106
coal::python::SerializableVisitor
Definition: serializable.hh:23
coal::CollisionGeometry
The geometry for the object for collision or distance computation.
Definition: coal/collision_object.h:94
DEF_RW_CLASS_ATTRIB
#define DEF_RW_CLASS_ATTRIB(CLASS, ATTRIB)
Definition: python/fwd.hh:29
serializable.hh
coal::Transform3s
Simple transform class used locally by InterpMotion.
Definition: coal/math/transform.h:55
res
res
coal::DistanceRequest
request to the distance computation
Definition: coal/collision_data.h:985
coal::python
Definition: python/broadphase/fwd.hh:11
fwd.hh
deprecation.hh
value
float value
distance.h
coal::DistanceResult
distance result
Definition: coal/collision_data.h:1051
coal::CollisionObject
the object for collision or distance computation, contains the geometry and the transform information
Definition: coal/collision_object.h:214
coal::ComputeDistance
Definition: coal/distance.h:73
coal::python::deprecated_warning_policy
Definition: deprecation.hh:16
collision_data.h
COAL_COMPILER_DIAGNOSTIC_POP
#define COAL_COMPILER_DIAGNOSTIC_POP
Definition: include/coal/fwd.hh:121
COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
#define COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
Definition: include/coal/fwd.hh:122
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
DistanceResultWrapper
Definition: distance.cc:61
doxygen::member_func_doc
const char * member_func_doc(FuncPtr)
Definition: doxygen.hh:33
DEF_RO_CLASS_ATTRIB
#define DEF_RO_CLASS_ATTRIB(CLASS, ATTRIB)
Definition: python/fwd.hh:32


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:58