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 FCL_MORTON_H
40 #define FCL_MORTON_H
41 
42 #include "fcl/common/types.h"
43 #include "fcl/math/bv/AABB.h"
44 
45 #include <bitset>
46 
47 namespace fcl
48 {
49 
51 namespace detail
52 {
53 
54 template <typename S>
55 FCL_EXPORT
56 uint32 quantize(S x, uint32 n);
57 
59 FCL_EXPORT
60 uint32 morton_code(uint32 x, uint32 y, uint32 z);
61 
63 FCL_EXPORT
64 uint64 morton_code60(uint32 x, uint32 y, uint32 z);
65 
70 template<typename S, typename T>
71 struct FCL_EXPORT morton_functor {};
72 
74 template<typename S>
75 struct FCL_EXPORT morton_functor<S, uint32>
76 {
77  morton_functor(const AABB<S>& bbox);
78 
79  uint32 operator() (const Vector3<S>& point) const;
80 
81  const Vector3<S> base;
82  const Vector3<S> inv;
83 
84  static constexpr size_t bits();
85 };
86 
87 using morton_functoru32f = morton_functor<float, uint32>;
88 using morton_functoru32d = morton_functor<double, uint32>;
89 
91 template<typename S>
92 struct FCL_EXPORT morton_functor<S, uint64>
93 {
94  morton_functor(const AABB<S>& bbox);
95 
96  uint64 operator() (const Vector3<S>& point) const;
97 
98  const Vector3<S> base;
99  const Vector3<S> inv;
100 
101  static constexpr size_t bits();
102 };
103 
104 using morton_functoru64f = morton_functor<float, uint64>;
105 using morton_functoru64d = morton_functor<double, uint64>;
106 
109 template<typename S, size_t N>
110 struct FCL_EXPORT morton_functor<S, std::bitset<N>>
111 {
112  static_assert(N%3==0, "Number of bits must be a multiple of 3");
113 
114  morton_functor(const AABB<S>& bbox);
115 
116  std::bitset<N> operator() (const Vector3<S>& point) const;
117 
118  const Vector3<S> base;
119  const Vector3<S> inv;
120 
121  static constexpr size_t bits();
122 };
123 
124 } // namespace detail
126 } // namespace fcl
127 
129 
130 #endif
types.h
fcl::uint64
std::uint64_t uint64
Definition: types.h:60
morton-inl.h
fcl::uint32
std::uint32_t uint32
Definition: types.h:62
fcl::time::point
std::chrono::system_clock::time_point point
Representation of a point in time.
Definition: time.h:52
std
Definition: gtest-tuple.h:104
AABB.h
fcl
Main namespace.
Definition: broadphase_bruteforce-inl.h:45


fcl
Author(s):
autogenerated on Tue Jun 22 2021 07:27:51