X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_ShapeType.cpp;h=33879572d94800294b603512c7d4307ca57aaf2c;hb=bea0049157a83f382b4557fa930425e260ee6845;hp=a7638e7be7ad0e30441d7577daaf2a8b0ab9109a;hpb=e91e5875dfa825c2a382737b2fd2e7e4cb4e2acd;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp old mode 100755 new mode 100644 index a7638e7be..33879572d --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 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 @@ -12,10 +12,9 @@ // // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "GeomValidators_ShapeType.h" @@ -34,6 +33,7 @@ #include +#include #include #include @@ -47,25 +47,34 @@ 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(::tolower(c)); }); if (MyShapeTypes.find(aType) != MyShapeTypes.end()) return MyShapeTypes[aType]; - Events_InfoMessage("Shape type defined in XML is not implemented!").send(); +// 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 = ""; @@ -73,14 +82,15 @@ std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape& if (MyShapeTypes.size() != 0) { std::map::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& theArguments, @@ -104,9 +114,8 @@ bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute, } if (!aValid && theError.empty()) { std::string aTypes; - std::list::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; @@ -160,14 +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 = @@ -189,9 +202,11 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute } } 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 = ""; @@ -286,6 +301,9 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape, case Shell: aValid = theShape->shapeType() == GeomAPI_Shape::SHELL; break; + case Plane: + aValid = theShape->isPlanar(); + break; case Solid: aValid = theShape->isSolid() || theShape->isCompSolid() || theShape->isCompoundOfSolids();