21 #ifndef __BOUNDING_BOX_TREE_1D_H 22 #define __BOUNDING_BOX_TREE_1D_H 26 #include <dolfin/common/constants.h> 27 #include "GenericBoundingBoxTree.h" 46 less_x(
const std::vector<double>& bboxes): bboxes(bboxes) {}
51 const double* bi = bboxes.data() + 2*i;
52 const double* bj = bboxes.data() + 2*j;
53 return bi[0] + bi[1] < bj[0] + bj[1];
58 std::size_t
gdim()
const {
return 1; }
70 const double eps = DOLFIN_EPS_LARGE*(b[1] - b[0]);
71 return b[0] - eps <= x[0] && x[0] <= b[1] + eps;
78 const double eps = DOLFIN_EPS_LARGE*(b[1] - b[0]);
79 return b[0] - eps <= a[1] && a[0] <= b[1] + eps;
84 unsigned int node)
const 94 if (x[0] < b[0]) r2 += (x[0] - b[0])*(x[0] - b[0]);
95 if (x[0] > b[1]) r2 += (x[0] - b[1])*(x[0] - b[1]);
102 unsigned int node)
const 105 return (x[0] - p[0])*(x[0] - p[0]);
111 const std::vector<double>& leaf_bboxes,
112 const std::vector<unsigned int>::iterator&
begin,
113 const std::vector<unsigned int>::iterator&
end)
115 typedef std::vector<unsigned int>::const_iterator iterator;
119 const double* b = leaf_bboxes.data() + 2*(*it);
124 for (++it; it !=
end; ++it)
126 const double* b = leaf_bboxes.data() + 2*(*it);
127 if (b[0] < bbox[0]) bbox[0] = b[0];
128 if (b[1] > bbox[1]) bbox[1] = b[1];
138 const std::vector<Point>& points,
139 const std::vector<unsigned int>::iterator&
begin,
140 const std::vector<unsigned int>::iterator&
end)
142 typedef std::vector<unsigned int>::const_iterator iterator;
146 const double* p = points[*it].coordinates();
151 for (; it !=
end; ++it)
153 const double* p = points[*it].coordinates();
154 if (p[0] < bbox[0]) bbox[0] = p[0];
155 if (p[0] > bbox[1]) bbox[1] = p[0];
164 const std::vector<double>& leaf_bboxes,
165 const std::vector<unsigned int>::iterator&
begin,
166 const std::vector<unsigned int>::iterator& middle,
167 const std::vector<unsigned int>::iterator&
end)
169 std::nth_element(begin, middle, end,
less_x(leaf_bboxes));
void compute_bbox_of_bboxes(double *bbox, std::size_t &axis, const std::vector< double > &leaf_bboxes, const std::vector< unsigned int >::iterator &begin, const std::vector< unsigned int >::iterator &end)
Compute bounding box of bounding boxes.
Definition: BoundingBoxTree1D.h:109
Definition: GenericBoundingBoxTree.h:40
void begin(std::string msg,...)
Begin task (increase indentation level)
Definition: log.cpp:153
void sort_bboxes(std::size_t axis, const std::vector< double > &leaf_bboxes, const std::vector< unsigned int >::iterator &begin, const std::vector< unsigned int >::iterator &middle, const std::vector< unsigned int >::iterator &end)
Sort leaf bounding boxes along given axis.
Definition: BoundingBoxTree1D.h:163
const double * get_bbox_coordinates(unsigned int node) const
Return bounding box coordinates for node.
Definition: BoundingBoxTree1D.h:61
void compute_bbox_of_points(double *bbox, std::size_t &axis, const std::vector< Point > &points, const std::vector< unsigned int >::iterator &begin, const std::vector< unsigned int >::iterator &end)
Compute bounding box of points.
Definition: BoundingBoxTree1D.h:136
bool point_in_bbox(const double *x, unsigned int node) const
Check whether point (x) is in bounding box (node)
Definition: BoundingBoxTree1D.h:67
bool operator()(unsigned int i, unsigned int j)
Comparison operator.
Definition: BoundingBoxTree1D.h:49
void end()
End task (decrease indentation level)
Definition: log.cpp:168
less_x(const std::vector< double > &bboxes)
Constructor.
Definition: BoundingBoxTree1D.h:46
bool bbox_in_bbox(const double *a, unsigned int node) const
Check whether bounding box (a) collides with bounding box (node)
Definition: BoundingBoxTree1D.h:75
double compute_squared_distance_bbox(const double *x, unsigned int node) const
Compute squared distance between point and bounding box.
Definition: BoundingBoxTree1D.h:83
std::size_t gdim() const
Return geometric dimension.
Definition: BoundingBoxTree1D.h:58
const std::vector< double > & bboxes
Bounding boxes.
Definition: BoundingBoxTree1D.h:43
std::vector< double > _bbox_coordinates
List of bounding box coordinates.
Definition: GenericBoundingBoxTree.h:118
Specialization of bounding box implementation to 1D.
Definition: BoundingBoxTree1D.h:34
double compute_squared_distance_point(const double *x, unsigned int node) const
Compute squared distance between point and point.
Definition: BoundingBoxTree1D.h:101
Definition: BoundingBoxTree1D.h:40