FCL  0.6.0
Flexible Collision Library
mesh_shape_distance_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_MESHSHAPEDISTANCETRAVERSALNODE_H
39 #define FCL_TRAVERSAL_MESHSHAPEDISTANCETRAVERSALNODE_H
40 
41 #include "fcl/geometry/shape/utility.h"
42 #include "fcl/narrowphase/detail/traversal/distance/bvh_shape_distance_traversal_node.h"
43 
44 namespace fcl
45 {
46 
47 namespace detail
48 {
49 
51 template <typename BV, typename Shape, typename NarrowPhaseSolver>
53  : public BVHShapeDistanceTraversalNode<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(S c) const;
66 
67  Vector3<S>* vertices;
68  Triangle* tri_indices;
69 
70  S rel_err;
71  S abs_err;
72 
73  const NarrowPhaseSolver* nsolver;
74 };
75 
76 template <typename BV, typename Shape, typename NarrowPhaseSolver>
77 void meshShapeDistanceOrientedNodeLeafTesting(
78  int b1, int /* b2 */,
79  const BVHModel<BV>* model1,
80  const Shape& model2,
81  Vector3<typename BV::S>* vertices,
82  Triangle* tri_indices,
83  const Transform3<typename BV::S>& tf1,
84  const Transform3<typename BV::S>& tf2,
85  const NarrowPhaseSolver* nsolver,
86  bool enable_statistics,
87  int & num_leaf_tests,
88  const DistanceRequest<typename BV::S>& /* request */,
90 
91 
92 template <typename BV, typename Shape, typename NarrowPhaseSolver>
93 void distancePreprocessOrientedNode(
94  const BVHModel<BV>* model1,
95  Vector3<typename BV::S>* vertices,
96  Triangle* tri_indices,
97  int init_tri_id,
98  const Shape& model2,
99  const Transform3<typename BV::S>& tf1,
100  const Transform3<typename BV::S>& tf2,
101  const NarrowPhaseSolver* nsolver,
102  const DistanceRequest<typename BV::S>& /* request */,
104 
107 template <typename BV, typename Shape, typename NarrowPhaseSolver>
108 bool initialize(
110  BVHModel<BV>& model1,
111  Transform3<typename BV::S>& tf1,
112  const Shape& model2,
113  const Transform3<typename BV::S>& tf2,
114  const NarrowPhaseSolver* nsolver,
117  bool use_refit = false, bool refit_bottomup = false);
118 
120 template <typename Shape, typename NarrowPhaseSolver>
123  RSS<typename Shape::S>, Shape, NarrowPhaseSolver>
124 {
125 public:
126  using S = typename Shape::S;
127 
129 
130  void preprocess();
131 
132  void postprocess();
133 
134  S BVTesting(int b1, int b2) const;
135 
136  void leafTesting(int b1, int b2) const;
137 };
138 
139 template <typename Shape, typename NarrowPhaseSolver>
140 bool initialize(
142  const BVHModel<RSS<typename Shape::S>>& model1,
143  const Transform3<typename Shape::S>& tf1,
144  const Shape& model2,
145  const Transform3<typename Shape::S>& tf2,
146  const NarrowPhaseSolver* nsolver,
147  const DistanceRequest<typename Shape::S>& request,
149 
150 template <typename Shape, typename NarrowPhaseSolver>
152  : public MeshShapeDistanceTraversalNode<kIOS<typename Shape::S>, Shape, NarrowPhaseSolver>
153 {
154 public:
155  using S = typename Shape::S;
156 
158 
159  void preprocess();
160 
161  void postprocess();
162 
163  S BVTesting(int b1, int b2) const;
164 
165  void leafTesting(int b1, int b2) const;
166 
167 };
168 
170 template <typename Shape, typename NarrowPhaseSolver>
171 bool initialize(
173  const BVHModel<kIOS<typename Shape::S>>& model1, const Transform3<typename Shape::S>& tf1,
174  const Shape& model2, const Transform3<typename Shape::S>& tf2,
175  const NarrowPhaseSolver* nsolver,
176  const DistanceRequest<typename Shape::S>& request,
178 
179 template <typename Shape, typename NarrowPhaseSolver>
181  : public MeshShapeDistanceTraversalNode<OBBRSS<typename Shape::S>, Shape, NarrowPhaseSolver>
182 {
183 public:
184  using S = typename Shape::S;
185 
187 
188  void preprocess();
189 
190  void postprocess();
191 
192  S BVTesting(int b1, int b2) const;
193 
194  void leafTesting(int b1, int b2) const;
195 
196 };
197 
199 template <typename Shape, typename NarrowPhaseSolver>
200 bool initialize(
202  const BVHModel<OBBRSS<typename Shape::S>>& model1,
203  const Transform3<typename Shape::S>& tf1,
204  const Shape& model2,
205  const Transform3<typename Shape::S>& tf2,
206  const NarrowPhaseSolver* nsolver,
207  const DistanceRequest<typename Shape::S>& request,
209 
210 } // namespace detail
211 } // namespace fcl
212 
213 #include "fcl/narrowphase/detail/traversal/distance/mesh_shape_distance_traversal_node-inl.h"
214 
215 #endif
bool canStop(S c) const
Whether the traversal process can stop early.
Definition: mesh_shape_distance_traversal_node-inl.h:98
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:49
Traversal node for distance between mesh and shape.
Definition: mesh_shape_distance_traversal_node.h:52
distance result
Definition: distance_request.h:48
Transform3< BV::S > tf2
configuration of second object
Definition: traversal_node_base.h:88
Traversal node for distance computation between BVH and shape.
Definition: bvh_shape_distance_traversal_node.h:52
Triangle with 3 indices for points.
Definition: triangle.h:47
S BVTesting(int b1, int b2) const
BV culling test in one BVTT node.
Definition: bvh_shape_distance_traversal_node-inl.h:85
DistanceRequest< BV::S > request
request setting for distance
Definition: distance_traversal_node_base.h:73
Traversal node for distance between mesh and shape, when mesh BVH is one of the oriented node (RSS...
Definition: mesh_shape_distance_traversal_node.h:121
Definition: mesh_shape_distance_traversal_node.h:151
Definition: mesh_shape_distance_traversal_node.h:180
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 leafTesting(int b1, int b2) const
Distance testing between leaves (one triangle and one shape)
Definition: mesh_shape_distance_traversal_node-inl.h:67
DistanceResult< BV::S > * result
distance result kept during the traversal iteration
Definition: distance_traversal_node_base.h:76
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
request to the distance computation
Definition: distance_request.h:52
bool enable_statistics
Whether stores statistics.
Definition: distance_traversal_node_base.h:79
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:48