Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Polygon.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_GEOMETRY_POLYGON_HPP
22 #define FUB_GEOMETRY_POLYGON_HPP
23 
24 #include "fub/core/span.hpp"
25 #include <boost/container/pmr/vector.hpp>
26 
27 namespace fub {
28 
29 class Polygon {
30 public:
31  using Vector = boost::container::pmr::vector<double>;
32 
33  Polygon(Vector xs, Vector ys) : xs_{std::move(xs)}, ys_{std::move(ys)} {}
34 
35  [[nodiscard]] span<const double> GetXs() const noexcept { return xs_; }
36  [[nodiscard]] span<const double> GetYs() const noexcept { return ys_; }
37 
38  [[nodiscard]] double ComputeDistanceTo(double x, double y) const noexcept;
39  [[nodiscard]] double ComputeDistanceTo(std::array<double, 2> xs) const
40  noexcept {
41  return ComputeDistanceTo(xs[0], xs[1]);
42  }
43 
44 private:
47 };
48 
49 } // namespace fub
50 
51 #endif
Definition: Polygon.hpp:29
Polygon(Vector xs, Vector ys)
Definition: Polygon.hpp:33
double ComputeDistanceTo(double x, double y) const noexcept
span< const double > GetXs() const noexcept
Definition: Polygon.hpp:35
Vector ys_
Definition: Polygon.hpp:46
double ComputeDistanceTo(std::array< double, 2 > xs) const noexcept
Definition: Polygon.hpp:39
boost::container::pmr::vector< double > Vector
Definition: Polygon.hpp:31
Vector xs_
Definition: Polygon.hpp:45
span< const double > GetYs() const noexcept
Definition: Polygon.hpp:36
A span is a view over a contiguous sequence of objects, the storage of which is owned by some other o...
Definition: span.hpp:81
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31