hpp-fcl: include/hpp/fcl/internal/traversal_node_base.h Source File

hpp-fcl 1.7.7 HPP fork of FCL -- The Flexible Collision Library

traversal_node_base.h
Go to the documentation of this file.
1 /*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011-2014, Willow Garage, Inc.
5 * Copyright (c) 2014-2015, 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 HPP_FCL_TRAVERSAL_NODE_BASE_H
39 #define HPP_FCL_TRAVERSAL_NODE_BASE_H
40
42
43 #include <hpp/fcl/data_types.h>
44 #include <hpp/fcl/math/transform.h>
45 #include <hpp/fcl/collision_data.h>
46
47 namespace hpp
48 {
49 namespace fcl
50 {
51
53
54 class TraversalNodeBase
55 {
56 public:
57 TraversalNodeBase () : enable_statistics(false) {}
58
59 virtual ~TraversalNodeBase() {}
60
61 virtual void preprocess() {}
62
63 virtual void postprocess() {}
64
66 virtual bool isFirstNodeLeaf(int /*b*/) const { return true; }
67
69 virtual bool isSecondNodeLeaf(int /*b*/) const { return true; }
70
72 virtual bool firstOverSecond(int /*b1*/, int /*b2*/) const { return true; }
73
75 virtual int getFirstLeftChild(int b) const { return b; }
76
78 virtual int getFirstRightChild(int b) const { return b; }
79
81 virtual int getSecondLeftChild(int b) const { return b; }
82
84 virtual int getSecondRightChild(int b) const { return b; }
85
87 void enableStatistics(bool enable) { enable_statistics = enable; }
88
90 Transform3f tf1;
91
93 Transform3f tf2;
94
96 bool enable_statistics;
97 };
98
102
104 class CollisionTraversalNodeBase : public TraversalNodeBase
105 {
106 public:
107 CollisionTraversalNodeBase (const CollisionRequest& request_) :
108 request (request_), result(NULL) {}
109
110 virtual ~CollisionTraversalNodeBase() {}
111
113 virtual bool BVDisjoints(int b1, int b2) const = 0;
114
119 virtual bool BVDisjoints(int b1, int b2, FCL_REAL& sqrDistLowerBound) const = 0;
120
122 virtual void leafCollides(int /*b1*/, int /*b2*/, FCL_REAL& /*sqrDistLowerBound*/) const = 0;
123
125 bool canStop() const { return this->request.isSatisfied(*(this->result)); }
126
128 const CollisionRequest& request;
129
131 CollisionResult* result;
132
133 };
134
136
140
142 class DistanceTraversalNodeBase : public TraversalNodeBase
143 {
144 public:
145 DistanceTraversalNodeBase() : result(NULL) {}
146
147 virtual ~DistanceTraversalNodeBase() {}
148
152 virtual FCL_REAL BVDistanceLowerBound(int /*b1*/, int /*b2*/) const
153 {
154 return (std::numeric_limits<FCL_REAL>::max)();
155 }
156
158 virtual void leafComputeDistance(int b1, int b2) const = 0;
159
161 virtual bool canStop(FCL_REAL /*c*/) const
162 { return false; }
163
165 DistanceRequest request;
166
168 DistanceResult* result;
169 };
170
172
173 }
174
175 } // namespace hpp
176
178
179 #endif
180
collision_data.h
data_types.h
hpp::fcl::FCL_REAL
double FCL_REAL
Definition: data_types.h:66
hpp
Main namespace.
Definition: AABB.h:44
transform.h