hpp-fcl: include/hpp/fcl/BV/BV_node.h Source File

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

BV_node.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
39 #ifndef HPP_FCL_BV_NODE_H
40 #define HPP_FCL_BV_NODE_H
41
42 #include <hpp/fcl/data_types.h>
43
44 #include <hpp/fcl/BV/BV.h>
45 #include <iostream>
46
47 namespace hpp
48 {
49 namespace fcl
50 {
51
55
57 struct HPP_FCL_DLLAPI BVNodeBase
58 {
63 int first_child;
64
67 int first_primitive;
68
70 int num_primitives;
71
73 BVNodeBase()
74 : first_child(0)
75 , first_primitive(-1)
76 , num_primitives(-1)
77 {}
78
80 bool operator==(const BVNodeBase & other) const
81 {
82 return
83 first_child == other.first_child
84 && first_primitive == other.first_primitive
85 && num_primitives == other.num_primitives;
86 }
87
89 bool operator!=(const BVNodeBase & other) const
90 {
91 return !(*this == other);
92 }
93
95 inline bool isLeaf() const { return first_child < 0; }
96
98 inline int primitiveId() const { return -(first_child + 1); }
99
101 inline int leftChild() const { return first_child; }
102
104 inline int rightChild() const { return first_child + 1; }
105 };
106
108 template<typename BV>
109 struct HPP_FCL_DLLAPI BVNode : public BVNodeBase
110 {
111 typedef BVNodeBase Base;
112
114 BV bv;
115
117 bool operator==(const BVNode & other) const
118 {
119 return Base::operator==(other) && bv == other.bv;
120 }
121
123 bool operator!=(const BVNode & other) const
124 {
125 return !(*this == other);
126 }
127
129 bool overlap(const BVNode& other) const
130 {
131 return bv.overlap(other.bv);
132 }
134 bool overlap(const BVNode& other, const CollisionRequest& request,
135 FCL_REAL& sqrDistLowerBound) const
136 {
137 return bv.overlap(other.bv, request, sqrDistLowerBound);
138 }
139
141 FCL_REAL distance(const BVNode& other, Vec3f* P1 = NULL, Vec3f* P2 = NULL) const
142 {
143 return bv.distance(other.bv, P1, P2);
144 }
145
147 Vec3f getCenter() const { return bv.center(); }
148
150 const Matrix3f& getOrientation() const
151 {
152 static const Matrix3f id3 = Matrix3f::Identity();
153 return id3;
154 }
155
157 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
159 };
160
161 template<>
162 inline const Matrix3f& BVNode<OBB>::getOrientation() const
163 {
164 return bv.axes;
165 }
166
167 template<>
168 inline const Matrix3f& BVNode<RSS>::getOrientation() const
169 {
170 return bv.axes;
171 }
172
173 template<>
174 inline const Matrix3f& BVNode<OBBRSS>::getOrientation() const
175 {
176 return bv.obb.axes;
177 }
178
179
180 }
181
182 } // namespace hpp
183
184 #endif
BV.h
data_types.h
hpp::fcl::BVNodeBase::first_child
int first_child
An index for first child node or primitive If the value is positive, it is the index of the first chi...
Definition: BV_node.h:63
hpp::fcl::BVNodeBase::operator!=
bool operator!=(const BVNodeBase &other) const
Difference operator.
Definition: BV_node.h:89
hpp::fcl::BVNode::operator!=
bool operator!=(const BVNode &other) const
Difference operator.
Definition: BV_node.h:123
hpp::fcl::BVNodeBase::rightChild
int rightChild() const
Return the index of the second child. The index is referred to the bounding volume array (i....
Definition: BV_node.h:104
hpp::fcl::BVNodeBase::leftChild
int leftChild() const
Return the index of the first child. The index is referred to the bounding volume array (i....
Definition: BV_node.h:101
hpp::fcl::BVNode::distance
FCL_REAL distance(const BVNode &other, Vec3f *P1=NULL, Vec3f *P2=NULL) const
Compute the distance between two BVNode. P1 and P2, if not NULL and the underlying BV supports distan...
Definition: BV_node.h:141
hpp::fcl::BVNode::bv
BV bv
bounding volume storing the geometry
Definition: BV_node.h:114
hpp::fcl::BVNodeBase::num_primitives
int num_primitives
The number of primitives belonging to the current node.
Definition: BV_node.h:70
hpp::fcl::BVNodeBase::BVNodeBase
BVNodeBase()
Default constructor.
Definition: BV_node.h:73
hpp::fcl::BVNodeBase::first_primitive
int first_primitive
The start id the primitive belonging to the current node. The index is referred to the primitive_indi...
Definition: BV_node.h:67
hpp::fcl::BVNodeBase::operator==
bool operator==(const BVNodeBase &other) const
Equality operator.
Definition: BV_node.h:80
hpp::fcl::BVNode::operator==
bool operator==(const BVNode &other) const
Equality operator.
Definition: BV_node.h:117
hpp::fcl::BVNode::getOrientation
const Matrix3f & getOrientation() const
Access to the orientation of the BV.
Definition: BV_node.h:150
hpp::fcl::BVNode::Base
BVNodeBase Base
Definition: BV_node.h:111
hpp::fcl::BVNode::getCenter
Vec3f getCenter() const
Access to the center of the BV.
Definition: BV_node.h:147
hpp::fcl::BVNodeBase::isLeaf
bool isLeaf() const
Whether current node is a leaf node (i.e. contains a primitive index.
Definition: BV_node.h:95
hpp::fcl::BVNodeBase::primitiveId
int primitiveId() const
Return the primitive index. The index is referred to the original data (i.e. vertices or tri_indices)...
Definition: BV_node.h:98
hpp::fcl::BVNode::overlap
bool overlap(const BVNode &other) const
Check whether two BVNode collide.
Definition: BV_node.h:129
hpp::fcl::BVNode::overlap
bool overlap(const BVNode &other, const CollisionRequest &request, FCL_REAL &sqrDistLowerBound) const
Check whether two BVNode collide.
Definition: BV_node.h:134
hpp::fcl::Matrix3f
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:68
hpp::fcl::Vec3f
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
hpp::fcl::FCL_REAL
double FCL_REAL
Definition: data_types.h:66
hpp
Main namespace.
Definition: AABB.h:44
hpp::fcl::BVNodeBase
BVNodeBase encodes the tree structure for BVH.
Definition: BV_node.h:58
hpp::fcl::BVNode
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:110
hpp::fcl::CollisionRequest
request to the collision algorithm
Definition: collision_data.h:209