FCL  0.6.0
Flexible Collision Library
mesh_shape_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_MESHSHAPECOLLISIONTRAVERSALNODE_H
39 #define FCL_TRAVERSAL_MESHSHAPECOLLISIONTRAVERSALNODE_H
40 
41 #include "fcl/geometry/shape/utility.h"
42 #include "fcl/narrowphase/detail/traversal/collision/bvh_shape_collision_traversal_node.h"
43 
44 namespace fcl
45 {
46 
47 namespace detail
48 {
49 
51 template <typename BV, typename Shape, typename NarrowPhaseSolver>
53  : public BVHShapeCollisionTraversalNode<BV, Shape>
54 {
55 public:
56 
57  using S = typename BV::S;
58 
60 
62  void leafTesting(int b1, int b2) const;
63 
65  bool canStop() const;
66 
67  Vector3<S>* vertices;
68  Triangle* tri_indices;
69 
70  S cost_density;
71 
72  const NarrowPhaseSolver* nsolver;
73 };
74 
77 template <typename BV, typename Shape, typename NarrowPhaseSolver>
78 bool initialize(
80  BVHModel<BV>& model1,
81  Transform3<typename BV::S>& tf1,
82  const Shape& model2,
83  const Transform3<typename BV::S>& tf2,
84  const NarrowPhaseSolver* nsolver,
87  bool use_refit = false, bool refit_bottomup = false);
88 
89 template <typename BV, typename Shape, typename NarrowPhaseSolver>
90 void meshShapeCollisionOrientedNodeLeafTesting(
91  int b1,
92  int b2,
93  const BVHModel<BV>* model1,
94  const Shape& model2,
95  Vector3<typename BV::S>* vertices,
96  Triangle* tri_indices,
97  const Transform3<typename BV::S>& tf1,
98  const Transform3<typename BV::S>& tf2,
99  const NarrowPhaseSolver* nsolver,
100  bool enable_statistics,
101  typename BV::S cost_density,
102  int& num_leaf_tests,
103  const CollisionRequest<typename BV::S>& request,
105 
107 template <typename Shape, typename NarrowPhaseSolver>
110  OBB<typename Shape::S>, Shape, NarrowPhaseSolver>
111 {
112 public:
114 
115  bool BVTesting(int b1, int b2) const;
116 
117  void leafTesting(int b1, int b2) const;
118 
119 };
120 
123 template <typename Shape, typename NarrowPhaseSolver>
124 bool initialize(
126  const BVHModel<OBB<typename Shape::S>>& model1,
127  const Transform3<typename Shape::S>& tf1,
128  const Shape& model2,
129  const Transform3<typename Shape::S>& tf2,
130  const NarrowPhaseSolver* nsolver,
133 
134 template <typename Shape, typename NarrowPhaseSolver>
137  RSS<typename Shape::S>, Shape, NarrowPhaseSolver>
138 {
139 public:
141 
142  bool BVTesting(int b1, int b2) const;
143 
144  void leafTesting(int b1, int b2) const;
145 
146 };
147 
150 template <typename Shape, typename NarrowPhaseSolver>
151 bool initialize(
153  const BVHModel<RSS<typename Shape::S>>& model1,
154  const Transform3<typename Shape::S>& tf1,
155  const Shape& model2,
156  const Transform3<typename Shape::S>& tf2,
157  const NarrowPhaseSolver* nsolver,
160 
161 template <typename Shape, typename NarrowPhaseSolver>
164  kIOS<typename Shape::S>, Shape, NarrowPhaseSolver>
165 {
166 public:
168 
169  bool BVTesting(int b1, int b2) const;
170 
171  void leafTesting(int b1, int b2) const;
172 
173 };
174 
177 template <typename Shape, typename NarrowPhaseSolver>
178 bool initialize(
180  const BVHModel<kIOS<typename Shape::S>>& model1,
181  const Transform3<typename Shape::S>& tf1,
182  const Shape& model2,
183  const Transform3<typename Shape::S>& tf2,
184  const NarrowPhaseSolver* nsolver,
187 
188 template <typename Shape, typename NarrowPhaseSolver>
191  OBBRSS<typename Shape::S>, Shape, NarrowPhaseSolver>
192 {
193 public:
195 
196  bool BVTesting(int b1, int b2) const;
197 
198  void leafTesting(int b1, int b2) const;
199 
200 };
201 
204 template <typename Shape, typename NarrowPhaseSolver>
205 bool initialize(
207  const BVHModel<OBBRSS<typename Shape::S>>& model1,
208  const Transform3<typename Shape::S>& tf1,
209  const Shape& model2,
210  const Transform3<typename Shape::S>& tf2,
211  const NarrowPhaseSolver* nsolver,
214 
215 } // namespace detail
216 } // namespace fcl
217 
218 #include "fcl/narrowphase/detail/traversal/collision/mesh_shape_collision_traversal_node-inl.h"
219 
220 #endif
Traversal node for collision between mesh and shape.
Definition: mesh_shape_collision_traversal_node.h:52
bool enable_statistics
Whether stores statistics.
Definition: collision_traversal_node_base.h:78
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
collision result
Definition: collision_request.h:48
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:49
void leafTesting(int b1, int b2) const
Intersection testing between leaves (one triangle and one shape)
Definition: mesh_shape_collision_traversal_node-inl.h:62
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
Traversal node for collision between BVH and shape.
Definition: bvh_shape_collision_traversal_node.h:52
Triangle with 3 indices for points.
Definition: triangle.h:47
Definition: mesh_shape_collision_traversal_node.h:189
bool canStop() const
Whether the traversal process can stop early.
Definition: mesh_shape_collision_traversal_node-inl.h:126
Traversal node for mesh and shape, when mesh BVH is one of the oriented node (OBB, RSS, OBBRSS, kIOS)
Definition: mesh_shape_collision_traversal_node.h:108
request to the collision algorithm
Definition: collision_request.h:52
bool BVTesting(int b1, int b2) const
BV culling test in one BVTT node.
Definition: bvh_shape_collision_traversal_node-inl.h:85
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
Class merging the OBB and RSS, can handle collision and distance simultaneously.
Definition: OBBRSS.h:50
Definition: mesh_shape_collision_traversal_node.h:162
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:48
Definition: mesh_shape_collision_traversal_node.h:135
Oriented bounding box class.
Definition: OBB.h:51