OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
BoundingBox2D.h
Go to the documentation of this file.
1 //
2 // Class BoundingBox2D
3 //
4 // This class provides functionality to compute bounding boxes, to compute if a position
5 // is inside the box.
6 //
7 // Copyright (c) 2018 - 2021, Christof Metzger-Kraus
8 //
9 // All rights reserved
10 //
11 // This file is part of OPAL.
12 //
13 // OPAL is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20 //
21 #ifndef MSLANG_BOUNDINGBOX_H
22 #define MSLANG_BOUNDINGBOX_H
23 
24 #include "Algorithms/Vektor.h"
25 
26 #include <iostream>
27 #include <fstream>
28 
29 namespace mslang {
30  struct BoundingBox2D {
32  double width_m;
33  double height_m;
34 
36  center_m(0.0),
37  width_m(0.0),
38  height_m(0.0)
39  { }
40 
42  center_m(right.center_m),
43  width_m(right.width_m),
44  height_m(right.height_m)
45  { }
46 
47  BoundingBox2D(const Vector_t &llc,
48  const Vector_t &urc):
49  center_m(0.5 * (llc + urc)),
50  width_m(urc[0] - llc[0]),
51  height_m(urc[1] - llc[1])
52  { }
53 
54  BoundingBox2D& operator=(const BoundingBox2D&) = default;
55  bool doesIntersect(const BoundingBox2D &bb) const;
56  bool isInside(const Vector_t &X) const;
57  bool isInside(const BoundingBox2D &b) const;
58  virtual void writeGnuplot(std::ostream &out) const;
59  void print(std::ostream &out) const;
60  };
61 
62  std::ostream & operator<< (std::ostream &out, const BoundingBox2D &bb);
63 }
64 
65 #endif
bool doesIntersect(const BoundingBox2D &bb) const
bool isInside(const Vector_t &X) const
void print(std::ostream &out) const
BoundingBox2D(const Vector_t &llc, const Vector_t &urc)
Definition: BoundingBox2D.h:47
#define X(arg)
Definition: fftpack.cpp:112
BoundingBox2D(const BoundingBox2D &right)
Definition: BoundingBox2D.h:41
virtual void writeGnuplot(std::ostream &out) const
BoundingBox2D & operator=(const BoundingBox2D &)=default
std::ostream & operator<<(std::ostream &out, const BoundingBox2D &bb)