Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomValidators / GeomValidators_ShapeType.cpp
index 963f53c9a12cc8851eae20fac69e1af0cd8aba68..98b1ba18b235907f7f54d943158761e73bdb59f9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  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
@@ -33,6 +33,7 @@
 
 #include <Events_InfoMessage.h>
 
+#include <algorithm>
 #include <string>
 #include <map>
 
@@ -46,23 +47,29 @@ GeomValidators_ShapeType::TypeOfShape
   if (MyShapeTypes.size() == 0) {
     MyShapeTypes["empty"]     = Empty;
     MyShapeTypes["vertex"]    = Vertex;
+    MyShapeTypes["vertices"]  = Vertex;
     MyShapeTypes["edge"]      = Edge;
+    MyShapeTypes["edges"]     = Edge;
     MyShapeTypes["line"]      = Line;
     MyShapeTypes["circle"]    = Circle;
     MyShapeTypes["wire"]      = Wire;
     MyShapeTypes["face"]      = Face;
+    MyShapeTypes["faces"]     = Face;
     MyShapeTypes["plane"]     = Plane;
     MyShapeTypes["shell"]     = Shell;
     MyShapeTypes["solid"]     = Solid;
+    MyShapeTypes["solids"]    = Solid;
     MyShapeTypes["compsolid"] = CompSolid;
     MyShapeTypes["compound"]  = Compound;
   }
   std::string aType = std::string(theType.c_str());
+  std::transform(aType.begin(), aType.end(), aType.begin(),
+                 [](char c) { return static_cast<char>(::tolower(c)); });
   if (MyShapeTypes.find(aType) != MyShapeTypes.end())
     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
 }
@@ -75,11 +82,11 @@ std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape&
   if (MyShapeTypes.size() != 0) {
     std::map<std::string, GeomValidators_ShapeType::TypeOfShape>::const_iterator
       anIt = MyShapeTypes.begin(), aLast = MyShapeTypes.end();
-    for (; anIt != aLast; anIt++) {
-      if (anIt->second == theType)
+    for (; anIt != aLast; anIt++)
+      if (anIt->second == theType) {
         aValue = anIt->first;
         break;
-    }
+      }
   }
   return aValue;
 }
@@ -107,9 +114,8 @@ bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
   }
   if (!aValid && theError.empty()) {
     std::string aTypes;
-    std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
     // returns true if the attribute satisfies at least one of given arguments
-    for (; anIt != aLast; anIt++) {
+    for (anIt = theArguments.begin(); anIt != aLast; anIt++) {
       if (!aTypes.empty())
         aTypes += ", ";
       aTypes += *anIt;
@@ -163,16 +169,18 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
         theError = "It has reference to an empty attribute";
       }
       else {
-        std::string anAttributeType = aRefAttr->attributeType();
-        aValid = anAttributeType == GeomDataAPI_Point2D::typeId();
+        std::string anAttrType = aRefAttr->attributeType();
+        aValid = anAttrType == GeomDataAPI_Point2D::typeId();
         if (!aValid) {
 // LCOV_EXCL_START
           theError = "Shape type is \"%1\", it should be \"%2\"";
-          theError.arg(anAttributeType).arg(getShapeTypeDescription(theShapeType));
+          theError.arg(anAttrType).arg(getShapeTypeDescription(theShapeType));
 // LCOV_EXCL_STOP
         }
       }
     }
+    else
+      aValid = false;
   }
   else if (anAttributeType == ModelAPI_AttributeReference::typeId()) {
     AttributeReferencePtr anAttr =