From de35a330e951b664bdb0fdad17d3ca627d575a8d Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 10 Apr 2024 10:29:57 -0400 Subject: [PATCH 1/3] Toponaming/Part: Transfer in python ElementMapVersion --- src/App/DocumentObject.cpp | 18 ++++++++++++++++++ src/App/DocumentObject.h | 14 ++++++++++++++ src/App/DocumentObjectPy.xml | 7 +++++++ src/App/DocumentObjectPyImp.cpp | 16 ++++++++++++++++ src/App/GeoFeaturePy.xml | 6 ++++++ src/App/GeoFeaturePyImp.cpp | 5 +++++ 6 files changed, 66 insertions(+) diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 5fa4e91c93..ad2bb4bacb 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -1304,6 +1304,24 @@ bool DocumentObject::adjustRelativeLinks( return touched; } +std::string DocumentObject::getElementMapVersion(const App::Property* _prop, bool restored) const +{ + auto prop = Base::freecad_dynamic_cast(_prop); + if (!prop) { + return std::string(); + } + return prop->getElementMapVersion(restored); +} + +bool DocumentObject::checkElementMapVersion(const App::Property* _prop, const char* ver) const +{ + auto prop = Base::freecad_dynamic_cast(_prop); + if (!prop) { + return false; + } + return prop->checkElementMapVersion(ver); +} + const std::string &DocumentObject::hiddenMarker() { static std::string marker("!hide"); return marker; diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 4cc24107d3..7052f92d7e 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -300,6 +300,20 @@ public: bool testIfLinkDAGCompatible(App::PropertyLinkSubList &linksTo) const; bool testIfLinkDAGCompatible(App::PropertyLinkSub &linkTo) const; + /** Return the element map version of the geometry data stored in the given property + * + * @param prop: the geometry property to query for element map version + * @param restored: whether to query for the restored element map version. + * In case of version upgrade, the restored version may + * be different from the current version. + * + * @return Return the element map version string. + */ + virtual std::string getElementMapVersion(const App::Property *prop, bool restored=false) const; + + /// Return true to signal re-generation of geometry element names + virtual bool checkElementMapVersion(const App::Property *prop, const char *ver) const; + public: /** mustExecute * We call this method to check if the object was modified to diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml index 8792376ad9..7424fc9a58 100644 --- a/src/App/DocumentObjectPy.xml +++ b/src/App/DocumentObjectPy.xml @@ -225,6 +225,13 @@ Return tuple(obj,newElementName,oldElementName) adjustRelativeLinks(parent,recursive=True) -- auto correct potential cyclic dependencies + + + + getElementMapVersion(property_name): return element map version of a given geometry property + + + A list of all objects this object links to. diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 4b3282a946..07344d2e93 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -745,6 +745,22 @@ PyObject* DocumentObjectPy::getPathsByOutList(PyObject *args) } } +PyObject* DocumentObjectPy::getElementMapVersion(PyObject* args) +{ + const char* name; + PyObject* restored = Py_False; + if (!PyArg_ParseTuple(args, "s|O", &name, &restored)) { + return NULL; + } + + Property* prop = getDocumentObjectPtr()->getPropertyByName(name); + if (!prop) { + throw Py::ValueError("property not found"); + } + return Py::new_reference_to( + Py::String(getDocumentObjectPtr()->getElementMapVersion(prop, Base::asBoolean(restored)))); +} + PyObject *DocumentObjectPy::getCustomAttributes(const char* ) const { return nullptr; diff --git a/src/App/GeoFeaturePy.xml b/src/App/GeoFeaturePy.xml index 83726bf70a..aeaefe7a4e 100644 --- a/src/App/GeoFeaturePy.xml +++ b/src/App/GeoFeaturePy.xml @@ -58,6 +58,12 @@ If an object has no such property then None is returned. Unlike to getPropertyNameOfGeometry this function returns the geometry, not its name. + + + Element map version + + + diff --git a/src/App/GeoFeaturePyImp.cpp b/src/App/GeoFeaturePyImp.cpp index ec2af688df..26a08a9f2d 100644 --- a/src/App/GeoFeaturePyImp.cpp +++ b/src/App/GeoFeaturePyImp.cpp @@ -93,3 +93,8 @@ int GeoFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { return 0; } + +Py::String GeoFeaturePy::getElementMapVersion() const { + return Py::String(getGeoFeaturePtr()->getElementMapVersion( + getGeoFeaturePtr()->getPropertyOfGeometry())); +} From b7daa607afb55536a26124f05eb5cc1689f30a39 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 10 Apr 2024 10:30:31 -0400 Subject: [PATCH 2/3] Toponaming/Part: Add Pad test, cleanup --- .../TestTopologicalNamingProblem.py | 75 +++++++++++++------ 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index 22ed6d4f98..593e12fd5c 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -110,11 +110,38 @@ class TestTopologicalNamingProblem(unittest.TestCase): else: print("TOPOLOGICAL NAMING PROBLEM IS PRESENT.") + def testPartDesignElementMapPad(self): + """ Test that padding a sketch results in a correct element map. Note that comprehensive testing + of the geometric functionality of the Pad is in TestPad.py """ + # Arrange + body = self.Doc.addObject('PartDesign::Body', 'Body') + padSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + pad = self.Doc.addObject("PartDesign::Pad", "Pad") + body.addObject(padSketch) + body.addObject(pad) + TestSketcherApp.CreateRectangleSketch(padSketch, (0, 0), (1, 1)) + pad.Profile = padSketch + pad.Length = 1 + # Act + self.Doc.recompute() + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. + return + reverseMap = pad.Shape.ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] + # Assert + self.assertEqual(pad.Shape.ElementMapSize,30) # 4 duplicated Vertexes in here + self.assertEqual(len(reverseMap),26) + self.assertEqual(len(faces),6) + self.assertEqual(len(edges),12) + self.assertEqual(len(vertexes),8) + def testPartDesignElementMapBox(self): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') box = self.Doc.addObject('PartDesign::AdditiveBox', 'Box') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(box.Shape.childShapes()), 0) @@ -131,7 +158,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') cylinder = self.Doc.addObject('PartDesign::AdditiveCylinder', 'Cylinder') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(cylinder.Shape.childShapes()), 0) @@ -148,7 +175,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') sphere = self.Doc.addObject('PartDesign::AdditiveSphere', 'Sphere') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(sphere.Shape.childShapes()), 0) @@ -165,7 +192,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') cone = self.Doc.addObject('PartDesign::AdditiveCone', 'Cone') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(cone.Shape.childShapes()), 0) @@ -182,7 +209,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') ellipsoid = self.Doc.addObject('PartDesign::AdditiveEllipsoid', 'Ellipsoid') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(ellipsoid.Shape.childShapes()), 0) @@ -199,7 +226,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') torus = self.Doc.addObject('PartDesign::AdditiveTorus', 'Torus') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(torus.Shape.childShapes()), 0) @@ -216,7 +243,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') prism = self.Doc.addObject('PartDesign::AdditivePrism', 'Prism') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(prism.Shape.childShapes()), 0) @@ -233,7 +260,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): # Arrange body = self.Doc.addObject('PartDesign::Body', 'Body') wedge = self.Doc.addObject('PartDesign::AdditiveWedge', 'Wedge') - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act / Assert self.assertEqual(len(wedge.Shape.childShapes()), 0) @@ -256,7 +283,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subbox = self.Doc.addObject('PartDesign::SubtractiveBox', 'Box') @@ -275,7 +302,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subcylinder = self.Doc.addObject('PartDesign::SubtractiveCylinder', 'Cylinder') @@ -294,7 +321,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subsphere = self.Doc.addObject('PartDesign::SubtractiveSphere', 'Sphere') @@ -313,7 +340,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subcone = self.Doc.addObject('PartDesign::SubtractiveCone', 'Cone') @@ -332,7 +359,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subellipsoid = self.Doc.addObject('PartDesign::SubtractiveEllipsoid', 'Ellipsoid') @@ -351,7 +378,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subtorus = self.Doc.addObject('PartDesign::SubtractiveTorus', 'Torus') @@ -370,7 +397,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subprism = self.Doc.addObject('PartDesign::SubtractivePrism', 'Prism') @@ -389,7 +416,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): box.Width = 20 box.Height = 20 body.addObject(box) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act subwedge = self.Doc.addObject('PartDesign::SubtractiveWedge', 'Wedge') @@ -405,7 +432,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): body = self.Doc.addObject('PartDesign::Body', 'Body') sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act pad = self.Doc.addObject('PartDesign::Pad', 'Pad') @@ -423,7 +450,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): body = self.Doc.addObject('PartDesign::Body', 'Body') sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act revolution = self.Doc.addObject('PartDesign::Revolution', 'Revolution') @@ -444,7 +471,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') TestSketcherApp.CreateRectangleSketch(sketch2, (0, 0), (2, 2)) sketch2.Placement.move(App.Vector(0, 0, 3)) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act loft = self.Doc.addObject('PartDesign::AdditiveLoft', 'Loft') @@ -465,7 +492,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) sketch2 = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') TestSketcherApp.CreateRectangleSketch(sketch2, (0, 0), (2, 2)) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act pipe = self.Doc.addObject('PartDesign::AdditivePipe', 'Pipe') @@ -484,7 +511,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): body = self.Doc.addObject('PartDesign::Body', 'Body') sketch = self.Doc.addObject('Sketcher::SketchObject', 'Sketch') TestSketcherApp.CreateRectangleSketch(sketch, (0, 0), (1, 1)) - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Act helix = self.Doc.addObject('PartDesign::AdditiveHelix', 'Helix') @@ -519,6 +546,8 @@ class TestTopologicalNamingProblem(unittest.TestCase): groove.Reversed = 0 groove.Base = App.Vector(0, 0, 0) self.Doc.recompute() + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. + return # Assert # print(groove.Shape.childShapes()[0].ElementMap) # TODO: Complete me as part of the subtractive features @@ -543,7 +572,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad.Profile = sketch body.addObject(pad) self.Doc.recompute() - if not hasattr(body,"ElementMapVersion"): # Skip without element maps. + if body.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Assert self.assertEqual(sketch.Shape.ElementMapSize, 12) @@ -562,7 +591,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): pad = self.Doc.addObject('PartDesign::Pad', 'Pad') pad.Profile = plane self.Doc.recompute() - if not hasattr(pad,"ElementMapVersion"): # Skip without element maps. + if pad.Shape.ElementMapVersion == "": # Should be '4' as of Mar 2023. return # Assert self.assertEqual(plane.Shape.ElementMapSize, 0) From 69f6f2230a23161e07feac0ece4408d9a2e35aeb Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 10 Apr 2024 18:28:27 -0400 Subject: [PATCH 3/3] Toponaming/Part: Enhanced testing for FeaturePrimitives --- .../TestTopologicalNamingProblem.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index 593e12fd5c..56ec3606e8 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -168,8 +168,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(cylinder) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 8) + self.assertEqual(len(reverseMap),8) + self.assertEqual(len(faces),3) + self.assertEqual(len(edges),3) + self.assertEqual(len(vertexes),2) def testPartDesignElementMapSphere(self): # Arrange @@ -185,8 +193,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(sphere) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 6) + self.assertEqual(len(reverseMap),6) + self.assertEqual(len(faces),1) + self.assertEqual(len(edges),3) + self.assertEqual(len(vertexes),2) def testPartDesignElementMapCone(self): # Arrange @@ -202,8 +218,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(cone) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 8) + self.assertEqual(len(reverseMap),8) + self.assertEqual(len(faces),3) + self.assertEqual(len(edges),3) + self.assertEqual(len(vertexes),2) def testPartDesignElementMapEllipsoid(self): # Arrange @@ -219,8 +243,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(ellipsoid) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 6) + self.assertEqual(len(reverseMap),6) + self.assertEqual(len(faces),1) + self.assertEqual(len(edges),3) + self.assertEqual(len(vertexes),2) def testPartDesignElementMapTorus(self): # Arrange @@ -236,8 +268,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(torus) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 4) + self.assertEqual(len(reverseMap),4) + self.assertEqual(len(faces),1) + self.assertEqual(len(edges),2) + self.assertEqual(len(vertexes),1) def testPartDesignElementMapPrism(self): # Arrange @@ -253,8 +293,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(prism) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 38) + self.assertEqual(len(reverseMap),38) + self.assertEqual(len(faces),8) + self.assertEqual(len(edges),18) + self.assertEqual(len(vertexes),12) def testPartDesignElementMapWedge(self): # Arrange @@ -270,8 +318,16 @@ class TestTopologicalNamingProblem(unittest.TestCase): body.addObject(wedge) self.assertEqual(len(body.Shape.childShapes()), 0) self.Doc.recompute() + reverseMap = body.Shape.childShapes()[0].ElementReverseMap + faces = [name for name in reverseMap.keys() if name.startswith("Face")] + edges = [name for name in reverseMap.keys() if name.startswith("Edge")] + vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 26) + self.assertEqual(len(reverseMap),26) + self.assertEqual(len(faces),6) + self.assertEqual(len(edges),12) + self.assertEqual(len(vertexes),8) # body.BaseFeature = box