Toponaming: Missing shape hasher line; fixed cleaned Transformed

This commit is contained in:
bgbsww
2024-08-12 17:31:17 -04:00
committed by Chris Hennes
parent aef3bdfe67
commit a1ce983035
6 changed files with 64 additions and 41 deletions

View File

@@ -777,7 +777,7 @@ size_t StringHasher::count() const
{
size_t count = 0;
for (auto& hasher : _hashes->right) {
if (hasher.second->getRefCount() > 1) {
if (hasher.second->isMarked() || hasher.second->isPersistent() ) {
++count;
}
}

View File

@@ -214,22 +214,22 @@ App::DocumentObjectExecReturn* Transformed::execute()
return App::DocumentObject::StdReturn;
}
std::vector<App::DocumentObject*> originals;
auto const mode = static_cast<Mode>(TransformMode.getValue());
if (mode == Mode::TransformBody) {
Originals.setValues({});
Originals.setStatus(App::Property::Status::Hidden, true);
} else {
Originals.setStatus(App::Property::Status::Hidden, false);
originals = Originals.getValues();
}
std::vector<App::DocumentObject*> originals = Originals.getValues();
// Remove suppressed features from the list so the transformations behave as if they are not
// there
{
auto eraseIter =
std::remove_if(originals.begin(), originals.end(), [](App::DocumentObject const* obj) {
auto feature = Base::freecad_dynamic_cast<PartDesign::Feature>(obj);
return feature != nullptr && feature->Suppressed.getValue();
});
originals.erase(eraseIter, originals.end());
}
auto eraseIter =
std::remove_if(originals.begin(), originals.end(), [](App::DocumentObject const* obj) {
auto feature = Base::freecad_dynamic_cast<PartDesign::Feature>(obj);
return feature != nullptr && feature->Suppressed.getValue();
});
originals.erase(eraseIter, originals.end());
if (mode == Mode::TransformToolShapes && originals.empty()) {
return App::DocumentObject::StdReturn;
@@ -284,14 +284,15 @@ App::DocumentObjectExecReturn* Transformed::execute()
supportShape.setTransform(Base::Matrix4D());
auto getTransformedCompShape = [&](const auto& origShape) {
std::vector<TopoShape> shapes;
auto getTransformedCompShape = [&](const auto& supportShape, const auto& origShape) {
std::vector<TopoShape> shapes = {supportShape};
TopoShape shape (origShape);
int idx=1;
for ( const auto& transformIter : transformations ) {
auto transformIter = transformations.cbegin();
transformIter++;
for ( ; transformIter != transformations.end(); transformIter++) {
auto opName = Data::indexSuffix(idx++);
auto transformed = shape.makeElementTransform(transformIter, opName.c_str());
shapes.emplace_back(transformed);
shapes.emplace_back(shape.makeElementTransform(*transformIter, opName.c_str()));
}
return shapes;
};
@@ -339,17 +340,16 @@ App::DocumentObjectExecReturn* Transformed::execute()
}
#endif
if (!fuseShape.isNull()) {
supportShape.makeElementFuse(getTransformedCompShape(fuseShape.getShape()));
supportShape.makeElementFuse(getTransformedCompShape(supportShape, fuseShape));
}
if (!cutShape.isNull()) {
supportShape.makeElementFuse(getTransformedCompShape(cutShape.getShape()));
supportShape.makeElementCut(getTransformedCompShape(supportShape, cutShape));
}
}
break;
case Mode::TransformBody: {
supportShape.makeElementFuse(getTransformedCompShape(supportShape));
supportShape.makeElementFuse(getTransformedCompShape(supportShape, supportShape));
break;
}
}

View File

@@ -44,7 +44,17 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# 44 + 84 + 42 = 170. 44 - 8 = 36 / 9 = 4. 84-12 = 72 / 9 = 8. 42 - 6 = 36 / 9 = 4
# We have the original 26 from the first shape, plus 4 more vertices, 8 more edges and
# 4 more faces for each additional copy. Since they have to touch ( single shape rule ),
# We're adding 4 points to define each additional prism's new points, 8 edges makes sense,
# and 4 faces makes sense since we're defining essentially a tube, not a box for each copy.
# self.assertNotEqual(self.LinearPattern.Shape.ElementReverseMap["Vertex44"], "")
# self.assertNotEqual(self.LinearPattern.Shape.ElementReverseMap["Edge84"], "")
# self.assertNotEqual(self.LinearPattern.Shape.ElementReverseMap["Face42"], "")
#
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def testYAxisLinearPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -62,7 +72,8 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def testZAxisLinearPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -80,7 +91,8 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def testNormalSketchAxisLinearPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -101,7 +113,8 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def testVerticalSketchAxisLinearPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -122,7 +135,8 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def testHorizontalSketchAxisLinearPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -143,7 +157,9 @@ class TestLinearPattern(unittest.TestCase):
self.Body.addObject(self.LinearPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.LinearPattern.Shape.Volume, 1e4)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 170) # TODO
# self.assertEqual(len(self.LinearPattern.Shape.ElementReverseMap), 170)
self.assertEqual(self.LinearPattern.Shape.ElementMapSize, 26)
def tearDown(self):
#closing doc

View File

@@ -44,7 +44,8 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def testYAxisPolarPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -62,7 +63,8 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def testZAxisPolarPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -80,7 +82,8 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def testNormalSketchAxisPolarPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -101,7 +104,8 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def testVerticalSketchAxisPolarPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -122,7 +126,8 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def testHorizontalSketchAxisPolarPattern(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
@@ -143,7 +148,12 @@ class TestPolarPattern(unittest.TestCase):
self.Body.addObject(self.PolarPattern)
self.Doc.recompute()
self.assertAlmostEqual(self.PolarPattern.Shape.Volume, 4000)
self.assertEqual(self.PolarPattern.Shape.ElementMapSize,26)
# 26 original plus 3 new instances:
# First and second have 4 new vertexes, 8 new edges and 5 new faces
# Final one has 2 new vertexes, 5 new edges and original loses one face.
# That makes 40.
# self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 66) # TODO
self.assertEqual(self.PolarPattern.Shape.ElementMapSize, 26)
def tearDown(self):
#closing doc

View File

@@ -803,13 +803,7 @@ class TestTopologicalNamingProblem(unittest.TestCase):
self.assertAlmostEqual(body.Shape.BoundBox.ZMax, 10)
self.assertEqual(len(body.Shape.childShapes()), 1)
self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 44)
revMap = pipe.Shape.ElementReverseMap
self.assertEqual(revMap['Vertex1'],"Vertex1")
self.assertEqual(revMap['Vertex8'],"Vertex8")
self.assertEqual(revMap['Edge1'],"Edge1")
self.assertEqual(revMap['Edge12'],"Edge12")
self.assertEqual(revMap['Face1'],"Face1")
self.assertEqual(revMap['Face6'],"Face6")
revMap = body.Shape.ElementReverseMap #
self.assertEqual(self.countFacesEdgesVertexes(revMap),(9,21,14))
def testPartDesignElementMapSubHelix(self):

View File

@@ -1107,7 +1107,10 @@ protected:
const std::string postfix {";:M;FUS;:Hb:7,F"};
auto mappedName = givenMappedName(prefix.c_str(), postfix.c_str());
QVector<App::StringIDRef> sids;
return Hasher()->getID(mappedName, sids);
auto ID = Hasher()->getID(mappedName, sids);
ID.mark(); // For this to be included in the count, and thus the memsize in needs to be
// marked.
return ID;
}
private: