libigl v2.5.0
Loading...
Searching...
No Matches
AABB.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License
6// v. 2.0. If a copy of the MPL was not distributed with this file, You can
7// obtain one at http://mozilla.org/MPL/2.0/.
8#ifndef IGL_AABB_H
9#define IGL_AABB_H
10
11#include "Hit.h"
12#include "igl_inline.h"
13#include <cassert>
14#include <Eigen/Core>
15#include <Eigen/Geometry>
16#include <vector>
17namespace igl
18{
29 template <typename DerivedV, int DIM>
30 class AABB
31 {
32public:
34// Member variables
37 typedef typename DerivedV::Scalar Scalar;
39 typedef Eigen::Matrix<Scalar,1,DIM> RowVectorDIMS;
41 typedef Eigen::Matrix<Scalar,DIM,1> VectorDIMS;
43 typedef Eigen::Matrix<Scalar,Eigen::Dynamic,DIM> MatrixXDIMS;
45 // Shared pointers are slower...
46 AABB * m_left;
48 AABB * m_right;
50 AABB * m_parent;
52 Eigen::AlignedBox<Scalar,DIM> m_box;
56// Non-templated member functions
58 //Scalar m_low_sqr_d;
59 //int m_depth;
61 AABB():
62 m_left(nullptr), m_right(nullptr),m_parent(nullptr),
63 m_box(), m_primitive(-1)
64 //m_low_sqr_d(std::numeric_limits<double>::infinity()),
65 //m_depth(0)
66 {
67 static_assert(DerivedV::ColsAtCompileTime == DIM || DerivedV::ColsAtCompileTime == Eigen::Dynamic,"DerivedV::ColsAtCompileTime == DIM || DerivedV::ColsAtCompileTime == Eigen::Dynamic");
68 }
70 // http://stackoverflow.com/a/3279550/148668
71 AABB(const AABB& other):
72 m_left (other.m_left ? new AABB(*other.m_left) : nullptr),
73 m_right(other.m_right ? new AABB(*other.m_right) : nullptr),
74 m_parent(other.m_parent),
75 m_box(other.m_box),
77 //m_low_sqr_d(other.m_low_sqr_d),
78 //m_depth(std::max(
79 // m_left ? m_left->m_depth + 1 : 0,
80 // m_right ? m_right->m_depth + 1 : 0))
81 {
82 if(m_left) { m_left->m_parent = this; }
83 if(m_right) { m_right->m_parent = this; }
84 }
86 // copy-swap idiom
87 friend void swap(AABB& first, AABB& second)
88 {
89 // Enable ADL
90 using std::swap;
91 swap(first.m_left,second.m_left);
92 swap(first.m_right,second.m_right);
93 swap(first.m_parent,second.m_parent);
94 swap(first.m_box,second.m_box);
95 swap(first.m_primitive,second.m_primitive);
96 //swap(first.m_low_sqr_d,second.m_low_sqr_d);
97 //swap(first.m_depth,second.m_depth);
98 }
99
100 // Pass-by-value (aka copy)
101 AABB& operator=(AABB other)
102 {
103 swap(*this,other);
104 return *this;
105 }
107 AABB(AABB&& other):
108 // initialize via default constructor
109 AABB()
110 {
111 swap(*this,other);
112 }
114 // Seems like there should have been an elegant solution to this using
115 // the copy-swap idiom above:
116 IGL_INLINE void clear()
117 {
118 m_primitive = -1;
119 m_box = Eigen::AlignedBox<Scalar,DIM>();
120 delete m_left;
121 m_left = nullptr;
122 delete m_right;
123 m_right = nullptr;
124 // Tell my parent I'm dead
125 if(m_parent)
126 {
127 if(m_parent->m_left == this)
128 {
129 m_parent->m_left = nullptr;
130 }else if(m_parent->m_right == this)
131 {
132 m_parent->m_right = nullptr;
133 }else
134 {
135 assert(false && "I'm not my parent's child");
136 }
137 auto * grandparent = m_parent->m_parent;
138 if(grandparent)
139 {
140 // Before
141 // grandparent
142 // ╱ ╲
143 // parent pibling
144 // ╱ ╲
145 // sibling this
146 //
147 // After
148 // grandparent
149 // ╱ ╲
150 // sibling® pibling
151 }else
152 {
153 // Before
154 // parent=root
155 // ╱ ╲
156 // sibling this
157 //
158 // After
159 // grandparent
160 // ╱ ╲
161 // sibling® pibling
162 }
163 }
164 // Now my parent is dead to me.
165 m_parent = nullptr;
166 }
168 ~AABB()
169 {
170 clear();
171 }
173 IGL_INLINE bool is_leaf() const;
175 IGL_INLINE bool is_root() const;
177 IGL_INLINE AABB<DerivedV,DIM>* root() const;
178 IGL_INLINE AABB<DerivedV,DIM>* detach();
184 IGL_INLINE std::vector<AABB<DerivedV,DIM>*> gather_leaves(const int m);
186 IGL_INLINE std::vector<AABB<DerivedV,DIM>*> gather_leaves();
191 IGL_INLINE AABB<DerivedV,DIM>* pad(
192 const std::vector<AABB<DerivedV,DIM>*> & leaves,
193 const Scalar pad,
194 const int polish_rotate_passes=0);
212 IGL_INLINE AABB<DerivedV,DIM>* update(
213 const Eigen::AlignedBox<Scalar,DIM> & new_box,
214 const Scalar pad=0);
251 IGL_INLINE AABB<DerivedV,DIM>* insert(AABB * other);
274 IGL_INLINE AABB<DerivedV,DIM>* insert_as_sibling(AABB * other);
292 IGL_INLINE Scalar rotate(const bool dry_run = false);
321 IGL_INLINE Scalar rotate_across(const bool dry_run = false);
343 IGL_INLINE Scalar rotate_up(const bool dry_run = false);
373 IGL_INLINE Scalar rotate_down(const bool dry_run = false);
398 const bool dry_run,
399 AABB<DerivedV,DIM>* reining,
400 AABB<DerivedV,DIM>* grandparent,
401 AABB<DerivedV,DIM>* parent,
402 AABB<DerivedV,DIM>* challenger,
403 AABB<DerivedV,DIM>* sibling);
404 // Should this be a static function with an argument?
419 const Eigen::AlignedBox<Scalar,DIM> & box,
420 std::vector<const AABB<DerivedV,DIM>*> & leaves) const;
422 IGL_INLINE typename DerivedV::Scalar internal_surface_area() const;
425 IGL_INLINE void validate() const;
427 IGL_INLINE void print(const int depth = 0) const;
432 IGL_INLINE int size() const;
434 IGL_INLINE int height() const;
435private:
452 IGL_INLINE void set_min(
453 const RowVectorDIMS & p,
454 const Scalar sqr_d_candidate,
455 const int & i_candidate,
456 const RowVectorDIMS & c_candidate,
457 Scalar & sqr_d,
458 int & i,
459 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
460public:
462// Templated member functions
476 template <
477 typename DerivedEle,
478 typename Derivedbb_mins,
479 typename Derivedbb_maxs,
480 typename Derivedelements>
482 const Eigen::MatrixBase<DerivedV> & V,
483 const Eigen::MatrixBase<DerivedEle> & Ele,
484 const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
485 const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
486 const Eigen::MatrixBase<Derivedelements> & elements,
487 const int i = 0);
493 template <typename DerivedEle>
495 const Eigen::MatrixBase<DerivedV> & V,
496 const Eigen::MatrixBase<DerivedEle> & Ele);
508 template <typename DerivedEle, typename DerivedSI, typename DerivedI>
510 const Eigen::MatrixBase<DerivedV> & V,
511 const Eigen::MatrixBase<DerivedEle> & Ele,
512 const Eigen::MatrixBase<DerivedSI> & SI,
513 const Eigen::MatrixBase<DerivedI>& I);
516 template <typename DerivedEle>
517 IGL_INLINE AABB<DerivedV,DIM>* update_primitive(
518 const Eigen::MatrixBase<DerivedV> & V,
519 const Eigen::MatrixBase<DerivedEle> & Ele,
520 const Scalar pad=0);
521
532 template <typename DerivedEle, typename Derivedq>
533 IGL_INLINE std::vector<int> find(
534 const Eigen::MatrixBase<DerivedV> & V,
535 const Eigen::MatrixBase<DerivedEle> & Ele,
536 const Eigen::MatrixBase<Derivedq> & q,
537 const bool first=false) const;
538
548 template <
549 typename Derivedbb_mins,
550 typename Derivedbb_maxs,
551 typename Derivedelements>
553 Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
554 Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
555 Eigen::PlainObjectBase<Derivedelements> & elements,
556 const int i = 0) const;
568 template <typename DerivedEle>
570 const Eigen::MatrixBase<DerivedV> & V,
571 const Eigen::MatrixBase<DerivedEle> & Ele,
572 const RowVectorDIMS & p,
573 int & i,
574 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
592 template <typename DerivedEle>
594 const Eigen::MatrixBase<DerivedV> & V,
595 const Eigen::MatrixBase<DerivedEle> & Ele,
596 const RowVectorDIMS & p,
597 const Scalar low_sqr_d,
598 const Scalar up_sqr_d,
599 int & i,
600 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
613 template <typename DerivedEle>
615 const Eigen::MatrixBase<DerivedV> & V,
616 const Eigen::MatrixBase<DerivedEle> & Ele,
617 const RowVectorDIMS & p,
618 const Scalar up_sqr_d,
619 int & i,
620 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
629 template <typename DerivedEle>
631 const Eigen::MatrixBase<DerivedV> & V,
632 const Eigen::MatrixBase<DerivedEle> & Ele,
633 const RowVectorDIMS & origin,
634 const RowVectorDIMS & dir,
635 std::vector<igl::Hit<typename DerivedV::Scalar>> & hits) const;
644 template <typename DerivedEle>
646 const Eigen::MatrixBase<DerivedV> & V,
647 const Eigen::MatrixBase<DerivedEle> & Ele,
648 const RowVectorDIMS & origin,
649 const RowVectorDIMS & dir,
651
661 template <typename DerivedEle>
663 const Eigen::MatrixBase<DerivedV> & V,
664 const Eigen::MatrixBase<DerivedEle> & Ele,
665 const RowVectorDIMS & origin,
666 const RowVectorDIMS & dir,
667 const Scalar min_t,
680 template <
681 typename DerivedEle,
682 typename DerivedOrigin,
683 typename DerivedDir,
684 typename DerivedI,
685 typename DerivedT,
686 typename DerivedUV>
688 const Eigen::MatrixBase<DerivedV> & V,
689 const Eigen::MatrixBase<DerivedEle> & Ele,
690 const Eigen::MatrixBase<DerivedOrigin> & origin,
691 const Eigen::MatrixBase<DerivedDir> & dir,
692 const Scalar min_t,
693 Eigen::PlainObjectBase<DerivedI> & I,
694 Eigen::PlainObjectBase<DerivedT> & T,
695 Eigen::PlainObjectBase<DerivedUV> & UV);
696 template <
697 typename DerivedEle,
698 typename DerivedOrigin,
699 typename DerivedDir>
701 const Eigen::MatrixBase<DerivedV> & V,
702 const Eigen::MatrixBase<DerivedEle> & Ele,
703 const Eigen::MatrixBase<DerivedOrigin> & origin,
704 const Eigen::MatrixBase<DerivedDir> & dir,
705 std::vector<std::vector<igl::Hit<typename DerivedV::Scalar>>> & hits);
716 template <
717 typename DerivedEle,
718 typename DerivedP,
719 typename DerivedsqrD,
720 typename DerivedI,
721 typename DerivedC>
723 const Eigen::MatrixBase<DerivedV> & V,
724 const Eigen::MatrixBase<DerivedEle> & Ele,
725 const Eigen::MatrixBase<DerivedP> & P,
726 Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
727 Eigen::PlainObjectBase<DerivedI> & I,
728 Eigen::PlainObjectBase<DerivedC> & C) const;
742 template <
743 typename DerivedEle,
744 typename Derivedother_V,
745 typename Derivedother_Ele,
746 typename DerivedsqrD,
747 typename DerivedI,
748 typename DerivedC>
750 const Eigen::MatrixBase<DerivedV> & V,
751 const Eigen::MatrixBase<DerivedEle> & Ele,
752 const AABB<Derivedother_V,DIM> & other,
753 const Eigen::MatrixBase<Derivedother_V> & other_V,
754 const Eigen::MatrixBase<Derivedother_Ele> & other_Ele,
755 Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
756 Eigen::PlainObjectBase<DerivedI> & I,
757 Eigen::PlainObjectBase<DerivedC> & C) const;
758private:
759 template <
760 typename DerivedEle,
761 typename Derivedother_V,
762 typename Derivedother_Ele,
763 typename DerivedsqrD,
764 typename DerivedI,
765 typename DerivedC>
766 IGL_INLINE Scalar squared_distance_helper(
767 const Eigen::MatrixBase<DerivedV> & V,
768 const Eigen::MatrixBase<DerivedEle> & Ele,
769 const AABB<Derivedother_V,DIM> * other,
770 const Eigen::MatrixBase<Derivedother_V> & other_V,
771 const Eigen::MatrixBase<Derivedother_Ele>& other_Ele,
772 const Scalar up_sqr_d,
773 Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
774 Eigen::PlainObjectBase<DerivedI> & I,
775 Eigen::PlainObjectBase<DerivedC> & C) const;
776 // Compute the squared distance to the primitive in this node: assumes
777 // that this is indeed a leaf node.
778 //
779 // Inputs:
780 // V #V by dim list of vertex positions
781 // Ele #Ele by dim list of simplex indices
782 // p dim-long query point
783 // sqr_d current minimum distance for this query, see output
784 // i current index into Ele of closest point, see output
785 // c dim-long current closest point, see output
786 // Outputs:
787 // sqr_d minimum of initial value and squared distance to this
788 // primitive
789 // i possibly updated index into Ele of closest point
790 // c dim-long possibly updated closest point
791 template <typename DerivedEle>
792 IGL_INLINE void leaf_squared_distance(
793 const Eigen::MatrixBase<DerivedV> & V,
794 const Eigen::MatrixBase<DerivedEle> & Ele,
795 const RowVectorDIMS & p,
796 const Scalar low_sqr_d,
797 Scalar & sqr_d,
798 int & i,
799 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
800 // Default low_sqr_d
801 template <typename DerivedEle>
802 IGL_INLINE void leaf_squared_distance(
803 const Eigen::MatrixBase<DerivedV> & V,
804 const Eigen::MatrixBase<DerivedEle> & Ele,
805 const RowVectorDIMS & p,
806 Scalar & sqr_d,
807 int & i,
808 Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
817 template <typename DerivedEle>
818 IGL_INLINE bool intersect_ray_opt(
819 const Eigen::MatrixBase<DerivedV> & V,
820 const Eigen::MatrixBase<DerivedEle> & Ele,
821 const RowVectorDIMS & origin,
822 const RowVectorDIMS & dir,
823 const RowVectorDIMS & inv_dir,
824 const RowVectorDIMS & inv_dir_pad,
825 std::vector<igl::Hit<typename DerivedV::Scalar>> & hits) const;
835 template <typename DerivedEle>
836 IGL_INLINE bool intersect_ray_opt(
837 const Eigen::MatrixBase<DerivedV> & V,
838 const Eigen::MatrixBase<DerivedEle> & Ele,
839 const RowVectorDIMS & origin,
840 const RowVectorDIMS & dir,
841 const RowVectorDIMS & inv_dir,
842 const RowVectorDIMS & inv_dir_pad,
843 const Scalar min_t,
845public:
846 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
847 };
848}
849
850
851#ifndef IGL_STATIC_LIBRARY
852# include "AABB.cpp"
853#endif
854
855#endif
Implementation of semi-general purpose axis-aligned bounding box hierarchy.
Definition AABB.h:31
IGL_INLINE std::vector< int > find(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< Derivedq > &q, const bool first=false) const
Find the indices of elements containing given point: this makes sense when Ele is a co-dimension 0 si...
IGL_INLINE bool intersect_ray(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &origin, const RowVectorDIMS &dir, std::vector< igl::Hit< typename DerivedV::Scalar > > &hits) const
Intersect a ray with the mesh return all hits.
IGL_INLINE std::vector< AABB< DerivedV, DIM > * > gather_leaves()
Eigen::Matrix< Scalar, DIM, 1 > VectorDIMS
Fixed-size (DIM) (Column)Vector type using Scalar.
Definition AABB.h:41
IGL_INLINE Scalar rotate_across(const bool dry_run=false)
Try to swap this node with its cousins if it will decrease total internal surface area.
IGL_INLINE void init(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< Derivedbb_mins > &bb_mins, const Eigen::MatrixBase< Derivedbb_maxs > &bb_maxs, const Eigen::MatrixBase< Derivedelements > &elements, const int i=0)
Build an Axis-Aligned Bounding Box tree for a given mesh and given serialization of a previous AABB t...
IGL_INLINE void squared_distance(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const AABB< Derivedother_V, DIM > &other, const Eigen::MatrixBase< Derivedother_V > &other_V, const Eigen::MatrixBase< Derivedother_Ele > &other_Ele, Eigen::PlainObjectBase< DerivedsqrD > &sqrD, Eigen::PlainObjectBase< DerivedI > &I, Eigen::PlainObjectBase< DerivedC > &C) const
Compute the squared distance from all query points in P already stored in its own AABB hierarchy to t...
AABB * m_left
Pointer to "left" child node (nullptr if leaf).
Definition AABB.h:46
IGL_INLINE bool is_leaf() const
Return whether at leaf node.
IGL_INLINE bool intersect_ray(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &origin, const RowVectorDIMS &dir, const Scalar min_t, igl::Hit< typename DerivedV::Scalar > &hit) const
Intersect a ray with the mesh return first hit farther than min_t.
IGL_INLINE AABB< DerivedV, DIM > * update_primitive(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Scalar pad=0)
IGL_INLINE void intersect_ray(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< DerivedOrigin > &origin, const Eigen::MatrixBase< DerivedDir > &dir, std::vector< std::vector< igl::Hit< typename DerivedV::Scalar > > > &hits)
IGL_INLINE AABB< DerivedV, DIM > * insert_as_sibling(AABB *other)
Insert other as a sibling to this by creating a new internal node to be their shared parent.
IGL_INLINE bool intersect_ray(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &origin, const RowVectorDIMS &dir, igl::Hit< typename DerivedV::Scalar > &hit) const
Intersect a ray with the mesh return first hit.
int m_primitive
Index of single primitive in this node if full leaf, otherwise -1 for non-leaf.
Definition AABB.h:54
static IGL_INLINE Scalar rotate_up(const bool dry_run, AABB< DerivedV, DIM > *reining, AABB< DerivedV, DIM > *grandparent, AABB< DerivedV, DIM > *parent, AABB< DerivedV, DIM > *challenger, AABB< DerivedV, DIM > *sibling)
"Rotate" (swap) reining with challenger.
IGL_INLINE void squared_distance(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< DerivedP > &P, Eigen::PlainObjectBase< DerivedsqrD > &sqrD, Eigen::PlainObjectBase< DerivedI > &I, Eigen::PlainObjectBase< DerivedC > &C) const
Compute the squared distance from all query points in P to the closest points on the primitives store...
IGL_INLINE void refit_lineage()
DerivedV::Scalar Scalar
Scalar type of vertex positions (e.g., double).
Definition AABB.h:37
IGL_INLINE void init(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele)
Build an Axis-Aligned Bounding Box tree for a given mesh and given serialization of a previous AABB t...
IGL_INLINE AABB< DerivedV, DIM > * pad(const std::vector< AABB< DerivedV, DIM > * > &leaves, const Scalar pad, const int polish_rotate_passes=0)
Pad leaves by pad in each dimension.
IGL_INLINE int size() const
IGL_INLINE void init(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< DerivedSI > &SI, const Eigen::MatrixBase< DerivedI > &I)
Build an Axis-Aligned Bounding Box tree for a given mesh.
IGL_INLINE bool append_intersecting_leaves(const Eigen::AlignedBox< Scalar, DIM > &box, std::vector< const AABB< DerivedV, DIM > * > &leaves) const
IGL_INLINE Scalar squared_distance(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &p, int &i, Eigen::PlainObjectBase< RowVectorDIMS > &c) const
Compute squared distance to a query point.
friend void swap(AABB &first, AABB &second)
Definition AABB.h:87
IGL_INLINE AABB< DerivedV, DIM > * detach()
AABB * m_right
Pointer to "right" child node (nullptr if leaf).
Definition AABB.h:48
IGL_INLINE void intersect_ray(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const Eigen::MatrixBase< DerivedOrigin > &origin, const Eigen::MatrixBase< DerivedDir > &dir, const Scalar min_t, Eigen::PlainObjectBase< DerivedI > &I, Eigen::PlainObjectBase< DerivedT > &T, Eigen::PlainObjectBase< DerivedUV > &UV)
Intersect a rays with the mesh return first hit for each.
IGL_INLINE int subtree_size() const
Number of nodes contained in subtree (is it?).
Eigen::Matrix< Scalar, Eigen::Dynamic, DIM > MatrixXDIMS
Fixed-width (DIM) Matrix type using Scalar.
Definition AABB.h:43
IGL_INLINE void rotate_lineage()
IGL_INLINE bool is_root() const
Return whether at root node.
IGL_INLINE Scalar squared_distance(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &p, const Scalar low_sqr_d, const Scalar up_sqr_d, int &i, Eigen::PlainObjectBase< RowVectorDIMS > &c) const
Compute squared distance to a query point if within low_sqr_d and up_sqr_d.
Eigen::Matrix< Scalar, 1, DIM > RowVectorDIMS
Fixed-size (DIM) RowVector type using Scalar.
Definition AABB.h:39
IGL_INLINE Scalar squared_distance(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedEle > &Ele, const RowVectorDIMS &p, const Scalar up_sqr_d, int &i, Eigen::PlainObjectBase< RowVectorDIMS > &c) const
Compute squared distance to a query point (default low_sqr_d).
IGL_INLINE Scalar rotate(const bool dry_run=false)
Try to swap this node with its close relatives if it will decrease total internal surface area.
IGL_INLINE Scalar rotate_down(const bool dry_run=false)
Try to swap this node with one of its niblings if it will decrease total internal surface area.
IGL_INLINE void serialize(Eigen::PlainObjectBase< Derivedbb_mins > &bb_mins, Eigen::PlainObjectBase< Derivedbb_maxs > &bb_maxs, Eigen::PlainObjectBase< Derivedelements > &elements, const int i=0) const
Serialize this class into 3 arrays (so we can pass it pack to matlab).
IGL_INLINE int height() const
IGL_INLINE Scalar rotate_up(const bool dry_run=false)
Try to swap this node with its pibling if it will decrease total internal surface area.
Eigen::AlignedBox< Scalar, DIM > m_box
Axis-Aligned Bounding Box containing this node.
Definition AABB.h:52
IGL_INLINE void validate() const
Validate the subtree under this node by running a bunch of assertions.
IGL_INLINE AABB< DerivedV, DIM > * update(const Eigen::AlignedBox< Scalar, DIM > &new_box, const Scalar pad=0)
IGL_INLINE DerivedV::Scalar internal_surface_area() const
Compute sum of surface area of all internal (non-root, non-leaf) boxes.
IGL_INLINE AABB< DerivedV, DIM > * insert(AABB *other)
Insert a (probably a leaf) AABB other into this AABB tree.
IGL_INLINE std::vector< AABB< DerivedV, DIM > * > gather_leaves(const int m)
Get a vector of leaves indexed by their m_primitive id (these better be non-negative and tightly pack...
IGL_INLINE AABB< DerivedV, DIM > * root() const
Return the root node of this node's tree by following its parent.
IGL_INLINE void print(const int depth=0) const
print the memory addresses of the tree in a somewhat legible way
AABB * m_parent
Pointer to "parent" node (nullptr if root).
Definition AABB.h:50
#define IGL_INLINE
Definition igl_inline.h:15
Definition AABB.h:18
Reimplementation of the embree::Hit struct from embree1.0.
Definition Hit.h:18