]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage GeomAPI]: Improve coverage of primitives
authorazv <azv@opencascade.com>
Wed, 19 Dec 2018 14:14:22 +0000 (17:14 +0300)
committerazv <azv@opencascade.com>
Wed, 19 Dec 2018 14:25:06 +0000 (17:25 +0300)
src/GeomAPI/Test/TestBox.py
src/GeomAPI/Test/TestCone.py
src/GeomAPI/Test/TestCylinder.py
src/GeomAPI/Test/TestSphere.py
src/GeomAPI/Test/TestTorus.py

index 32948b25aea675a807d613f9e1d8b5fd4fc1d9e7..d6a47389dcfefa0c03034b70d6edb9fae25d9f23 100644 (file)
@@ -162,4 +162,9 @@ checkShellNotBox(Part_1_doc, Shell_objects)
 Shell_objects = ["Rotation_3_1/MF:Rotated&Extrusion_1_1/To_Face", "Rotation_3_1/MF:Rotated&Extrusion_1_1/From_Face", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_1", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_2", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_3", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_4"]
 checkShellRotatedBox(Part_1_doc, Shell_objects, aCornerPara, aCornerPara1)
 
+# Test 6. One more check the shell is not a box
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10, 45)
+Shell_objects = ["Cylinder_1_1/Face_2", "Cylinder_1_1/Face_4"]
+checkShellNotBox(Part_1_doc, Shell_objects)
+
 model.end()
index f389e91c4d90364600852aeb25af4abc0fb9fc43..82ba81bcb6e251565e33be89a16b586d08a8647d 100644 (file)
@@ -50,7 +50,7 @@ def checkCircleFace(theDocument, theFaceName, theCenter, theRadius):
     assertCircle(aSubs[0].edge(), theCenter, theRadius)
     theDocument.removeFeature(aFaceFeature.feature())
 
-def assertEllipse(theEdge, theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius):
+def assertEllipse(theEdge, theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius, theNormal = None):
     assert(theEdge.isEllipse())
     anEllipse = theEdge.ellipse()
     assert(anEllipse.firstFocus().distance(theFirstFocus) < TOLERANCE), "({}, {}, {}) != expected ({}, {}, {})".format(anEllipse.firstFocus().x(), anEllipse.firstFocus().y(), anEllipse.firstFocus().z(), theFirstFocus.x(), theFirstFocus.y(), theFirstFocus.z())
