coal/broadphase/detail/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 COAL_MORTON_H
40 #define COAL_MORTON_H
41 
42 #include "coal/BV/AABB.h"
43 #include <cstdint>
44 #include <bitset>
45 
46 namespace coal {
47 
49 namespace detail {
50 
51 template <typename S>
52 uint32_t quantize(S x, uint32_t n);
53 
55 COAL_DLLAPI
56 uint32_t morton_code(uint32_t x, uint32_t y, uint32_t z);
57 
59 COAL_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 Vec3s& point) const;
75 
76  const Vec3s base;
77  const Vec3s 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<CoalScalar, 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 Vec3s& point) const;
91 
92  const Vec3s base;
93  const Vec3s 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 Vec3s& point) const;
107 
108  const Vec3s base;
109  const Vec3s inv;
110 
111  static constexpr size_t bits();
112 };
113 
114 } // namespace detail
116 } // namespace coal
117 
119 
120 #endif
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
uint32_t
uint32_t
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
uint64_t
uint64_t
morton-inl.h
base
MatrixDerived base(const Eigen::MatrixBase< MatrixDerived > &m)
AABB.h


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