Skip to content

Commit 07756cc

Browse files
Part: Toposhape: fix regressions due to changes in getElementTypeAndIndex (FreeCAD#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>
1 parent 6df651b commit 07756cc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Mod/Part/App/TopoShape.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ TopoShape::TopoShape(const TopoShape& shape)
295295
*this = shape;
296296
}
297297

298-
std::pair<std::string, unsigned long> TopoShape::getElementTypeAndIndex(const char* Name)
298+
std::pair<std::string, unsigned long> TopoShape::getElementTypeAndIndex(const char* RawName)
299299
{
300+
std::string strName = Data::oldElementName(RawName);
301+
const char* Name = strName.c_str();
300302
int index = 0;
301303
std::string element;
302-
// Regex modified to allow a prefix ending in a separator (e.g. TNP hash or Dot notation)
303-
// Matches "Face3", "Part.Face3", or ";#7:1;:G0...F.Face3"
304-
boost::regex ex("^(?:.*[.;:,])?(Face|Edge|Vertex)([1-9][0-9]*)$");
304+
boost::regex ex("^(Face|Edge|Vertex)([1-9][0-9]*)$");
305305
boost::cmatch what;
306306

307307
if (Name && boost::regex_match(Name, what, ex)) {

src/Mod/Part/App/TopoShape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class PartExport TopoShape: public Data::ComplexGeoData
387387
const TopoShape& shapeToLookIn
388388
);
389389
/// Unlike \ref getTypeAndIndex() this function only handles the supported
390-
/// element types.
390+
/// element types. It works only if Name is just an element name (with or without TNP hash).
391391
static std::pair<std::string, unsigned long> getElementTypeAndIndex(const char* Name);
392392
/** Sub type list
393393
* List of different subelement types

tests/src/Mod/Part/App/TopoShape.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ TEST_F(TopoShapeTest, TestElementTypeWithHash)
8787
TEST_F(TopoShapeTest, TestElementTypeWithSubelements)
8888
{
8989
EXPECT_EQ(Part::TopoShape::getElementTypeAndIndex("Part.Body.Pad.Face3"),
90-
std::make_pair(std::string("Face"), 3UL));
90+
std::make_pair(std::string(), 0UL));
9191
}
9292

9393
TEST_F(TopoShapeTest, TestElementTypeNonMatching)

0 commit comments

Comments
 (0)