27 template<
typename Tvec,
class paving_func>
28 inline AABB<Tvec> f_aabb(
29 const paving_func &paving,
const AABB<Tvec> &aabb,
int i,
int j,
int k) {
31 static_assert(!paving_func::can_deform_aabb,
"The paving function cannot deform the AABB");
33 Tvec min = paving.f(aabb.lower, i, j, k);
34 Tvec max = paving.f(aabb.upper, i, j, k);
37 for (
size_t d = 0; d < shambase::VectorProperties<Tvec>::dimension; ++d) {
38 if (min[d] > max[d]) {
39 std::swap(min[d], max[d]);
43 return AABB<Tvec>{min, max};
46 template<
typename Tvec,
class paving_func>
47 inline AABB<Tvec> f_aabb_inv(
48 const paving_func &paving,
const AABB<Tvec> &aabb,
int i,
int j,
int k) {
50 static_assert(!paving_func::can_deform_aabb,
"The paving function cannot deform the AABB");
52 Tvec min = paving.f_inv(aabb.lower, i, j, k);
53 Tvec max = paving.f_inv(aabb.upper, i, j, k);
56 for (
size_t d = 0; d < shambase::VectorProperties<Tvec>::dimension; ++d) {
57 if (min[d] > max[d]) {
58 std::swap(min[d], max[d]);
62 return AABB<Tvec>{min, max};
70 template<
typename Tvec>
74 inline static constexpr bool can_deform_aabb =
false;
87 Tvec
f(Tvec x,
int i,
int j,
int k)
const {
return x +
box_size * Tvec{i, j, k}; }
98 Tvec
f_inv(Tvec x,
int i,
int j,
int k)
const {
return x -
box_size * Tvec{i, j, k}; }
101 return shammath::f_aabb(*
this, aabb, i, j, k);
104 inline AABB<Tvec> f_aabb_inv(
const AABB<Tvec> &aabb,
int i,
int j,
int k)
const {
105 return shammath::f_aabb_inv(*
this, aabb, i, j, k);
108 inline std::vector<std::array<int, 3>> get_paving_index_intersecting(
109 AABB<Tvec> aabb)
const {
114 lower[0] = std::floor(lower[0]);
115 lower[1] = std::floor(lower[1]);
116 lower[2] = std::floor(lower[2]);
119 static_cast<i32>(lower[0]),
static_cast<i32>(lower[1]),
static_cast<i32>(lower[2])};
121 std::vector<std::array<int, 3>> indices;
123 for (
int i = low_int[0]; i <= upper[0]; ++i) {
124 for (
int j = low_int[1]; j <= upper[1]; ++j) {
125 for (
int k = low_int[2]; k <= upper[2]; ++k) {
126 indices.push_back({i, j, k});
141 template<
typename Tvec>
145 inline static constexpr bool can_deform_aabb =
false;
147 using Tscal = shambase::VecComponent<Tvec>;
178 Tvec
f(Tvec x,
int i,
int j,
int k)
const {
181 (is_y_periodic) ? 0 : (x[1] -
box_center[1]) * (sham::m1pown<Tscal>(j) - 1),
182 (is_z_periodic) ? 0 : (x[2] -
box_center[2]) * (sham::m1pown<Tscal>(k) - 1)};
183 return x +
box_size * Tvec{i, j, k} + off;
195 Tvec
f_inv(Tvec x,
int i,
int j,
int k)
const {
196 Tvec tmp = x -
box_size * Tvec{i, j, k};
199 (is_y_periodic) ? 0 : (tmp[1] -
box_center[1]) * (sham::m1pown<Tscal>(j) - 1),
200 (is_z_periodic) ? 0 : (tmp[2] -
box_center[2]) * (sham::m1pown<Tscal>(k) - 1)};
205 return shammath::f_aabb(*
this, aabb, i, j, k);
208 inline AABB<Tvec> f_aabb_inv(
const AABB<Tvec> &aabb,
int i,
int j,
int k)
const {
209 return shammath::f_aabb_inv(*
this, aabb, i, j, k);
212 inline std::vector<std::array<int, 3>> get_paving_index_intersecting(
213 AABB<Tvec> aabb)
const {
218 lower[0] = std::floor(lower[0]);
219 lower[1] = std::floor(lower[1]);
220 lower[2] = std::floor(lower[2]);
223 static_cast<i32>(lower[0]),
static_cast<i32>(lower[1]),
static_cast<i32>(lower[2])};
225 std::vector<std::array<int, 3>> indices;
227 for (
int i = low_int[0]; i <= upper[0]; ++i) {
228 for (
int j = low_int[1]; j <= upper[1]; ++j) {
229 for (
int k = low_int[2]; k <= upper[2]; ++k) {
230 indices.push_back({i, j, k});
248 template<
typename Tvec>
252 inline static constexpr bool can_deform_aabb =
false;
254 using Tscal = shambase::VecComponent<Tvec>;
277 Tvec
f(Tvec x,
int i,
int j,
int k)
const {
294 Tvec
f_inv(Tvec x,
int i,
int j,
int k)
const {
304 return shammath::f_aabb(*
this, aabb, i, j, k);
307 inline AABB<Tvec> f_aabb_inv(
const AABB<Tvec> &aabb,
int i,
int j,
int k)
const {
308 return shammath::f_aabb_inv(*
this, aabb, i, j, k);
311 inline std::vector<std::array<int, 3>> get_paving_index_intersecting(
312 AABB<Tvec> aabb)
const {
317 lower[0] = std::floor(lower[0]);
318 lower[1] = std::floor(lower[1]);
319 lower[2] = std::floor(lower[2]);
325 static_cast<i32>(lower[0]),
static_cast<i32>(lower[1]),
static_cast<i32>(lower[2])};
327 std::vector<std::array<int, 3>> indices;
329 for (
int i = low_int[0]; i <= upper[0]; ++i) {
330 for (
int j = low_int[1]; j <= upper[1]; ++j) {
331 for (
int k = low_int[2]; k <= upper[2]; ++k) {
334 i32 s_x =
static_cast<i32>(shear_x_floor);
338 auto aabb_mapped = f_aabb(
344 if (aabb_mapped.get_intersect(aabb).is_volume_not_null()) {
345 indices.push_back({i_s, j, k});
std::int32_t i32
32 bit integer
Define the fmt formatters for sycl::vec.
namespace for math utility
Axis-Aligned bounding box.
A structure for 3D paving functions with shearing along the x-axis and general boundary conditions.
Tscal shear_x
Shearing factor applied along the x-axis.
Tvec box_center
The center of the box in each dimension.
Tvec f_inv(Tvec x, int i, int j, int k) const
Applies the inverse of the paving function with shearing and boundary conditions.
Tvec f(Tvec x, int i, int j, int k) const
Applies the paving function with shearing and boundary conditions.
Tvec box_size
The size of the box in each dimension.
A structure for 3D paving functions with general boundary conditions (periodic or reflective per dire...
bool is_x_periodic
The boundary condition in each dimension.
Tvec box_size
The size of the box in each dimension.
Tvec f_inv(Tvec x, int i, int j, int k) const
Applies the inverse of the paving function.
Tvec f(Tvec x, int i, int j, int k) const
Applies the paving function with periodic or reflective boundary conditions.
Tvec box_center
The center of the box in each dimension.
A structure for 3D paving functions with periodic boundary conditions.
Tvec f_inv(Tvec x, int i, int j, int k) const
Applies the inverse of the paving function.
Tvec box_size
The size of the box in each dimension.
Tvec f(Tvec x, int i, int j, int k) const
Applies the paving function with periodic boundary conditions.