Salome HOME
Issue #591 - Highlight of the first argument of constraints
[modules/shaper.git] / src / GeomValidators / GeomValidators_Face.cpp
index 821b45cb0755d58d8e11b839b9167a4817beb3d1..c8797278b42d94c15b4674c65d4233594deac427 100644 (file)
@@ -46,16 +46,26 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
     AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
                                                                  (theAttribute);
     std::shared_ptr<GeomAPI_Shape> aGeomShape = aSelectionAttr->value();
-    std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
-    if (aGeomFace.get() != NULL) {
-      switch(aFaceType) {
-          case GeomAbs_Plane:
-            aValid = aGeomFace->isPlanar();
-            break;
-          case GeomAbs_Cylinder:
-            break;
-          default:
-            break;
+    if (!aGeomShape.get()) {
+      // if the shape is empty, apply the validator to the shape of result
+      aGeomShape = aSelectionAttr->context()->shape();
+    }
+    // it is necessary to check whether the shape is face in order to set in selection a value
+    // with any type and check the type in this validator
+    // It is realized to select any object in OB and filter it in this validator (sketch plane)
+    if (aGeomShape->isFace()) {
+      std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
+      if (aGeomFace.get() != NULL) {
+        switch(aFaceType) {
+            case GeomAbs_Plane:
+              aValid = aGeomFace->isPlanar();
+              break;
+            case GeomAbs_Cylinder:
+              aValid = aGeomFace->isCylindrical();
+              break;
+            default:
+              break;
+        }
       }
     }
   }