Commit 2a895832 authored by Matthias Möller's avatar Matthias Möller
Browse files

tabified

parent f3a3221f
Pipeline #7212 passed with stages
in 5 minutes and 51 seconds
......@@ -57,15 +57,15 @@ public:
template <class Handle>
bool py_has_property(const std::string& _name) {
HandleToPropHandle<Handle> dummy;
return py_get_property_handle<Handle>(dummy, _name);
HandleToPropHandle<Handle> dummy;
return py_get_property_handle<Handle>(dummy, _name);
}
template <class Handle>
void py_remove_property(const std::string& _name) {
HandleToPropHandle<Handle> h;
Mesh::get_property_handle(h, _name);
Mesh::remove_property(h);
HandleToPropHandle<Handle> h;
Mesh::get_property_handle(h, _name);
Mesh::remove_property(h);
}
template <class Handle, class PropHandle>
......@@ -217,17 +217,17 @@ private:
template <class Handle>
void py_deepcopy_prop(MeshWrapperT *_copy, py::object _copyfunc, py::dict _memo) {
using PropHandle = HandleToPropHandle<Handle>;
const auto enditer = this->end(Handle());
for (auto iter = this->begin(Handle()); iter != enditer; ++iter){
using PropHandle = HandleToPropHandle<Handle>;
const auto enditer = this->end(Handle());
for (auto iter = this->begin(Handle()); iter != enditer; ++iter){
// only select properties owned by python (all properties with type "py::none")
const OpenMesh::BaseProperty* baseProp = *iter;
const auto* srcProp = dynamic_cast< const OpenMesh::PropertyT<py::none>* >(baseProp);
if (!srcProp)
continue; //not a python prop -> dont copy
// only select properties owned by python (all properties with type "py::none")
const OpenMesh::BaseProperty* baseProp = *iter;
const auto* srcProp = dynamic_cast< const OpenMesh::PropertyT<py::none>* >(baseProp);
if (!srcProp)
continue; //not a python prop -> dont copy
const PropHandle targetProp = _copy->py_prop_on_demand<Handle, PropHandle>(srcProp->name());
const PropHandle targetProp = _copy->py_prop_on_demand<Handle, PropHandle>(srcProp->name());
for (size_t i = 0; i < srcProp->n_elements(); ++i) {
_copy->property(targetProp, Handle(i)) = _copyfunc((*srcProp)[i], _memo);
......@@ -235,78 +235,78 @@ private:
}
}
template <class Handle, class PropHandle>
bool py_get_property_handle(PropHandle &_out, const std::string& _name) {
template <class Handle, class PropHandle>
bool py_get_property_handle(PropHandle &_out, const std::string& _name) {
#ifdef OM_FORCE_STATIC_CAST
// Enable type checking for OpenMesh Properties.
// In OpenMesh it is disabled due to a problem with the shared linkage using libc++
// We link the static library and therefore, OpenMesh-Python is not affected by this
// This function enables type checking, if it is disabled in OpenMesh (per default, in Relase mode)
// Use normal OpenMesh property_handle function, when type checking is not disabled (debug more or hopefully in the future)
int idx = -1;
const auto it = std::find_if(this->begin(Handle()), this->end(Handle()), [&_name, &idx](OpenMesh::BaseProperty* p)
{
++idx;
return ((p != nullptr) && (p->name() == _name) && (dynamic_cast<OpenMesh::PropertyT<py::none>*>(p) != nullptr));
});
if (it == this->end(Handle()))
{
_out = PropHandle();
return false;
}
else
{
_out = PropHandle(idx);
return true;
}
// Enable type checking for OpenMesh Properties.
// In OpenMesh it is disabled due to a problem with the shared linkage using libc++
// We link the static library and therefore, OpenMesh-Python is not affected by this
// This function enables type checking, if it is disabled in OpenMesh (per default, in Relase mode)
// Use normal OpenMesh property_handle function, when type checking is not disabled (debug more or hopefully in the future)
int idx = -1;
const auto it = std::find_if(this->begin(Handle()), this->end(Handle()), [&_name, &idx](OpenMesh::BaseProperty* p)
{
++idx;
return ((p != nullptr) && (p->name() == _name) && (dynamic_cast<OpenMesh::PropertyT<py::none>*>(p) != nullptr));
});
if (it == this->end(Handle()))
{
_out = PropHandle();
return false;
}
else
{
_out = PropHandle(idx);
return true;
}
#else
return Mesh::get_property_handle(_out, _name);
return Mesh::get_property_handle(_out, _name);
#endif
}
}
template <class Handle, class PropHandle>
PropHandle py_prop_on_demand(const std::string& _name) {
PropHandle result;
if (!py_get_property_handle<Handle>(result, _name))
Mesh::add_property(result, _name);
PropHandle result;
if (!py_get_property_handle<Handle>(result, _name))
Mesh::add_property(result, _name);
return result;
}
typename Mesh::prop_iterator begin(OpenMesh::VertexHandle) { return this->vprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::VertexHandle) { return this->vprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::HalfedgeHandle) { return this->hprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::HalfedgeHandle) { return this->hprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::EdgeHandle) { return this->eprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::EdgeHandle) { return this->eprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::FaceHandle) { return this->fprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::FaceHandle) { return this->fprops_end(); }
template<typename Handle, typename Dummy>
struct HandleToPropHandle_D
{};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::VertexHandle, Dummy>
{
using type = VPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::HalfedgeHandle, Dummy>
{
using type = HPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::EdgeHandle, Dummy>
{
using type = EPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::FaceHandle, Dummy>
{
using type = FPropHandle;
};
template<typename Handle>
using HandleToPropHandle = typename HandleToPropHandle_D<Handle,Handle>::type;
typename Mesh::prop_iterator begin(OpenMesh::VertexHandle) { return this->vprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::VertexHandle) { return this->vprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::HalfedgeHandle) { return this->hprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::HalfedgeHandle) { return this->hprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::EdgeHandle) { return this->eprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::EdgeHandle) { return this->eprops_end(); }
typename Mesh::prop_iterator begin(OpenMesh::FaceHandle) { return this->fprops_begin(); }
typename Mesh::prop_iterator end(OpenMesh::FaceHandle) { return this->fprops_end(); }
template<typename Handle, typename Dummy>
struct HandleToPropHandle_D
{};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::VertexHandle, Dummy>
{
using type = VPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::HalfedgeHandle, Dummy>
{
using type = HPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::EdgeHandle, Dummy>
{
using type = EPropHandle;
};
template<typename Dummy>
struct HandleToPropHandle_D<OpenMesh::FaceHandle, Dummy>
{
using type = FPropHandle;
};
template<typename Handle>
using HandleToPropHandle = typename HandleToPropHandle_D<Handle,Handle>::type;
};
......
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