/usr/include/vtk-7.1/vtkdiy/pick.hpp is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | #ifndef DIY_PICK_HPP
#define DIY_PICK_HPP
#include "link.hpp"
namespace diy
{
template<class Bounds, class Point, class OutIter>
void near(const RegularLink<Bounds>& link, const Point& p, float r, OutIter out,
const Bounds& domain);
template<class Bounds, class Point, class OutIter>
void in(const RegularLink<Bounds>& link, const Point& p, OutIter out, const Bounds& domain);
template<class Point, class Bounds>
float distance(int dim, const Bounds& bounds, const Point& p);
template<class Bounds>
inline
float distance(int dim, const Bounds& bounds1, const Bounds& bounds2);
template<class Bounds>
void wrap_bounds(Bounds& bounds, Direction wrap_dir, const Bounds& domain, int dim);
}
//! Finds the neighbors within radius r of a target point.
template<class Bounds, class Point, class OutIter>
void
diy::
near(const RegularLink<Bounds>& link, //!< neighbors
const Point& p, //!< target point (must be in current block)
float r, //!< target radius (>= 0.0)
OutIter out, //!< insert iterator for output set of neighbors
const Bounds& domain) //!< global domain bounds
{
Bounds neigh_bounds; // neighbor block bounds
// for all neighbors of this block
for (int n = 0; n < link.size(); n++)
{
// wrap neighbor bounds, if necessary, otherwise bounds will be unchanged
neigh_bounds = link.bounds(n);
wrap_bounds(neigh_bounds, link.wrap(n), domain, link.dimension());
if (distance(link.dimension(), neigh_bounds, p) <= r)
*out++ = n;
} // for all neighbors
}
//! Find the distance between point `p` and box `bounds`.
template<class Point, class Bounds>
float
diy::
distance(int dim, const Bounds& bounds, const Point& p)
{
float res = 0;
for (int i = 0; i < dim; ++i)
{
// avoids all the annoying case logic by finding
// diff = max(bounds.min[i] - p[i], 0, p[i] - bounds.max[i])
float diff = 0, d;
d = bounds.min[i] - p[i];
if (d > diff) diff = d;
d = p[i] - bounds.max[i];
if (d > diff) diff = d;
res += diff*diff;
}
return sqrt(res);
}
template<class Bounds>
float
diy::
distance(int dim, const Bounds& bounds1, const Bounds& bounds2)
{
float res = 0;
for (int i = 0; i < dim; ++i)
{
float diff = 0, d;
float d1 = bounds1.max[i] - bounds2.min[i];
float d2 = bounds2.max[i] - bounds1.min[i];
if (d1 > 0 && d2 > 0)
diff = 0;
else if (d1 <= 0)
diff = -d1;
else if (d2 <= 0)
diff = -d2;
res += diff*diff;
}
return sqrt(res);
}
//! Finds the neighbor(s) containing the target point.
template<class Bounds, class Point, class OutIter>
void
diy::
in(const RegularLink<Bounds>& link, //!< neighbors
const Point& p, //!< target point
OutIter out, //!< insert iterator for output set of neighbors
const Bounds& domain) //!< global domain bounds
{
Bounds neigh_bounds; // neighbor block bounds
// for all neighbors of this block
for (int n = 0; n < link.size(); n++)
{
// wrap neighbor bounds, if necessary, otherwise bounds will be unchanged
neigh_bounds = link.bounds(n);
wrap_bounds(neigh_bounds, link.wrap(n), domain, link.dimension());
if (distance(link.dimension(), neigh_bounds, p) == 0)
*out++ = n;
} // for all neighbors
}
// wraps block bounds
// wrap dir is the wrapping direction from original block to wrapped neighbor block
// overall domain bounds and dimensionality are also needed
template<class Bounds>
void
diy::
wrap_bounds(Bounds& bounds, Direction wrap_dir, const Bounds& domain, int dim)
{
for (int i = 0; i < dim; ++i)
{
bounds.min[i] += wrap_dir[i] * (domain.max[i] - domain.min[i]);
bounds.max[i] += wrap_dir[i] * (domain.max[i] - domain.min[i]);
}
}
#endif
|