From 91a6855ca09f826fd2522f1bb72c4aa00707b254 Mon Sep 17 00:00:00 2001 From: Daniel Zint Date: Thu, 12 Oct 2023 11:15:51 -0400 Subject: [PATCH] Adding `invariants` namespace to `MinIncidentValenceInvariant`. --- .../MinIncidentValenceInvariant.cpp | 22 +++++++++++++++++-- .../MinIncidentValenceInvariant.hpp | 6 ++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/wmtk/invariants/MinIncidentValenceInvariant.cpp b/src/wmtk/invariants/MinIncidentValenceInvariant.cpp index 8ae0b7420c..7c7f6b2f90 100644 --- a/src/wmtk/invariants/MinIncidentValenceInvariant.cpp +++ b/src/wmtk/invariants/MinIncidentValenceInvariant.cpp @@ -3,12 +3,15 @@ #include #include -wmtk::MinIncidentValenceInvariant::MinIncidentValenceInvariant(const Mesh& m, long min_valence) +namespace wmtk::invariants { + + +MinIncidentValenceInvariant::MinIncidentValenceInvariant(const Mesh& m, long min_valence) : MeshInvariant(m) , m_min_valence(min_valence) {} -bool wmtk::MinIncidentValenceInvariant::before(const Tuple& t) const +bool MinIncidentValenceInvariant::before(const Tuple& t) const { const Tuple v0 = t; const Tuple v1 = mesh().switch_vertex(t); @@ -17,3 +20,18 @@ bool wmtk::MinIncidentValenceInvariant::before(const Tuple& t) const return val0 >= m_min_valence && val1 >= m_min_valence; } + +bool MinIncidentValenceInvariant::after(PrimitiveType type, const std::vector& t) const +{ + assert(type == PrimitiveType::Edge); + + for (const Tuple& e : t) { + if (!before(e)) { + return false; + } + } + + return true; +} + +} // namespace wmtk::invariants \ No newline at end of file diff --git a/src/wmtk/invariants/MinIncidentValenceInvariant.hpp b/src/wmtk/invariants/MinIncidentValenceInvariant.hpp index ca13bcdc5b..f1753c01af 100644 --- a/src/wmtk/invariants/MinIncidentValenceInvariant.hpp +++ b/src/wmtk/invariants/MinIncidentValenceInvariant.hpp @@ -3,7 +3,7 @@ #include #include "MeshInvariant.hpp" -namespace wmtk { +namespace wmtk::invariants { /** * Invariant for minimum valence on both incident vertices of an edge. */ @@ -13,9 +13,9 @@ class MinIncidentValenceInvariant : public MeshInvariant MinIncidentValenceInvariant(const Mesh& m, long min_valence); using MeshInvariant::MeshInvariant; bool before(const Tuple& t) const override; + bool after(PrimitiveType type, const std::vector& t) const override; private: - const MeshAttributeHandle m_coordinate_handle; long m_min_valence; }; -} // namespace wmtk +} // namespace wmtk::invariants