coal 3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
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
46namespace coal {
47
49namespace detail {
50
51template <typename S>
52uint32_t quantize(S x, uint32_t n);
53
56uint32_t morton_code(uint32_t x, uint32_t y, uint32_t z);
57
60uint64_t morton_code60(uint32_t x, uint32_t y, uint32_t z);
61
66template <typename S, typename T>
67struct morton_functor {};
68
70template <typename S>
71struct 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
82using morton_functoru32f = morton_functor<float, uint32_t>;
83using morton_functoru32d = morton_functor<Scalar, uint32_t>;
84
86template <typename S>
87struct 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
100template <typename S, size_t N>
101struct 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
#define COAL_DLLAPI
Definition config.hh:88
Main namespace.
Definition broadphase_bruteforce.h:44
Eigen::Matrix< Scalar, 3, 1 > Vec3s
Definition data_types.h:70