@@ -90,100 +90,6 @@ namespace geode
9090 return result;
9191 }
9292
93- template < index_t dimension >
94- void AABBTree< dimension >::Impl::containing_boxes_recursive(
95- index_t node_index,
96- index_t element_begin,
97- index_t element_end,
98- const Point< dimension >& query,
99- std::vector< index_t >& result ) const
100- {
101- OPENGEODE_ASSERT ( node_index < tree_.size (), " Node index out of tree" );
102- OPENGEODE_ASSERT ( element_begin != element_end,
103- " Begin and End indices should be different" );
104- if ( !node ( node_index ).contains ( query ) )
105- {
106- return ;
107- }
108- if ( is_leaf ( element_begin, element_end ) )
109- {
110- result.push_back ( mapping_morton ( element_begin ) );
111- return ;
112- }
113- const auto it =
114- get_recursive_iterators ( node_index, element_begin, element_end );
115- containing_boxes_recursive (
116- it.child_left , element_begin, it.middle_box , query, result );
117- containing_boxes_recursive (
118- it.child_right , it.middle_box , element_end, query, result );
119- }
120-
121- /* *
122- * \brief Computes the hierarchy of bounding boxes recursively.
123- * \param[in] bboxes the array of bounding boxes
124- * \param[in] node_index the index of the root of the subtree
125- * \param[in] element_begin first box index in the vector \p bboxes
126- * \param[in] element_end one position past the last box index in the vector
127- * \p
128- * bboxes
129- */
130- template < index_t dimension >
131- void AABBTree< dimension >::Impl::initialize_tree_recursive(
132- absl::Span< const BoundingBox< dimension > > bboxes,
133- index_t node_index,
134- index_t element_begin,
135- index_t element_end )
136- {
137- OPENGEODE_ASSERT ( node_index < tree_.size (), " Node index out of tree" );
138- OPENGEODE_ASSERT ( element_begin != element_end,
139- " Begin and End indices should be different" );
140- if ( is_leaf ( element_begin, element_end ) )
141- {
142- tree_[node_index] = bboxes[mapping_morton_[element_begin]];
143- return ;
144- }
145- const auto it =
146- get_recursive_iterators ( node_index, element_begin, element_end );
147- OPENGEODE_ASSERT (
148- it.child_left < tree_.size (), " Left index out of tree" );
149- OPENGEODE_ASSERT (
150- it.child_right < tree_.size (), " Right index out of tree" );
151- initialize_tree_recursive (
152- bboxes, it.child_left , element_begin, it.middle_box );
153- initialize_tree_recursive (
154- bboxes, it.child_right , it.middle_box , element_end );
155- // before box_union
156- tree_[node_index].add_box ( node ( it.child_left ) );
157- tree_[node_index].add_box ( node ( it.child_right ) );
158- }
159-
160- template < index_t dimension >
161- index_t AABBTree< dimension >::Impl::closest_element_box_hint(
162- const Point< dimension >& query ) const
163- {
164- index_t box_begin{ 0 };
165- index_t box_end{ nb_bboxes () };
166- index_t node_index{ Impl::ROOT_INDEX };
167- while ( !is_leaf ( box_begin, box_end ) )
168- {
169- const auto it =
170- get_recursive_iterators ( node_index, box_begin, box_end );
171- if ( node ( it.child_left ).signed_distance ( query )
172- < node ( it.child_right ).signed_distance ( query ) )
173- {
174- box_end = it.middle_box ;
175- node_index = it.child_left ;
176- }
177- else
178- {
179- box_begin = it.middle_box ;
180- node_index = it.child_right ;
181- }
182- }
183-
184- return mapping_morton ( box_begin );
185- }
186-
18793 template class opengeode_geometry_api AABBTree< 2 >;
18894 template class opengeode_geometry_api AABBTree< 3 >;
18995} // namespace geode
0 commit comments