FCL  0.6.0
Flexible Collision Library
mesh_collision_traversal_node.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_MESHCOLLISIONTRAVERSALNODE_H
39 #define FCL_TRAVERSAL_MESHCOLLISIONTRAVERSALNODE_H
40 
41 #include "fcl/math/bv/OBB.h"
42 #include "fcl/math/bv/RSS.h"
43 #include "fcl/math/bv/OBBRSS.h"
44 #include "fcl/math/bv/kIOS.h"
45 #include "fcl/narrowphase/contact.h"
46 #include "fcl/narrowphase/cost_source.h"
47 #include "fcl/narrowphase/detail/traversal/collision/intersect.h"
48 #include "fcl/narrowphase/detail/traversal/collision/bvh_collision_traversal_node.h"
49 
50 namespace fcl
51 {
52 
53 namespace detail
54 {
55 
57 template <typename BV>
59 {
60 public:
61 
62  using S = typename BV::S;
63 
65 
67  void leafTesting(int b1, int b2) const;
68 
70  bool canStop() const;
71 
72  Vector3<S>* vertices1;
73  Vector3<S>* vertices2;
74 
75  Triangle* tri_indices1;
76  Triangle* tri_indices2;
77 
78  S cost_density;
79 };
80 
83 template <typename BV>
84 bool initialize(
87  Transform3<typename BV::S>& tf1,
89  Transform3<typename BV::S>& tf2,
92  bool use_refit = false,
93  bool refit_bottomup = false);
94 
97 template <typename S>
99 {
100 public:
102 
103  bool BVTesting(int b1, int b2) const;
104 
105  void leafTesting(int b1, int b2) const;
106 
107  bool BVTesting(int b1, int b2, const Matrix3<S>& Rc, const Vector3<S>& Tc) const;
108 
109  bool BVTesting(int b1, int b2, const Transform3<S>& tf) const;
110 
111  void leafTesting(int b1, int b2, const Matrix3<S>& Rc, const Vector3<S>& Tc) const;
112 
113  void leafTesting(int b1, int b2, const Transform3<S>& tf) const;
114 
115  Matrix3<S> R;
116  Vector3<S> T;
117 
118  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
119 };
120 
123 
126 template <typename S>
127 bool initialize(
129  const BVHModel<OBB<S>>& model1,
130  const Transform3<S>& tf1,
131  const BVHModel<OBB<S>>& model2,
132  const Transform3<S>& tf2,
133  const CollisionRequest<S>& request,
134  CollisionResult<S>& result);
135 
136 template <typename S>
138 {
139 public:
141 
142  bool BVTesting(int b1, int b2) const;
143 
144  void leafTesting(int b1, int b2) const;
145 
146 // FCL_DEPRECATED
147 // bool BVTesting(int b1, int b2, const Matrix3<S>& Rc, const Vector3<S>& Tc) const;
148 
149  bool BVTesting(int b1, int b2, const Transform3<S>& tf) const;
150 
151 // FCL_DEPRECATED
152 // void leafTesting(int b1, int b2, const Matrix3<S>& Rc, const Vector3<S>& Tc) const;
153 
154  void leafTesting(int b1, int b2, const Transform3<S>& tf) const;
155 
156  Matrix3<S> R;
157  Vector3<S> T;
158 
159  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
160 };
161 
164 
167 template <typename S>
168 bool initialize(
170  const BVHModel<RSS<S>>& model1,
171  const Transform3<S>& tf1,
172  const BVHModel<RSS<S>>& model2,
173  const Transform3<S>& tf2,
174  const CollisionRequest<S>& request,
175  CollisionResult<S>& result);
176 
177 template <typename S>
179 {
180 public:
182 
183  bool BVTesting(int b1, int b2) const;
184 
185  void leafTesting(int b1, int b2) const;
186 
187  Matrix3<S> R;
188  Vector3<S> T;
189 
190  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
191 };
192 
195 
198 template <typename S>
199 bool initialize(
201  const BVHModel<kIOS<S>>& model1,
202  const Transform3<S>& tf1,
203  const BVHModel<kIOS<S>>& model2,
204  const Transform3<S>& tf2,
205  const CollisionRequest<S>& request,
206  CollisionResult<S>& result);
207 
208 template <typename S>
210 {
211 public:
213 
214 
215  bool BVTesting(int b1, int b2) const;
216 
217  void leafTesting(int b1, int b2) const;
218 
219  Matrix3<S> R;
220  Vector3<S> T;
221 
222  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
223 };
224 
227 
230 template <typename S>
231 bool initialize(
233  const BVHModel<OBBRSS<S>>& model1,
234  const Transform3<S>& tf1,
235  const BVHModel<OBBRSS<S>>& model2,
236  const Transform3<S>& tf2,
237  const CollisionRequest<S>& request,
238  CollisionResult<S>& result);
239 
240 template <typename BV>
241 void meshCollisionOrientedNodeLeafTesting(
242  int b1,
243  int b2,
244  const BVHModel<BV>* model1,
245  const BVHModel<BV>* model2,
246  Vector3<typename BV::S>* vertices1,
247  Vector3<typename BV::S>* vertices2,
248  Triangle* tri_indices1,
249  Triangle* tri_indices2,
250  const Matrix3<typename BV::S>& R,
251  const Vector3<typename BV::S>& T,
252  const Transform3<typename BV::S>& tf1,
253  const Transform3<typename BV::S>& tf2,
254  bool enable_statistics,
255  typename BV::S cost_density,
256  int& num_leaf_tests,
257  const CollisionRequest<typename BV::S>& request,
259 
260 template <typename BV>
261 void meshCollisionOrientedNodeLeafTesting(
262  int b1,
263  int b2,
264  const BVHModel<BV>* model1,
265  const BVHModel<BV>* model2,
266  Vector3<typename BV::S>* vertices1,
267  Vector3<typename BV::S>* vertices2,
268  Triangle* tri_indices1,
269  Triangle* tri_indices2,
270  const Transform3<typename BV::S>& tf,
271  const Transform3<typename BV::S>& tf1,
272  const Transform3<typename BV::S>& tf2,
273  bool enable_statistics,
274  typename BV::S cost_density,
275  int& num_leaf_tests,
276  const CollisionRequest<typename BV::S>& request,
278 
279 } // namespace detail
280 } // namespace fcl
281 
282 #include "fcl/narrowphase/detail/traversal/collision/mesh_collision_traversal_node-inl.h"
283 
284 #endif
bool enable_statistics
Whether stores statistics.
Definition: collision_traversal_node_base.h:78
Definition: mesh_collision_traversal_node.h:209
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
collision result
Definition: collision_request.h:48
Definition: mesh_collision_traversal_node.h:137
void leafTesting(int b1, int b2) const
Intersection testing between leaves (two triangles)
Definition: mesh_collision_traversal_node-inl.h:124
Transform3< BV::S > tf2
configuration of second object
Definition: traversal_node_base.h:88
CollisionRequest< BV::S > request
request setting for collision
Definition: collision_traversal_node_base.h:72
const BVHModel< BV > * model1
The first BVH model.
Definition: bvh_collision_traversal_node.h:86
Triangle with 3 indices for points.
Definition: triangle.h:47
Definition: mesh_collision_traversal_node.h:178
request to the collision algorithm
Definition: collision_request.h:52
Traversal node for collision between BVH models.
Definition: bvh_collision_traversal_node.h:52
Traversal node for collision between two meshes.
Definition: mesh_collision_traversal_node.h:58
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:57
CollisionResult< BV::S > * result
collision result kept during the traversal iteration
Definition: collision_traversal_node_base.h:75
Transform3< BV::S > tf1
configuation of first object
Definition: traversal_node_base.h:85
bool canStop() const
Whether the traversal process can stop early.
Definition: mesh_collision_traversal_node-inl.h:202
const BVHModel< BV > * model2
The second BVH model.
Definition: bvh_collision_traversal_node.h:89
Traversal node for collision between two meshes if their underlying BVH node is oriented node (OBB...
Definition: mesh_collision_traversal_node.h:98
bool BVTesting(int b1, int b2) const
BV culling test in one BVTT node.
Definition: bvh_collision_traversal_node-inl.h:121