morton.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-2016, Open Source Robotics Foundation
6  * Copyright (c) 2016, Toyota Research Institute
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Open Source Robotics Foundation nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
39 #ifndef HPP_FCL_MORTON_H
40 #define HPP_FCL_MORTON_H
41 
42 #include "hpp/fcl/BV/AABB.h"
43 #include <bitset>
44 
45 namespace hpp {
46 namespace fcl {
47 
49 namespace detail {
50 
51 template <typename S>
52 uint32_t quantize(S x, uint32_t n);
53 
55 HPP_FCL_DLLAPI
56 uint32_t morton_code(uint32_t x, uint32_t y, uint32_t z);
57 
59 HPP_FCL_DLLAPI
60 uint64_t morton_code60(uint32_t x, uint32_t y, uint32_t z);
61 
66 template <typename S, typename T>
67 struct morton_functor {};
68 
70 template <typename S>
71 struct morton_functor<S, uint32_t> {
72  morton_functor(const AABB& bbox);
73 
74  uint32_t operator()(const Vec3f& point) const;
75 
76  const Vec3f base;
77  const Vec3f inv;
78 
79  static constexpr size_t bits();
80 };
81 
82 using morton_functoru32f = morton_functor<float, uint32_t>;
83 using morton_functoru32d = morton_functor<FCL_REAL, uint32_t>;
84 
86 template <typename S>
87 struct morton_functor<S, uint64_t> {
88  morton_functor(const AABB& bbox);
89 
90  uint64_t operator()(const Vec3f& point) const;
91 
92  const Vec3f base;
93  const Vec3f inv;
94 
95  static constexpr size_t bits();
96 };
97 
100 template <typename S, size_t N>
101 struct morton_functor<S, std::bitset<N>> {
102  static_assert(N % 3 == 0, "Number of bits must be a multiple of 3");
103 
104  morton_functor(const AABB& bbox);
105 
106  std::bitset<N> operator()(const Vec3f& point) const;
107 
108  const Vec3f base;
109  const Vec3f inv;
110 
111  static constexpr size_t bits();
112 };
113 
114 } // namespace detail
116 } // namespace fcl
117 } // namespace hpp
118 
120 
121 #endif
hpp::fcl::Vec3f
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
uint32_t
uint32_t
uint64_t
uint64_t
morton-inl.h
hpp
Main namespace.
Definition: broadphase_bruteforce.h:44
AABB.h
base
MatrixDerived base(const Eigen::MatrixBase< MatrixDerived > &m)


hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14