From 266ba3a9179517c4b288232eb8d9db1bac4c56b7 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Thu, 22 Oct 2020 23:10:37 +0300 Subject: [PATCH] Issue #20245: New error when loading python dump: attribute "ExternalFeature" is invalid Improve dumping of Extrusion/Revolution if the type of selected shapes is not the same as the selection type of the feature. --- src/FeaturesAPI/FeaturesAPI_Extrusion.cpp | 34 ++- src/FeaturesAPI/FeaturesAPI_Extrusion.h | 12 +- src/FeaturesAPI/FeaturesAPI_Revolution.cpp | 34 ++- src/FeaturesAPI/FeaturesAPI_Revolution.h | 12 +- src/FeaturesPlugin/CMakeLists.txt | 2 + src/FeaturesPlugin/Test/Test20245_1.py | 248 +++++++++++++++++++++ src/FeaturesPlugin/Test/Test20245_2.py | 114 ++++++++++ 7 files changed, 436 insertions(+), 20 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test20245_1.py create mode 100644 src/FeaturesPlugin/Test/Test20245_2.py diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp index 33956df7c..6c6c7a02f 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp @@ -75,11 +75,14 @@ FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize) + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theDirection, mydirection); setSizes(theToSize, theFromSize); } @@ -107,11 +110,14 @@ FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptrsetSelectionType(theSelectionType); fillAttribute(theDirection, mydirection); setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); } @@ -228,6 +234,18 @@ void FeaturesAPI_Extrusion::dump(ModelHighAPI_Dumper& theDumper) const ", " << anAttrFromObject << ", " << anAttrFromOffset; } + // write explicitly the type of selection if it does not correspond + // to the type of first selected shape + if (!anAttrSketch->isInitialized()) { + std::string aListSelType = anAttrObjects->selectionType(); + AttributeSelectionPtr aFirstSelection = anAttrObjects->value(0); + GeomShapePtr aFirstShape = aFirstSelection->value(); + if (!aFirstShape) + aFirstShape = aFirstSelection->context()->shape(); + if (!aFirstShape || aFirstShape->shapeType() != GeomAPI_Shape::shapeTypeByStr(aListSelType)) + theDumper << ", \"" << aListSelType << "\""; + } + theDumper << ")" << std::endl; if(anAttrSketch->isInitialized()) { @@ -277,14 +295,16 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize) + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID()); return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theDirection, theToSize, - theFromSize)); + theFromSize, + theSelectionType)); } //================================================================================================== @@ -311,7 +331,8 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID()); return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, @@ -320,5 +341,6 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, theToObject, theToOffset, theFromObject, - theFromOffset)); + theFromOffset, + theSelectionType)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.h b/src/FeaturesAPI/FeaturesAPI_Extrusion.h index b56f662b1..84d66913a 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.h +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.h @@ -66,7 +66,8 @@ public: const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize); + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType = std::string()); /// Constructor with values. FEATURESAPI_EXPORT @@ -85,7 +86,8 @@ public: const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); /// Destructor. FEATURESAPI_EXPORT @@ -183,7 +185,8 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize); + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType = std::string()); /// \ingroup CPPHighAPI /// \brief Create Extrusion feature. @@ -204,6 +207,7 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); #endif // FeaturesAPI_Extrusion_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp index f2b511b6f..51a1a1297 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp @@ -52,11 +52,14 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution( const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle) + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theAxis, myaxis); setAngles(theToAngle, theFromAngle); } @@ -70,11 +73,14 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution( const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theAxis, myaxis); setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); } @@ -191,6 +197,18 @@ void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const ", " << anAttrFromObject << ", " << anAttrFromOffset; } + // write explicitly the type of selection if it does not correspond + // to the type of first selected shape + if (!anAttrSketch->isInitialized()) { + std::string aListSelType = anAttrObjects->selectionType(); + AttributeSelectionPtr aFirstSelection = anAttrObjects->value(0); + GeomShapePtr aFirstShape = aFirstSelection->value(); + if (!aFirstShape) + aFirstShape = aFirstSelection->context()->shape(); + if (!aFirstShape || aFirstShape->shapeType() != GeomAPI_Shape::shapeTypeByStr(aListSelType)) + theDumper << ", \"" << aListSelType << "\""; + } + theDumper << ")" << std::endl; if(anAttrSketch->isInitialized()) { @@ -221,14 +239,16 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle) + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID()); return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theToAngle, - theFromAngle)); + theFromAngle, + theSelectionType)); } //================================================================================================== @@ -238,7 +258,8 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID()); return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, @@ -247,5 +268,6 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, theToObject, theToOffset, theFromObject, - theFromOffset)); + theFromOffset, + theSelectionType)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.h b/src/FeaturesAPI/FeaturesAPI_Revolution.h index b947db43b..cc1c78bf5 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.h +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.h @@ -54,7 +54,8 @@ public: const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle); + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType = std::string()); /// Constructor with values. FEATURESAPI_EXPORT @@ -64,7 +65,8 @@ public: const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); /// Destructor. FEATURESAPI_EXPORT @@ -147,7 +149,8 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle); + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType = std::string()); /// \ingroup CPPHighAPI /// \brief Create Revolution feature. @@ -158,6 +161,7 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); #endif // FeaturesAPI_Revolution_H_ diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index c93c66a17..045f25231 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -684,4 +684,6 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillet1D_Wire_5.py Test19931.py Test20027.py + Test20245_1.py + Test20245_2.py ) diff --git a/src/FeaturesPlugin/Test/Test20245_1.py b/src/FeaturesPlugin/Test/Test20245_1.py new file mode 100644 index 000000000..e77f4f5e7 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20245_1.py @@ -0,0 +1,248 @@ +# Copyright (C) 2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "r_ext", "80") +model.addParameter(Part_1_doc, "r_int", "60") +model.addParameter(Part_1_doc, "r_cut", "30") +model.addParameter(Part_1_doc, "h", "200") + +### Create Cylinder +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_ext", "h") + +### Create Cylinder +Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_int", "h") + +### Create Sphere +Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_ext") + +### Create Sphere +Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_int") + +### Create Rotation +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True) + +### Create Rotation +Rotation_2 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_2")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True) + +### Create Translation +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Rotation_1_1"), model.selection("COMPOUND", "Rotation_2_1")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "h", keepSubResults = True) + +### Create Fuse +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Translation_1_1_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True) + +### Create Fuse +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_2_1"), model.selection("SOLID", "Translation_1_2_1")], keepSubResults = True) + +### Create Partition +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Fuse_1_1"), model.selection("SOLID", "Fuse_2_1")], keepSubResults = True) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(0, 30, -30, 0) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(-30, 0, 0, -30) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(0, -30, 30, 0) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_5 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.result()) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(30, 0, 0, 30) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_6.startPoint()) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) + +### Create SketchLine +SketchLine_7 = Sketch_1.addLine(-30, 0, -110, 0) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_7.startPoint()) +Sketch_1.setHorizontal(SketchLine_7.result()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(0, -30, 0, -110) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint()) +Sketch_1.setVertical(SketchLine_8.result()) + +### Create SketchLine +SketchLine_9 = Sketch_1.addLine(0, 30, 0, 110) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_9.startPoint()) +Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_10 = Sketch_1.addLine(30, 0, 110, 0) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_10.startPoint()) +Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_5.result()) +Sketch_1.setEqual(SketchLine_10.result(), SketchLine_7.result()) +Sketch_1.setEqual(SketchLine_9.result(), SketchLine_8.result()) +Sketch_1.setParallel(SketchLine_1.result(), SketchLine_4.result()) +Sketch_1.setParallel(SketchLine_6.result(), SketchLine_3.result()) +Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_2.result()) +Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_3.result()) +Sketch_1.setLength(SketchLine_7.result(), "r_ext") +Sketch_1.setDistance(SketchLine_7.startPoint(), SketchLine_2.result(), "r_int/2", True) +Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_5.result()) +Sketch_1.setEqual(SketchLine_9.result(), SketchLine_10.result()) +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "h", 0, "Edges") + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "h", False) + +### Create Split +Split_1 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], [model.selection("FACE", "Plane_1"), model.selection("COMPOUND", "Extrusion_1_1")], keepSubResults = True) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchProjection +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_10/Modified_Edge&Extrusion_1_1_1/To_Edge"), True) +SketchLine_11 = SketchProjection_3.createdFeature() + +### Create SketchProjection +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_9/Modified_Edge&Extrusion_1_1_4/To_Edge"), True) +SketchLine_12 = SketchProjection_4.createdFeature() + +### Create SketchProjection +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_8/Modified_Edge&Extrusion_1_1_3/To_Edge"), True) +SketchLine_13 = SketchProjection_5.createdFeature() + +### Create SketchProjection +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_2/To_Edge"), True) +SketchLine_14 = SketchProjection_6.createdFeature() +model.do() + +### Create Extrusion +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), "r_cut/sqrt(2)", 0, "Faces|Wires") + +### Create Sketch +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) + +### Create SketchProjection +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_5]"), True) +SketchLine_15 = SketchProjection_7.createdFeature() + +### Create SketchProjection +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_6/To_Edge"), True) +SketchLine_16 = SketchProjection_8.createdFeature() + +### Create SketchProjection +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_2/Modified_Edge&Extrusion_1_1_6/To_Edge"), True) +SketchLine_17 = SketchProjection_9.createdFeature() + +### Create SketchLine +SketchLine_18 = Sketch_3.addLine(-30, 221.2132034355964, -136.4686528504195, 327.681856286016) +Sketch_3.setCoincident(SketchAPI_Line(SketchLine_15).endPoint(), SketchLine_18.startPoint()) + +### Create SketchLine +SketchLine_19 = Sketch_3.addLine(-136.4686528504195, 327.681856286016, -80, 200) +Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) +Sketch_3.setCoincident(SketchAPI_Line(SketchLine_17).endPoint(), SketchLine_19.endPoint()) + +### Create SketchConstraintAngle +Sketch_3.setAngle(SketchLine_15.result(), SketchLine_18.result(), 135, type = "Direct") +model.do() + +### Create Face +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchProjection_7r-SketchLine_18f-SketchLine_19f-SketchProjection_9r-SketchProjection_8r")]) + +### Create AngularCopy +AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True) + +### Create Plane +Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "AngularCopy_1_1_3/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_18_StartVertex&Sketch_3/SketchProjection_7_EndVertex")) + +### Create Sketch +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) + +### Create SketchProjection +SketchProjection_10 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_3/ME:Rotated&Sketch_3/SketchLine_18"), True) +SketchLine_20 = SketchProjection_10.createdFeature() + +### Create SketchProjection +SketchProjection_11 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_3][Extrusion_2_1/To_Face]"), True) +SketchLine_21 = SketchProjection_11.createdFeature() + +### Create SketchProjection +SketchProjection_12 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_4/ME:Rotated&Sketch_3/SketchLine_18"), True) +SketchLine_22 = SketchProjection_12.createdFeature() + +### Create SketchLine +SketchLine_23 = Sketch_4.addLine(-245.2017461009716, 231.7060626516377, -78.06246341670106, 328.2039725015621) +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_22).endPoint(), SketchLine_23.startPoint()) +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_20).endPoint(), SketchLine_23.endPoint()) +model.do() + +### Create Face +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchProjection_10r-SketchLine_23r-SketchProjection_12r-SketchProjection_11r")]) + +### Create AngularCopy +AngularCopy_2 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True) + +### Create Split +Split_2_objects_2 = [model.selection("COMPOUND", "AngularCopy_1_1"), + model.selection("COMPOUND", "AngularCopy_2_1"), + model.selection("SOLID", "Extrusion_2_1")] +Split_2 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Split_1_1")], Split_2_objects_2, keepSubResults = True) + +### Create Group +Group_1_objects = [model.selection("FACE", "Split_2_1_16/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_17/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_18/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_19/Modified_Face&Cylinder_2_1/Face_1")] +Group_1 = model.addGroup(Part_1_doc, "Faces", Group_1_objects) +Group_1.setName("shared_face_cyl") +Group_1.result().setName("shared_face_cyl") + +model.end() + +from GeomAPI import * + +model.testNbResults(Split_2, 1) +model.testNbSubResults(Split_2, [20]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.SOLID, [20]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.FACE, [120]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.EDGE, [492]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.VERTEX, [984]) +model.testResultsVolumes(Split_2, [5093568.889]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20245_2.py b/src/FeaturesPlugin/Test/Test20245_2.py new file mode 100644 index 000000000..de33ec847 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20245_2.py @@ -0,0 +1,114 @@ +# Copyright (C) 2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Box +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(7.071067811865538, 2.928932188134462, 2.928932188134676, 2.928932188134462) + +### Create SketchLine +SketchLine_2 = Sketch_1.addLine(2.928932188134676, 2.928932188134462, 2.928932188134676, 7.071067811865324) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(2.928932188134676, 7.071067811865324, 7.071067811865538, 7.071067811865324) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(7.071067811865538, 7.071067811865324, 7.071067811865538, 2.928932188134462) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +Sketch_1.setHorizontal(SketchLine_1.result()) +Sketch_1.setVertical(SketchLine_2.result()) +Sketch_1.setHorizontal(SketchLine_3.result()) +Sketch_1.setVertical(SketchLine_4.result()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(0, 0, 2.928932188134676, 2.928932188134462) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchPoint_1.result()) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.endPoint()) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(10, 0, 7.071067811865538, 2.928932188134462) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchPoint_2.result()) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) + +### Create SketchLine +SketchLine_7 = Sketch_1.addLine(10, 10, 7.071067811865538, 7.071067811865324) + +### Create SketchProjection +SketchProjection_3 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), False) +SketchPoint_3 = SketchProjection_3.createdFeature() +Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchPoint_3.result()) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_7.endPoint()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(0, 10, 2.928932188134676, 7.071067811865324) + +### Create SketchProjection +SketchProjection_4 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), False) +SketchPoint_4 = SketchProjection_4.createdFeature() +Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchPoint_4.result()) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_8.endPoint()) +Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result()) +Sketch_1.setEqual(SketchLine_5.result(), SketchLine_6.result()) +Sketch_1.setEqual(SketchLine_6.result(), SketchLine_7.result()) +Sketch_1.setEqual(SketchLine_5.result(), SketchLine_2.result()) +model.do() + +### Create Revolution +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0, 90, "Edges") + +### Create Split +Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Revolution_1_1")], keepSubResults = True) + +model.end() + +from GeomAPI import * + +model.testNbResults(Split_1, 1) +model.testNbSubResults(Split_1, [5]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.FACE, [32]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.EDGE, [124]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.VERTEX, [248]) +model.testResultsVolumes(Split_1, [1000]) + +assert(model.checkPythonDump()) -- 2.39.2