diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index dba69ae4fe..6cf3bd98d8 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -295,13 +295,13 @@ TopoShape::TopoShape(const TopoShape& shape) *this = shape; } -std::pair TopoShape::getElementTypeAndIndex(const char* Name) +std::pair 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)) { diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index f5733222f2..b4ff2064be 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -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 getElementTypeAndIndex(const char* Name); /** Sub type list * List of different subelement types diff --git a/tests/src/Mod/Part/App/TopoShape.cpp b/tests/src/Mod/Part/App/TopoShape.cpp index d22d3b0190..52c6eda179 100644 --- a/tests/src/Mod/Part/App/TopoShape.cpp +++ b/tests/src/Mod/Part/App/TopoShape.cpp @@ -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)