hpp-fcl 1.8.1
HPP fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
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>
46
47namespace hpp
48{
49namespace fcl
50{
51
53
54class TraversalNodeBase
55{
56public:
57 TraversalNodeBase () : enable_statistics(false) {}
58
59 virtual ~TraversalNodeBase() {}
60
61 virtual void preprocess() {}
62
63 virtual void postprocess() {}
64
66 virtual bool isFirstNodeLeaf(unsigned int /*b*/) const { return true; }
67
69 virtual bool isSecondNodeLeaf(unsigned int /*b*/) const { return true; }
70
72 virtual bool firstOverSecond(unsigned int /*b1*/, unsigned int /*b2*/) const { return true; }
73
75 virtual int getFirstLeftChild(unsigned int b) const { return (int)b; }
76
78 virtual int getFirstRightChild(unsigned int b) const { return (int)b; }
79
81 virtual int getSecondLeftChild(unsigned int b) const { return (int)b; }
82
84 virtual int getSecondRightChild(unsigned int b) const { return (int)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
104class CollisionTraversalNodeBase : public TraversalNodeBase
105{
106public:
107 CollisionTraversalNodeBase (const CollisionRequest& request_) :
108 request (request_), result(NULL) {}
109
110 virtual ~CollisionTraversalNodeBase() {}
111
113 virtual bool BVDisjoints(unsigned int b1, unsigned int b2) const = 0;
114
119 virtual bool BVDisjoints(unsigned int b1, unsigned int b2, FCL_REAL& sqrDistLowerBound) const = 0;
120
122 virtual void leafCollides(unsigned int /*b1*/, unsigned 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
142class DistanceTraversalNodeBase : public TraversalNodeBase
143{
144public:
145 DistanceTraversalNodeBase() : result(NULL) {}
146
147 virtual ~DistanceTraversalNodeBase() {}
148
152 virtual FCL_REAL BVDistanceLowerBound(unsigned int /*b1*/, unsigned int /*b2*/) const
153 {
154 return (std::numeric_limits<FCL_REAL>::max)();
155 }
156
158 virtual void leafComputeDistance(unsigned int b1, unsigned 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
double FCL_REAL
Definition: data_types.h:66
Main namespace.
Definition: AABB.h:44