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