Commit fd5bd843 authored by Alexander Dielen's avatar Alexander Dielen

use py::none instead of py::object as the property type

parent 992863a8
......@@ -51,10 +51,10 @@ PYBIND11_MODULE(openmesh, m) {
typedef IteratorWrapperT<OM::PolyConnectivity::EdgeIter, &OM::ArrayKernel::n_edges> EdgeIterWrapper;
typedef IteratorWrapperT<OM::PolyConnectivity::FaceIter, &OM::ArrayKernel::n_faces> FaceIterWrapper;
expose_property_manager<OM::VPropHandleT<py::object>, OM::VertexHandle, VertexIterWrapper>(m, "VPropertyManager");
expose_property_manager<OM::HPropHandleT<py::object>, OM::HalfedgeHandle, HalfedgeIterWrapper>(m, "HPropertyManager");
expose_property_manager<OM::EPropHandleT<py::object>, OM::EdgeHandle, EdgeIterWrapper>(m, "EPropertyManager");
expose_property_manager<OM::FPropHandleT<py::object>, OM::FaceHandle, FaceIterWrapper>(m, "FPropertyManager");
expose_property_manager<OM::VPropHandleT<py::none>, OM::VertexHandle, VertexIterWrapper>(m, "VPropertyManager");
expose_property_manager<OM::HPropHandleT<py::none>, OM::HalfedgeHandle, HalfedgeIterWrapper>(m, "HPropertyManager");
expose_property_manager<OM::EPropHandleT<py::none>, OM::EdgeHandle, EdgeIterWrapper>(m, "EPropertyManager");
expose_property_manager<OM::FPropHandleT<py::none>, OM::FaceHandle, FaceIterWrapper>(m, "FPropertyManager");
expose_io(m);
......
This diff is collapsed.
......@@ -50,35 +50,35 @@ void expose_handles(py::module& m) {
.def(py::init<int>())
;
py::class_<OM::BasePropHandleT<py::object>, OM::BaseHandle>(m, "BasePropHandle")
py::class_<OM::BasePropHandleT<py::none>, OM::BaseHandle>(m, "BasePropHandle")
.def(py::init<>())
.def(py::init<int>())
;
py::class_<OM::VPropHandleT<py::object>, OM::BasePropHandleT<py::object> >(m, "VPropHandle")
py::class_<OM::VPropHandleT<py::none>, OM::BasePropHandleT<py::none> >(m, "VPropHandle")
.def(py::init<>())
.def(py::init<int>())
.def(py::init<const OM::BasePropHandleT<py::object>&>())
.def(py::init<const OM::BasePropHandleT<py::none>&>())
;
py::class_<OM::HPropHandleT<py::object>, OM::BasePropHandleT<py::object> >(m, "HPropHandle")
py::class_<OM::HPropHandleT<py::none>, OM::BasePropHandleT<py::none> >(m, "HPropHandle")
.def(py::init<>())
.def(py::init<int>())
.def(py::init<const OM::BasePropHandleT<py::object>&>())
.def(py::init<const OM::BasePropHandleT<py::none>&>())
;
py::class_<OM::EPropHandleT<py::object>, OM::BasePropHandleT<py::object> >(m, "EPropHandle")
py::class_<OM::EPropHandleT<py::none>, OM::BasePropHandleT<py::none> >(m, "EPropHandle")
.def(py::init<>())
.def(py::init<int>())
.def(py::init<const OM::BasePropHandleT<py::object>&>())
.def(py::init<const OM::BasePropHandleT<py::none>&>())
;
py::class_<OM::FPropHandleT<py::object>, OM::BasePropHandleT<py::object> >(m, "FPropHandle")
py::class_<OM::FPropHandleT<py::none>, OM::BasePropHandleT<py::none> >(m, "FPropHandle")
.def(py::init<>())
.def(py::init<int>())
.def(py::init<const OM::BasePropHandleT<py::object>&>())
.def(py::init<const OM::BasePropHandleT<py::none>&>())
;
py::class_<OM::MPropHandleT<py::object>, OM::BasePropHandleT<py::object> >(m, "MPropHandle")
py::class_<OM::MPropHandleT<py::none>, OM::BasePropHandleT<py::none> >(m, "MPropHandle")
.def(py::init<>())
.def(py::init<int>())
.def(py::init<const OM::BasePropHandleT<py::object>&>())
.def(py::init<const OM::BasePropHandleT<py::none>&>())
;
}
......
......@@ -22,7 +22,7 @@ namespace OM = OpenMesh;
* @return The requested property value.
*/
template <class PropertyManager, class IndexHandle>
py::object propman_get_item(PropertyManager& _self, IndexHandle _handle) {
py::none propman_get_item(PropertyManager& _self, IndexHandle _handle) {
return _self[_handle];
}
......@@ -100,8 +100,8 @@ void expose_property_manager(py::module& m, const char *_name) {
typedef OM::PropertyManager<PropHandle, OM::PolyConnectivity> PropertyManager;
// Function pointers
py::object (*getitem)(PropertyManager&, IndexHandle ) = &propman_get_item;
void (*setitem)(PropertyManager&, IndexHandle, py::object) = &propman_set_item;
py::none (*getitem)(PropertyManager&, IndexHandle ) = &propman_get_item;
void (*setitem)(PropertyManager&, IndexHandle, py::object) = &propman_set_item;
void (*set_range)(PropertyManager&, Iterator, py::object) = &propman_set_range;
......
......@@ -57,8 +57,8 @@ class Python(unittest.TestCase):
self.assertTrue(propman.property_exists(self.mesh, "prop"))
# Check initial property values
# for v in self.mesh.vertices():
# self.assertEqual(propman[v], None)
for v in self.mesh.vertices():
self.assertEqual(propman[v], None)
# Set property values
propman.set_range(self.mesh.vertices(), 0.0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment