From 6a8195921a1e4dba54e54f75500d7e8c3a942f46 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 28 Feb 2019 13:44:51 +0300 Subject: [PATCH] Issue #2878: In Extrusion, can't select all in Vertex feature Add checks of vertices to the corresponding validator. --- src/FeaturesPlugin/CMakeLists.txt | 1 + .../FeaturesPlugin_Validators.cpp | 7 ++- src/FeaturesPlugin/FeaturesPlugin_msg_en.ts | 28 +++++----- src/FeaturesPlugin/Test/Test2878.py | 56 +++++++++++++++++++ 4 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test2878.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 97a7f3ad7..907daf153 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -458,4 +458,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2751.py Test2826.py Test2854.py + Test2878.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index cb18ffafa..ee82a62f5 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -254,7 +254,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA std::dynamic_pointer_cast(aContext); if(!aResultConstruction.get()) { // It is not a result construction. - // If shape is compound check that it contains only faces and edges. + // If shape is compound check that it contains only faces, edges or vertices. GeomShapePtr aShape = aSelectionAttr->value(); if(!aShape.get()) { if (aContext.get()) { @@ -268,9 +268,10 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA if(aShape->shapeType() == GeomAPI_Shape::COMPOUND) { for(GeomAPI_ShapeIterator anIt(aShape); anIt.more(); anIt.next()) { GeomShapePtr aSubShape = anIt.current(); - if(aSubShape->shapeType() != GeomAPI_Shape::EDGE + if(aSubShape->shapeType() != GeomAPI_Shape::VERTEX + && aSubShape->shapeType() != GeomAPI_Shape::EDGE && aSubShape->shapeType() != GeomAPI_Shape::FACE) { - theError = "Error: Compound should contain only faces and edges."; + theError = "Error: Compound should contain only faces, edges or vertices."; return false; } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts index aa489e343..0caebe362 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts @@ -152,8 +152,8 @@ Extrusion:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -580,8 +580,8 @@ ExtrusionCut:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -1042,8 +1042,8 @@ Revolution:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -1448,8 +1448,8 @@ RevolutionCut:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -1875,8 +1875,8 @@ ExtrusionFuse:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -2372,8 +2372,8 @@ RevolutionFuse:base:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. @@ -2932,8 +2932,8 @@ Pipe:base_objects:FeaturesPlugin_ValidatorBaseForGeneration - Error: Compound should contain only faces and edges. - Compound should contain only faces and edges. + Error: Compound should contain only faces, edges or vertices. + Compound should contain only faces, edges or vertices. diff --git a/src/FeaturesPlugin/Test/Test2878.py b/src/FeaturesPlugin/Test/Test2878.py new file mode 100644 index 000000000..8d9dd769b --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2878.py @@ -0,0 +1,56 @@ +## Copyright (C) 2019-20xx 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() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(68.30992366412212, 32.22748091603054, -50.73129770992366, 32.22748091603054) +SketchLine_2 = Sketch_1.addLine(-50.73129770992366, 32.22748091603054, -50.73129770992366, -43.02137404580152) +SketchLine_3 = Sketch_1.addLine(-50.73129770992366, -43.02137404580152, 68.30992366412212, -43.02137404580152) +SketchLine_4 = Sketch_1.addLine(68.30992366412212, -43.02137404580152, 68.30992366412212, 32.22748091603054) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +model.do() +Vertex_1_objects = [model.selection("VERTEX", "Sketch_1/SketchLine_2_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex")] +Vertex_1 = model.addVertex(Part_1_doc, Vertex_1_objects) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Vertex_1")], model.selection("EDGE", "PartSet/OZ"), 10, 0) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Extrusion_1, 1) +model.testNbSubResults(Extrusion_1, [4]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [8]) + +assert(model.checkPythonDump()) \ No newline at end of file -- 2.39.2