-# Copyright (C) 2014-2022 CEA/DEN, EDF R&D
+# Copyright (C) 2014-2023 CEA, EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
from salome.shaper import model
from GeomAPI import GeomAPI_Shape
-aShapeTypes = {
- GeomAPI_Shape.SOLID: "GeomAPI_Shape.SOLID",
- GeomAPI_Shape.FACE: "GeomAPI_Shape.FACE",
- GeomAPI_Shape.EDGE: "GeomAPI_Shape.EDGE",
- GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
-
-def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
- """ Tests number of unique feature sub-shapes of passed type for each result.
- :param theFeature: feature to test.
- :param theShapeType: shape type of sub-shapes to test.
- :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
- """
- aResults = theFeature.feature().results()
- aNbResults = len(aResults)
- aListSize = len(theExpectedNbSubShapes)
- assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
- for anIndex in range(0, aNbResults):
- aNbResultSubShapes = 0
- anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
- aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
- assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
-
model.begin()
partSet = model.moduleDocument()
model.testNbResults(Cut_1, 1)
model.testNbSubResults(Cut_1, [0])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [6])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [6])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [6])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [6])
### Set a higher fuzzy value
Param_fuzzy.setValue(1.e-4)
model.testNbResults(Cut_1, 1)
model.testNbSubResults(Cut_1, [0])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [4])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [4])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4])