Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d8/d05/BoundingBoxTree_8h_source.html
DOLFINx 0.6.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
BoundingBoxTree.h
1// Copyright (C) 2013 Anders Logg
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <algorithm>
10#include <array>
11#include <cassert>
12#include <cstdint>
13#include <mpi.h>
14#include <span>
15#include <string>
16#include <vector>
17
18namespace dolfinx::mesh
19{
20class Mesh;
21}
22
24{
25
29{
30
31public:
40 BoundingBoxTree(const mesh::Mesh& mesh, int tdim,
41 std::span<const std::int32_t> entities, double padding = 0);
42
49 BoundingBoxTree(const mesh::Mesh& mesh, int tdim, double padding = 0);
50
54 std::vector<std::pair<std::array<double, 3>, std::int32_t>> points);
55
58
60 BoundingBoxTree(const BoundingBoxTree& tree) = delete;
61
64
66 BoundingBoxTree& operator=(const BoundingBoxTree& other) = default;
67
69 ~BoundingBoxTree() = default;
70
76 std::array<double, 6> get_bbox(std::size_t node) const
77 {
78 std::array<double, 6> x;
79 std::copy_n(_bbox_coordinates.data() + 6 * node, 6, x.begin());
80 return x;
81 }
82
88 BoundingBoxTree create_global_tree(MPI_Comm comm) const;
89
91 std::int32_t num_bboxes() const;
92
94 int tdim() const;
95
97 std::string str() const;
98
106 std::array<std::int32_t, 2> bbox(std::size_t node) const
107 {
108 assert(2 * node + 1 < _bboxes.size());
109 return {_bboxes[2 * node], _bboxes[2 * node + 1]};
110 }
111
112private:
113 // Constructor
114 BoundingBoxTree(std::vector<std::int32_t>&& bboxes,
115 std::vector<double>&& bbox_coords);
116
117 // Topological dimension of leaf entities
118 int _tdim;
119
120 // Print out recursively, for debugging
121 void tree_print(std::stringstream& s, std::int32_t i) const;
122
123 // List of bounding boxes (parent-child-entity relations)
124 std::vector<std::int32_t> _bboxes;
125
126 // List of bounding box coordinates
127 std::vector<double> _bbox_coordinates;
128};
129} // namespace dolfinx::geometry
Axis-Aligned bounding box binary tree. It is used to find entities in a collection (often a mesh::Mes...
Definition: BoundingBoxTree.h:29
BoundingBoxTree & operator=(const BoundingBoxTree &other)=default
Copy assignment.
std::array< double, 6 > get_bbox(std::size_t node) const
Return bounding box coordinates for a given node in the tree,.
Definition: BoundingBoxTree.h:76
BoundingBoxTree & operator=(BoundingBoxTree &&other)=default
Move assignment.
BoundingBoxTree create_global_tree(MPI_Comm comm) const
Compute a global bounding tree (collective on comm) This can be used to find which process a point mi...
Definition: BoundingBoxTree.cpp:273
int tdim() const
Topological dimension of leaf entities.
Definition: BoundingBoxTree.cpp:314
BoundingBoxTree(BoundingBoxTree &&tree)=default
Move constructor.
std::int32_t num_bboxes() const
Return number of bounding boxes.
Definition: BoundingBoxTree.cpp:305
std::array< std::int32_t, 2 > bbox(std::size_t node) const
Get bounding box child nodes.
Definition: BoundingBoxTree.h:106
BoundingBoxTree(const BoundingBoxTree &tree)=delete
Copy constructor.
~BoundingBoxTree()=default
Destructor.
std::string str() const
Print out for debugging.
Definition: BoundingBoxTree.cpp:307
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:34
Geometry data structures and algorithms.
Definition: BoundingBoxTree.h:24
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:31