From 7d281c14376a7150d1a2d0f9d70510106d81d682 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 13 Oct 2020 21:49:41 +0200 Subject: [PATCH] add methods to SmartHandles that give access to the status --- src/OpenMesh/Core/Mesh/SmartHandles.hh | 87 ++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 4 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/SmartHandles.hh b/src/OpenMesh/Core/Mesh/SmartHandles.hh index 2fd0af68..4d46bd49 100644 --- a/src/OpenMesh/Core/Mesh/SmartHandles.hh +++ b/src/OpenMesh/Core/Mesh/SmartHandles.hh @@ -43,6 +43,8 @@ #error Do not include this directly, include instead PolyConnectivity.hh #endif//OPENMESH_POLYCONNECTIVITY_INTERFACE_INCLUDE +#include + //== NAMESPACES =============================================================== namespace OpenMesh { @@ -73,8 +75,29 @@ private: }; +/// Base class for all smart handle types that contains status related methods +template +class SmartBaseHandleStatus +{ +public: + /// Returns true iff the handle is marked as feature + bool feature() const; + /// Returns true iff the handle is marked as selected + bool selected() const; + /// Returns true iff the handle is marked as tagged + bool tagged() const; + /// Returns true iff the handle is marked as tagged2 + bool tagged2() const; + /// Returns true iff the handle is marked as locked + bool locked() const; + /// Returns true iff the handle is marked as hidden + bool hidden() const; + /// Returns true iff the handle is marked as deleted + bool deleted() const; +}; + /// Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access to navigation methods -struct OPENMESHDLLEXPORT SmartVertexHandle : public SmartBaseHandle, VertexHandle +struct OPENMESHDLLEXPORT SmartVertexHandle : public SmartBaseHandle, VertexHandle, SmartBaseHandleStatus { explicit SmartVertexHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), VertexHandle(_idx) {} @@ -104,7 +127,7 @@ struct OPENMESHDLLEXPORT SmartVertexHandle : public SmartBaseHandle, VertexHandl bool is_manifold() const; }; -struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeHandle +struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeHandle, SmartBaseHandleStatus { explicit SmartHalfedgeHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), HalfedgeHandle(_idx) {} @@ -130,7 +153,7 @@ struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeH bool is_boundary() const; }; -struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle +struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle, SmartBaseHandleStatus { explicit SmartEdgeHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), EdgeHandle(_idx) {} @@ -155,7 +178,7 @@ struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle bool is_boundary() const; }; -struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle +struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle, SmartBaseHandleStatus { explicit SmartFaceHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), FaceHandle(_idx) {} @@ -207,6 +230,62 @@ template <> struct SmartHandle { using type = SmartEdgeHandle; template <> struct SmartHandle { using type = SmartFaceHandle; }; +template +inline bool SmartBaseHandleStatus::feature() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).feature(); +} + +template +inline bool SmartBaseHandleStatus::selected() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).selected(); +} + +template +inline bool SmartBaseHandleStatus::tagged() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).tagged(); +} + +template +inline bool SmartBaseHandleStatus::tagged2() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).tagged2(); +} + +template +inline bool SmartBaseHandleStatus::locked() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).locked(); +} + +template +inline bool SmartBaseHandleStatus::hidden() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).hidden(); +} + +template +inline bool SmartBaseHandleStatus::deleted() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->status(handle).deleted(); +} + inline SmartHalfedgeHandle SmartVertexHandle::out() const { assert(mesh() != nullptr);