OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
BoundingBox.h
Go to the documentation of this file.
1//
2// Class BoundingBox: defines a 3D box and provides functionality to determine whether a point
3// is in- or outside it. Additionally provides functionality to compute the
4// intersection point with a line.
5//
6// This class provides functionality to compute bounding boxes, to compute if a position
7// is inside the box and to compute the intersection point between a ray and the bounding box.
8//
9// Copyright (c) 201x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
10//
11// All rights reserved
12//
13// This file is part of OPAL.
14//
15// OPAL is free software: you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation, either version 3 of the License, or
18// (at your option) any later version.
19//
20// You should have received a copy of the GNU General Public License
21// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22//
23#ifndef BOUNDINGBOX_H
24#define BOUNDINGBOX_H
25
26#include "Algorithms/Vektor.h"
27
28#include "boost/optional.hpp"
29
30#include <vector>
31#include <utility>
32
34{
35public:
37
38 static BoundingBox getBoundingBox(const std::vector<Vector_t>& positions);
39
40 void enlargeToContainPosition(const Vector_t& position);
41 void enlargeToContainBoundingBox(const BoundingBox& boundingBox);
42
43 boost::optional<Vector_t> getIntersectionPoint(const Vector_t& position,
44 const Vector_t& direction) const;
45
46 bool isInside(const Vector_t& position) const;
47 bool isOutside(const Vector_t& position) const;
48 void print(std::ostream& output) const;
49
50 std::pair<Vector_t, Vector_t> getCorners() const;
51private:
54};
55
56inline
57std::pair<Vector_t, Vector_t> BoundingBox::getCorners() const {
58 return std::make_pair(lowerLeftCorner_m, upperRightCorner_m);
59}
60
61inline
62bool BoundingBox::isOutside(const Vector_t& position) const {
63 return !isInside(position);
64}
65#endif
void print(std::ostream &output) const
static BoundingBox getBoundingBox(const std::vector< Vector_t > &positions)
Definition: BoundingBox.cpp:31
std::pair< Vector_t, Vector_t > getCorners() const
Definition: BoundingBox.h:57
bool isInside(const Vector_t &position) const
Definition: BoundingBox.cpp:99
bool isOutside(const Vector_t &position) const
Definition: BoundingBox.h:62
Vector_t lowerLeftCorner_m
Definition: BoundingBox.h:52
Vector_t upperRightCorner_m
Definition: BoundingBox.h:53
boost::optional< Vector_t > getIntersectionPoint(const Vector_t &position, const Vector_t &direction) const
Definition: BoundingBox.cpp:57
void enlargeToContainBoundingBox(const BoundingBox &boundingBox)
Definition: BoundingBox.cpp:49
void enlargeToContainPosition(const Vector_t &position)
Definition: BoundingBox.cpp:41