From dedc9e74b8751c6ab79b90871c2b117a2abaa252 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 20 Nov 2019 08:45:29 +0300 Subject: [PATCH] Task 5.1.4 Join 2 features "fuse" and "union" into one feature (issue #3062) --- src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp | 3 +-- src/FeaturesPlugin/FeaturesPlugin_Validators.cpp | 3 --- src/FeaturesPlugin/Test/TestUnion.py | 10 ++++++---- src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py | 2 +- src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py | 2 +- src/FeaturesPlugin/Test/TestUnion4Faces.py | 4 ++-- src/FeaturesPlugin/Test/TestUnionOfUnion.py | 4 ++-- src/FeaturesPlugin/plugin-Features.xml | 2 +- src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp | 5 +++++ 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 9fccd0f08..5013a68bc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -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); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 44de21fb5..07db4dd86 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -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; diff --git a/src/FeaturesPlugin/Test/TestUnion.py b/src/FeaturesPlugin/Test/TestUnion.py index ccb6e644b..14b0973da 100644 --- a/src/FeaturesPlugin/Test/TestUnion.py +++ b/src/FeaturesPlugin/Test/TestUnion.py @@ -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()) diff --git a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py index fbcf82f52..f2b650ec8 100644 --- a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py +++ b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py @@ -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]) diff --git a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py index 8679aeb10..c1082408c 100644 --- a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py +++ b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestUnion4Faces.py b/src/FeaturesPlugin/Test/TestUnion4Faces.py index 0f4346757..a3772deae 100644 --- a/src/FeaturesPlugin/Test/TestUnion4Faces.py +++ b/src/FeaturesPlugin/Test/TestUnion4Faces.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestUnionOfUnion.py b/src/FeaturesPlugin/Test/TestUnionOfUnion.py index 6d44cb3dc..2d4a0cac3 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.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() diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 65c1a1e45..0fd56642c 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -81,7 +81,7 @@ + icon="icons/Features/union.png" helpfile="unionFeature.html" internal="1"> +#include #include #include @@ -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; -- 2.39.2