Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyAABB.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
16#include "shambase/string.hpp"
20#include "shammath/AABB.hpp"
21
22namespace shampylib {
23
24 template<class T>
25 void init_shamrock_math_AABB(py::module &m, std::string name) {
26 py::class_<shammath::AABB<T>>(m, name.c_str())
27 .def(py::init([](f64_3 min, f64_3 max) {
28 return std::make_unique<shammath::AABB<T>>(min, max);
29 }))
30 .def("get_intersect", &shammath::AABB<T>::get_intersect)
31 .def("get_volume", &shammath::AABB<T>::get_volume)
32 .def("get_center", &shammath::AABB<T>::get_center)
33 .def("sum_bounds", &shammath::AABB<T>::sum_bounds)
34 .def_readwrite(
35 "lower", &shammath::AABB<T>::lower, py::return_value_policy::reference_internal)
36 .def_readwrite(
37 "upper", &shammath::AABB<T>::upper, py::return_value_policy::reference_internal)
38 .def("delt", &shammath::AABB<T>::delt)
39 .def("is_not_empty", &shammath::AABB<T>::is_not_empty)
40 .def("is_volume_not_null", &shammath::AABB<T>::is_volume_not_null)
41 .def("is_surface", &shammath::AABB<T>::is_surface)
42 .def("is_surface_or_volume", &shammath::AABB<T>::is_surface_or_volume)
43 .def("intersect_ray", &shammath::AABB<T>::intersect_ray)
44 .def(
45 "__str__",
46 [](const shammath::AABB<T> &aabb) {
47 return shambase::format("AABB(lower={}, upper={})", aabb.lower, aabb.upper);
48 })
49 .def("__repr__", [](const shammath::AABB<T> &aabb) {
50 return shambase::format("AABB(lower={}, upper={})", aabb.lower, aabb.upper);
51 });
52 }
53
54 template void init_shamrock_math_AABB<f64_3>(py::module &m, std::string name);
55
56} // namespace shampylib
Define the fmt formatters for sycl::vec.
Pybind11 include and definitions.
Axis-Aligned bounding box.
Definition AABB.hpp:99
T lower
Lower bound of the AABB.
Definition AABB.hpp:104
T upper
Upper bound of the AABB.
Definition AABB.hpp:105