hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
geometric_shapes_utility.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2015, Open Source Robotics Foundation
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 Open Source Robotics Foundation 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 
38 #ifndef HPP_FCL_GEOMETRIC_SHAPES_UTILITY_H
39 #define HPP_FCL_GEOMETRIC_SHAPES_UTILITY_H
40 
41 #include <vector>
43 #include <hpp/fcl/BV/BV.h>
45 
46 namespace hpp {
47 namespace fcl {
48 
50 namespace details {
53 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Box& box,
54  const Transform3f& tf);
55 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Sphere& sphere,
56  const Transform3f& tf);
57 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Ellipsoid& ellipsoid,
58  const Transform3f& tf);
59 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Capsule& capsule,
60  const Transform3f& tf);
61 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Cone& cone,
62  const Transform3f& tf);
63 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const Cylinder& cylinder,
64  const Transform3f& tf);
65 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const ConvexBase& convex,
66  const Transform3f& tf);
67 HPP_FCL_DLLAPI std::vector<Vec3f> getBoundVertices(const TriangleP& triangle,
68  const Transform3f& tf);
69 } // namespace details
71 
73 template <typename BV, typename S>
74 inline void computeBV(const S& s, const Transform3f& tf, BV& bv) {
75  if (s.getSweptSphereRadius() > 0) {
76  HPP_FCL_THROW_PRETTY("Swept-sphere radius not yet supported.",
77  std::runtime_error);
78  }
79  std::vector<Vec3f> convex_bound_vertices = details::getBoundVertices(s, tf);
80  fit(&convex_bound_vertices[0], (unsigned int)convex_bound_vertices.size(),
81  bv);
82 }
83 
84 template <>
86  AABB& bv);
87 
88 template <>
90  const Transform3f& tf, AABB& bv);
91 
92 template <>
94  const Transform3f& tf, AABB& bv);
95 
96 template <>
98  const Transform3f& tf, AABB& bv);
99 
100 template <>
102  AABB& bv);
103 
104 template <>
106  const Transform3f& tf, AABB& bv);
107 
108 template <>
110  const Transform3f& tf,
111  AABB& bv);
112 
113 template <>
115  const Transform3f& tf, AABB& bv);
116 
117 template <>
119  const Transform3f& tf, AABB& bv);
120 
121 template <>
123  const Transform3f& tf, AABB& bv);
124 
125 template <>
127  OBB& bv);
128 
129 template <>
131  const Transform3f& tf, OBB& bv);
132 
133 template <>
135  const Transform3f& tf, OBB& bv);
136 
137 template <>
139  OBB& bv);
140 
141 template <>
143  const Transform3f& tf, OBB& bv);
144 
145 template <>
147  const Transform3f& tf, OBB& bv);
148 
149 template <>
151  const Transform3f& tf, OBB& bv);
152 
153 template <>
155  const Transform3f& tf, RSS& bv);
156 
157 template <>
159  const Transform3f& tf,
160  OBBRSS& bv);
161 
162 template <>
164  const Transform3f& tf, kIOS& bv);
165 
166 template <>
167 HPP_FCL_DLLAPI void computeBV<KDOP<16>, Halfspace>(const Halfspace& s,
168  const Transform3f& tf,
169  KDOP<16>& bv);
170 
171 template <>
172 HPP_FCL_DLLAPI void computeBV<KDOP<18>, Halfspace>(const Halfspace& s,
173  const Transform3f& tf,
174  KDOP<18>& bv);
175 
176 template <>
177 HPP_FCL_DLLAPI void computeBV<KDOP<24>, Halfspace>(const Halfspace& s,
178  const Transform3f& tf,
179  KDOP<24>& bv);
180 
181 template <>
183  OBB& bv);
184 
185 template <>
187  RSS& bv);
188 
189 template <>
191  const Transform3f& tf, OBBRSS& bv);
192 
193 template <>
195  const Transform3f& tf, kIOS& bv);
196 
197 template <>
198 HPP_FCL_DLLAPI void computeBV<KDOP<16>, Plane>(const Plane& s,
199  const Transform3f& tf,
200  KDOP<16>& bv);
201 
202 template <>
203 HPP_FCL_DLLAPI void computeBV<KDOP<18>, Plane>(const Plane& s,
204  const Transform3f& tf,
205  KDOP<18>& bv);
206 
207 template <>
208 HPP_FCL_DLLAPI void computeBV<KDOP<24>, Plane>(const Plane& s,
209  const Transform3f& tf,
210  KDOP<24>& bv);
211 
214 HPP_FCL_DLLAPI void constructBox(const AABB& bv, Box& box, Transform3f& tf);
215 
216 HPP_FCL_DLLAPI void constructBox(const OBB& bv, Box& box, Transform3f& tf);
217 
218 HPP_FCL_DLLAPI void constructBox(const OBBRSS& bv, Box& box, Transform3f& tf);
219 
220 HPP_FCL_DLLAPI void constructBox(const kIOS& bv, Box& box, Transform3f& tf);
221 
222 HPP_FCL_DLLAPI void constructBox(const RSS& bv, Box& box, Transform3f& tf);
223 
225 
227 
229 
230 HPP_FCL_DLLAPI void constructBox(const AABB& bv, const Transform3f& tf_bv,
231  Box& box, Transform3f& tf);
232 
233 HPP_FCL_DLLAPI void constructBox(const OBB& bv, const Transform3f& tf_bv,
234  Box& box, Transform3f& tf);
235 
236 HPP_FCL_DLLAPI void constructBox(const OBBRSS& bv, const Transform3f& tf_bv,
237  Box& box, Transform3f& tf);
238 
239 HPP_FCL_DLLAPI void constructBox(const kIOS& bv, const Transform3f& tf_bv,
240  Box& box, Transform3f& tf);
241 
242 HPP_FCL_DLLAPI void constructBox(const RSS& bv, const Transform3f& tf_bv,
243  Box& box, Transform3f& tf);
244 
245 HPP_FCL_DLLAPI void constructBox(const KDOP<16>& bv, const Transform3f& tf_bv,
246  Box& box, Transform3f& tf);
247 
248 HPP_FCL_DLLAPI void constructBox(const KDOP<18>& bv, const Transform3f& tf_bv,
249  Box& box, Transform3f& tf);
250 
251 HPP_FCL_DLLAPI void constructBox(const KDOP<24>& bv, const Transform3f& tf_bv,
252  Box& box, Transform3f& tf);
253 
255 
257 
258 HPP_FCL_DLLAPI std::array<Halfspace, 2> transformToHalfspaces(
259  const Plane& a, const Transform3f& tf);
260 
261 } // namespace fcl
262 
263 } // namespace hpp
264 
265 #endif
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition: AABB.h:56
Center at zero point, axis aligned box.
Definition: geometric_shapes.h:164
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition: geometric_shapes.h:381
Cone The base of the cone is at and the top is at .
Definition: geometric_shapes.h:465
Base for convex polytope.
Definition: geometric_shapes.h:638
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition: geometric_shapes.h:555
Ellipsoid centered at point zero.
Definition: geometric_shapes.h:303
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition: geometric_shapes.h:885
KDOP class describes the KDOP collision structures. K is set as the template parameter,...
Definition: kDOP.h:92
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition: geometric_shapes.h:976
Center at zero point sphere.
Definition: geometric_shapes.h:238
Simple transform class used locally by InterpMotion.
Definition: transform.h:56
Triangle stores the points instead of only indices of points.
Definition: geometric_shapes.h:109
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:53
#define HPP_FCL_DLLAPI
Definition: config.hh:88
#define HPP_FCL_THROW_PRETTY(message, exception)
Definition: fwd.hh:64
void computeBV< OBBRSS, Halfspace >(const Halfspace &s, const Transform3f &tf, OBBRSS &bv)
void computeBV(const S &s, const Transform3f &tf, BV &bv)
calculate a bounding volume for a shape in a specific configuration
Definition: geometric_shapes_utility.h:74
void constructBox(const AABB &bv, Box &box, Transform3f &tf)
construct a box shape (with a configuration) from a given bounding volume
void computeBV< OBB, Plane >(const Plane &s, const Transform3f &tf, OBB &bv)
void computeBV< AABB, ConvexBase >(const ConvexBase &s, const Transform3f &tf, AABB &bv)
void computeBV< OBB, Capsule >(const Capsule &s, const Transform3f &tf, OBB &bv)
void computeBV< OBB, Box >(const Box &s, const Transform3f &tf, OBB &bv)
void computeBV< AABB, TriangleP >(const TriangleP &s, const Transform3f &tf, AABB &bv)
void computeBV< RSS, Halfspace >(const Halfspace &s, const Transform3f &tf, RSS &bv)
void computeBV< AABB, Cylinder >(const Cylinder &s, const Transform3f &tf, AABB &bv)
void computeBV< AABB, Box >(const Box &s, const Transform3f &tf, AABB &bv)
void computeBV< OBBRSS, Plane >(const Plane &s, const Transform3f &tf, OBBRSS &bv)
void computeBV< OBB, ConvexBase >(const ConvexBase &s, const Transform3f &tf, OBB &bv)
void computeBV< RSS, Plane >(const Plane &s, const Transform3f &tf, RSS &bv)
void fit(Vec3f *ps, unsigned int n, BV &bv)
Compute a bounding volume that fits a set of n points.
Definition: BV_fitter.h:52
void computeBV< AABB, Plane >(const Plane &s, const Transform3f &tf, AABB &bv)
void computeBV< AABB, Ellipsoid >(const Ellipsoid &e, const Transform3f &tf, AABB &bv)
void computeBV< OBB, Cone >(const Cone &s, const Transform3f &tf, OBB &bv)
std::array< Halfspace, 2 > transformToHalfspaces(const Plane &a, const Transform3f &tf)
void computeBV< OBB, Halfspace >(const Halfspace &s, const Transform3f &tf, OBB &bv)
void computeBV< AABB, Cone >(const Cone &s, const Transform3f &tf, AABB &bv)
void computeBV< AABB, Sphere >(const Sphere &s, const Transform3f &tf, AABB &bv)
void computeBV< kIOS, Plane >(const Plane &s, const Transform3f &tf, kIOS &bv)
void computeBV< OBB, Sphere >(const Sphere &s, const Transform3f &tf, OBB &bv)
Halfspace transform(const Halfspace &a, const Transform3f &tf)
void computeBV< kIOS, Halfspace >(const Halfspace &s, const Transform3f &tf, kIOS &bv)
void computeBV< OBB, Cylinder >(const Cylinder &s, const Transform3f &tf, OBB &bv)
void computeBV< AABB, Capsule >(const Capsule &s, const Transform3f &tf, AABB &bv)
void computeBV< AABB, Halfspace >(const Halfspace &s, const Transform3f &tf, AABB &bv)
Main namespace.
Definition: broadphase_bruteforce.h:44
Class merging the OBB and RSS, can handle collision and distance simultaneously.
Definition: OBBRSS.h:54
Oriented bounding box class.
Definition: OBB.h:52
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:54