FCL  0.6.0
Flexible Collision Library
shape_mesh_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_SHAPEMESHDISTANCETRAVERSALNODE_H
39 #define FCL_TRAVERSAL_SHAPEMESHDISTANCETRAVERSALNODE_H
40 
41 #include "fcl/narrowphase/detail/traversal/distance/shape_bvh_distance_traversal_node.h"
42 #include "fcl/geometry/bvh/BVH_model.h"
43 
44 namespace fcl
45 {
46 
47 namespace detail
48 {
49 
51 template <typename Shape, typename BV, typename NarrowPhaseSolver>
53  : public ShapeBVHDistanceTraversalNode<Shape, BV>
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 
78 template <typename Shape, typename BV, typename NarrowPhaseSolver>
79 bool initialize(
81  const Shape& model1,
82  const Transform3<typename BV::S>& tf1,
83  BVHModel<BV>& model2,
84  Transform3<typename BV::S>& tf2,
85  const NarrowPhaseSolver* nsolver,
88  bool use_refit = false,
89  bool refit_bottomup = false);
90 
91 template <typename Shape, typename NarrowPhaseSolver>
94  Shape, RSS<typename Shape::S>, NarrowPhaseSolver>
95 {
96 public:
97 
98  using S = typename Shape::S;
99 
101 
102  void preprocess();
103 
104  void postprocess();
105 
106  S BVTesting(int b1, int b2) const;
107 
108  void leafTesting(int b1, int b2) const;
109 
110 };
111 
114 template <typename Shape, typename NarrowPhaseSolver>
115 bool initialize(
117  const Shape& model1,
118  const Transform3<typename Shape::S>& tf1,
119  const BVHModel<RSS<typename Shape::S>>& model2,
120  const Transform3<typename Shape::S>& tf2,
121  const NarrowPhaseSolver* nsolver,
122  const DistanceRequest<typename Shape::S>& request,
124 
125 template <typename Shape, typename NarrowPhaseSolver>
128  Shape, kIOS<typename Shape::S>, NarrowPhaseSolver>
129 {
130 public:
131 
132  using S = typename Shape::S;
133 
135 
136  void preprocess();
137 
138  void postprocess();
139 
140  S BVTesting(int b1, int b2) const;
141 
142  void leafTesting(int b1, int b2) const;
143 
144 };
145 
148 template <typename Shape, typename NarrowPhaseSolver>
149 bool initialize(
151  const Shape& model1,
152  const Transform3<typename Shape::S>& tf1,
153  const BVHModel<kIOS<typename Shape::S>>& model2,
154  const Transform3<typename Shape::S>& tf2,
155  const NarrowPhaseSolver* nsolver,
156  const DistanceRequest<typename Shape::S>& request,
158 
159 template <typename Shape, typename NarrowPhaseSolver>
162  Shape, OBBRSS<typename Shape::S>, NarrowPhaseSolver>
163 {
164 public:
165 
166  using S = typename Shape::S;
167 
169 
170  void preprocess();
171 
172  void postprocess();
173 
174  S BVTesting(int b1, int b2) const;
175 
176  void leafTesting(int b1, int b2) const;
177 
178 };
179 
182 template <typename Shape, typename NarrowPhaseSolver>
183 bool initialize(
185  const Shape& model1,
186  const Transform3<typename Shape::S>& tf1,
187  const BVHModel<OBBRSS<typename Shape::S>>& model2,
188  const Transform3<typename Shape::S>& tf2,
189  const NarrowPhaseSolver* nsolver,
190  const DistanceRequest<typename Shape::S>& request,
192 
193 } // namespace detail
194 } // namespace fcl
195 
196 #include "fcl/narrowphase/detail/traversal/distance/shape_mesh_distance_traversal_node-inl.h"
197 
198 #endif
Definition: shape_mesh_distance_traversal_node.h:92
Traversal node for distance between shape and mesh.
Definition: shape_mesh_distance_traversal_node.h:52
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
Definition: shape_mesh_distance_traversal_node.h:126
A class for rectangle sphere-swept bounding volume.
Definition: RSS.h:49
distance result
Definition: distance_request.h:48
Transform3< BV::S > tf2
configuration of second object
Definition: traversal_node_base.h:88
Definition: shape_mesh_distance_traversal_node.h:160
Traversal node for distance computation between shape and BVH.
Definition: shape_bvh_distance_traversal_node.h:53
Triangle with 3 indices for points.
Definition: triangle.h:47
bool canStop(S c) const
Whether the traversal process can stop early.
Definition: shape_mesh_distance_traversal_node-inl.h:98
S BVTesting(int b1, int b2) const
BV culling test in one BVTT node.
Definition: shape_bvh_distance_traversal_node-inl.h:86
DistanceRequest< BV::S > request
request setting for distance
Definition: distance_traversal_node_base.h:73
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 shape and one triangle)
Definition: shape_mesh_distance_traversal_node-inl.h:66
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
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:48