Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomValidators / GeomValidators_ZeroOffset.cpp
index 4a919d0c4b6afe96dc4c0fe774509a0478fb1863..8375e1ad57f9306e968325a1a552ce7655259e59 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <GeomValidators_ZeroOffset.h>
@@ -31,6 +30,7 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Pnt.h>
 
@@ -39,23 +39,27 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
                                         const std::list<std::string>& theArguments,
                                         Events_InfoMessage& theError) const
 {
+// LCOV_EXCL_START
   if(theArguments.size() != 9) {
-    theError = "Wrong number of validator arguments in xml(expected 9).";
+    theError = "Wrong number of validator arguments in xml (expected 9).";
     return false;
   }
+// LCOV_EXCL_STOP
 
-  std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+  std::list<std::string>::const_iterator anIt = theArguments.begin();
 
   std::string aSelectedMethod;
   if(theFeature->string(*anIt)) {
     aSelectedMethod = theFeature->string(*anIt)->value();
   }
+  if (aSelectedMethod == "ThroughAll") return true;
   anIt++;
   std::string aCreationMethod = *anIt;
   anIt++;
 
   ListOfShape aFacesList;
   if(theFeature->selection(*anIt)) {
+// LCOV_EXCL_START
     AttributeSelectionPtr aFaceSelection = theFeature->selection(*anIt);
     ResultConstructionPtr aConstruction =
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceSelection->context());
@@ -69,6 +73,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
         }
       }
     }
+// LCOV_EXCL_STOP
   } else if(theFeature->selectionList(*anIt)) {
     AttributeSelectionListPtr aFacesSelectionList = theFeature->selectionList(*anIt);
     for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) {
@@ -131,6 +136,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
     if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) {
       aToShape =  anAttrSel->context()->shape();
     }
+    if (aToShape->isCompound()) {
+      GeomAPI_ShapeIterator aSIt(aToShape);
+      aToShape = aSIt.current();
+    }
   }
   anIt++;
 
@@ -146,6 +155,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
     if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) {
       aFromShape = anAttrSel->context()->shape();
     }
+    if (aFromShape->isCompound()) {
+      GeomAPI_ShapeIterator aSIt(aFromShape);
+      aFromShape = aSIt.current();
+    }
   }
   anIt++;
 
@@ -214,6 +227,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
 }
 
 //=================================================================================================
+// LCOV_EXCL_START
 bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::string theAttribute)
 {
   if(theAttribute == "from_object" || theAttribute == "to_object") {
@@ -222,3 +236,4 @@ bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::str
 
   return false;
 }
+// LCOV_EXCL_STOP