Salome HOME
Issue #1739: Naming on faces not correct
[modules/shaper.git] / src / GeomValidators / GeomValidators_ShapeType.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 9b7df36..4991b92
@@ -13,7 +13,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeReference.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <string>
 #include <map>
@@ -25,20 +25,24 @@ static EdgeTypes MyShapeTypes;
 GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const std::string& theType)
 {
   if (MyShapeTypes.size() == 0) {
-    MyShapeTypes["empty"]  = Empty;
-    MyShapeTypes["vertex"] = Vertex;
-    MyShapeTypes["edge"]   = Edge;
-    MyShapeTypes["line"]   = Line;
-    MyShapeTypes["circle"] = Circle;
-    MyShapeTypes["face"]   = Face;
-    MyShapeTypes["solid"]  = Solid;
-    MyShapeTypes["plane"]  = Plane;
+    MyShapeTypes["empty"]     = Empty;
+    MyShapeTypes["vertex"]    = Vertex;
+    MyShapeTypes["edge"]      = Edge;
+    MyShapeTypes["line"]      = Line;
+    MyShapeTypes["circle"]    = Circle;
+    MyShapeTypes["wire"]      = Wire;
+    MyShapeTypes["face"]      = Face;
+    MyShapeTypes["plane"]     = Plane;
+    MyShapeTypes["shell"]     = Shell;
+    MyShapeTypes["solid"]     = Solid;
+    MyShapeTypes["compsolid"] = CompSolid;
+    MyShapeTypes["compound"]  = Compound;
   }
   std::string aType = std::string(theType.c_str());
   if (MyShapeTypes.find(aType) != MyShapeTypes.end())
     return MyShapeTypes[aType];
-  
-  Events_Error::send("Shape type defined in XML is not implemented!");
+
+  Events_InfoMessage("Shape type defined in XML is not implemented!").send();
   return AnyShape;
 }
 
@@ -60,7 +64,7 @@ std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape&
 
 bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
                                        const std::list<std::string>& theArguments,
-                                       std::string& theError) const
+                                       Events_InfoMessage& theError) const
 {
   bool aValid = false;
 
@@ -86,8 +90,8 @@ bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
       if (!aTypes.empty())
         aTypes += ", ";
     }
-    theError = "It does not contain element with acceptable shape type. The type should be one of the next: "
-               + aTypes;
+    theError = "It does not contain element with acceptable shape type. The type should be one of the next: %1";
+    theError.arg(aTypes);
   }
 
   return aValid;
@@ -95,7 +99,7 @@ bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
 
 bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute,
                                                 const TypeOfShape theShapeType,
-                                                std::string& theError) const
+                                                Events_InfoMessage& theError) const
 {
   bool aValid = true;
 
@@ -122,9 +126,10 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
       else {
         std::string anAttributeType = aRefAttr->attributeType();
         aValid = anAttributeType == GeomDataAPI_Point2D::typeId();
-        if (!aValid)
-          theError = "Shape type is \"" + anAttributeType +
-                     "\", it should be \"" + getShapeTypeDescription(theShapeType) + "\"";
+        if (!aValid) {
+          theError = "Shape type is \"%1\", it should be \"%2\"";
+          theError.arg(anAttributeType).arg(getShapeTypeDescription(theShapeType));
+        }
       }
     }
   }
@@ -149,14 +154,15 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
   }
   else {
     aValid = false;
-    theError = "The attribute with the " + anAttributeType  + " type is not processed";
+    theError = "The attribute with the %1 type is not processed";
+    theError.arg(anAttributeType);
   }
   return aValid;
 }
 
 bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
                                              const TypeOfShape theShapeType,
-                                             std::string& theError) const
+                                             Events_InfoMessage& theError) const
 {
   bool aValid = true;
   if (!theObject.get()) {
@@ -187,7 +193,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
 
 bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
                                             const TypeOfShape theShapeType,
-                                            std::string& theError) const
+                                            Events_InfoMessage& theError) const
 {
   bool aValid = true;
 
@@ -197,31 +203,40 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
   }
   else {
     switch (theShapeType) {
+    case Vertex:
+      aValid = theShape->isVertex();
+      break;
     case Edge:
       aValid = theShape->isEdge();
       break;
-      case Line:
-        aValid = theShape->isEdge() && !GeomAPI_Curve(theShape).isCircle();
+    case Line:
+      aValid = theShape->isEdge() && !GeomAPI_Curve(theShape).isCircle();
       break;
-      case Circle:
-        aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle();
+    case Circle:
+      aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle();
       break;
-      case Vertex:
-        aValid = theShape->isVertex();
+    case Wire:
+      aValid = theShape->shapeType() == GeomAPI_Shape::WIRE;
+      break;
+    case Face:
+      aValid = theShape->isFace();
+      break;
+    case Shell:
+      aValid = theShape->shapeType() == GeomAPI_Shape::SHELL;
+      break;
+    case Solid:
+      aValid = theShape->isSolid() || theShape->isCompSolid() ||
+               theShape->isCompoundOfSolids();
+      break;
+    case CompSolid:
+      aValid = theShape->shapeType() == GeomAPI_Shape::COMPSOLID;
+      break;
+    case Compound:
+      aValid = theShape->isCompound();
+      break;
+    default:
+      aValid = false;
       break;
-      case Solid:
-        aValid = theShape->isSolid() || theShape->isCompSolid() ||
-                 theShape->isCompoundOfSolids();
-        break;
-      case Face:
-        aValid = theShape->isFace();
-        break;
-      case Compound:
-        aValid = theShape->isCompound();
-        break;
-      default:
-        aValid = false;
-        break;
     }
   }
   return aValid;