-# 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)
-
-def testCompound(theFeature,theModel,NbSubRes,NbSolid,NbFace,NbEdge,NbVertex):
- """ Tests numbers of unique sub-shapes in compound result
- """
- aResults = theFeature.feature().results()
- aNbResults = len(aResults)
- assert (aNbResults == 1), "Number of results: {} not equal to 1.".format(aNbResults)
- assert aResults[0].shape().isCompound(), "Result shape type: {}. Expected: COMPOUND.".format(aResults[0].shape().shapeTypeStr())
- theModel.testNbSubResults(theFeature, NbSubRes)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SOLID, NbSolid)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+
# Create document
model.begin()
model.end()
# gluing successful
-testCompound(GlueFaces_1, model, [2], [2], [11], [20], [12])
+model.testCompSolid(GlueFaces_1, [2], [2], [11], [20], [12])
# =============================================================================
# Test 2. Glue faces for 2 solids with 1 common edge only
GlueFaces_2 = model.addGlueFaces(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")], 1.0e-7, True)
model.end()
-# no faces glued
-testCompound(GlueFaces_2, model, [2], [2], [12], [24], [16])
+# gluing successful
+model.testCompound(GlueFaces_2, [2], [2], [12], [23], [14])
# =============================================================================
# Test 3. Glue faces for 2 solids with 2 adjacent faces above default tolerance
model.end()
# no faces glued
-testCompound(GlueFaces_3, model, [2], [2], [12], [24], [16])
+model.testCompound(GlueFaces_3, [2], [2], [12], [24], [16])
# =============================================================================
# Test 4. Glue faces for 2 solids with 2 adjacent faces using different tolerance
model.end()
# gluing successful
-testCompound(GlueFaces_4, model, [2], [2], [11], [20], [12])
+model.testCompSolid(GlueFaces_4, [2], [2], [11], [20], [12])
# =============================================================================
# Test 5. Check Python dump