AABBtree  0.0.0
A C++ non-recursive ND AABB tree
Loading...
Searching...
No Matches
AABBtree.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, 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 * e-mail: davide.stocco@unitn.it e-mail: 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 <limits>
18#include <type_traits>
19#include <array>
20#include <vector>
21#include <queue>
22#include <set>
23#include <map>
24#include <iostream>
25#include <utility>
26#include <memory>
27#include <algorithm>
28#include <numeric>
29#include <iterator>
30#include <functional>
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 std::ostringstream os; os << MSG; \
40 throw std::runtime_error(os.str()); \
41}
42#endif
43
44// Assert for AABBtree
45#ifndef AABBTREE_ASSERT
46#define AABBTREE_ASSERT(COND, MSG) if (!(COND)) { AABBTREE_ERROR(MSG); }
47#endif
48
49// Warning for AABBtree
50#ifndef AABBTREE_WARNING
51#define AABBTREE_WARNING(MSG) { std::cout << MSG << '\n' }
52#endif
53
54// Warning assert for AABBtree
55#ifndef AABBTREE_ASSERT_WARNING
56#define AABBTREE_ASSERT_WARNING(COND, MSG) if (!(COND)) { AABBTREE_WARNING(MSG); }
57#endif
58
59// Default integer AABBtree type
60#ifndef AABBTREE_DEFAULT_INTEGER_TYPE
61#define AABBTREE_DEFAULT_INTEGER_TYPE int
62#endif
63
69namespace AABBtree
70{
71
79 static_assert(std::is_integral<Integer>::value, "AABBTREE_DEFAULT_INTEGER_TYPE must be an integral type.");
80
81 using IndexSet = std::set<Integer>;
82 using IndexMap = std::map<Integer, IndexSet>;
83 using IndexList = std::vector<Integer>;
84 using OutStream = std::basic_ostream<char>;
85
86 // Type aliases
87 template <typename Real, Integer N> class Box;
88 template <typename Real, Integer N> using BoxUniquePtr = std::unique_ptr<Box<Real, N>>;
89 template <typename Real, Integer N> using BoxUniquePtrList = std::vector<BoxUniquePtr<Real, N>>;
90 template <typename Real, Integer N> using Vector = Eigen::Vector<Real, N>;
91 template <typename Real, Integer N> using Point = Eigen::Vector<Real, N>;
92
93} // namespace AABBtree
94
95#include "AABBtree/Box.hxx"
96#include "AABBtree/Ray.hxx"
97#include "AABBtree/Tree.hxx"
98
99#endif // INCLUDE_AABBTREE_HH
#define AABBTREE_DEFAULT_INTEGER_TYPE
Definition AABBtree.hh:61
A class representing an axis-aligned bounding box (AABB) in N-dimensional space.
Definition Box.hxx:49
Namespace for the AABBtree library.
Definition AABBtree.hh:70
std::basic_ostream< char > OutStream
Definition AABBtree.hh:84
Eigen::Vector< Real, N > Point
Definition AABBtree.hh:91
std::map< Integer, IndexSet > IndexMap
Definition AABBtree.hh:82
std::set< Integer > IndexSet
Definition AABBtree.hh:81
std::unique_ptr< Box< Real, N > > BoxUniquePtr
Definition AABBtree.hh:88
std::vector< BoxUniquePtr< Real, N > > BoxUniquePtrList
Definition AABBtree.hh:89
std::vector< Integer > IndexList
Definition AABBtree.hh:83
Eigen::Vector< Real, N > Vector
Definition AABBtree.hh:90
AABBTREE_DEFAULT_INTEGER_TYPE Integer
The Integer type used in the AABBtree class.
Definition AABBtree.hh:78