Commit 08f59ad5 authored by Alexander Dielen's avatar Alexander Dielen

removed old property interface and updated copy_property()

parent c457a6aa
......@@ -40,46 +40,6 @@ void set_status(Mesh& _self, IndexHandle _h, const OpenMesh::Attributes::StatusI
_self.status(_h) = _info;
}
/**
* Set the value of a property of an item.
*
* @tparam Mesh A mesh type.
* @tparam PropHandle A property handle type.
* @tparam IndexHandle The appropriate handle type.
*
* @param _self The mesh instance that is to be used.
* @param _ph The property that is to be set.
* @param _h The handle of the item whose property is to be set.
* @param _value The value to be set.
*
* Depending on @ref OPENMESH_PYTHON_DEFAULT_POLICY, Mesh::property may
* return by value instead of reference. This function ensures that the
* property value of an item can be changed nonetheless.
*/
template <class Mesh, class PropHandle, class IndexHandle>
void set_property(Mesh& _self, PropHandle _ph, IndexHandle _h, const py::object& _value) {
_self.property(_ph, _h) = _value;
}
/**
* Set the value of a mesh property.
*
* @tparam Mesh A mesh type.
* @tparam PropHandle A property handle type.
*
* @param _self The mesh instance that is to be used.
* @param _ph The property that is to be set.
* @param _value The value to be set.
*
* Depending on @ref OPENMESH_PYTHON_DEFAULT_POLICY, Mesh::property may
* return by value instead of reference. This function ensures that the
* property value of an item can be changed nonetheless.
*/
template <class Mesh, class PropHandle>
void set_property(Mesh& _self, PropHandle _ph, const py::object& _value) {
_self.property(_ph) = _value;
}
/**
* Thin wrapper for assign_connectivity.
*
......@@ -541,41 +501,6 @@ void expose_mesh(py::module& m, const char *_name) {
void (*set_status_eh)(Mesh&, OM::EdgeHandle, const StatusInfo&) = &set_status;
void (*set_status_fh)(Mesh&, OM::FaceHandle, const StatusInfo&) = &set_status;
// Property management - add property
void (Mesh::*add_property_vph)(OM::VPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
void (Mesh::*add_property_eph)(OM::EPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
void (Mesh::*add_property_hph)(OM::HPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
void (Mesh::*add_property_fph)(OM::FPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
void (Mesh::*add_property_mph)(OM::MPropHandleT<py::none>&, const std::string&) = &Mesh::add_property;
// Property management - remove property
void (Mesh::*remove_property_vph)(OM::VPropHandleT<py::none>&) = &Mesh::remove_property;
void (Mesh::*remove_property_eph)(OM::EPropHandleT<py::none>&) = &Mesh::remove_property;
void (Mesh::*remove_property_hph)(OM::HPropHandleT<py::none>&) = &Mesh::remove_property;
void (Mesh::*remove_property_fph)(OM::FPropHandleT<py::none>&) = &Mesh::remove_property;
void (Mesh::*remove_property_mph)(OM::MPropHandleT<py::none>&) = &Mesh::remove_property;
// Property management - get property by name
bool (Mesh::*get_property_handle_vph)(OM::VPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
bool (Mesh::*get_property_handle_eph)(OM::EPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
bool (Mesh::*get_property_handle_hph)(OM::HPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
bool (Mesh::*get_property_handle_fph)(OM::FPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
bool (Mesh::*get_property_handle_mph)(OM::MPropHandleT<py::none>&, const std::string&) const = &Mesh::get_property_handle;
// Property management - get property value for an item
const py::none& (Mesh::*property_vertex )(OM::VPropHandleT<py::none>, OM::VertexHandle ) const = &Mesh::property;
const py::none& (Mesh::*property_edge )(OM::EPropHandleT<py::none>, OM::EdgeHandle ) const = &Mesh::property;
const py::none& (Mesh::*property_halfedge)(OM::HPropHandleT<py::none>, OM::HalfedgeHandle) const = &Mesh::property;
const py::none& (Mesh::*property_face )(OM::FPropHandleT<py::none>, OM::FaceHandle ) const = &Mesh::property;
const py::none& (Mesh::*property_mesh )(OM::MPropHandleT<py::none> ) const = &Mesh::property;
// Property management - set property value for an item
void (*set_property_vertex )(Mesh&, OM::VPropHandleT<py::none>, OM::VertexHandle, const py::object&) = &set_property;
void (*set_property_edge )(Mesh&, OM::EPropHandleT<py::none>, OM::EdgeHandle, const py::object&) = &set_property;
void (*set_property_halfedge)(Mesh&, OM::HPropHandleT<py::none>, OM::HalfedgeHandle, const py::object&) = &set_property;
void (*set_property_face )(Mesh&, OM::FPropHandleT<py::none>, OM::FaceHandle, const py::object&) = &set_property;
void (*set_property_mesh )(Mesh&, OM::MPropHandleT<py::none>, const py::object&) = &set_property;
// Low-level adding new items
OM::VertexHandle (Mesh::*new_vertex_void )(void ) = &Mesh::new_vertex;
OM::FaceHandle (Mesh::*new_face_void )(void ) = &Mesh::new_face;
......@@ -596,12 +521,6 @@ void expose_mesh(py::module& m, const char *_name) {
// BaseKernel Function Pointers
//======================================================================
// Copy property
void (Mesh::*copy_property_vprop)(OM::VPropHandleT<py::none>&, OM::VertexHandle, OM::VertexHandle ) = &Mesh::copy_property;
void (Mesh::*copy_property_hprop)(OM::HPropHandleT<py::none>, OM::HalfedgeHandle, OM::HalfedgeHandle) = &Mesh::copy_property;
void (Mesh::*copy_property_eprop)(OM::EPropHandleT<py::none>, OM::EdgeHandle, OM::EdgeHandle ) = &Mesh::copy_property;
void (Mesh::*copy_property_fprop)(OM::FPropHandleT<py::none>, OM::FaceHandle, OM::FaceHandle ) = &Mesh::copy_property;
// Copy all properties
void (Mesh::*copy_all_properties_vh_vh_bool)(OM::VertexHandle, OM::VertexHandle, bool) = &Mesh::copy_all_properties;
void (Mesh::*copy_all_properties_hh_hh_bool)(OM::HalfedgeHandle, OM::HalfedgeHandle, bool) = &Mesh::copy_all_properties;
......@@ -805,36 +724,6 @@ void expose_mesh(py::module& m, const char *_name) {
.def("has_face_status", &Mesh::has_face_status)
.def("has_face_texture_index", &Mesh::has_face_texture_index)
.def("add_property", add_property_vph, py::arg("ph"), py::arg("name")="<vprop>")
.def("add_property", add_property_eph, py::arg("ph"), py::arg("name")="<eprop>")
.def("add_property", add_property_hph, py::arg("ph"), py::arg("name")="<hprop>")
.def("add_property", add_property_fph, py::arg("ph"), py::arg("name")="<fprop>")
.def("add_property", add_property_mph, py::arg("ph"), py::arg("name")="<mprop>")
.def("remove_property", remove_property_vph)
.def("remove_property", remove_property_eph)
.def("remove_property", remove_property_hph)
.def("remove_property", remove_property_fph)
.def("remove_property", remove_property_mph)
.def("get_property_handle", get_property_handle_vph)
.def("get_property_handle", get_property_handle_eph)
.def("get_property_handle", get_property_handle_hph)
.def("get_property_handle", get_property_handle_fph)
.def("get_property_handle", get_property_handle_mph)
.def("property", property_vertex, OPENMESH_PYTHON_DEFAULT_POLICY)
.def("property", property_edge, OPENMESH_PYTHON_DEFAULT_POLICY)
.def("property", property_halfedge, OPENMESH_PYTHON_DEFAULT_POLICY)
.def("property", property_face, OPENMESH_PYTHON_DEFAULT_POLICY)
.def("property", property_mesh, OPENMESH_PYTHON_DEFAULT_POLICY)
.def("set_property", set_property_vertex)
.def("set_property", set_property_edge)
.def("set_property", set_property_halfedge)
.def("set_property", set_property_face)
.def("set_property", set_property_mesh)
.def("new_vertex", new_vertex_void)
.def("new_vertex", [](Mesh& _self, py::array_t<typename Point::value_type> _arr) {
return _self.new_vertex(Point(_arr.at(0), _arr.at(1), _arr.at(2)));
......@@ -859,11 +748,6 @@ void expose_mesh(py::module& m, const char *_name) {
// BaseKernel
//======================================================================
.def("copy_property", copy_property_vprop)
.def("copy_property", copy_property_hprop)
.def("copy_property", copy_property_eprop)
.def("copy_property", copy_property_fprop)
.def("copy_all_properties", copy_all_properties_vh_vh_bool,
py::arg("vh_from"), py::arg("vh_to"), py::arg("copy_build_in")=false)
.def("copy_all_properties", copy_all_properties_hh_hh_bool,
......@@ -1369,6 +1253,15 @@ void expose_mesh(py::module& m, const char *_name) {
.def("set_halfedge_property_array", &Mesh::template py_set_property_array<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
.def("set_edge_property_array", &Mesh::template py_set_property_array<OM::EdgeHandle, typename Mesh::EPropHandle>)
.def("set_face_property_array", &Mesh::template py_set_property_array<OM::FaceHandle, typename Mesh::FPropHandle>)
//======================================================================
// new property interface: copy
//======================================================================
.def("copy_property", &Mesh::template py_copy_property<OM::VertexHandle, typename Mesh::VPropHandle>)
.def("copy_property", &Mesh::template py_copy_property<OM::HalfedgeHandle, typename Mesh::HPropHandle>)
.def("copy_property", &Mesh::template py_copy_property<OM::EdgeHandle, typename Mesh::EPropHandle>)
.def("copy_property", &Mesh::template py_copy_property<OM::FaceHandle, typename Mesh::FPropHandle>)
;
expose_type_specific_functions(class_mesh);
......
......@@ -167,6 +167,12 @@ public:
}
}
template <class Handle, class PropHandle>
void py_copy_property(const std::string& _name, Handle _from, Handle _to) {
auto prop = py_prop_on_demand<Handle, PropHandle>(_name);
Mesh::copy_property(prop, _from, _to);
}
private:
template <class Handle, class PropHandle>
......
......@@ -49,37 +49,6 @@ void expose_handles(py::module& m) {
.def(py::init<>())
.def(py::init<int>())
;
py::class_<OM::BasePropHandleT<py::none>, OM::BaseHandle>(m, "BasePropHandle")
.def(py::init<>())
.def(py::init<int>())
;
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::none>&>())
;
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::none>&>())
;
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::none>&>())
;
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::none>&>())
;
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::none>&>())
;
}
......
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