]> SALOME platform Git repositories - modules/shaper.git/commitdiff
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 05:45:29 +0000 (08:45 +0300)
committerazv <azv@opencascade.com>
Wed, 20 Nov 2019 05:45:29 +0000 (08:45 +0300)
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/Test/TestUnion.py
src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py
src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py
src/FeaturesPlugin/Test/TestUnion4Faces.py
src/FeaturesPlugin/Test/TestUnionOfUnion.py
src/FeaturesPlugin/plugin-Features.xml
src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp

index 9fccd0f081b8bb658a857dc494db4b09db7eed40..5013a68bc44c1d925e533bbc7de385906c39a484 100644 (file)
@@ -115,8 +115,7 @@ void FeaturesPlugin_BooleanFuse::execute()
   // in boolean operation and will be added to result.
   ListOfShape aShapesToAdd;
   for (ObjectHierarchy::Iterator anObjectsIt = anObjectsHierarchy.Begin();
-       !isSimpleCreation && anObjectsIt != anObjectsHierarchy.End();
-       ++anObjectsIt) {
+       anObjectsIt != anObjectsHierarchy.End(); ++anObjectsIt) {
     GeomShapePtr anObject = *anObjectsIt;
     GeomShapePtr aParent = anObjectsHierarchy.Parent(anObject, false);
 
index 44de21fb5ffc40aa01ab76d7432e6a4a2bf01a98..07db4dd86f32d32371a2dede20b1e61811bde22f 100644 (file)
@@ -1742,9 +1742,6 @@ bool FeaturesPlugin_ValidatorBooleanFuseArguments::isValid(
   if (anObjectsNb + aToolsNb < 2) {
     theError = "Not enough arguments for Fuse operation.";
     return false;
-  } else if (isAllInSameCompSolid) {
-    theError = "Operations only between sub-shapes of the same shape not allowed.";
-    return false;
   }
 
   return true;
index ccb6e644b85c7df2cad239ee2bb2cdced28beb74..14b0973da9b0808e3823208b4dd305c12b9000d2 100644 (file)
@@ -84,10 +84,12 @@ anExtrusionResult = modelAPI_ResultBody(anExtrusionFeature.firstResult())
 # Make union on extrusion
 #=========================================================================
 aSession.startOperation()
-aUnionFeature = aPart.addFeature("Union")
-aUnionFeature.selectionList("base_objects").append(anExtrusionResult.subResult(0), None);
-aUnionFeature.selectionList("base_objects").append(anExtrusionResult.subResult(1), None);
-aUnionFeature.selectionList("base_objects").append(anExtrusionResult.subResult(2), None);
+aUnionFeature = aPart.addFeature("Fuse")
+aUnionFeature.string("creation_method").setValue("simple")
+aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(0), None);
+aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(1), None);
+aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(2), None);
+aUnionFeature.boolean("remove_intersection_edges").setValue(False)
 aSession.finishOperation()
 assert (len(aUnionFeature.results()) > 0)
 anUnionResult = modelAPI_ResultBody(aUnionFeature.firstResult())
index fbcf82f5256d9866af98b726a341e05bf24a20ae..f2b650ec86521cf2a8ea077ce9311d70281cdc2a 100644 (file)
@@ -37,7 +37,7 @@ model.do()
 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")])
 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OY"), 200, 0)
 Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "Revolution_1_1")])
-Union_1 = model.addUnion(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2")])
+Union_1 = model.addFuse(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2")], True)
 model.do()
 
 model.checkResult(Union_1,model,1,[0],[0],[1],[4],[8])
index 8679aeb10773f4647f398d539825c2f4f21c678c..c1082408cf4d30b1fdc0d68551901cd6905e7532 100644 (file)
@@ -39,7 +39,7 @@ Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_
 Partition_1_objects = [model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/XOY"), model.selection("FACE", "Revolution_1_1")]
 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
 Union_1_objects = [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")]
-Union_1 = model.addUnion(Part_1_doc, Union_1_objects)
+Union_1 = model.addFuse(Part_1_doc, Union_1_objects, True)
 model.testHaveNamingSubshapes(Union_1,model,Part_1_doc)
 model.do()
 model.end()
index 0f43467578b3154f770d196f66c73237d55b107a..a3772deae41d6fda4b9ff7a711ac4f6c888a24a2 100644 (file)
@@ -57,11 +57,11 @@ Face_2 = model.addFace(Part_1_doc, Face_2_objects)
 Partition_1_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "PartSet/YOZ")]
 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
 Union_1_objects = [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")]
-Union_1 = model.addUnion(Part_1_doc, Union_1_objects)
+Union_1 = model.addFuse(Part_1_doc, Union_1_objects, True, 20190506)
 model.do()
 
 model.checkResult(Union_1,model,1,[2],[0],[2],[13],[26])
-#model.testHaveNamingSubshapes(Union_1,model,Part_1_doc)
+model.testHaveNamingSubshapes(Union_1,model,Part_1_doc)
 
 model.end()
 
index 6d44cb3dcdc42ddd07332e8ab7d44c252edbf86c..2d4a0cac391c248fc846c16fbddcc334de8ff7bb 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.addUnion(Part_1_doc, [model.selection("SOLID", "Partition_1_1_3"), model.selection("SOLID", "Partition_1_1_1")])
-Union_2 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Union_1_1_2"), model.selection("SOLID", "Union_1_1_1")])
+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")])
 model.do()
 model.end()
 
index 65c1a1e45998eb49143b4a11e0321efc1f02a32c..0fd56642c048dd5dd604aeb1227053bb1f36f90a 100644 (file)
@@ -81,7 +81,7 @@
           <source path="boolean_split_widget.xml"/>
       </feature>
       <feature id="Union" title="Union" tooltip="Perform union operations with shapes"
-               icon="icons/Features/union.png" helpfile="unionFeature.html">
+               icon="icons/Features/union.png" helpfile="unionFeature.html" internal="1">
           <source path="union_widget.xml"/>
       </feature>
       <feature id="Remove_SubShapes" title="Remove Sub-Shapes" tooltip="Allows to remove sub-shapes from wires, shells, compsolids and compounds"
index c33177b73d961182d402d189ed6032270f9c3203..1aeb1140f60800294cb513ad202693e5c93cbcb6 100644 (file)
@@ -20,6 +20,7 @@
 #include "GeomAlgoAPI_UnifySameDomain.h"
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_DFLoader.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
 #include <ShapeUpgrade_UnifySameDomain.hxx>
@@ -113,6 +114,10 @@ void GeomAlgoAPI_UnifySameDomain::build(const GeomShapePtr& theShape,
   if (aResult.IsNull()) {
     return;
   }
+  // taske off the compound if it consists of single sub-shape
+  if (aResult.ShapeType() == TopAbs_COMPOUND) {
+    aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+  }
 
   if (theIsToSimplifyShell && aResult.ShapeType() == TopAbs_SHELL) {
     int aNb = 0;