]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2878: In Extrusion, can't select all in Vertex feature
authorazv <azv@opencascade.com>
Thu, 28 Feb 2019 10:44:51 +0000 (13:44 +0300)
committerazv <azv@opencascade.com>
Thu, 28 Feb 2019 10:44:51 +0000 (13:44 +0300)
Add checks of vertices to the corresponding validator.

src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/FeaturesPlugin_msg_en.ts
src/FeaturesPlugin/Test/Test2878.py [new file with mode: 0644]

index 97a7f3ad742384e05ffd470270adbb22438d3b65..907daf15375632cca10e7b0389796f4b6ccf8133 100644 (file)
@@ -458,4 +458,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test2751.py
                Test2826.py
                Test2854.py
+               Test2878.py
 )
index cb18ffafa06fc05c4e9513b46746be3c8ce2b34f..ee82a62f5c8c415cd3a897a4818c44d102358822 100644 (file)
@@ -254,7 +254,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
         std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(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;
             }
           }
index aa489e3434478293e2c113f0f86cb64313399a84..0caebe362d418c7fe24000cbbeb1ccd5048a2b95 100644 (file)
   <context>
     <name>Extrusion:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>ExtrusionCut:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>Revolution:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>RevolutionCut:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>ExtrusionFuse:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>RevolutionFuse:base:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
   <context>
     <name>Pipe:base_objects:FeaturesPlugin_ValidatorBaseForGeneration</name>
     <message>
-      <source>Error: Compound should contain only faces and edges.</source>
-      <translation>Compound should contain only faces and edges.</translation>
+      <source>Error: Compound should contain only faces, edges or vertices.</source>
+      <translation>Compound should contain only faces, edges or vertices.</translation>
     </message>
   </context>
   <context>
diff --git a/src/FeaturesPlugin/Test/Test2878.py b/src/FeaturesPlugin/Test/Test2878.py
new file mode 100644 (file)
index 0000000..8d9dd76
--- /dev/null
@@ -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<mailto: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