Salome HOME
Task 5.1.4 Join 2 features "fuse" and "union" into one feature (issue #3062)
authorazv <azv@opencascade.com>
Wed, 20 Nov 2019 12:26:19 +0000 (15:26 +0300)
committerazv <azv@opencascade.com>
Wed, 20 Nov 2019 12:26:19 +0000 (15:26 +0300)
* Correct processing of faces during the fuse
* Update unit-tests according to new behavior

src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py
src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py
src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py
src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v0_3.py
src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_2.py
src/FeaturesPlugin/Test/TestBooleanFuse_MultiLevelCompound_v20190506_3.py
src/FeaturesPlugin/Test/TestUnionOfUnion.py

index 5013a68bc44c1d925e533bbc7de385906c39a484..04194d5b10c1acd26516246a8254efd8b3ca2857 100644 (file)
@@ -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()) {
index 6ed38227224ad719726a55562dff460d5a878c58..ee29a96b32cb8ea0c421b6164c648bbd5bcbc11f 100644 (file)
@@ -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()
index d69e7931494a687e747740b268920875aceca73c..b90c2f27624ef3cf1cbac1e5d8aab1728447c81d 100644 (file)
@@ -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()
 
index 87e7b0c90571ccbcfbca6aefbb1b52e003b851da..ce912b897f573cb18f6ed18704bb5ae0482e2642 100644 (file)
@@ -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])
index 64de0bacc28028fc518661fe1cf6f9c9c7ce3982..c6ba22f70ed70ff444f971aa7b89cb00019d25a9 100644 (file)
@@ -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])
index 7cb0da09deb601113da5a4d243ab092ee258b8e6..77fb3065759ad460a1f7f8233bdc0657f83529b9 100644 (file)
@@ -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())
index 23e7c75afc9348e7f545079eaadc55c2b2f2f003..57226b3e3b367f24e94628bd3b02429c5a1a7bd2 100644 (file)
@@ -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])
index 2d4a0cac391c248fc846c16fbddcc334de8ff7bb..39ff6a3cde07c6386c0802cdd0db36e2e24e809b 100644 (file)
@@ -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()