From 8607b62ba4fd0681fe1f406efed0ad0a48a382e0 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 20 Nov 2019 15:26:19 +0300 Subject: [PATCH] Task 5.1.4 Join 2 features "fuse" and "union" into one feature (issue #3062) * Correct processing of faces during the fuse * Update unit-tests according to new behavior --- src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp | 11 ++++++++--- .../Test/TestBooleanFuse_CompSolid_Face.py | 8 +++++++- src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py | 6 ++++-- src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py | 2 +- .../Test/TestBooleanFuse_MultiLevelCompound_v0_3.py | 10 +++++++++- .../TestBooleanFuse_MultiLevelCompound_v20190506_2.py | 10 +++++----- .../TestBooleanFuse_MultiLevelCompound_v20190506_3.py | 10 +++++++++- src/FeaturesPlugin/Test/TestUnionOfUnion.py | 4 ++-- 8 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 5013a68bc..04194d5b1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -113,9 +113,11 @@ void FeaturesPlugin_BooleanFuse::execute() // Collecting solids from compsolids which will not be modified // in boolean operation and will be added to result. + bool isProcessCompsolid = !isSimpleCreation || aFuseVersion >= THE_FUSE_VERSION_1; ListOfShape aShapesToAdd; for (ObjectHierarchy::Iterator anObjectsIt = anObjectsHierarchy.Begin(); - anObjectsIt != anObjectsHierarchy.End(); ++anObjectsIt) { + isProcessCompsolid && anObjectsIt != anObjectsHierarchy.End(); + ++anObjectsIt) { GeomShapePtr anObject = *anObjectsIt; GeomShapePtr aParent = anObjectsHierarchy.Parent(anObject, false); @@ -143,8 +145,11 @@ void FeaturesPlugin_BooleanFuse::execute() aMakeShapeList->appendAlgo(aCutAlgo); } } - anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), - anEdgesAndFaces.end()); + + if (aShapesToAdd.empty() || !aCuttedEdgesAndFaces) { + anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), + anEdgesAndFaces.end()); + } // If we have compsolids then cut with not used solids all others. if (!aShapesToAdd.empty()) { diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py index 6ed382272..ee29a96b3 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py @@ -60,6 +60,12 @@ model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [32]) model.testResultsVolumes(Fuse_1, [785.398163397447774514148477465]) Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Extrusion_1_1_1")], [model.selection("FACE", "Fuse_1_1_1")]) -assert(Fuse_2.feature().error() != "") +model.testNbResults(Fuse_2, 1) +model.testNbSubResults(Fuse_2, [2]) +model.testNbSubShapes(Fuse_2, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Fuse_2, GeomAPI_Shape.FACE, [19]) +model.testNbSubShapes(Fuse_2, GeomAPI_Shape.EDGE, [82]) +model.testNbSubShapes(Fuse_2, GeomAPI_Shape.VERTEX, [164]) +model.testResultsVolumes(Fuse_2, [25803.607097738855372881516814232]) model.end() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py index d69e79314..b90c2f276 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py @@ -31,11 +31,13 @@ assert(Fuse_1.feature().error() != "") Part_1_doc.removeFeature(Fuse_1.feature()) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_2")]) -assert(Fuse_1.feature().error() != "") +# after merging Union and Fuse features, fusing of solids in the same composolid should work (issue #3062) +assert(Fuse_1.feature().error() == "") Part_1_doc.removeFeature(Fuse_1.feature()) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")], [model.selection("SOLID", "Partition_1_1_2")]) -assert(Fuse_1.feature().error() != "") +# after merging Union and Fuse features, fusing of solids in the same composolid should work (issue #3062) +assert(Fuse_1.feature().error() == "") Part_1_doc.removeFeature(Fuse_1.feature()) model.end() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py index 87e7b0c90..ce912b897 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py @@ -39,7 +39,7 @@ model.end() from GeomAPI import GeomAPI_Shape model.testNbResults(Fuse_1, 1) -model.testNbSubResults(Fuse_1, [1]) +model.testNbSubResults(Fuse_1, [0]) model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [0]) model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [1]) model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [2]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v0_3.py b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v0_3.py index 64de0bacc..c6ba22f70 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v0_3.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v0_3.py @@ -78,4 +78,12 @@ Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrus Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1_1")], [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("FACE", "Compound_1_1_2")], True) model.end() -assert(Fuse_1.feature().error() != "") +from GeomAPI import * + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [2]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [16]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [78]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [156]) +model.testResultsVolumes(Fuse_1, [1589.048622670478835]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_2.py b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_2.py index 7cb0da09d..77fb30657 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_2.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_2.py @@ -86,10 +86,10 @@ from GeomAPI import GeomAPI_Shape model.testNbResults(Fuse_1, 1) model.testNbSubResults(Fuse_1, [3]) -model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [6]) -model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [23]) -model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [70]) -model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [140]) -model.testResultsVolumes(Fuse_1, [5016.039439659862]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [7]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [31]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [108]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [216]) +model.testResultsVolumes(Fuse_1, [5516.039439659862]) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_3.py b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_3.py index 23e7c75af..57226b3e3 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_3.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_3.py @@ -78,4 +78,12 @@ Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrus Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1_1")], [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("FACE", "Compound_1_1_2")], True, 20190506) model.end() -assert(Fuse_1.feature().error() != "") +from GeomAPI import * + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [5]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [9]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [44]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [160]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [320]) +model.testResultsVolumes(Fuse_1, [6516.03943965772123]) diff --git a/src/FeaturesPlugin/Test/TestUnionOfUnion.py b/src/FeaturesPlugin/Test/TestUnionOfUnion.py index 2d4a0cac3..39ff6a3cd 100644 --- a/src/FeaturesPlugin/Test/TestUnionOfUnion.py +++ b/src/FeaturesPlugin/Test/TestUnionOfUnion.py @@ -28,8 +28,8 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), 5, Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5, True) Partition_1_objects = [model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"), model.selection("SOLID", "Box_1_1")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Union_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_3"), model.selection("SOLID", "Partition_1_1_1")]) -Union_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Fuse_1_1_2"), model.selection("SOLID", "Fuse_1_1_1")]) +Union_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_3"), model.selection("SOLID", "Partition_1_1_1")], False, 20190506) +Union_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Fuse_1_1_2"), model.selection("SOLID", "Fuse_1_1_1")], False, 20190506) model.do() model.end() -- 2.39.2