-# Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+# Copyright (C) 2014-2022 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
aResultsVolumes.append(GeomAlgoAPI_ShapeTools_volume(theFeature.results()[anIndex].resultSubShapePair()[0].shape()))
print("model.testResultsVolumes({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsVolumes)))
+ if "testResultsAreas" in theTestsList or len(theTestsList) == 0:
+ aNbResults = len(theFeature.results())
+ aResultsAreas = []
+ for anIndex in range(0, aNbResults):
+ aResultsAreas.append(GeomAlgoAPI_ShapeTools_area(theFeature.results()[anIndex].resultSubShapePair()[0].shape()))
+ print("model.testResultsAreas({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsAreas)))
+
def testNbResults(theFeature, theExpectedNbResults):
""" Tests number of feature results.
anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0")
assert math.fabs(aResultVolume - anExpectedResultVolume) <= aTolerance * math.fabs(anExpectedResultVolume), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits)
+
+def testResultsAreas(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 7):
+ """ Tests results areas.
+ :param theFeature: feature to test.
+ :param theExpectedResultsAreas: list of results areas. 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)
+ for anIndex in range(0, aNbResults):
+ aResultVolume = GeomAlgoAPI_ShapeTools_area(theFeature.results()[anIndex].resultSubShapePair()[0].shape())
+ aResultVolumeStr = "{:0.27f}".format(aResultVolume).lstrip("0").lstrip(".").lstrip("0")
+ anExpectedResultVolume = theExpectedResultsVolumes[anIndex]
+ anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0")
+ assert math.fabs(aResultVolume - anExpectedResultVolume) <= aTolerance * math.fabs(anExpectedResultVolume), "Area 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
:param theFeature: feature to test.