]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3236: Generalization of extrusion
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 23 Jul 2020 13:02:09 +0000 (16:02 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 23 Jul 2020 13:49:47 +0000 (16:49 +0300)
Allow to use wires and shells as an argument of the Extrusion

src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/GeomValidators/GeomValidators_ShapeType.cpp
src/GeomValidators/GeomValidators_ShapeType.h

index bdda2db8ba05a3ad28124df70190086bb83c5533..ab0d12b7dcf130baddc7216f2134834c446a3ef4 100644 (file)
@@ -51,6 +51,7 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the
   if(theInitFlags & InitBaseObjectsList) {
     data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
     myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType();
+    selectionList(BASE_OBJECTS_ID())->setWholeResultAllowed(true);
   }
 }
 
index 7277bfe0f3c9327dbcf541b7aed1d0fd41618c1b..44068e38394423c0a93d4a1e7e1f83fd2a6e05d4 100644 (file)
@@ -31,6 +31,8 @@
 #include <GeomAPI_PlanarEdges.h>
 #include <GeomAPI_ShapeIterator.h>
 
+#include <GeomValidators_ShapeType.h>
+
 //==================================================================================================
 void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
                                               const ListOfShape& theBaseShapes,
@@ -201,15 +203,18 @@ bool FeaturesPlugin_Tools::getShape(const AttributeSelectionListPtr theSelection
         theError = "Error: Selected sketches does not have results.";
         return false;
       }
-      int aFacesNum = aConstruction->facesNum();
+      GeomValidators_ShapeType::TypeOfShape aSelType =
+          GeomValidators_ShapeType::shapeType(theSelectionList->selectionType());
+      int aFacesNum = 0;
+      if (aSelType != GeomValidators_ShapeType::Vertex &&
+          aSelType != GeomValidators_ShapeType::Edge)
+        aFacesNum = aConstruction->facesNum();
       if(aFacesNum == 0) {
         // Probably it can be construction.
         aBaseShape = aConstruction->shape();
         if(aBaseShape.get() && !aBaseShape->isNull()) {
           GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType();
-          if(aST != GeomAPI_Shape::VERTEX && aST != GeomAPI_Shape::EDGE &&
-             aST != GeomAPI_Shape::WIRE &&
-             aST != GeomAPI_Shape::FACE && aST != GeomAPI_Shape::SHELL) {
+          if(aST == GeomAPI_Shape::SOLID || aST == GeomAPI_Shape::COMPSOLID) {
             theError = "Error: Selected shapes has unsupported type.";
             return false;
           }
index c8b96f14403b868062e04fe60793ba918360a237..6c3c1d9f77161b920c23527426c0cedaf6028577 100644 (file)
@@ -61,6 +61,8 @@
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <GeomAlgoAPI_WireBuilder.h>
 
+#include <algorithm>
+
 #define _USE_MATH_DEFINES
 #include <math.h>
 
@@ -399,9 +401,29 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
   if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aListAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+
+    const std::string& aSelType = aListAttr->selectionType();
+    std::list<std::string> anApplicableTypes;
+    switch (GeomValidators_ShapeType::shapeType(aSelType)) {
+    case GeomValidators_ShapeType::Vertex:
+      anApplicableTypes.push_back("vertex");
+      break;
+    case GeomValidators_ShapeType::Edge:
+      anApplicableTypes.push_back("edge");
+      anApplicableTypes.push_back("wire");
+      break;
+    case GeomValidators_ShapeType::Face:
+      anApplicableTypes.push_back("face");
+      anApplicableTypes.push_back("shell");
+      break;
+    default:
+      anApplicableTypes = theArguments;
+      break;
+    }
+
     for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
       // If at least one attribute is invalid, the result is false.
-      if(!isValidAttribute(aListAttr->value(anIndex), theArguments, theError)) {
+      if(!isValidAttribute(aListAttr->value(anIndex), anApplicableTypes, theError)) {
         return false;
       }
     }
@@ -441,8 +463,9 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
 
       aContextShape = aContext->shape();
       if(aShape->isEqual(aContextShape)) {
-        // Whole construction selected. Check that it have faces.
-        if(aConstruction->facesNum() > 0) {
+        // Whole construction selected. Check that it has faces.
+        if((theArguments.front() == "face" && aConstruction->facesNum() > 0) ||
+            theArguments.front() == "edge") {
           return true;
         }
       } else {
index 4b81b7eec129a702b80b7cac89d75e0cc6507b93..146837e7abcf972e5294674c95217508100937ed 100644 (file)
@@ -69,7 +69,7 @@ GeomValidators_ShapeType::TypeOfShape
     return MyShapeTypes[aType];
 
 // LCOV_EXCL_START
-  Events_InfoMessage("Shape type defined in XML is not implemented!").send();
+  //Events_InfoMessage("Shape type defined in XML is not implemented!").send();
   return AnyShape;
 // LCOV_EXCL_STOP
 }
index cc0b1c5b8f02b00454e03b897a22047cda7ffdde..3f581bc791368577e1ea26f61390433c77eca88d 100644 (file)
@@ -63,11 +63,12 @@ class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
                                              const std::list<std::string>& theArguments,
                                              Events_InfoMessage& theError) const;
-protected:
+
   /// Convert string to TypeOfShape value
   /// \param theType a string value
   GEOMVALIDATORS_EXPORT static TypeOfShape shapeType(const std::string& theType);
 
+protected:
   /// Returns true if the attibute's object type satisfies the argument value
   /// \param[in] theAttribute a checked attribute
   /// \param[in] theShapeType a type of shape