Debian Codegraph @

include/deal.II/boost_adaptors/bounding_box.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2018 - 2025 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_boost_adaptor_bounding_box_h
16 #define dealii_boost_adaptor_bounding_box_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/bounding_box.h>
21
22 #include <deal.II/boost_adaptors/point.h>
23
24 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
25 #include <boost/geometry/core/coordinate_dimension.hpp>
26 #include <boost/geometry/core/coordinate_system.hpp>
27 #include <boost/geometry/core/coordinate_type.hpp>
28 #include <boost/geometry/core/cs.hpp>
29 #include <boost/geometry/core/tag.hpp>
30 #include <boost/geometry/strategies/strategies.hpp>
31 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
32
33
34 DEAL_II_NAMESPACE_OPEN
35 DEAL_II_NAMESPACE_CLOSE // Do not convert for module purposes
36
37 namespace boost
38 {
39 namespace geometry
40 {
41 namespace traits
42 {
43 /**
44 * Tag adaptor for dealii::BoundingBox.
45 */
46 template <int dim, class Number>
47 struct tag<dealii::BoundingBox<dim, Number>>
48 {
49 using type = box_tag;
50 };
51
52 /**
53 * Point type adaptor for dealii::BoundingBox.
54 */
55 template <int dim, class Number>
56 struct point_type<dealii::BoundingBox<dim, Number>>
57 {
58 using type = dealii::Point<dim, Number>;
59 };
60
61 /**
62 * Access to the D-th coordinate of the lower left corner of a
63 * dealii::BoundingBox.
64 */
65 template <int dim, class Number, std::size_t D>
66 struct indexed_access<dealii::BoundingBox<dim, Number>,
67 #if DEAL_II_BOOST_VERSION_GTE(1, 89, 0)
68 min_corner,
69 #else
70 // Until Boost 1.88, max_corner was a
71 // static variable in a header file, which
72 // we can't export in the module wrapper
73 // for Boost. Use the variable's numeric
74 // value instead.
75 /*min_corner*/ 0,
76 #endif
77 D>
78 {
79 /**
80 * Getter function for the D-th coordinate of the lower left corner of
81 * a dealii::BoundingBox.
82 */
83 static inline double
84 get(const dealii::BoundingBox<dim, Number> &box)
85 {
86 return box.get_boundary_points().first[D];
87 }
88
89 /**
90 * Setter function for the D-th coordinate of the lower left corner of
91 * a dealii::BoundingBox.
92 */
93 static inline void
94 set(dealii::BoundingBox<dim, Number> &box, Number value)
95 {
96 box.get_boundary_points().first[D] = value;
97 }
98 };
99
100 /**
101 * Access to the D-th coordinate of the upper right corner of a
102 * dealii::BoundingBox.
103 */
104 template <int dim, class Number, std::size_t D>
105 struct indexed_access<dealii::BoundingBox<dim, Number>,
106 #if DEAL_II_BOOST_VERSION_GTE(1, 89, 0)
107 max_corner,
108 #else
109 // Until Boost 1.88, max_corner was a
110 // static variable in a header file, which
111 // we can't export in the module wrapper
112 // for Boost. Use the variable's numeric
113 // value instead.
114 /*max_corner*/ 1,
115 #endif
116 D>
117 {
118 /**
119 * Getter function for the D-th coordinate of the upper right corner of
120 * a dealii::BoundingBox.
121 */
122 static inline double
123 get(const dealii::BoundingBox<dim, Number> &box)
124 {
125 return box.get_boundary_points().second[D];
126 }
127
128 /**
129 * Setter function for the D-th coordinate of the upper right corner of
130 * a dealii::BoundingBox.
131 */
132 static inline void
133 set(dealii::BoundingBox<dim, Number> &box, Number value)
134 {
135 box.get_boundary_points().second[D] = value;
136 }
137 };
138 } // namespace traits
139 } // namespace geometry
140 } // namespace boost
141
142 DEAL_II_NAMESPACE_OPEN // Do not convert for module purposes
143 DEAL_II_NAMESPACE_CLOSE
144
145 #endif