OGS
SpatialPosition.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "SpatialPosition.h"
5
6#include <iomanip>
7#include <limits>
8#include <ostream>
9
10namespace ParameterLib
11{
12std::ostream& operator<<(std::ostream& os, SpatialPosition const& pos)
13{
14 auto const default_precision = os.precision();
15 os << "{ node: ";
16 if (auto const node_id = pos.getNodeID())
17 {
18 os << *node_id;
19 }
20 else
21 {
22 os << "not set";
23 }
24
25 os << ", element: ";
26 if (auto const element_id = pos.getElementID())
27 {
28 os << *element_id;
29 }
30 else
31 {
32 os << "not set";
33 }
34
35 os << ", coordinates: ";
36 if (auto const coordinates = pos.getCoordinates())
37 {
38 os << std::setprecision(std::numeric_limits<double>::digits10 + 1)
39 << "(" << *coordinates << ")"
40 << std::setprecision(default_precision);
41 }
42 else
43 {
44 os << "not set";
45 }
46 os << " }";
47 return os;
48}
49} // namespace ParameterLib
std::optional< std::size_t > getNodeID() const
std::optional< std::size_t > getElementID() const
std::optional< MathLib::Point3d > const getCoordinates() const
std::ostream & operator<<(std::ostream &os, SpatialPosition const &pos)