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(Common_1, 1)
model.testNbSubResults(Common_1, [0])
-testNbUniqueSubShapes(Common_1, GeomAPI_Shape.SOLID, [1])
-testNbUniqueSubShapes(Common_1, GeomAPI_Shape.FACE, [3])
-testNbUniqueSubShapes(Common_1, GeomAPI_Shape.EDGE, [3])
-testNbUniqueSubShapes(Common_1, GeomAPI_Shape.VERTEX, [2])
+model.testNbUniqueSubShapes(Common_1, GeomAPI_Shape.SOLID, [1])
+model.testNbUniqueSubShapes(Common_1, GeomAPI_Shape.FACE, [3])
+model.testNbUniqueSubShapes(Common_1, GeomAPI_Shape.EDGE, [3])
+model.testNbUniqueSubShapes(Common_1, GeomAPI_Shape.VERTEX, [2])
### Set a higher fuzzy value
Param_fuzzy.setValue(1.e-5)
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.SOLID, [1])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [14])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [1])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [14])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
model.testResultsVolumes(Cut_1, [49.093623770546])
### Set a higher fuzzy value
model.testNbResults(Cut_1, 1)
model.testNbSubResults(Cut_1, [4])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [20])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
-testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [20])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
+model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
model.testResultsVolumes(Cut_1, [49.088834629314])
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])
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(Fuse_1, 1)
model.testNbSubResults(Fuse_1, [0])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [11])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [24])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [15])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [11])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [24])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [15])
model.testResultsVolumes(Fuse_1, [2000.02000010])
### Set a higher fuzzy value
model.testNbResults(Fuse_1, 1)
model.testNbSubResults(Fuse_1, [0])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [10])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [20])
-testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [12])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [10])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [20])
+model.testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [12])
model.testResultsVolumes(Fuse_1, [2000.02166677])
#
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.testCompound(GlueFaces_1, [2], [2], [11], [20], [12])
# =============================================================================
# Test 2. Glue faces for 2 solids with 1 common edge only
model.end()
# no faces glued
-testCompound(GlueFaces_2, model, [2], [2], [12], [23], [14])
+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.testCompound(GlueFaces_4, [2], [2], [11], [20], [12])
# =============================================================================
# Test 5. Check Python dump
#
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.do()
# gluing successful
-testCompound(GlueFaces_1, model, [2], [2], [11], [20], [12])
+model.testCompound(GlueFaces_1, [2], [2], [11], [20], [12])
# =============================================================================
# Test 2. Glue faces for 2 faces with 1 common edge only
model.do()
# gluing successful
-testCompound(GlueFaces_2, model, [2], [0], [2], [7], [6])
+model.testCompound(GlueFaces_2, [2], [0], [2], [7], [6])
# =============================================================================
# Test 3. Glue faces for 1 solid and 1 faces with 1 common edge
model.end()
# no faces glued
-testCompound(GlueFaces_3, model, [2], [1], [7], [15], [10])
+model.testCompound(GlueFaces_3, [2], [1], [7], [15], [10])
#
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], [0], [3], [10], [8])
+model.testCompound(GlueFaces_1, [2], [0], [3], [10], [8])
# =============================================================================
# Test 2. Glue faces for 2 shells with 1 common edge only
model.end()
# gluing successful
-testCompound(GlueFaces_2, model, [2], [0], [4], [13], [10])
+model.testCompound(GlueFaces_2, [2], [0], [4], [13], [10])
# =============================================================================
# Test 3. Glue faces for 2 shells with 2 adjacent faces above default tolerance
model.end()
# no faces glued
-testCompound(GlueFaces_3, model, [2], [0], [4], [14], [12])
+model.testCompound(GlueFaces_3, [2], [0], [4], [14], [12])
# =============================================================================
# Test 4. Glue faces for 2 solids with 2 adjacent faces using different tolerance
model.end()
# gluing successful
-testCompound(GlueFaces_4, model, [2], [0], [3], [10], [8])
+model.testCompound(GlueFaces_4, [2], [0], [3], [10], [8])
# =============================================================================
# Test 5. Check Python dump
#
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.testCompound(GlueFaces_1, [2], [2], [11], [20], [12])
# =============================================================================
# Test 2. Glue faces for 2 solids with 1 common edge only
model.end()
# gluing successful
-testCompound(GlueFaces_2, model, [2], [2], [12], [23], [14])
+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.testCompound(GlueFaces_4, [2], [2], [11], [20], [12])
# =============================================================================
# Test 5. Check Python dump
from salome.shaper import model
-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 testResults(theFeature,theModel,NbRes,NbSubRes,NbShell,NbFace,NbEdge,NbVertex):
- """ Tests numbers of unique sub-shapes in the results
- """
- aResults = theFeature.feature().results()
- aNbResults = len(aResults)
- assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
- theModel.testNbSubResults(theFeature, NbSubRes)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
-
model.begin()
partSet = model.moduleDocument()
Sewing_1 = model.addSewing(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], 0.0001, allowNonManifold = True, alwaysCreateResult = False)
model.do()
-testResults(Sewing_1, model, 1, [0], [1], [2], [7], [6])
+model.testResults(Sewing_1, 1, [0], [1], [2], [7], [6])
# Move the groups after Sewing (move to the end)
Part_1_doc.moveFeature(Group_1.feature(), Sewing_1.feature())
Part_1_doc.moveFeature(Group_2.feature(), Sewing_1.feature())
model.end()
+print("-------------------------------------------------------------------------")
+print("IMPORTANT NOTE:")
+print("The following checks will fail, as long as bos #33216 does not get fixed!")
+print("-------------------------------------------------------------------------")
model.testNbResults(Group_1, 1)
model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [4])
model.testNbResults(Group_2, 1)
Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")])
model.do()
-testResults(Shell_1, model, 2, [0,0], [1,1], [1,1], [4,4], [4,4])
+model.testResults(Shell_1, 2, [0,0], [1,1], [1,1], [4,4], [4,4])
model.testNbSubShapes(Shell_1, GeomAPI_Shape.EDGE, [4,4])
# Move the groups after Shell (move to the end)
#
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 testResults(theFeature,theModel,NbRes,NbSubRes,NbShell,NbFace,NbEdge,NbVertex):
- """ Tests numbers of unique sub-shapes in the results
- """
- aResults = theFeature.feature().results()
- aNbResults = len(aResults)
- assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
- theModel.testNbSubResults(theFeature, NbSubRes)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+
# Create document
model.begin()
model.end()
# sewing successful
-testResults(Sewing_1a, model, 1, [0], [1], [10], [23], [14])
+model.testResults(Sewing_1a, 1, [0], [1], [10], [23], [14])
# =============================================================================
# Test 1b. Sew two shells with a single common edge (do not create result)
model.end()
# sewing successful
-testResults(Sewing_1b, model, 1, [0], [1], [10], [23], [14])
+model.testResults(Sewing_1b, 1, [0], [1], [10], [23], [14])
# =============================================================================
# Test 2a. Sew two shells with four common edges (create result)
model.end()
# sewing successful
-testResults(Sewing_2a, model, 1, [0], [1], [10], [20], [12])
+model.testResults(Sewing_2a, 1, [0], [1], [10], [20], [12])
# =============================================================================
# Test 2b. Sew two shells with four common edges (do not create result)
model.end()
# sewing successful
-testResults(Sewing_2b, model, 1, [0], [1], [10], [20], [12])
+model.testResults(Sewing_2b, 1, [0], [1], [10], [20], [12])
# =============================================================================
# Test 3a. Sew two slightly disconnected shells (create result)
model.end()
# no sewing done (result is a compound with the two input shells)
-testResults(Sewing_3a, model, 1, [2], [2], [10], [24], [16])
+model.testResults(Sewing_3a, 1, [2], [2], [10], [24], [16])
# =============================================================================
# Test 3b. Sew two slightly disconnected shells (do not create result)
model.end()
# sewing successful
-testResults(Sewing_4a, model, 1, [0], [1], [10], [20], [12])
+model.testResults(Sewing_4a, 1, [0], [1], [10], [20], [12])
# =============================================================================
# Test 4b. Sew two slightly disconnected shells with larger tolerance (do not create result)
model.end()
# sewing successful
-testResults(Sewing_4b, model, 1, [0], [1], [10], [20], [12])
+model.testResults(Sewing_4b, 1, [0], [1], [10], [20], [12])
#
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 testResults(theFeature,theModel,NbRes,NbSubRes,NbShell,NbFace,NbEdge,NbVertex):
- """ Tests numbers of unique sub-shapes in the results
- """
- aResults = theFeature.feature().results()
- aNbResults = len(aResults)
- assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
- theModel.testNbSubResults(theFeature, NbSubRes)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
- testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
# Create document
model.begin()
model.end()
# sewing failed (result is a compound with the two input shells)
-testResults(Sewing_1, model, 1, [2], [2], [4], [14], [12])
+model.testResults(Sewing_1, 1, [2], [2], [4], [14], [12])
# =============================================================================
# Test 2. Sew the same two shells allowing non-manifold results
model.end()
# sewing successful
-testResults(Sewing_2, model, 1, [0], [1], [4], [13], [10])
+model.testResults(Sewing_2, 1, [0], [1], [4], [13], [10])
assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+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, NbSubRes, NbSolid, NbFace, NbEdge, NbVertex):
+ """ Tests number 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())
+ 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)
+
+
+def testResults(theFeature, NbRes, NbSubRes, NbShell, NbFace, NbEdge, NbVertex):
+ """ Tests numbers of unique sub-shapes in the results
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ assert (aNbResults == NbRes), "Number of results: {} not equal to {}}.".format(aNbResults, NbRes)
+ testNbSubResults(theFeature, NbSubRes)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.SHELL, NbShell)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.FACE, NbFace)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.EDGE, NbEdge)
+ testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+
+
def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDigits = 7):
""" Tests results volumes.
:param theFeature: feature to test.