NorMIT-nav  18.04
An IGT application
cxBoundingBox3D.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXBOUNDINGBOX3D_H_
13 #define CXBOUNDINGBOX3D_H_
14 
15 #include "cxResourceExport.h"
16 #include "cxPrecompiledHeader.h"
17 
18 #include "boost/array.hpp"
19 #include "cxVector3D.h"
20 #include <vector>
21 
22 // --------------------------------------------------------
23 namespace cx
24 {
25 //namespace utils
26 //{
27 // --------------------------------------------------------
28 
38 class cxResource_EXPORT IntBoundingBox3D: public boost::array<int, 6>
39 {
40 public:
42  explicit IntBoundingBox3D(int x0, int x1, int y0, int y1, int z0 = 0, int z1 = 0);
43  explicit IntBoundingBox3D(const Vector3D& a, const Vector3D& b);
44  explicit IntBoundingBox3D(const Eigen::Vector3i& a, const Eigen::Vector3i& b);
45  explicit IntBoundingBox3D(const double* data);
46  explicit IntBoundingBox3D(const int* data);
47 
48  Eigen::Vector3i bottomLeft() const;
49  Eigen::Vector3i topRight() const;
50  Eigen::Vector3i center() const;
51  Eigen::Vector3i range() const;
52  Eigen::Vector3i corner(int x, int y, int z) const;
53  bool contains(const Eigen::Vector3i& p) const;
54 };
55 // --------------------------------------------------------
56 
57 cxResource_EXPORT std::ostream& operator<<(std::ostream& s, const IntBoundingBox3D& data);
58 
63 class cxResource_EXPORT DoubleBoundingBox3D: public boost::array<double, 6>
64 {
65 public:
67  explicit DoubleBoundingBox3D(double x0, double x1, double y0, double y1, double z0 = 0.0, double z1 = 0.0);
68  explicit DoubleBoundingBox3D(const Vector3D& a, const Vector3D& b);
69  explicit DoubleBoundingBox3D(const double* data);
70  explicit DoubleBoundingBox3D(const IntBoundingBox3D& bb);
71  explicit DoubleBoundingBox3D(const int* data);
72  static DoubleBoundingBox3D fromViewport(const double* data);
73  static DoubleBoundingBox3D fromCloud(std::vector<Vector3D> cloud);
74  static DoubleBoundingBox3D fromString(const QString& text);
75  static DoubleBoundingBox3D zero() { return DoubleBoundingBox3D(0,0,0,0,0,0); }
76 
77  Vector3D bottomLeft() const;
78  Vector3D topRight() const;
79  Vector3D center() const;
80  Vector3D range() const;
81  Vector3D corner(int x, int y, int z) const;
82  bool contains(const Vector3D& p) const;
83  DoubleBoundingBox3D unionWith(const DoubleBoundingBox3D& other) const;
84 };
85 // --------------------------------------------------------
86 
87 cxResource_EXPORT bool similar(const DoubleBoundingBox3D& a, const DoubleBoundingBox3D& b, double tol = 1.0E-6);
88 
89 cxResource_EXPORT std::ostream& operator<<(std::ostream& s, const DoubleBoundingBox3D& data);
90 
96 
101 // --------------------------------------------------------
102 //} // namespace utils
103 //using namespace utils;
104 } // namespace cx
105 // --------------------------------------------------------
106 
107 #endif /*CXBOUNDINGBOX3D_H_*/
Eigen::Vector2d fromString(const QString &text)
Definition: cxVector3D.cpp:106
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)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
DoubleBoundingBox3D intersection(DoubleBoundingBox3D a, DoubleBoundingBox3D b)
bool contains(std::string const &s, std::string const &infix)
Definition: catch.hpp:168
Namespace for all CustusX production code.