Part: Toposhape: fix regressions due to changes in getElementTypeAndIndex (#26596)

* Part: Toposhape: fix regressions due to changes in getElementTypeAndIndex

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update TopoShape.cpp

* Update TopoShape.cpp

* Update TopoShape.cpp

* Update TopoShape.h

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
PaddleStroke
2026-01-02 19:37:09 +01:00
committed by GitHub
parent 6df651b5c8
commit 07756cc838
3 changed files with 6 additions and 6 deletions

View File

@@ -295,13 +295,13 @@ TopoShape::TopoShape(const TopoShape& shape)
*this = shape;
}
std::pair<std::string, unsigned long> TopoShape::getElementTypeAndIndex(const char* Name)
std::pair<std::string, unsigned long> TopoShape::getElementTypeAndIndex(const char* RawName)
{
std::string strName = Data::oldElementName(RawName);
const char* Name = strName.c_str();
int index = 0;
std::string element;
// Regex modified to allow a prefix ending in a separator (e.g. TNP hash or Dot notation)
// Matches "Face3", "Part.Face3", or ";#7:1;:G0...F.Face3"
boost::regex ex("^(?:.*[.;:,])?(Face|Edge|Vertex)([1-9][0-9]*)$");
boost::regex ex("^(Face|Edge|Vertex)([1-9][0-9]*)$");
boost::cmatch what;
if (Name && boost::regex_match(Name, what, ex)) {

View File

@@ -387,7 +387,7 @@ public:
const TopoShape& shapeToLookIn
);
/// Unlike \ref getTypeAndIndex() this function only handles the supported
/// element types.
/// element types. It works only if Name is just an element name (with or without TNP hash).
static std::pair<std::string, unsigned long> getElementTypeAndIndex(const char* Name);
/** Sub type list
* List of different subelement types

View File

@@ -87,7 +87,7 @@ TEST_F(TopoShapeTest, TestElementTypeWithHash)
TEST_F(TopoShapeTest, TestElementTypeWithSubelements)
{
EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Part.Body.Pad.Face3"),
std::make_pair(std::string("Face"), 3UL));
std::make_pair(std::string(), 0UL));
}
TEST_F(TopoShapeTest, TestElementTypeNonMatching)