coal/BV/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 
38 #ifndef COAL_BV_NODE_H
39 #define COAL_BV_NODE_H
40 
41 #include "coal/data_types.h"
42 #include "coal/BV/BV.h"
43 
44 namespace coal {
45 
49 
51 struct COAL_DLLAPI BVNodeBase {
57 
61  unsigned int first_primitive;
62 
64  unsigned int num_primitives;
65 
68  : first_child(0),
69  first_primitive(
70  (std::numeric_limits<unsigned int>::max)()) // value we should help
71  // to raise an issue
72  ,
73  num_primitives(0) {}
74 
76  bool operator==(const BVNodeBase& other) const {
77  return first_child == other.first_child &&
78  first_primitive == other.first_primitive &&
79  num_primitives == other.num_primitives;
80  }
81 
83  bool operator!=(const BVNodeBase& other) const { return !(*this == other); }
84 
87  inline bool isLeaf() const { return first_child < 0; }
88 
91  inline int primitiveId() const { return -(first_child + 1); }
92 
95  inline int leftChild() const { return first_child; }
96 
99  inline int rightChild() const { return first_child + 1; }
100 };
101 
105 template <typename BV>
106 struct COAL_DLLAPI BVNode : public BVNodeBase {
107  typedef BVNodeBase Base;
108 
110  BV bv;
111 
113  bool operator==(const BVNode& other) const {
114  return Base::operator==(other) && bv == other.bv;
115  }
116 
118  bool operator!=(const BVNode& other) const { return !(*this == other); }
119 
121  bool overlap(const BVNode& other) const { return bv.overlap(other.bv); }
123  bool overlap(const BVNode& other, const CollisionRequest& request,
124  CoalScalar& sqrDistLowerBound) const {
125  return bv.overlap(other.bv, request, sqrDistLowerBound);
126  }
127 
130  CoalScalar distance(const BVNode& other, Vec3s* P1 = NULL,
131  Vec3s* P2 = NULL) const {
132  return bv.distance(other.bv, P1, P2);
133  }
134 
136  Vec3s getCenter() const { return bv.center(); }
137 
139  const Matrix3s& getOrientation() const {
140  static const Matrix3s id3 = Matrix3s::Identity();
141  return id3;
142  }
143 
145  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
147 };
148 
149 template <>
150 inline const Matrix3s& BVNode<OBB>::getOrientation() const {
151  return bv.axes;
152 }
153 
154 template <>
155 inline const Matrix3s& BVNode<RSS>::getOrientation() const {
156  return bv.axes;
157 }
158 
159 template <>
161  return bv.obb.axes;
162 }
163 
164 } // namespace coal
165 
166 #endif
coal::BVNode::distance
CoalScalar distance(const BVNode &other, Vec3s *P1=NULL, Vec3s *P2=NULL) const
Compute the distance between two BVNode. P1 and P2, if not NULL and the underlying BV supports distan...
Definition: coal/BV/BV_node.h:130
coal::BVNodeBase::primitiveId
int primitiveId() const
Return the primitive index. The index is referred to the original data (i.e. vertices or tri_indices)...
Definition: coal/BV/BV_node.h:91
coal::BVNodeBase::operator==
bool operator==(const BVNodeBase &other) const
Equality operator.
Definition: coal/BV/BV_node.h:76
coal::BVNode::getCenter
Vec3s getCenter() const
Access to the center of the BV.
Definition: coal/BV/BV_node.h:136
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
coal::BVNode::getOrientation
const Matrix3s & getOrientation() const
Access to the orientation of the BV.
Definition: coal/BV/BV_node.h:139
gjk.P2
tuple P2
Definition: test/scripts/gjk.py:22
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::BVNodeBase
BVNodeBase encodes the tree structure for BVH.
Definition: coal/BV/BV_node.h:51
coal::BVNodeBase::num_primitives
unsigned int num_primitives
The number of primitives belonging to the current node.
Definition: coal/BV/BV_node.h:64
coal::BVNodeBase::rightChild
int rightChild() const
Return the index of the second child. The index is referred to the bounding volume array (i....
Definition: coal/BV/BV_node.h:99
coal::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: coal/BV/BV_node.h:56
BV.h
coal::BVNode::overlap
bool overlap(const BVNode &other) const
Check whether two BVNode collide.
Definition: coal/BV/BV_node.h:121
coal::BVNode::bv
BV bv
bounding volume storing the geometry
Definition: coal/BV/BV_node.h:110
gjk.P1
tuple P1
Definition: test/scripts/gjk.py:21
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::BVNodeBase::first_primitive
unsigned int first_primitive
The start id the primitive belonging to the current node. The index is referred to the primitive_indi...
Definition: coal/BV/BV_node.h:61
coal::BVNode
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: coal/BV/BV_node.h:106
coal::BVNodeBase::operator!=
bool operator!=(const BVNodeBase &other) const
Difference operator.
Definition: coal/BV/BV_node.h:83
coal::BVNode::overlap
bool overlap(const BVNode &other, const CollisionRequest &request, CoalScalar &sqrDistLowerBound) const
Check whether two BVNode collide.
Definition: coal/BV/BV_node.h:123
coal::Matrix3s
Eigen::Matrix< CoalScalar, 3, 3 > Matrix3s
Definition: coal/data_types.h:81
coal::BVNode::operator!=
bool operator!=(const BVNode &other) const
Difference operator.
Definition: coal/BV/BV_node.h:118
coal::BVNodeBase::BVNodeBase
BVNodeBase()
Default constructor.
Definition: coal/BV/BV_node.h:67
coal::BVNodeBase::isLeaf
bool isLeaf() const
Whether current node is a leaf node (i.e. contains a primitive index.
Definition: coal/BV/BV_node.h:87
coal::BVNode::operator==
bool operator==(const BVNode &other) const
Equality operator.
Definition: coal/BV/BV_node.h:113
coal::BVNode::Base
BVNodeBase Base
Definition: coal/BV/BV_node.h:107
data_types.h
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::BVNodeBase::leftChild
int leftChild() const
Return the index of the first child. The index is referred to the bounding volume array (i....
Definition: coal/BV/BV_node.h:95


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57