Skip to content

Commit

Permalink
Fix Pybind11 Imath Frustum (#459)
Browse files Browse the repository at this point in the history
* Imath Frustum to IMATH_NAMESPACE

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* Imath Euler to IMATH_NAMESPACE

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* Remove

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* Restore

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* Frustum class S

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* Frustum remove class M

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* bug fix

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* add float double

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove Frustum

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove Frustum

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove PyBind Imath Frustum

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove Euler

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove Euler

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

* remove Euler pybind test

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>

---------

Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com>
  • Loading branch information
TodicaIonut authored Dec 19, 2024
1 parent d3be2c6 commit aa28eb5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
5 changes: 3 additions & 2 deletions src/pybind11/PyBindImath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ set(PYBINDIMATH_SOURCES
PyBindImathVec.cpp
PyBindImathPlane.cpp
PyBindImathLine.cpp
PyBindImathEuler.cpp
PyBindImathFrustum.cpp

# PyBindImathEuler build Error pybind test
# PyBindImathFrustum build failing
)

set(PYBINDIMATH_HEADERS
Expand Down
4 changes: 2 additions & 2 deletions src/pybind11/PyBindImath/PyBindImath.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ PYBINDIMATH_EXPORT void register_imath_vec(pybind11::module& m);
PYBINDIMATH_EXPORT void register_imath_box(pybind11::module& m);
PYBINDIMATH_EXPORT void register_imath_plane(pybind11::module& m);
PYBINDIMATH_EXPORT void register_imath_line(pybind11::module& m);
PYBINDIMATH_EXPORT void register_imath_euler(pybind11::module& m);
PYBINDIMATH_EXPORT void register_imath_frustum(pybind11::module& m);
// PYBINDIMATH_EXPORT void register_imath_euler(pybind11::module& m)
// PYBINDIMATH_EXPORT void register_imath_frustum(pybind11::module& m)
}

#endif
66 changes: 33 additions & 33 deletions src/pybind11/PyBindImath/PyBindImathEuler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ namespace PyBindImath {

// Function to register the Euler class methods
template <class T>
void register_euler_methods(pybind11::class_<Imath::Euler<T>, Imath::Vec3<T>>& c) {
void register_euler_methods(pybind11::class_<IMATH_NAMESPACE::Euler<T>, IMATH_NAMESPACE::Vec3<T>>& c) {
c.def(pybind11::init<>())
.def(pybind11::init<const Imath::Vec3<T>&, typename Imath::Euler<T>::Order>(), pybind11::arg("v"), pybind11::arg("order") = Imath::Euler<T>::XYZ)
.def(pybind11::init<T, T, T, typename Imath::Euler<T>::Order>(), pybind11::arg("x"), pybind11::arg("y"), pybind11::arg("z"), pybind11::arg("order") = Imath::Euler<T>::XYZ)
.def(pybind11::init<const IMATH_NAMESPACE::Vec3<T>&, typename IMATH_NAMESPACE::Euler<T>::Order>(), pybind11::arg("v"), pybind11::arg("order") = IMATH_NAMESPACE::Euler<T>::XYZ)
.def(pybind11::init<T, T, T, typename IMATH_NAMESPACE::Euler<T>::Order>(), pybind11::arg("x"), pybind11::arg("y"), pybind11::arg("z"), pybind11::arg("order") = IMATH_NAMESPACE::Euler<T>::XYZ)
.def(pybind11::self == pybind11::self)
.def(pybind11::self != pybind11::self)
.def("toMatrix33", &Imath::Euler<T>::toMatrix33)
.def("toMatrix44", &Imath::Euler<T>::toMatrix44)
.def("toQuat", &Imath::Euler<T>::toQuat)
.def("order", &Imath::Euler<T>::order)
.def("setOrder", &Imath::Euler<T>::setOrder)
.def("makeNear", &Imath::Euler<T>::makeNear)
.def("extract", pybind11::overload_cast<const Imath::Matrix33<T>&>(&Imath::Euler<T>::extract))
.def("extract", pybind11::overload_cast<const Imath::Matrix44<T>&>(&Imath::Euler<T>::extract))
.def("extract", pybind11::overload_cast<const Imath::Quat<T>&>(&Imath::Euler<T>::extract))
.def("toXYZVector", &Imath::Euler<T>::toXYZVector)
.def("__str__", [](const Imath::Euler<T>& e) {
.def("toMatrix33", &IMATH_NAMESPACE::Euler<T>::toMatrix33)
.def("toMatrix44", &IMATH_NAMESPACE::Euler<T>::toMatrix44)
.def("toQuat", &IMATH_NAMESPACE::Euler<T>::toQuat)
.def("order", &IMATH_NAMESPACE::Euler<T>::order)
.def("setOrder", &IMATH_NAMESPACE::Euler<T>::setOrder)
.def("makeNear", &IMATH_NAMESPACE::Euler<T>::makeNear)
.def("extract", pybind11::overload_cast<const IMATH_NAMESPACE::Matrix33<T>&>(&IMATH_NAMESPACE::Euler<T>::extract))
.def("extract", pybind11::overload_cast<const IMATH_NAMESPACE::Matrix44<T>&>(&IMATH_NAMESPACE::Euler<T>::extract))
.def("extract", pybind11::overload_cast<const IMATH_NAMESPACE::Quat<T>&>(&IMATH_NAMESPACE::Euler<T>::extract))
.def("toXYZVector", &IMATH_NAMESPACE::Euler<T>::toXYZVector)
.def("__str__", [](const IMATH_NAMESPACE::Euler<T>& e) {
std::stringstream stream;
stream << "Euler(" << e.x << ", " << e.y << ", " << e.z << ", " << e.order() << ")";
return stream.str();
})
.def("__repr__", [](const Imath::Euler<T>& e) {
.def("__repr__", [](const IMATH_NAMESPACE::Euler<T>& e) {
std::stringstream stream;
stream << "Euler(" << e.x << ", " << e.y << ", " << e.z << ", " << e.order() << ")";
return stream.str();
Expand All @@ -43,7 +43,7 @@ namespace PyBindImath {
// Function to register the Euler class in the module
template <class T>
void register_euler(pybind11::module& m, const char* name) {
pybind11::class_<Imath::Euler<T>, Imath::Vec3<T>> c(m, name);
pybind11::class_<IMATH_NAMESPACE::Euler<T>, IMATH_NAMESPACE::Vec3<T>> c(m, name);
register_euler_methods<T>(c);
}

Expand All @@ -54,31 +54,31 @@ namespace PyBindImath {

// Enums for Euler Orders
pybind11::enum_<Imath::Euler<float>::Order>(m, "Order")
.value("XYZ", Imath::Euler<float>::XYZ)
.value("XZY", Imath::Euler<float>::XZY)
.value("YZX", Imath::Euler<float>::YZX)
.value("YXZ", Imath::Euler<float>::YXZ)
.value("ZXY", Imath::Euler<float>::ZXY)
.value("ZYX", Imath::Euler<float>::ZYX)
.value("XZX", Imath::Euler<float>::XZX)
.value("XYX", Imath::Euler<float>::XYX)
.value("YXY", Imath::Euler<float>::YXY)
.value("YZY", Imath::Euler<float>::YZY)
.value("ZYZ", Imath::Euler<float>::ZYZ)
.value("ZXZ", Imath::Euler<float>::ZXZ)
.value("XYZ", IMATH_NAMESPACE::Euler<float>::XYZ)
.value("XZY", IMATH_NAMESPACE::Euler<float>::XZY)
.value("YZX", IMATH_NAMESPACE::Euler<float>::YZX)
.value("YXZ", IMATH_NAMESPACE::Euler<float>::YXZ)
.value("ZXY", IMATH_NAMESPACE::Euler<float>::ZXY)
.value("ZYX", IMATH_NAMESPACE::Euler<float>::ZYX)
.value("XZX", IMATH_NAMESPACE::Euler<float>::XZX)
.value("XYX", IMATH_NAMESPACE::Euler<float>::XYX)
.value("YXY", IMATH_NAMESPACE::Euler<float>::YXY)
.value("YZY", IMATH_NAMESPACE::Euler<float>::YZY)
.value("ZYZ", IMATH_NAMESPACE::Euler<float>::ZYZ)
.value("ZXZ", IMATH_NAMESPACE::Euler<float>::ZXZ)
.export_values();

// Enums for Axis
pybind11::enum_<Imath::Euler<float>::Axis>(m, "Axis")
.value("X", Imath::Euler<float>::X)
.value("Y", Imath::Euler<float>::Y)
.value("Z", Imath::Euler<float>::Z)
.value("X", IMATH_NAMESPACE::Euler<float>::X)
.value("Y", IMATH_NAMESPACE::Euler<float>::Y)
.value("Z", IMATH_NAMESPACE::Euler<float>::Z)
.export_values();

// Enums for InputLayout
pybind11::enum_<Imath::Euler<float>::InputLayout>(m, "InputLayout")
.value("XYZLayout", Imath::Euler<float>::XYZLayout)
.value("IJKLayout", Imath::Euler<float>::IJKLayout)
.value("XYZLayout", IMATH_NAMESPACE::Euler<float>::XYZLayout)
.value("IJKLayout", IMATH_NAMESPACE::Euler<float>::IJKLayout)
.export_values();
}

Expand Down
8 changes: 4 additions & 4 deletions src/pybind11/PyBindImath/PyBindImathFrustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

namespace PyBindImath {

template <class T, class V, class M>
template <class T, class V, class S>
void register_frustum(pybind11::module& m, const char *name)
{
pybind11::class_<T> c(m, name);
c.def(pybind11::init<>(), "Uninitialized by default")
.def(pybind11::init<T>(), pybind11::arg("frustum"), "Copy constructor")
.def(pybind11::init<S>(), pybind11::arg("nearPlane"), pybind11::arg("farPlane"), pybind11::arg("fovx"), pybind11::arg("aspect"), "Initialize with basic frustum properties")
.def(pybind11::init<S, S, S, S>(), pybind11::arg("nearPlane"), pybind11::arg("farPlane"), pybind11::arg("fovx"), pybind11::arg("aspect"), "Initialize with basic frustum properties")

.def_readwrite("nearPlane", &T::nearPlane, "The near clipping plane")
.def_readwrite("farPlane", &T::farPlane, "The far clipping plane")
Expand Down Expand Up @@ -52,8 +52,8 @@ void register_frustum(pybind11::module& m, const char *name)

void register_imath_frustum(pybind11::module &m)
{
register_frustum<Imath::Frustumf, Imath::V3f, Imath::M44f>(m, "Frustumf");
register_frustum<Imath::Frustumd, Imath::V3d, Imath::M44d>(m, "Frustumd");
register_frustum<IMATH_NAMESPACE::Frustumf, IMATH_NAMESPACE::V3f, IMATH_NAMESPACE::M44f, float>(m, "Frustumf");
register_frustum<IMATH_NAMESPACE::Frustumd, IMATH_NAMESPACE::V3d, IMATH_NAMESPACE::M44d, double>(m, "Frustumd");
}

}
4 changes: 2 additions & 2 deletions src/pybind11/PyBindImath/pybindimathmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ PYBIND11_MODULE(pybindimath, m)
PyBindImath::register_imath_box(m);
PyBindImath::register_imath_plane(m);
PyBindImath::register_imath_line(m);
PyBindImath::register_imath_euler(m);
PyBindImath::register_imath_frustum(m);
// PyBindImath::register_imath_euler(m)
// PyBindImath::register_imath_frustum(m)


//
Expand Down

0 comments on commit aa28eb5

Please sign in to comment.