DOLFIN
DOLFIN C++ interface
BoundingBoxTree.h
1 // Copyright (C) 2013 Anders Logg
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2013-04-09
19 // Last changed: 2014-05-12
20 
21 #ifndef __BOUNDING_BOX_TREE_H
22 #define __BOUNDING_BOX_TREE_H
23 
24 #include <limits>
25 #include <vector>
26 #include <memory>
27 
28 namespace dolfin
29 {
30 
31  // Forward declarations
32  class Point;
33  class GenericBoundingBoxTree;
34  class Mesh;
35 
39 
41  {
42  public:
43 
46 
49 
55  void build(const Mesh& mesh);
56 
65  void build(const Mesh& mesh, std::size_t tdim);
66 
74  void build(const std::vector<Point>& points, std::size_t gdim);
75 
87  std::vector<unsigned int>
88  compute_collisions(const Point& point) const;
89 
116  std::pair<std::vector<unsigned int>, std::vector<unsigned int> >
117  compute_collisions(const BoundingBoxTree& tree) const;
118 
129  std::vector<unsigned int>
130  compute_entity_collisions(const Point& point) const;
131 
144  std::vector<unsigned int>
145  compute_process_collisions(const Point& point) const;
146 
168  std::pair<std::vector<unsigned int>, std::vector<unsigned int> >
169  compute_entity_collisions(const BoundingBoxTree& tree) const;
170 
183  unsigned int
184  compute_first_collision(const Point& point) const;
185 
198  unsigned int
199  compute_first_entity_collision(const Point& point) const;
200 
215  std::pair<unsigned int, double>
216  compute_closest_entity(const Point& point) const;
217 
240  std::pair<unsigned int, double>
241  compute_closest_point(const Point& point) const;
242 
250  bool collides(const Point& point) const;
251 
260  bool collides_entity(const Point& point) const;
261 
262  private:
263 
264  // Check that tree has been built
265  void _check_built() const;
266 
267  // Dimension-dependent implementation
268  std::shared_ptr<GenericBoundingBoxTree> _tree;
269 
270  // Pointer to the mesh. We all know that we don't really want
271  // to store a pointer to the mesh here, but without it we will
272  // be forced to make calls like
273  // tree_A.compute_entity_intersections(tree_B, mesh_A, mesh_B).
274  const Mesh* _mesh;
275 
276  };
277 
278 }
279 
280 #endif
Definition: BoundingBoxTree.h:40
void build(const Mesh &mesh)
Definition: BoundingBoxTree.cpp:43
std::vector< unsigned int > compute_entity_collisions(const Point &point) const
Definition: BoundingBoxTree.cpp:111
std::vector< unsigned int > compute_process_collisions(const Point &point) const
Definition: BoundingBoxTree.cpp:123
std::pair< unsigned int, double > compute_closest_point(const Point &point) const
Definition: BoundingBoxTree.cpp:183
Definition: adapt.h:29
Definition: Point.h:40
unsigned int compute_first_entity_collision(const Point &point) const
Definition: BoundingBoxTree.cpp:159
std::pair< unsigned int, double > compute_closest_entity(const Point &point) const
Definition: BoundingBoxTree.cpp:171
BoundingBoxTree()
Create empty bounding box tree.
Definition: BoundingBoxTree.cpp:33
std::vector< unsigned int > compute_collisions(const Point &point) const
Definition: BoundingBoxTree.cpp:88
unsigned int compute_first_collision(const Point &point) const
Definition: BoundingBoxTree.cpp:148
bool collides(const Point &point) const
Definition: BoundingBoxTree.cpp:193
~BoundingBoxTree()
Destructor.
Definition: BoundingBoxTree.cpp:38
bool collides_entity(const Point &point) const
Definition: BoundingBoxTree.cpp:198
Definition: Mesh.h:82