@@ -58,11 +58,17 @@ def assertEllipse(theEdge, theFirstFocus, theSecondFocus, theMajorRadius, theMin
     assert(math.fabs(anEllipse.majorRadius() - theMajorRadius) < TOLERANCE), "Major radius {} != {}".format(anEllipse.majorRadius(), theMajorRadius)
     assert(math.fabs(anEllipse.minorRadius() - theMinorRadius) < TOLERANCE), "Minor radius {} != {}".format(anEllipse.minorRadius(), theMinorRadius)
 
-def checkEllipseEdge(theDocument, theEdgeName, theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius):
+    center = GeomAPI.GeomAPI_Pnt((theFirstFocus.x() + theSecondFocus.x()) * 0.5, (theFirstFocus.y() + theSecondFocus.y()) * 0.5, (theFirstFocus.z() + theSecondFocus.z()) * 0.5)
+    assert(anEllipse.center().distance(center) < TOLERANCE), "({}, {}, {}) != expected ({}, {}, {})".format(anEllipse.center().x(), anEllipse.center().y(), anEllipse.center().z(), center.x(), center.y(), center.z())
+
+    if theNormal is not None:
+        assert(math.fabs(anEllipse.normal().dot(theNormal) - 1.) < TOLERANCE), "Normal ({}, {}, {}) != ({}, {}, {})".format(anEllipse.normal().x(), anEllipse.normal().y(), anEllipse.normal().z(), theNormal.x(), theNormal.y(), theNormal.z())
+
+def checkEllipseEdge(theDocument, theEdgeName, theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius, theNormal):
     anEdge = model.addEdge(theDocument, [model.selection("EDGE", theEdgeName)])
     aShape = anEdge.result().resultSubShapePair()[0].shape()
     assert(aShape.isEdge())
-    assertEllipse(aShape.edge(), theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius)
+    assertEllipse(aShape.edge(), theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius, theNormal)
     theDocument.removeFeature(anEdge.feature())
 
 def checkEllipseFace(theDocument, theFaceName, theFirstFocus, theSecondFocus, theMajorRadius, theMinorRadius):
@@ -107,6 +113,17 @@ def checkConeShell(theDocument, theFaceNames, theApex, theAxis, theSemiAngle, th
     assertCone(aShape.shell().getCone(), theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight)
     theDocument.removeFeature(aShell.feature())
 
+def checkConeSolid(theDocument, theFaceNames, theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight):
+    # check cone
+    aSelection = []
+    for name in theFaceNames:
+        aSelection.append(model.selection("FACE", name))
+    aSolid = model.addSolid(theDocument, aSelection)
+    aShape = aSolid.result().resultSubShapePair()[0].shape()
+    assert(aShape.isSolid())
+    assertCone(aShape.solid().getCone(), theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight)
+    theDocument.removeFeature(aSolid.feature())
+
 def checkConeAll(theDocument, theFeature, theFaceName, theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight):
     # check solid
     aShape = theFeature.result().resultSubShapePair()[0].shape()
@@ -116,6 +133,16 @@ def checkConeAll(theDocument, theFeature, theFaceName, theApex, theAxis, theSemi
     checkConeShell(theDocument, [theFaceName], theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight)
     checkConeFace(theDocument, theFaceName, theApex, theAxis, theSemiAngle, theRadius1, theRadius2, theHeight)
 
+def checkNonCone(theFeature):
+    aShape = theFeature.result().resultSubShapePair()[0].shape()
+    assert(aShape.isSolid())
+    assert(aShape.solid().getCone() is None)
+
+def checkNonConeShell(theFeature):
+    aShape = theFeature.result().resultSubShapePair()[0].shape()
+    assert(aShape.isShell())
+    assert(aShape.shell().getCone() is None)
+
 def checkSegment(theDocument, theEdgeName, theStartPoint, theEndPoint):
     anEdgeFeature = model.addEdge(theDocument, [model.selection("EDGE", theEdgeName)])
     aShape = anEdgeFeature.result().resultSubShapePair()[0].shape()
@@ -217,7 +244,37 @@ aFirstFocus = GeomAPI.GeomAPI_Pnt(20, 0, 31.062397266842858)
 aSecondFocus = GeomAPI.GeomAPI_Pnt(20, 0, -1.0935246846933797)
 aMajorRadius = 27.91915871311068
 aMinorRadius = 22.824955511666207
+aNormal = GeomAPI.GeomAPI_Dir(1, 0, 0)
 checkEllipseFace(Part_1_doc, "_weak_name_1_Partition_1_1_2", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius)
-checkEllipseEdge(Part_1_doc, "Partition_1_1_1/Generated_Edge&Cone_1_1/Face_1", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius)
+checkEllipseEdge(Part_1_doc, "Partition_1_1_1/Generated_Edge&Cone_1_1/Face_1", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius, aNormal)
+
+# Test 6. Compose a conical solid
+Solid_1_objects = ["Rotation_1_1/MF:Rotated&Cone_1_1/Face_3",
+                   "Partition_1_1_1/Modified_Face&Cone_1_1/Face_1",
+                   "Partition_1_1_2/Modified_Face&Cone_1_1/Face_1",
+                   "Rotation_1_1/MF:Rotated&Cone_1_1/Face_2"]
+checkConeSolid(Part_1_doc, Solid_1_objects, anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value())
+
+# Test 7. Check non-cone
+Cone_2 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 5, 10)
+Cone_3 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10, 20)
+Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cone_2_1"), model.selection("SOLID", "Cone_3_1")], True)
+Solid_2_objects = [model.selection("FACE", "Fuse_1_1/Modified_Face&Cone_2_1/Face_3&Cone_3_1/Face_3"),
+                   model.selection("FACE", "Fuse_1_1/Modified_Face&Cone_2_1/Face_1"),
+                   model.selection("FACE", "Fuse_1_1/Modified_Face&Cone_3_1/Face_1"),
+                   model.selection("FACE", "Cone_3_1/Face_2")]
+Solid_2 = model.addSolid(Part_1_doc, Solid_2_objects)
+checkNonCone(Solid_2)
+
+# Test 8. Check non-conical shell
+Shell_1_objects = [model.selection("FACE", "Rotation_1_1/MF:Rotated&Cone_1_1/Face_3"),
+                   model.selection("FACE", "Partition_1_1_1/Modified_Face&Cone_1_1/Face_1"),
+                   model.selection("FACE", "Partition_1_1_2/Modified_Face&Cone_1_1/Face_1"),
+                   model.selection("FACE", "Rotation_1_1/MF:Rotated&Cone_1_1/Face_2")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+checkNonConeShell(Shell_1)
+
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Fuse_1_1/Modified_Face&Cone_2_1/Face_1"), model.selection("FACE", "Fuse_1_1/Modified_Face&Cone_3_1/Face_1")])
+checkNonConeShell(Shell_2)
 
 model.end()
index 9091faee821ded0465d4684fba9dabc6100a7635..1a8766b4987771031a8d5c92206293aa5edc6b1c 100644 (file)
@@ -54,6 +54,16 @@ def checkCylinderShell(theDocument, theFaceNames, theLocation, theAxis, theRadiu
     assertCylinder(aShape.shell().getCylinder(), theLocation, theAxis, theRadius, theHeight)
     theDocument.removeFeature(aShell.feature())
 
+def checkCylinderSolid(theDocument, theFaceNames, theLocation, theAxis, theRadius, theHeight):
+    aSelection = []
+    for name in theFaceNames:
+        aSelection.append(model.selection("FACE", name))
+    aSolid = model.addSolid(theDocument, aSelection)
+    aShape = aSolid.result().resultSubShapePair()[0].shape()
+    assert(aShape.isSolid())
+    assertCylinder(aShape.solid().getCylinder(), theLocation, theAxis, theRadius, theHeight)
+    theDocument.removeFeature(aSolid.feature())
+
 def checkCylinderAll(theDocument, theFeature, theFaceName, theLocation, theAxis, theRadius, theHeight):
     aShape = theFeature.result().resultSubShapePair()[0].shape()
     assert(aShape.isSolid())
@@ -67,6 +77,11 @@ def checkNonCylinder(theFeature):
     assert(aShape.isSolid())
     assert(aShape.solid().getCylinder() is None)
 
+def checkNonCylindricalShell(theFeature):
+    aShape = theFeature.result().resultSubShapePair()[0].shape()
+    assert(aShape.isShell())
+    assert(aShape.shell().getCylinder() is None)
+
 
 model.begin()
 partSet = model.moduleDocument()
@@ -149,4 +164,42 @@ Shell_1_objects = ["Partition_1_1_1/Modified_Face&Sketch_2/SketchLine_4",
                    "(Partition_1_1_2/Modified_Face&Revolution_1_1/To_Face)(Partition_1_1_2/Modified_Face&Sketch_2/SketchLine_1)"]
 checkCylinderShell(Part_1_doc, Shell_1_objects, aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value())
 
+# Test 4. Split cylinder and compose a solid
+Partition_2 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Rotation_1_1"), model.selection("FACE", "PartSet/XOZ")])
+Solid_1_objects = ["(Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_3)(Partition_2_1_1/Modified_Face&PartSet/XOZ/XOZ)(Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_2)",
+                   "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_1&weak_name_2",
+                   "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_2",
+                   "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_3",
+                   "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_1",
+                   "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_2",
+                   "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_3"]
+checkCylinderSolid(Part_1_doc, Solid_1_objects, aLoc1, anAxis, 2 * ParamR.value(), ParamH.value())
+
+# Test 5. Check non-cylinder
+Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_2 = Sketch_3.addCircle(12.62721775445329, 9.188425784259302, 5)
+SketchCircle_3 = Sketch_3.addCircle(16.49821418064359, 12.35313535520289, 5)
+SketchConstraintRadius_2 = Sketch_3.setRadius(SketchCircle_2.results()[1], 5)
+SketchConstraintEqual_1 = Sketch_3.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1])
+SketchConstraintDistance_1 = Sketch_3.setDistance(SketchCircle_2.center(), SketchCircle_3.center(), 5, True)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 10, 0)
+Solid_1_objects = [model.selection("FACE", "Extrusion_2_1_1/From_Face"), model.selection("FACE", "Extrusion_2_1_1/To_Face"), model.selection("FACE", "Extrusion_2_1_2/From_Face"), model.selection("FACE", "Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_3_2&weak_name_2"), model.selection("FACE", "Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_3_2&weak_name_1"), model.selection("FACE", "Extrusion_2_1_2/To_Face"), model.selection("FACE", "Extrusion_2_1_3/From_Face"), model.selection("FACE", "Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_2_2"), model.selection("FACE", "Extrusion_2_1_3/To_Face")]
+Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects)
+checkNonCylinder(Solid_1)
+
+# Test 6. Check non-cylindrical shell
+Shell_1_objects = [model.selection("FACE", "(Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_3)(Partition_2_1_1/Modified_Face&PartSet/XOZ/XOZ)(Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_2)"),
+                   model.selection("FACE", "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_1&weak_name_2"),
+                   model.selection("FACE", "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_2"),
+                   model.selection("FACE", "Partition_2_1_1/Modified_Face&Cylinder_1_1/Face_3"),
+                   model.selection("FACE", "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_1"),
+                   model.selection("FACE", "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_2"),
+                   model.selection("FACE", "Partition_2_1_2/Modified_Face&Cylinder_1_1/Face_3")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+checkNonCylindricalShell(Shell_1)
+
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_2_2"), model.selection("FACE", "Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_3_2&weak_name_1")])
+checkNonCylindricalShell(Shell_2)
+
 model.end()
index 1990fbc20cab131c4c66648d5830c6d3228053fb..530b22c55af866a62049396b3bbd1db05a31b6cd 100644 (file)
@@ -72,6 +72,11 @@ def checkSphereAll(theDocument, theFeature, theFaceName, theCenter, theRadius):
     anArcName = "[" + theFaceName + "][weak_name_3]"
     checkArc(theDocument, anArcName, theCenter, theRadius)
 
+def checkNonSphereShell(theFeature):
+    aShape = theFeature.result().resultSubShapePair()[0].shape()
+    assert(aShape.isShell())
+    assert(aShape.shell().getSphere() is None)
+
 
 model.begin()
 partSet = model.moduleDocument()
@@ -123,4 +128,23 @@ checkSphereShell(Part_1_doc, "Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2", a
 checkArc(Part_1_doc, "[Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2][Rotation_1_1/MF:Rotated&Revolution_1_1/From_Face]", aCenter, ParamR.value())
 checkArc(Part_1_doc, "[Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2][Rotation_1_1/MF:Rotated&Revolution_1_1/To_Face]", aCenter, ParamR.value())
 
+# Test 5. Sheck non-spherical shell
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Rotation_1_1/MF:Rotated&Revolution_1_1/To_Face"), model.selection("FACE", "Rotation_1_1/MF:Rotated&Revolution_1_1/From_Face")])
+checkNonSphereShell(Shell_1)
+
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_2 = Sketch_2.addLine(18.12152721893265, 20.53645178481853, 73.15172297255518, 20.53645178481853)
+SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_2.result())
+SketchArc_2 = Sketch_2.addArc(60.28852631862447, 20.53645178481853, 73.15172297255518, 20.53645178481853, 58.16589238004093, 33.22330534748203, False)
+SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_2.result(), SketchArc_2.center())
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchArc_2.startPoint())
+SketchArc_3 = Sketch_2.addArc(40.15343392262997, 20.53645178481853, 18.12152721893265, 20.53645178481853, 58.16589238004093, 33.22330534748203, True)
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_2.result(), SketchArc_3.center())
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchArc_3.startPoint())
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchArc_3.endPoint())
+model.do()
+Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_2r-SketchArc_2_2f-SketchArc_3_2f")], model.selection("EDGE", "Sketch_2/SketchLine_2"), 360, 0)
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Revolution_2_1/Generated_Face&Sketch_2/SketchArc_3_2"), model.selection("FACE", "Revolution_2_1/Generated_Face&Sketch_2/SketchArc_2_2")])
+checkNonSphereShell(Shell_2)
+
 model.end()
