OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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 "OPALTypes.h"
27
28#include "boost/optional.hpp"
29
30#include <utility>
31#include <vector>
32
34public:
36
37 static BoundingBox getBoundingBox(const std::vector<Vector_t<double, 3>>& positions);
38
40 void enlargeToContainBoundingBox(const BoundingBox& boundingBox);
41
42 boost::optional<Vector_t<double, 3>> getIntersectionPoint(
43 const Vector_t<double, 3>& position, const Vector_t<double, 3>& direction) const;
44
45 bool isInside(const Vector_t<double, 3>& position) const;
46 bool isOutside(const Vector_t<double, 3>& position) const;
47 void print(std::ostream& output) const;
48
49 std::pair<Vector_t<double, 3>, Vector_t<double, 3>> getCorners() const;
50
51private:
54};
55
56inline std::pair<Vector_t<double, 3>, Vector_t<double, 3>> BoundingBox::getCorners() const {
57 return std::make_pair(lowerLeftCorner_m, upperRightCorner_m);
58}
59
60inline bool BoundingBox::isOutside(const Vector_t<double, 3>& position) const {
61 return !isInside(position);
62}
63#endif
ippl::Vector< T, Dim > Vector_t
void print(std::ostream &output) const
Vector_t< double, 3 > lowerLeftCorner_m
Definition BoundingBox.h:52
bool isOutside(const Vector_t< double, 3 > &position) const
Definition BoundingBox.h:60
boost::optional< Vector_t< double, 3 > > getIntersectionPoint(const Vector_t< double, 3 > &position, const Vector_t< double, 3 > &direction) const
Vector_t< double, 3 > upperRightCorner_m
Definition BoundingBox.h:53
bool isInside(const Vector_t< double, 3 > &position) const
void enlargeToContainPosition(const Vector_t< double, 3 > &position)
std::pair< Vector_t< double, 3 >, Vector_t< double, 3 > > getCorners() const
Definition BoundingBox.h:56
static BoundingBox getBoundingBox(const std::vector< Vector_t< double, 3 > > &positions)
void enlargeToContainBoundingBox(const BoundingBox &boundingBox)