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
15
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.
T delt() const
Returns the delta of the AABB.
Definition AABB.hpp:152
T get_center() const noexcept
Returns the center of the AABB.
Definition AABB.hpp:174
bool is_surface() const noexcept
Checks if the AABB is a surface.
Definition AABB.hpp:293
bool is_surface_or_volume() const noexcept
Checks if the AABB is a surface or a volume.
Definition AABB.hpp:307
bool intersect_ray(Ray< T > ray) const noexcept
Check if the ray intersect the AABB.
Definition AABB.hpp:356
bool is_volume_not_null() const noexcept
Checks if the AABB has a non-zero volume.
Definition AABB.hpp:280
T lower
Lower bound of the AABB.
Definition AABB.hpp:104
bool is_not_empty() const noexcept
Checks if the AABB is non-empty.
Definition AABB.hpp:268
Tscal get_volume()
Returns the volume of the AABB.
Definition AABB.hpp:164
T upper
Upper bound of the AABB.
Definition AABB.hpp:105
AABB get_intersect(AABB other) const noexcept
Compute the intersection of two AABB.
Definition AABB.hpp:234
T sum_bounds() const noexcept
Returns the sum of the lower and upper bounds of the AABB.
Definition AABB.hpp:184