index a710df35b6d9e08bfb8cc1d836b2b627fd3d873d..5e258d96f41c865f183a207d9a19353f447a43f2 100644 (file)
@@ -61,6 +61,11 @@ def checkTorusAll(theDocument, theFeature, theFaceName, theCenter, theAxis, theM
     checkTorusShell(theDocument, [theFaceName], theCenter, theAxis, theMajorRadius, theMinorRadius)
     checkTorusFace(theDocument, theFaceName, theCenter, theAxis, theMajorRadius, theMinorRadius)
 
+def checkNonTorusShell(theFeature):
+    aShape = theFeature.result().resultSubShapePair()[0].shape()
+    assert(aShape.isShell())
+    assert(aShape.shell().getTorus() is None)
+
 
 model.begin()
 partSet = model.moduleDocument()
@@ -95,4 +100,12 @@ Shell_1_objects = ["Partition_1_1_6/Modified_Face&Torus_1_1/Face_1",
                    "Partition_1_1_5/Modified_Face&Torus_1_1/Face_1"]
 checkTorusShell(Part_1_doc, Shell_1_objects, aCenter, anAxis, ParamRMax.value(), ParamRMin.value())
 
+# Test 4. Check non-torus shell
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Partition_1_1_1/Modified_Face&Torus_1_1/Face_1"), model.selection("FACE", "Partition_1_1_1/Modified_Face&PartSet/YOZ/YOZ")])
+checkNonTorusShell(Shell_1)
+
+Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("FACE", "PartSet/XOY"), True)
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "_weak_name_1_Symmetry_1_1_1"), model.selection("FACE", "_weak_name_1_Symmetry_1_1_2")])
+checkNonTorusShell(Shell_2)
+
 model.end()