FeaturesAPI_GlueFaces::FeaturesAPI_GlueFaces(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<ModelHighAPI_Selection>& theMainObjects,
const ModelHighAPI_Double& theTolerance,
- bool theIsKeepNonSolids=true)
+ bool theIsKeepNonSolids)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_GlueFaces.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_Tools.h>
#include <sstream>
return;
}
+ if (aResult->isCompound()) {
+ aResult = GeomAlgoAPI_ShapeTools::groupSharedTopology(aResult);
+
+ // If the subshape of the compound is already a Compound or CompSolid,
+ // use that compound subshape as the result.
+ if (aResult->typeOfCompoundShapes() == GeomAPI_Shape::COMPSOLID) {
+ ListOfShape aResults;
+ aResult = GeomAlgoAPI_ShapeTools::combineShapes(aResult, GeomAPI_Shape::COMPSOLID, aResults);
+ }
+ else if (aResult->typeOfCompoundShapes() == GeomAPI_Shape::COMPOUND) {
+ aResult = aResult->subShapes(GeomAPI_Shape::COMPOUND).front();
+ }
+ }
+
int anIndex = 0;
ResultBodyPtr aResultBody = document()->createBody(data(), anIndex);
aResultBody->storeModified(aShapes, aResult, aGluingAlgo);
model.end()
# gluing successful
-model.testCompound(GlueFaces_1, [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
model.end()
# gluing successful
-model.testCompound(GlueFaces_4, [2], [2], [11], [20], [12])
+model.testCompSolid(GlueFaces_4, [2], [2], [11], [20], [12])
# =============================================================================
# Test 5. Check Python dump
model.do()
# gluing successful
-model.testCompound(GlueFaces_1, [2], [2], [11], [20], [12])
+model.testCompSolid(GlueFaces_1, [2], [2], [11], [20], [12])
# =============================================================================
# Test 2. Glue faces for 2 faces with 1 common edge only
model.end()
# gluing successful
-model.testCompound(GlueFaces_1, [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
model.end()
# gluing successful
-model.testCompound(GlueFaces_4, [2], [2], [11], [20], [12])
+model.testCompSolid(GlueFaces_4, [2], [2], [11], [20], [12])
# =============================================================================
# Test 5. Check Python dump
testNbUniqueSubShapes(theFeature, GeomAPI_Shape.VERTEX, NbVertex)
+def testCompSolid(theFeature, NbSubRes, NbSolid, NbFace, NbEdge, NbVertex):
+ """ Tests number of unique sub-shapes in compsolid result
+ """
+ aResults = theFeature.feature().results()
+ aNbResults = len(aResults)
+ assert (aNbResults == 1), "Number of results: {} not equal to 1.".format(aNbResults)
+ assert aResults[0].shape().isCompSolid(), "Result shape type: {}. Expected: COMPSOLID.".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
"""