assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
-def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 10):
+def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 7):
""" Tests results volumes.
:param theFeature: feature to test.
:param theExpectedResultsVolumes: list of results volumes. Size of list should be equal to len(theFeature.results()).
"""
+ aTolerance = 10**(-theNbSignificantDigits)
aNbResults = len(theFeature.results())
aListSize = len(theExpectedResultsVolumes)
assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
aResultVolumeStr = "{:0.27f}".format(aResultVolume).lstrip("0").lstrip(".").lstrip("0")
anExpectedResultVolume = theExpectedResultsVolumes[anIndex]
anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0")
- assert (aResultVolumeStr[:theNbSignificantDigits] == anExpectedResultVolumeStr[:theNbSignificantDigits]), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
+ assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * anExpectedResultVolume, "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
""" Tests if all faces of result have a name
SketchLine_33.result().setName("SketchLine_32")
SketchConstraintDistance_10 = Sketch_4.setDistance(SketchLine_22.startPoint(), SketchLine_32.result(), 4.5)
SketchConstraintDistance_10.setName("SketchConstraintDistance_13")
-SketchPoint_2 = Sketch_4.addPoint(0.0367430766441097, 12.3548825983447)
SketchLine_34 = Sketch_4.addLine(-8.5, 12.23281708580693, 8.5, 12.23281708580693)
SketchLine_34.setName("SketchLine_33")
SketchLine_34.result().setName("SketchLine_33")
SketchConstraintDistance_17.setName("SketchConstraintDistance_18")
SketchConstraintDistance_18 = Sketch_4.setDistance(SketchLine_30.endPoint(), SketchLine_20.result(), 6.1)
SketchConstraintDistance_18.setName("SketchConstraintDistance_19")
+SketchConstraintCoincidence_67 = Sketch_4.setCoincident(SketchArc_3.center(), SketchCircle_3.center())
+SketchConstraintCoincidence_67.setName("SketchConstraintCoincidence_149")
+SketchConstraintCoincidence_68 = Sketch_4.setCoincident(SketchArc_4.center(), SketchArc_3.center())
+SketchConstraintCoincidence_68.setName("SketchConstraintCoincidence_150")
+SketchConstraintDistance_19 = Sketch_4.setDistance(SketchArc_4.center(), SketchLine_34.result(), 12)
+SketchConstraintDistance_19.setName("SketchConstraintDistance_43")
model.do()
Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), 50, 30)
Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 22, 22)
model.testNbResults(Boolean_7, 1)
model.testNbSubResults(Boolean_7, [0])
model.testNbSubShapes(Boolean_7, GeomAPI_Shape.SOLID, [1])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [49])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [263])
-model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [526])
-model.testResultsVolumes(Boolean_7, [157000.328896829247241839766502380])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.FACE, [50])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.EDGE, [266])
+model.testNbSubShapes(Boolean_7, GeomAPI_Shape.VERTEX, [532])
+model.testResultsVolumes(Boolean_7, [156999.218330596777377650141716003])
assert(model.checkPythonDump)
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [35])
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [162])
model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [324])
-model.testResultsVolumes(Boolean_1, [2053931.555419394280761480331420898])
+model.testResultsVolumes(Boolean_1, [2053931.913933836854994297027587891])
assert(model.checkPythonDump())