diff --git a/src/OpenMesh/Core/Mesh/SmartHandles.hh b/src/OpenMesh/Core/Mesh/SmartHandles.hh index 4d46bd49..fbe4a94e 100644 --- a/src/OpenMesh/Core/Mesh/SmartHandles.hh +++ b/src/OpenMesh/Core/Mesh/SmartHandles.hh @@ -77,7 +77,7 @@ private: /// Base class for all smart handle types that contains status related methods template -class SmartBaseHandleStatus +class SmartHandleStatusPredicates { public: /// Returns true iff the handle is marked as feature @@ -96,8 +96,17 @@ public: bool deleted() const; }; +/// Base class for all smart handle types that contains status related methods +template +class SmartHandleBoundaryPredicate +{ +public: + /// Returns true iff the handle is boundary + bool is_boundary() 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, SmartBaseHandleStatus +struct OPENMESHDLLEXPORT SmartVertexHandle : public SmartBaseHandle, VertexHandle, SmartHandleStatusPredicates, SmartHandleBoundaryPredicate { explicit SmartVertexHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), VertexHandle(_idx) {} @@ -121,13 +130,11 @@ struct OPENMESHDLLEXPORT SmartVertexHandle : public SmartBaseHandle, VertexHandl /// Returns valence of the vertex uint valence() const; - /// Returns true iff the vertex is incident to a boundary halfedge - bool is_boundary() const; /// Returns true iff (the mesh at) the vertex is two-manifold ? bool is_manifold() const; }; -struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeHandle, SmartBaseHandleStatus +struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeHandle, SmartHandleStatusPredicates, SmartHandleBoundaryPredicate { explicit SmartHalfedgeHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), HalfedgeHandle(_idx) {} @@ -148,12 +155,9 @@ struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeH /// Returns a range of halfedges in the face of the halfedge (or along the boundary) (PolyConnectivity::hl_range()) PolyConnectivity::ConstHalfedgeLoopRange loop() const; - - /// Returns true iff the halfedge is on the boundary (i.e. it has no corresponding face) - bool is_boundary() const; }; -struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle, SmartBaseHandleStatus +struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle, SmartHandleStatusPredicates, SmartHandleBoundaryPredicate { explicit SmartEdgeHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), EdgeHandle(_idx) {} @@ -173,12 +177,9 @@ struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle, S SmartVertexHandle v0() const; /// Shorthand for vertex(1) SmartVertexHandle v1() const; - - /// Returns true iff the edge lies on the boundary (i.e. one of the halfedges is boundary) - bool is_boundary() const; }; -struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle, SmartBaseHandleStatus +struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle, SmartHandleStatusPredicates, SmartHandleBoundaryPredicate { explicit SmartFaceHandle(int _idx=-1, const PolyConnectivity* _mesh = nullptr) : SmartBaseHandle(_mesh), FaceHandle(_idx) {} @@ -196,8 +197,6 @@ struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle, S /// Returns the valence of the face uint valence() const; - /// Returns true iff the face lies at the boundary (i.e. one of the edges is boundary) - bool is_boundary() const; }; @@ -231,7 +230,7 @@ template <> struct SmartHandle { using type = SmartFaceHandle; template -inline bool SmartBaseHandleStatus::feature() const +inline bool SmartHandleStatusPredicates::feature() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -239,7 +238,7 @@ inline bool SmartBaseHandleStatus::feature() const } template -inline bool SmartBaseHandleStatus::selected() const +inline bool SmartHandleStatusPredicates::selected() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -247,7 +246,7 @@ inline bool SmartBaseHandleStatus::selected() const } template -inline bool SmartBaseHandleStatus::tagged() const +inline bool SmartHandleStatusPredicates::tagged() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -255,7 +254,7 @@ inline bool SmartBaseHandleStatus::tagged() const } template -inline bool SmartBaseHandleStatus::tagged2() const +inline bool SmartHandleStatusPredicates::tagged2() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -263,7 +262,7 @@ inline bool SmartBaseHandleStatus::tagged2() const } template -inline bool SmartBaseHandleStatus::locked() const +inline bool SmartHandleStatusPredicates::locked() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -271,7 +270,7 @@ inline bool SmartBaseHandleStatus::locked() const } template -inline bool SmartBaseHandleStatus::hidden() const +inline bool SmartHandleStatusPredicates::hidden() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); @@ -279,13 +278,21 @@ inline bool SmartBaseHandleStatus::hidden() const } template -inline bool SmartBaseHandleStatus::deleted() const +inline bool SmartHandleStatusPredicates::deleted() const { const auto& handle = static_cast(*this); assert(handle.mesh() != nullptr); return handle.mesh()->status(handle).deleted(); } +template +inline bool SmartHandleBoundaryPredicate::is_boundary() const +{ + const auto& handle = static_cast(*this); + assert(handle.mesh() != nullptr); + return handle.mesh()->is_boundary(handle); +} + inline SmartHalfedgeHandle SmartVertexHandle::out() const { assert(mesh() != nullptr); @@ -308,12 +315,6 @@ inline uint SmartVertexHandle::valence() const return mesh()->valence(*this); } -inline bool SmartVertexHandle::is_boundary() const -{ - assert(mesh() != nullptr); - return mesh()->is_boundary(*this); -} - inline bool SmartVertexHandle::is_manifold() const { assert(mesh() != nullptr); @@ -362,12 +363,6 @@ inline SmartFaceHandle SmartHalfedgeHandle::face() const return make_smart(mesh()->face_handle(*this), mesh()); } -inline bool SmartHalfedgeHandle::is_boundary() const -{ - assert(mesh() != nullptr); - return mesh()->is_boundary(*this); -} - inline SmartHalfedgeHandle SmartEdgeHandle::halfedge(unsigned int _i) const { assert(mesh() != nullptr); @@ -409,12 +404,6 @@ inline SmartVertexHandle SmartEdgeHandle::v1() const return v(1); } -inline bool SmartEdgeHandle::is_boundary() const -{ - assert(mesh() != nullptr); - return mesh()->is_boundary(*this); -} - inline SmartHalfedgeHandle SmartFaceHandle::halfedge() const { assert(mesh() != nullptr); @@ -427,11 +416,6 @@ inline uint SmartFaceHandle::valence() const return mesh()->valence(*this); } -inline bool SmartFaceHandle::is_boundary() const -{ - assert(mesh() != nullptr); - return mesh()->is_boundary(*this); -} //============================================================================= } // namespace OpenMesh //=============================================================================