FCL  0.6.0
Flexible Collision Library
octree_solver.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, 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 FCL_TRAVERSAL_OCTREE_OCTREESOLVER_H
39 #define FCL_TRAVERSAL_OCTREE_OCTREESOLVER_H
40 
41 #include "fcl/config.h"
42 #if not(FCL_HAVE_OCTOMAP)
43 #error "This header requires fcl to be compiled with octomap support"
44 #endif
45 
46 #include "fcl/math/bv/utility.h"
47 #include "fcl/geometry/octree/octree.h"
48 #include "fcl/geometry/shape/utility.h"
49 #include "fcl/geometry/shape/box.h"
50 
51 namespace fcl
52 {
53 
54 namespace detail
55 {
56 
58 template <typename NarrowPhaseSolver>
60 {
61 private:
62 
63  using S = typename NarrowPhaseSolver::S;
64 
65  const NarrowPhaseSolver* solver;
66 
67  mutable const CollisionRequest<S>* crequest;
68  mutable const DistanceRequest<S>* drequest;
69 
70  mutable CollisionResult<S>* cresult;
71  mutable DistanceResult<S>* dresult;
72 
73 public:
74  OcTreeSolver(const NarrowPhaseSolver* solver_);
75 
77  void OcTreeIntersect(const OcTree<S>* tree1, const OcTree<S>* tree2,
78  const Transform3<S>& tf1, const Transform3<S>& tf2,
79  const CollisionRequest<S>& request_,
80  CollisionResult<S>& result_) const;
81 
83  void OcTreeDistance(const OcTree<S>* tree1, const OcTree<S>* tree2,
84  const Transform3<S>& tf1, const Transform3<S>& tf2,
85  const DistanceRequest<S>& request_,
86  DistanceResult<S>& result_) const;
87 
89  template <typename BV>
90  void OcTreeMeshIntersect(const OcTree<S>* tree1, const BVHModel<BV>* tree2,
91  const Transform3<S>& tf1, const Transform3<S>& tf2,
92  const CollisionRequest<S>& request_,
93  CollisionResult<S>& result_) const;
94 
96  template <typename BV>
97  void OcTreeMeshDistance(const OcTree<S>* tree1, const BVHModel<BV>* tree2,
98  const Transform3<S>& tf1, const Transform3<S>& tf2,
99  const DistanceRequest<S>& request_,
100  DistanceResult<S>& result_) const;
101 
103  template <typename BV>
104  void MeshOcTreeIntersect(const BVHModel<BV>* tree1, const OcTree<S>* tree2,
105  const Transform3<S>& tf1, const Transform3<S>& tf2,
106  const CollisionRequest<S>& request_,
107  CollisionResult<S>& result_) const;
108 
110  template <typename BV>
111  void MeshOcTreeDistance(const BVHModel<BV>* tree1, const OcTree<S>* tree2,
112  const Transform3<S>& tf1, const Transform3<S>& tf2,
113  const DistanceRequest<S>& request_,
114  DistanceResult<S>& result_) const;
115 
117  template <typename Shape>
118  void OcTreeShapeIntersect(const OcTree<S>* tree, const Shape& s,
119  const Transform3<S>& tf1, const Transform3<S>& tf2,
120  const CollisionRequest<S>& request_,
121  CollisionResult<S>& result_) const;
122 
124  template <typename Shape>
125  void ShapeOcTreeIntersect(const Shape& s, const OcTree<S>* tree,
126  const Transform3<S>& tf1, const Transform3<S>& tf2,
127  const CollisionRequest<S>& request_,
128  CollisionResult<S>& result_) const;
129 
131  template <typename Shape>
132  void OcTreeShapeDistance(const OcTree<S>* tree, const Shape& s,
133  const Transform3<S>& tf1, const Transform3<S>& tf2,
134  const DistanceRequest<S>& request_,
135  DistanceResult<S>& result_) const;
136 
138  template <typename Shape>
139  void ShapeOcTreeDistance(const Shape& s, const OcTree<S>* tree,
140  const Transform3<S>& tf1, const Transform3<S>& tf2,
141  const DistanceRequest<S>& request_,
142  DistanceResult<S>& result_) const;
143 
144 private:
145 
146  template <typename Shape>
147  bool OcTreeShapeDistanceRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
148  const Shape& s, const AABB<S>& aabb2,
149  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
150 
151  template <typename Shape>
152  bool OcTreeShapeIntersectRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
153  const Shape& s, const OBB<S>& obb2,
154  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
155 
156  template <typename BV>
157  bool OcTreeMeshDistanceRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
158  const BVHModel<BV>* tree2, int root2,
159  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
160 
161 
162  template <typename BV>
163  bool OcTreeMeshIntersectRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
164  const BVHModel<BV>* tree2, int root2,
165  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
166 
167  bool OcTreeDistanceRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
168  const OcTree<S>* tree2, const typename OcTree<S>::OcTreeNode* root2, const AABB<S>& bv2,
169  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
170 
171 
172  bool OcTreeIntersectRecurse(const OcTree<S>* tree1, const typename OcTree<S>::OcTreeNode* root1, const AABB<S>& bv1,
173  const OcTree<S>* tree2, const typename OcTree<S>::OcTreeNode* root2, const AABB<S>& bv2,
174  const Transform3<S>& tf1, const Transform3<S>& tf2) const;
175 };
176 
177 } // namespace detail
178 } // namespace fcl
179 
180 #include "fcl/narrowphase/detail/traversal/octree/octree_solver-inl.h"
181 
182 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
void OcTreeIntersect(const OcTree< S > *tree1, const OcTree< S > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const CollisionRequest< S > &request_, CollisionResult< S > &result_) const
collision between two octrees
Definition: octree_solver-inl.h:66
collision result
Definition: collision_request.h:48
void OcTreeShapeDistance(const OcTree< S > *tree, const Shape &s, const Transform3< S > &tf1, const Transform3< S > &tf2, const DistanceRequest< S > &request_, DistanceResult< S > &result_) const
distance between octree and shape
Definition: octree_solver-inl.h:231
void ShapeOcTreeDistance(const Shape &s, const OcTree< S > *tree, const Transform3< S > &tf1, const Transform3< S > &tf2, const DistanceRequest< S > &request_, DistanceResult< S > &result_) const
distance between shape and octree
Definition: octree_solver-inl.h:253
distance result
Definition: distance_request.h:48
request to the collision algorithm
Definition: collision_request.h:52
Algorithms for collision related with octree.
Definition: octree_solver.h:59
void OcTreeDistance(const OcTree< S > *tree1, const OcTree< S > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const DistanceRequest< S > &request_, DistanceResult< S > &result_) const
distance between two octrees
Definition: octree_solver-inl.h:84
void OcTreeMeshDistance(const OcTree< S > *tree1, const BVHModel< BV > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const DistanceRequest< S > &request_, DistanceResult< S > &result_) const
distance between octree and mesh
Definition: octree_solver-inl.h:122
void MeshOcTreeDistance(const BVHModel< BV > *tree1, const OcTree< S > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const DistanceRequest< S > &request_, DistanceResult< S > &result_) const
distance between mesh and octree
Definition: octree_solver-inl.h:162
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:57
void ShapeOcTreeIntersect(const Shape &s, const OcTree< S > *tree, const Transform3< S > &tf1, const Transform3< S > &tf2, const CollisionRequest< S > &request_, CollisionResult< S > &result_) const
collision between shape and octree
Definition: octree_solver-inl.h:207
void OcTreeMeshIntersect(const OcTree< S > *tree1, const BVHModel< BV > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const CollisionRequest< S > &request_, CollisionResult< S > &result_) const
collision between octree and mesh
Definition: octree_solver-inl.h:103
void OcTreeShapeIntersect(const OcTree< S > *tree, const Shape &s, const Transform3< S > &tf1, const Transform3< S > &tf2, const CollisionRequest< S > &request_, CollisionResult< S > &result_) const
collision between octree and shape
Definition: octree_solver-inl.h:182
void MeshOcTreeIntersect(const BVHModel< BV > *tree1, const OcTree< S > *tree2, const Transform3< S > &tf1, const Transform3< S > &tf2, const CollisionRequest< S > &request_, CollisionResult< S > &result_) const
collision between mesh and octree
Definition: octree_solver-inl.h:141
request to the distance computation
Definition: distance_request.h:52