FCL  0.6.0
Flexible Collision Library
collision_node-inl.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_COLLISION_NODE_INL_H
39 #define FCL_COLLISION_NODE_INL_H
40 
41 #include "fcl/narrowphase/detail/traversal/collision_node.h"
42 
44 namespace fcl
45 {
46 
47 namespace detail
48 {
49 
50 //==============================================================================
51 extern template
52 void collide(CollisionTraversalNodeBase<double>* node, BVHFrontList* front_list);
53 
54 //==============================================================================
55 extern template
56 void selfCollide(CollisionTraversalNodeBase<double>* node, BVHFrontList* front_list);
57 
58 //==============================================================================
59 extern template
60 void distance(DistanceTraversalNodeBase<double>* node, BVHFrontList* front_list, int qsize);
61 
62 //==============================================================================
63 extern template
64 void collide2(MeshCollisionTraversalNodeOBB<double>* node, BVHFrontList* front_list);
65 
66 //==============================================================================
67 extern template
68 void collide2(MeshCollisionTraversalNodeRSS<double>* node, BVHFrontList* front_list);
69 
70 //==============================================================================
71 template <typename S>
72 void collide(CollisionTraversalNodeBase<S>* node, BVHFrontList* front_list)
73 {
74  if(front_list && front_list->size() > 0)
75  {
76  propagateBVHFrontListCollisionRecurse(node, front_list);
77  }
78  else
79  {
80  collisionRecurse(node, 0, 0, front_list);
81  }
82 }
83 
84 //==============================================================================
85 template <typename S>
86 void collide2(MeshCollisionTraversalNodeOBB<S>* node, BVHFrontList* front_list)
87 {
88  if(front_list && front_list->size() > 0)
89  {
90  propagateBVHFrontListCollisionRecurse(node, front_list);
91  }
92  else
93  {
94  Matrix3<S> Rtemp, R;
95  Vector3<S> Ttemp, T;
96  Rtemp = node->R * node->model2->getBV(0).getOrientation();
97  R = node->model1->getBV(0).getOrientation().transpose() * Rtemp;
98  Ttemp = node->R * node->model2->getBV(0).getCenter() + node->T;
99  Ttemp -= node->model1->getBV(0).getCenter();
100  T = node->model1->getBV(0).getOrientation().transpose() * Ttemp;
101 
102  collisionRecurse(node, 0, 0, R, T, front_list);
103  }
104 }
105 
106 //==============================================================================
107 template <typename S>
108 void collide2(MeshCollisionTraversalNodeRSS<S>* node, BVHFrontList* front_list)
109 {
110  if(front_list && front_list->size() > 0)
111  {
112  propagateBVHFrontListCollisionRecurse(node, front_list);
113  }
114  else
115  {
116  collisionRecurse(node, 0, 0, node->R, node->T, front_list);
117  }
118 }
119 
120 //==============================================================================
121 template <typename S>
122 void selfCollide(CollisionTraversalNodeBase<S>* node, BVHFrontList* front_list)
123 {
124 
125  if(front_list && front_list->size() > 0)
126  {
127  propagateBVHFrontListCollisionRecurse(node, front_list);
128  }
129  else
130  {
131  selfCollisionRecurse(node, 0, front_list);
132  }
133 }
134 
135 //==============================================================================
136 template <typename S>
137 void distance(DistanceTraversalNodeBase<S>* node, BVHFrontList* front_list, int qsize)
138 {
139  node->preprocess();
140 
141  if(qsize <= 2)
142  distanceRecurse(node, 0, 0, front_list);
143  else
144  distanceQueueRecurse(node, 0, 0, front_list, qsize);
145 
146  node->postprocess();
147 }
148 
149 } // namespace detail
150 } // namespace fcl
151 
152 #endif
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS-inl.h:266