43 for (
unsigned i = 0; i < a.size(); ++i)
45 bl[i] = std::min(a[i], b[i]);
46 tr[i] = std::max(a[i], b[i]);
49 elems[0] =
static_cast<int> (bl[0]);
50 elems[1] =
static_cast<int> (tr[0]);
51 elems[2] =
static_cast<int> (bl[1]);
52 elems[3] =
static_cast<int> (tr[1]);
53 elems[4] =
static_cast<int> (bl[2]);
54 elems[5] =
static_cast<int> (tr[2]);
59 Eigen::Vector3i bl, tr;
60 for (
unsigned i = 0; i < a.size(); ++i)
62 bl[i] = std::min(a[i], b[i]);
63 tr[i] = std::max(a[i], b[i]);
66 elems[0] =
static_cast<int> (bl[0]);
67 elems[1] =
static_cast<int> (tr[0]);
68 elems[2] =
static_cast<int> (bl[1]);
69 elems[3] =
static_cast<int> (tr[1]);
70 elems[4] =
static_cast<int> (bl[2]);
71 elems[5] =
static_cast<int> (tr[2]);
76 for (
unsigned i = 0; i < size(); ++i)
77 elems[i] = static_cast<int> (data[i]);
82 std::copy(data, data + size(), elems);
87 return Eigen::Vector3i(elems[0], elems[2], elems[4]);
91 return Eigen::Vector3i(elems[1], elems[3], elems[5]);
108 c[0] = x ? elems[1] : elems[0];
109 c[1] = y ? elems[3] : elems[2];
110 c[2] = z ? elems[5] : elems[4];
120 for (
unsigned i = 0; i < 3; ++i)
121 inside &= ((elems[2 * i] <= p[i]) && (p[i] <= elems[2 * i + 1]));
150 for (
unsigned i = 0; i < a.size(); ++i)
152 bl[i] = std::min(a[i], b[i]);
153 tr[i] = std::max(a[i], b[i]);
165 std::copy(data, data + size(), elems);
169 std::copy(data, data + size(), elems);
173 for (
unsigned i = 0; i < size(); ++i)
175 elems[i] = bb.elems[i];
190 return Vector3D(elems[0], elems[2], elems[4]);
194 return Vector3D(elems[1], elems[3], elems[5]);
211 c[0] = x ? elems[1] : elems[0];
212 c[1] = y ? elems[3] : elems[2];
213 c[2] = z ? elems[5] : elems[4];
223 for (
unsigned i = 0; i < 3; ++i)
224 inside &= ((elems[2 * i] <= p[i]) && (p[i] <= elems[2 * i + 1]));
247 for (
unsigned int i = 0; i < cloud.size(); ++i)
249 for (
unsigned int j = 0; j < 3; ++j)
251 a[j] = std::min(a[j], cloud[i][j]);
252 b[j] = std::max(b[j], cloud[i][j]);
268 std::vector<Vector3D> cloud;
269 cloud.push_back(
corner(0,0,0));
270 cloud.push_back(other.
corner(0,0,0));
271 cloud.push_back(
corner(0,0,1));
272 cloud.push_back(other.
corner(0,0,1));
273 cloud.push_back(
corner(0,1,0));
274 cloud.push_back(other.
corner(0,1,0));
275 cloud.push_back(
corner(0,1,1));
276 cloud.push_back(other.
corner(0,1,1));
277 cloud.push_back(
corner(1,0,0));
278 cloud.push_back(other.
corner(1,0,0));
279 cloud.push_back(
corner(1,0,1));
280 cloud.push_back(other.
corner(1,0,1));
281 cloud.push_back(
corner(1,1,0));
282 cloud.push_back(other.
corner(1,1,0));
283 cloud.push_back(
corner(1,1,1));
284 cloud.push_back(other.
corner(1,1,1));
285 return fromCloud(cloud);
292 for (
int i=0; i<3; ++i)
294 bb[2*i] = std::max(a[2*i], b[2*i]);
295 bb[2*i+1] = std::min(a[2*i+1], b[2*i+1]);
300 for (
int i=0; i<3; ++i)
DoubleBoundingBox3D unionWith(const DoubleBoundingBox3D &other) const
Vector3D topRight() const
Vector3D corner(int x, int y, int z) const
static DoubleBoundingBox3D fromViewport(const double *data)
Vector3D bottomLeft() const
static DoubleBoundingBox3D fromString(const QString &text)
construct a bb from a string containing 6 whitespace-separated numbers
std::ostream & stream_range(std::ostream &s, ITER begin, ITER end, char separator=' ')
static DoubleBoundingBox3D fromCloud(std::vector< Vector3D > cloud)
Eigen::Vector3i topRight() const
Eigen::Vector3i bottomLeft() const
Eigen::Vector3i range() const
static DoubleBoundingBox3D zero()
Representation of an integer bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
std::ostream & operator<<(std::ostream &s, const IntBoundingBox3D &data)
bool contains(const Eigen::Vector3i &p) const
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Eigen::Vector3i corner(int x, int y, int z) const
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
DoubleBoundingBox3D intersection(DoubleBoundingBox3D a, DoubleBoundingBox3D b)
Eigen::Vector3i center() const
std::vector< double > convertQString2DoubleVector(const QString &input, bool *ok)
bool contains(const Vector3D &p) const
Namespace for all CustusX production code.