Toponaming: make sure toposhapes have hashers

This commit is contained in:
bgbsww
2024-08-02 21:39:21 -04:00
parent e4b2bf7630
commit cd128984e1
4 changed files with 16 additions and 15 deletions

View File

@@ -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<MappedElement> ComplexGeoData::getElementMap() const
{
flushElementMap();

View File

@@ -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<MappedElement> getElementMap() const;

View File

@@ -1075,7 +1075,6 @@ std::pair<bool,int> Document::addStringHasher(const StringHasherRef & hasher) co
StringHasherRef Document::getStringHasher(int idx) const {
if(idx<0) {
return d->Hasher;
return d->Hasher;
}
StringHasherRef hasher;

View File

@@ -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))