diff --git a/src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh b/src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh index 5f4de1b528598827fe10f8883499f6448b073188..6afa29aed8267bdf67f9744a6fe3d35ab424bbd5 100644 --- a/src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh +++ b/src/OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh @@ -48,6 +48,7 @@ #include #include "../System/FunctionalInclude.hh" +#include "../System/Deprecation.hh" namespace OpenVolumeMesh { @@ -85,7 +86,8 @@ public: void idx(const int& _idx) { idx_ = _idx; } - inline operator int() const { return idx_; } + OVM_DEPRECATED("use explicit .idx() instead") + inline operator int() const { return idx_; } void reset() { idx_ = -1; } diff --git a/src/OpenVolumeMesh/Core/PropertyDefinesT.cc b/src/OpenVolumeMesh/Core/PropertyDefinesT.cc index 3f93c2dbb12643a8dd2859bfc27ba199caf8c63d..351c78ab66a981e4c198ca9190629a06b50d44ee 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefinesT.cc +++ b/src/OpenVolumeMesh/Core/PropertyDefinesT.cc @@ -66,7 +66,7 @@ template BaseProperty *VertexPropertyT::clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new VertexPropertyT(prop_clone, _resMan, VertexPropHandle(_handle)); + return new VertexPropertyT(prop_clone, _resMan, VertexPropHandle(_handle.idx())); } template @@ -94,7 +94,7 @@ template BaseProperty *EdgePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new EdgePropertyT(prop_clone, _resMan, EdgePropHandle(_handle)); + return new EdgePropertyT(prop_clone, _resMan, EdgePropHandle(_handle.idx())); } template @@ -122,7 +122,7 @@ template BaseProperty *HalfEdgePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new HalfEdgePropertyT(prop_clone, _resMan, HalfEdgePropHandle(_handle)); + return new HalfEdgePropertyT(prop_clone, _resMan, HalfEdgePropHandle(_handle.idx())); } template @@ -150,7 +150,7 @@ template BaseProperty *FacePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new FacePropertyT(prop_clone, _resMan, FacePropHandle(_handle)); + return new FacePropertyT(prop_clone, _resMan, FacePropHandle(_handle.idx())); } template @@ -178,7 +178,7 @@ template BaseProperty *HalfFacePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new HalfFacePropertyT(prop_clone, _resMan, HalfFacePropHandle(_handle)); + return new HalfFacePropertyT(prop_clone, _resMan, HalfFacePropHandle(_handle.idx())); } template @@ -206,7 +206,7 @@ template BaseProperty *CellPropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new CellPropertyT(prop_clone, _resMan, CellPropHandle(_handle)); + return new CellPropertyT(prop_clone, _resMan, CellPropHandle(_handle.idx())); } template @@ -234,7 +234,7 @@ template BaseProperty *MeshPropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new MeshPropertyT(prop_clone, _resMan, MeshPropHandle(_handle)); + return new MeshPropertyT(prop_clone, _resMan, MeshPropHandle(_handle.idx())); } template diff --git a/src/OpenVolumeMesh/Core/ResourceManager.hh b/src/OpenVolumeMesh/Core/ResourceManager.hh index 141fd95c8caa170800f167877b05c6eade890b04..47530b76fb71cefcc56fdd165787e55507392526 100644 --- a/src/OpenVolumeMesh/Core/ResourceManager.hh +++ b/src/OpenVolumeMesh/Core/ResourceManager.hh @@ -120,7 +120,7 @@ protected: { PropIterator p_iter = _begin; for (; p_iter != _end; ++p_iter) - (*p_iter)->swap_elements(_h1, _h2); + (*p_iter)->swap_elements(_h1.idx(), _h2.idx()); } diff --git a/src/OpenVolumeMesh/Core/TopologyKernel.cc b/src/OpenVolumeMesh/Core/TopologyKernel.cc index 99d7d2ab852a46a66251ab343ca10d2501af368f..f975e450596cd859adc0c4d0ccbe388aeca51e24 100644 --- a/src/OpenVolumeMesh/Core/TopologyKernel.cc +++ b/src/OpenVolumeMesh/Core/TopologyKernel.cc @@ -562,13 +562,13 @@ void TopologyKernel::set_cell(const CellHandle& _ch, const std::vector::const_iterator hf_it = hfs.begin(), hf_end = hfs.end(); hf_it != hf_end; ++hf_it) { - incident_cell_per_hf_[*hf_it] = InvalidCellHandle; + incident_cell_per_hf_[hf_it->idx()] = InvalidCellHandle; } for(std::vector::const_iterator hf_it = _hfs.begin(), hf_end = _hfs.end(); hf_it != hf_end; ++hf_it) { - incident_cell_per_hf_[*hf_it] = _ch; + incident_cell_per_hf_[hf_it->idx()] = _ch; } } @@ -1503,7 +1503,7 @@ void TopologyKernel::swap_face_indices(FaceHandle _h1, FaceHandle _h2) for (unsigned int j = 0; j < 2; ++j) // for both halffaces { HalfFaceHandle hfh = HalfFaceHandle(2*id+j); - CellHandle ch = incident_cell_per_hf_[hfh]; + CellHandle ch = incident_cell_per_hf_[hfh.idx()]; if (!ch.is_valid()) continue; @@ -1570,7 +1570,7 @@ void TopologyKernel::swap_face_indices(FaceHandle _h1, FaceHandle _h2) if (has_edge_bottom_up_incidences()) { - std::set processed_halfedges; // to ensure ids are only swapped once (in the case that a halfedge is incident to both swapped faces) + std::set processed_halfedges; // to ensure ids are only swapped once (in the case that a halfedge is incident to both swapped faces) for (unsigned int i = 0; i < 2; ++i) // For both swapped faces { unsigned int id = ids[i]; @@ -1583,7 +1583,7 @@ void TopologyKernel::swap_face_indices(FaceHandle _h1, FaceHandle _h2) { HalfEdgeHandle heh = hf.halfedges()[k]; - if (processed_halfedges.find(heh.idx()) != processed_halfedges.end()) + if (processed_halfedges.find(heh) != processed_halfedges.end()) continue; std::vector& incident_halffaces = incident_hfs_per_he_[heh.idx()]; @@ -1713,7 +1713,7 @@ void TopologyKernel::swap_edge_indices(EdgeHandle _h1, EdgeHandle _h2) if (has_vertex_bottom_up_incidences()) { - std::set processed_vertices; + std::set processed_vertices; for (unsigned int i = 0; i < 2; ++i) // For both swapped edges { Edge e = edge(EdgeHandle(ids[i])); @@ -1723,7 +1723,7 @@ void TopologyKernel::swap_edge_indices(EdgeHandle _h1, EdgeHandle _h2) for (unsigned int j = 0; j < 2; ++j) // for both incident vertices { - if (processed_vertices.find(vhs[j].idx()) != processed_vertices.end()) + if (processed_vertices.find(vhs[j]) != processed_vertices.end()) continue; std::vector& outgoing_hes = outgoing_hes_per_vertex_[vhs[j].idx()]; @@ -1782,14 +1782,14 @@ void TopologyKernel::swap_vertex_indices(VertexHandle _h1, VertexHandle _h2) if (processed_edges.find(e_id) == processed_edges.end()) { Edge& e = edges_[e_id]; - if (e.from_vertex() == (int)ids[0]) + if (e.from_vertex().idx() == (int)ids[0]) e.set_from_vertex(VertexHandle(ids[1])); - else if (e.from_vertex() == (int)ids[1]) + else if (e.from_vertex().idx() == (int)ids[1]) e.set_from_vertex(VertexHandle(ids[0])); - if (e.to_vertex() == (int)ids[0]) + if (e.to_vertex().idx() == (int)ids[0]) e.set_to_vertex(VertexHandle(ids[1])); - else if (e.to_vertex() == (int)ids[1]) + else if (e.to_vertex().idx() == (int)ids[1]) e.set_to_vertex(VertexHandle(ids[0])); processed_edges.insert(e_id); @@ -1805,14 +1805,14 @@ void TopologyKernel::swap_vertex_indices(VertexHandle _h1, VertexHandle _h2) for (unsigned int i = 0; i < edges_.size(); ++i) { Edge& e = edges_[i]; - if (e.from_vertex() == (int)ids[0]) + if (e.from_vertex().idx() == (int)ids[0]) e.set_from_vertex(VertexHandle(ids[1])); - else if (e.from_vertex() == (int)ids[1]) + else if (e.from_vertex().idx() == (int)ids[1]) e.set_from_vertex(VertexHandle(ids[0])); - if (e.to_vertex() == (int)ids[0]) + if (e.to_vertex().idx() == (int)ids[0]) e.set_to_vertex(VertexHandle(ids[1])); - else if (e.to_vertex() == (int)ids[1]) + else if (e.to_vertex().idx() == (int)ids[1]) e.set_to_vertex(VertexHandle(ids[0])); } } diff --git a/src/OpenVolumeMesh/System/Deprecation.hh b/src/OpenVolumeMesh/System/Deprecation.hh new file mode 100644 index 0000000000000000000000000000000000000000..2804883cbfe71e5f48e35cde5af728b52d53c1d2 --- /dev/null +++ b/src/OpenVolumeMesh/System/Deprecation.hh @@ -0,0 +1,14 @@ +#pragma once + +#if defined(__cplusplus) && (__cplusplus >= 201402L) +# define OVM_DEPRECATED(msg) [[deprecated(msg)]] +#elif defined(__GNUC__) || defined(__clang__) +# define OVM_DEPRECATED(msg) __attribute__((deprecated)) +#elif defined(_MSC_VER) +# define OVM_DEPRECATED(msg) __declspec(deprecated) +#else +# pragma message("WARNING: You need to implement DEPRECATED for this compiler") +# define OVM_DEPRECATED(msg) +#endif + + diff --git a/src/Unittests/unittests_basics.cc b/src/Unittests/unittests_basics.cc index 102cb2f09eac92d5a37c156430ddab08f8f35a7e..6aa108be801808a602f3a8c916bf6b60b767c951 100644 --- a/src/Unittests/unittests_basics.cc +++ b/src/Unittests/unittests_basics.cc @@ -796,7 +796,7 @@ TEST_F(PolyhedralMeshBase, DeleteFaceBUTest1) { if(mesh_.face_handle(hfh) == FaceHandle(0)) continue; - hfh.idx((hfh.idx() > mesh_.halfface_handle(FaceHandle(0), 1) ? hfh.idx() - 2 : hfh.idx())); + hfh.idx((hfh.idx() > mesh_.halfface_handle(FaceHandle(0), 1).idx() ? hfh.idx() - 2 : hfh.idx())); ihfs[i].push_back(hfh); } @@ -834,13 +834,13 @@ TEST_F(PolyhedralMeshBase, DeleteEdgeBUTest1) { std::vector hes0; for(VertexOHalfEdgeIter voh_it = mesh_.voh_iter(vh0); voh_it.valid(); ++voh_it) { if(mesh_.edge_handle(*voh_it) == EdgeHandle(0)) continue; - hes0.push_back(HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1) ? voh_it->idx() - 2 : voh_it->idx())); + hes0.push_back(HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1).idx() ? voh_it->idx() - 2 : voh_it->idx())); } std::vector hes1; for(VertexOHalfEdgeIter voh_it = mesh_.voh_iter(vh1); voh_it.valid(); ++voh_it) { if(mesh_.edge_handle(*voh_it) == EdgeHandle(0)) continue; - hes1.push_back(HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1) ? voh_it->idx() - 2 : voh_it->idx())); + hes1.push_back(HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1).idx() ? voh_it->idx() - 2 : voh_it->idx())); } mesh_.delete_edge(EdgeHandle(0)); @@ -913,7 +913,7 @@ TEST_F(PolyhedralMeshBase, DeleteFaceBUTest1noBU) { if(mesh_.face_handle(hfh) == FaceHandle(0)) continue; - hfh.idx((hfh.idx() > mesh_.halfface_handle(FaceHandle(0), 1) ? hfh.idx() - 2 : hfh.idx())); + hfh.idx((hfh.idx() > mesh_.halfface_handle(FaceHandle(0), 1).idx() ? hfh.idx() - 2 : hfh.idx())); ihfs[i].push_back(hfh); } @@ -968,7 +968,7 @@ TEST_F(PolyhedralMeshBase, DeleteEdgeBUTest1noBU) { if(mesh_.halfedge(*he_it).from_vertex() == vh0) { if(mesh_.edge_handle(*he_it) == EdgeHandle(0)) continue; - hes0.push_back(HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1) ? he_it->idx() - 2 : he_it->idx())); + hes0.push_back(HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1).idx() ? he_it->idx() - 2 : he_it->idx())); } } @@ -978,7 +978,7 @@ TEST_F(PolyhedralMeshBase, DeleteEdgeBUTest1noBU) { if(mesh_.halfedge(*he_it).from_vertex() == vh1) { if(mesh_.edge_handle(*he_it) == EdgeHandle(0)) continue; - hes1.push_back(HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1) ? he_it->idx() - 2 : he_it->idx())); + hes1.push_back(HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(EdgeHandle(0), 1).idx() ? he_it->idx() - 2 : he_it->idx())); } }