-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// 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_ShapeType.h"
#include <Events_InfoMessage.h>
+#include <algorithm>
#include <string>
#include <map>
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(), ::tolower);
if (MyShapeTypes.find(aType) != MyShapeTypes.end())
return MyShapeTypes[aType];
+// LCOV_EXCL_START
Events_InfoMessage("Shape type defined in XML is not implemented!").send();
return AnyShape;
+// LCOV_EXCL_STOP
}
+// LCOV_EXCL_START
std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape& theType)
{
std::string aValue = "";
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;
}
+// LCOV_EXCL_STOP
bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string anAttributeType = aRefAttr->attributeType();
aValid = anAttributeType == GeomDataAPI_Point2D::typeId();
if (!aValid) {
+// LCOV_EXCL_START
theError = "Shape type is \"%1\", it should be \"%2\"";
theError.arg(anAttributeType).arg(getShapeTypeDescription(theShapeType));
+// LCOV_EXCL_STOP
}
}
}
}
}
else {
+// LCOV_EXCL_START
aValid = false;
theError = "The attribute with the %1 type is not processed";
theError.arg(anAttributeType);
+// LCOV_EXCL_STOP
}
if (aValid)
theError = "";
case Shell:
aValid = theShape->shapeType() == GeomAPI_Shape::SHELL;
break;
+ case Plane:
+ aValid = theShape->isPlanar();
+ break;
case Solid:
aValid = theShape->isSolid() || theShape->isCompSolid() ||
theShape->isCompoundOfSolids();