From dbaa76afe1acc4de1f714a171cd7270212280405 Mon Sep 17 00:00:00 2001 From: Jared Duffey Date: Fri, 6 Dec 2024 16:12:43 -0500 Subject: [PATCH] Merged m_NumJunctions into m_BitFlag * The number of junctions can be at most 6 so it can be stored in 3 bits and m_BitFlag has enough unused bits at the end to accommodate it Signed-off-by: Jared Duffey --- .../src/SimplnxCore/SurfaceNets/MMCellFlag.cpp | 10 ++++++---- .../src/SimplnxCore/SurfaceNets/MMCellFlag.h | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp index d6fde4d171..3f0f904f30 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.cpp @@ -194,7 +194,7 @@ void MMCellFlag::set(const int32_t cellLabels[8]) // Determine vertex type int32_t numFaceCrossings = 0; - m_NumJunctions = 0; + uint32_t numJunctions = 0; for(Face face = Face::LeftFace; face <= Face::TopFace; ++face) { if(faceCrossingType(face) != FaceCrossingType::NoFaceCrossing) @@ -202,18 +202,18 @@ void MMCellFlag::set(const int32_t cellLabels[8]) numFaceCrossings++; if(faceCrossingType(face) == FaceCrossingType::JunctionFaceCrossing) { - m_NumJunctions++; + numJunctions++; } } } if(numFaceCrossings != 0) { uint32_t vertexTypeBits = 0; - if(m_NumJunctions < 1) + if(numJunctions < 1) { vertexTypeBits = static_cast(VertexType::SurfaceVertex); } - else if(m_NumJunctions <= 2) + else if(numJunctions <= 2) { vertexTypeBits = static_cast(VertexType::EdgeVertex); } @@ -223,6 +223,8 @@ void MMCellFlag::set(const int32_t cellLabels[8]) } m_BitFlag |= (vertexTypeBits << k_VertexTypeShift); } + + m_BitFlag |= numJunctions << k_NumJunctionsBitShift; } MMCellFlag::VertexType MMCellFlag::vertexType() const diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h index 50a6424bed..d7d9eaf9e6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/SurfaceNets/MMCellFlag.h @@ -73,13 +73,16 @@ class MMCellFlag bool isEdgeCrossing(Edge edge) const; uint8_t numJunctions() const { - return m_NumJunctions; + return m_BitFlag >> k_NumJunctionsBitShift; } private: + static inline constexpr uint32_t k_NumJunctionsBitShift = 29; + // The bitflag + // The last 3 bits of the bitflag are the number of junctions + // numJunctions can at most be 6 uint32_t m_BitFlag = 0; - uint8_t m_NumJunctions = 0; }; // For iterating over cell faces