From 2dc5e8de5b7efcade5ca1da690621f280ef0e037 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sat, 23 Dec 2023 11:39:57 -0600 Subject: [PATCH] Part/Toponaming: clang-tidy cleanup of cache calls --- src/Mod/Part/App/TopoShapeCache.h | 4 ++-- src/Mod/Part/App/TopoShapeExpansion.cpp | 9 ++++----- tests/src/Mod/Part/App/TopoShapeCache.cpp | 18 ------------------ 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/Mod/Part/App/TopoShapeCache.h b/src/Mod/Part/App/TopoShapeCache.h index 40beddf648..190bfe3b28 100644 --- a/src/Mod/Part/App/TopoShapeCache.h +++ b/src/Mod/Part/App/TopoShapeCache.h @@ -79,14 +79,14 @@ public: /// Inverse of location TopLoc_Location locationInverse; - struct AncestorInfo + struct PartExport AncestorInfo { bool initialized = false; TopTools_IndexedDataMapOfShapeListOfShape shapes; }; /// Class for caching the ancestor and children shapes mapping - class Ancestry + class PartExport Ancestry { private: TopoShapeCache* owner = nullptr; diff --git a/src/Mod/Part/App/TopoShapeExpansion.cpp b/src/Mod/Part/App/TopoShapeExpansion.cpp index 2eaea9c368..09b90fe98f 100644 --- a/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -138,22 +138,21 @@ int TopoShape::findShape(const TopoDS_Shape& subshape) const return _cache->findShape(_Shape, subshape); } -static const std::string _SubShape("SubShape"); TopoDS_Shape TopoShape::findShape(const char* name) const { if (!name) { - return TopoDS_Shape(); + return {}; } Data::MappedElement res = getElementName(name); if (!res.index) { - return TopoDS_Shape(); + return {}; } auto idx = shapeTypeAndIndex(name); - if (!idx.second) { - return TopoDS_Shape(); + if (idx.second == 0) { + return {}; } initCache(); return _cache->findShape(_Shape, idx.first, idx.second); diff --git a/tests/src/Mod/Part/App/TopoShapeCache.cpp b/tests/src/Mod/Part/App/TopoShapeCache.cpp index d75dfc1861..b3faa3ca2d 100644 --- a/tests/src/Mod/Part/App/TopoShapeCache.cpp +++ b/tests/src/Mod/Part/App/TopoShapeCache.cpp @@ -8,9 +8,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -62,22 +60,6 @@ private: App::StringHasherRef _hasher; }; -/* -Methods to test - ------------- -DONE - explicit TopoShapeCache(const TopoDS_Shape& tds); -DONE - void insertRelation(const ShapeRelationKey& key, const QVector& value); -DONE - bool isTouched(const TopoDS_Shape& tds) const; -DONE Ancestry& getAncestry(TopAbs_ShapeEnum type); -DONE int countShape(TopAbs_ShapeEnum type); -DONE int findShape(const TopoDS_Shape& parent, const TopoDS_Shape& subShape); -DONE TopoDS_Shape findShape(const TopoDS_Shape& parent, TopAbs_ShapeEnum type, int index); -TopoDS_Shape findAncestor(const TopoDS_Shape& parent, - const TopoDS_Shape& subShape, - TopAbs_ShapeEnum type, - std::vector* ancestors = nullptr); - */ - TEST_F(TopoShapeCacheTest, ConstructionFromTopoDS_Shape) { // Arrange - create a TopoDS shape with some location transformation applied