diff --git a/doc/python/magnum.trade.rst b/doc/python/magnum.trade.rst index b512cbe..a757b7c 100644 --- a/doc/python/magnum.trade.rst +++ b/doc/python/magnum.trade.rst @@ -126,6 +126,16 @@ .. py:property:: magnum.trade.AbstractImporter.image3d_count :raise RuntimeError: If no file is opened +.. py:function:: magnum.trade.AbstractImporter.image1d_level_count + :raise RuntimeError: If no file is opened + :raise ValueError: If :p:`id` is negative or not less than `image1d_count` +.. py:function:: magnum.trade.AbstractImporter.image2d_level_count + :raise RuntimeError: If no file is opened + :raise ValueError: If :p:`id` is negative or not less than `image2d_count` +.. py:function:: magnum.trade.AbstractImporter.image3d_level_count + :raise RuntimeError: If no file is opened + :raise ValueError: If :p:`id` is negative or not less than `image3d_count` + .. py:function:: magnum.trade.AbstractImporter.image1d_for_name :raise RuntimeError: If no file is opened .. py:function:: magnum.trade.AbstractImporter.image2d_for_name diff --git a/src/python/magnum/test/test_trade.py b/src/python/magnum/test/test_trade.py index c05ffad..46216a4 100644 --- a/src/python/magnum/test/test_trade.py +++ b/src/python/magnum/test/test_trade.py @@ -143,6 +143,13 @@ class Importer(unittest.TestCase): with self.assertRaisesRegex(RuntimeError, "no file opened"): importer.image3d_count + with self.assertRaisesRegex(RuntimeError, "no file opened"): + importer.image1d_level_count(0) + with self.assertRaisesRegex(RuntimeError, "no file opened"): + importer.image2d_level_count(0) + with self.assertRaisesRegex(RuntimeError, "no file opened"): + importer.image3d_level_count(0) + with self.assertRaisesRegex(RuntimeError, "no file opened"): importer.image1d_for_name('') with self.assertRaisesRegex(RuntimeError, "no file opened"): @@ -178,6 +185,13 @@ class Importer(unittest.TestCase): with self.assertRaises(IndexError): importer.mesh3d(0) + with self.assertRaises(IndexError): + importer.image1d_level_count(0) + with self.assertRaises(IndexError): + importer.image2d_level_count(1) + with self.assertRaises(IndexError): + importer.image3d_level_count(0) + with self.assertRaises(IndexError): importer.image1d_name(0) with self.assertRaises(IndexError): @@ -223,6 +237,7 @@ class Importer(unittest.TestCase): importer.open_file(os.path.join(os.path.dirname(__file__), 'rgb.png')) self.assertEqual(importer.image2d_count, 1) + self.assertEqual(importer.image2d_level_count(0), 1) self.assertEqual(importer.image2d_name(0), '') self.assertEqual(importer.image2d_for_name(''), -1) diff --git a/src/python/magnum/trade.cpp b/src/python/magnum/trade.cpp index 8e358b3..b52c53e 100644 --- a/src/python/magnum/trade.cpp +++ b/src/python/magnum/trade.cpp @@ -282,6 +282,9 @@ void trade(py::module& m) { .def_property_readonly("image1d_count", checkOpened, "One-dimensional image count") .def_property_readonly("image2d_count", checkOpened, "Two-dimensional image count") .def_property_readonly("image3d_count", checkOpened, "Three-dimensional image count") + .def("image1d_level_count", checkOpenedBounds, "One-dimensional image level count", py::arg("id")) + .def("image2d_level_count", checkOpenedBounds, "Two-dimensional image level count", py::arg("id")) + .def("image3d_level_count", checkOpenedBounds, "Three-dimensional image level count", py::arg("id")) .def("image1d_for_name", checkOpened, "One-dimensional image ID for given name") .def("image2d_for_name", checkOpened, "Two-dimensional image ID for given name") .def("image3d_for_name", checkOpened, "Three-dimensional image ID for given name")