AABBtree  0.0.1
A C++ non-recursive ND AABB tree
Loading...
Searching...
No Matches
AABBtree.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2026, Davide Stocco and Enrico Bertolazzi. *
3 * *
4 * The AABBtree project is distributed under the BSD 2-Clause License. *
5 * *
6 * Davide Stocco Enrico Bertolazzi *
7 * University of Trento University of Trento *
8 * davide.stocco@unitn.it enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#pragma once
12
13#ifndef INCLUDE_AABBTREE_HH
14#define INCLUDE_AABBTREE_HH
15
16// C++17 standard libraries
17#include <algorithm>
18#include <array>
19#include <functional>
20#include <iostream>
21#include <iterator>
22#include <limits>
23#include <map>
24#include <memory>
25#include <numeric>
26#include <queue>
27#include <set>
28#include <type_traits>
29#include <utility>
30#include <vector>
31
32// Eigen library
33#include <Eigen/Dense>
34#include <Eigen/Geometry>
35
36// Print AABBtree errors
37#ifndef AABBTREE_ERROR
38#define AABBTREE_ERROR(MSG) \
39 { \
40 std::ostringstream os; \
41 os << MSG; \
42 throw std::runtime_error(os.str()); \
43 }
44#endif
45
46// Assert for AABBtree
47#ifndef AABBTREE_ASSERT
48#define AABBTREE_ASSERT(COND, MSG) \
49 if (!(COND)) { \
50 AABBTREE_ERROR(MSG); \
51 }
52#endif
53
54// Warning for AABBtree
55#ifndef AABBTREE_WARNING
56#define AABBTREE_WARNING(MSG) \
57 { \
58 std::cout << MSG << std::endl; \
59 }
60#endif
61
62// Warning assert for AABBtree
63#ifndef AABBTREE_ASSERT_WARNING
64#define AABBTREE_ASSERT_WARNING(COND, MSG) \
65 if (!(COND)) { \
66 AABBTREE_WARNING(MSG); \
67 }
68#endif
69
70// Default integer AABBtree type
71#ifndef AABBTREE_DEFAULT_INTEGER_TYPE
72#define AABBTREE_DEFAULT_INTEGER_TYPE int
73#endif
74
81namespace AABBtree {
82
90static_assert(std::is_integral<Integer>::value,
91 "AABBTREE_DEFAULT_INTEGER_TYPE must be an integral type.");
92
93using IndexSet = std::set<Integer>;
94using IndexMap = std::map<Integer, IndexSet>;
95using IndexList = std::vector<Integer>;
96using OutStream = std::basic_ostream<char>;
97
98// Type aliases
99template <typename Real, Integer N> class Box;
100template <typename Real, Integer N>
101using BoxUniquePtr = std::unique_ptr<Box<Real, N>>;
102template <typename Real, Integer N>
103using BoxUniquePtrList = std::vector<BoxUniquePtr<Real, N>>;
104template <typename Real, Integer N> using Vector = Eigen::Vector<Real, N>;
105template <typename Real, Integer N> using Point = Eigen::Vector<Real, N>;
106
107} // namespace AABBtree
108
109#include "AABBtree/Box.hxx"
110#include "AABBtree/Ray.hxx"
111#include "AABBtree/Tree.hxx"
112
113#endif // INCLUDE_AABBTREE_HH
#define AABBTREE_DEFAULT_INTEGER_TYPE
Definition AABBtree.hh:72
A class representing an axis-aligned bounding box (AABB) in N-dimensional space.
Definition Box.hxx:50
Namespace for the AABBtree library.
Definition AABBtree.hh:81
std::basic_ostream< char > OutStream
Definition AABBtree.hh:96
Eigen::Vector< Real, N > Point
Definition AABBtree.hh:105
std::map< Integer, IndexSet > IndexMap
Definition AABBtree.hh:94
std::set< Integer > IndexSet
Definition AABBtree.hh:93
std::unique_ptr< Box< Real, N > > BoxUniquePtr
Definition AABBtree.hh:101
std::vector< BoxUniquePtr< Real, N > > BoxUniquePtrList
Definition AABBtree.hh:103
std::vector< Integer > IndexList
Definition AABBtree.hh:95
Eigen::Vector< Real, N > Vector
Definition AABBtree.hh:104
AABBTREE_DEFAULT_INTEGER_TYPE Integer
The Integer type used in the AABBtree class.
Definition AABBtree.hh:89