From cd128984e14cd1d8f01d574e89257c8817404f51 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Fri, 2 Aug 2024 21:39:21 -0400 Subject: [PATCH] Toponaming: make sure toposhapes have hashers --- src/App/ComplexGeoData.cpp | 10 ++++++++++ src/App/ComplexGeoData.h | 6 +----- src/App/Document.cpp | 1 - .../TestTopologicalNamingProblem.py | 14 +++++--------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/App/ComplexGeoData.cpp b/src/App/ComplexGeoData.cpp index 475ce35d2b..19dbe6afa9 100644 --- a/src/App/ComplexGeoData.cpp +++ b/src/App/ComplexGeoData.cpp @@ -296,6 +296,16 @@ ComplexGeoData::getElementMappedNames(const IndexedName& element, bool needUnmap return {std::make_pair(MappedName(element), ElementIDRefs())}; } +ElementMapPtr ComplexGeoData::resetElementMap(ElementMapPtr elementMap) +{ + _elementMap.swap(elementMap); + // We expect that if the ComplexGeoData ( TopoShape ) has a hasher, then its elementMap will + // have the same one. Make sure that happens. + if ( _elementMap && ! _elementMap->hasher ) + _elementMap->hasher = Hasher; + return elementMap; +} + std::vector ComplexGeoData::getElementMap() const { flushElementMap(); diff --git a/src/App/ComplexGeoData.h b/src/App/ComplexGeoData.h index 3f3c846ccf..73110093e7 100644 --- a/src/App/ComplexGeoData.h +++ b/src/App/ComplexGeoData.h @@ -316,11 +316,7 @@ public: * * @return Returns the existing element map. */ - virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap = ElementMapPtr()) - { - _elementMap.swap(elementMap); - return elementMap; - } + virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap = ElementMapPtr()); /// Get the entire element map std::vector getElementMap() const; diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 988803e236..f83c0d4343 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1075,7 +1075,6 @@ std::pair Document::addStringHasher(const StringHasherRef & hasher) co StringHasherRef Document::getStringHasher(int idx) const { if(idx<0) { - return d->Hasher; return d->Hasher; } StringHasherRef hasher; diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index 5af1cfb398..a236bbbc49 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -577,15 +577,11 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.Doc.recompute() # Assert self.assertEqual(len(body.Shape.childShapes()), 1) - self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 30) - self.assertEqual(loft.Shape.ElementMapSize, 30) - revMap = body.Shape.childShapes()[0].ElementReverseMap - # 4 vertexes and 4 edges in each of the two sketches = 16. - # Loft is a rectangular prism and so 26. - # End map is 12 Edge + 6 face + 8 vertexes (with 4 duplicates) - # Why only 4 dup vertexes in the map, not 8 and 8 dup edges? - # Theory: only vertexes on the actual profile matter to the mapper. - # Has newnames, so we must have done a boolean to attach the ends to the pipe. + # 6 face 12 edge 8 vertexes = 26 + # 4 edges are duplicated (the originals from the sketch loft profile, and then those in the loft) + # 4 vertexes are quad dups for 12 more. 26 + 4 + 12 = 42 + self.assertEqual(body.Shape.ElementMapSize, 42) + revMap = body.Shape.ElementReverseMap self.assertNotEqual(loft.Shape.ElementReverseMap['Vertex1'],"Vertex1") self.assertNotEqual(revMap['Vertex1'],"Vertex1") self.assertEqual(self.countFacesEdgesVertexes(loft.Shape.ElementReverseMap),(6,12,8))