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:
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user