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 namespace fcl {
49 
51 
52 class TraversalNodeBase {
53  public:
54  TraversalNodeBase() : enable_statistics(false) {}
55 
56  virtual ~TraversalNodeBase() {}
57 
58  virtual void preprocess() {}
59 
60  virtual void postprocess() {}
61 
63  virtual bool isFirstNodeLeaf(unsigned int /*b*/) const { return true; }
64 
66  virtual bool isSecondNodeLeaf(unsigned int /*b*/) const { return true; }
67 
69  virtual bool firstOverSecond(unsigned int /*b1*/, unsigned int /*b2*/) const {
70  return true;
71  }
72 
74  virtual int getFirstLeftChild(unsigned int b) const { return (int)b; }
75 
77  virtual int getFirstRightChild(unsigned int b) const { return (int)b; }
78 
80  virtual int getSecondLeftChild(unsigned int b) const { return (int)b; }
81 
83  virtual int getSecondRightChild(unsigned int b) const { return (int)b; }
84 
86  void enableStatistics(bool enable) { enable_statistics = enable; }
87 
89  Transform3f tf1;
90 
92  Transform3f tf2;
93 
95  bool enable_statistics;
96 };
97 
101 
104 class CollisionTraversalNodeBase : public TraversalNodeBase {
105  public:
106  CollisionTraversalNodeBase(const CollisionRequest& request_)
107  : request(request_), result(NULL) {}
108 
109  virtual ~CollisionTraversalNodeBase() {}
110 
115  virtual bool BVDisjoints(unsigned int b1, unsigned int b2,
116  FCL_REAL& sqrDistLowerBound) const = 0;
117 
119  virtual void leafCollides(unsigned int /*b1*/, unsigned int /*b2*/,
120  FCL_REAL& /*sqrDistLowerBound*/) const = 0;
121 
123  bool canStop() const { return this->request.isSatisfied(*(this->result)); }
124 
126  const CollisionRequest& request;
127 
129  CollisionResult* result;
130 };
131 
133 
137 
140 class DistanceTraversalNodeBase : public TraversalNodeBase {
141  public:
142  DistanceTraversalNodeBase() : result(NULL) {}
143 
144  virtual ~DistanceTraversalNodeBase() {}
145 
149  virtual FCL_REAL BVDistanceLowerBound(unsigned int /*b1*/,
150  unsigned int /*b2*/) const {
151  return (std::numeric_limits<FCL_REAL>::max)();
152  }
153 
155  virtual void leafComputeDistance(unsigned int b1, unsigned int b2) const = 0;
156 
158  virtual bool canStop(FCL_REAL /*c*/) const { return false; }
159 
161  DistanceRequest request;
162 
164  DistanceResult* result;
165 };
166 
168 
169 } // namespace fcl
170 
171 } // namespace hpp
172 
174 
175 #endif
Main namespace.
tuple tf2
double FCL_REAL
Definition: data_types.h:65
tuple tf1


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:02