X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Tools.cpp;h=119a0a1ebe7419fde56a05551a71a9065197b255;hb=2054879244f3323c305222c79c57d2db6a487538;hp=abb75c38bb4ba6086c27985a56d5db18f005b569;hpb=0bada2df7b7948c756effe42fe860cc1b93b77af;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index abb75c38b..119a0a1eb 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D // Name : ModelHighAPI_Tools.cpp -// Purpose: +// Purpose: // // History: // 07/06/16 - Sergey POKHODENKO - Creation of the file @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -194,18 +195,42 @@ void fillAttribute(const std::string & theValue, { theAttribute->setValue(theValue); } + +//-------------------------------------------------------------------------------------- void fillAttribute(const char * theValue, const std::shared_ptr & theAttribute) { theAttribute->setValue(theValue); } +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setValue(anIndex, *it); +} + +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array +} + //================================================================================================== GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr) { GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE; - std::transform(theShapeTypeStr.begin(), theShapeTypeStr.end(), + std::transform(theShapeTypeStr.begin(), theShapeTypeStr.end(), theShapeTypeStr.begin(), ::tolower); if(theShapeTypeStr == "compound") { @@ -260,6 +285,32 @@ GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection return aShapeType; } +//-------------------------------------------------------------------------------------- +ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr) +{ + std::string aType = theValueTypeStr; + std::transform(aType.begin(), aType.end(), aType.begin(), ::tolower); + if (aType == "boolean") + return ModelAPI_AttributeTables::BOOLEAN; + else if (aType == "integer") + return ModelAPI_AttributeTables::INTEGER; + else if (aType == "string") + return ModelAPI_AttributeTables::STRING; + return ModelAPI_AttributeTables::DOUBLE; // default +} + +//-------------------------------------------------------------------------------------- +std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType) +{ + switch(theType) { + case ModelAPI_AttributeTables::BOOLEAN: return "BOOLEAN"; + case ModelAPI_AttributeTables::INTEGER: return "INTEGER"; + case ModelAPI_AttributeTables::DOUBLE: return "DOUBLE"; + case ModelAPI_AttributeTables::STRING: return "STRING"; + } + return ""; // bad case +} + /// stores the features information, recoursively stores sub-documetns features std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, std::map >& theStore, @@ -280,7 +331,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, for(; allIter != allFeatures.end(); allIter++) { FeaturePtr aFeat = *allIter; if (theCompare) { - std::map::iterator + std::map::iterator aFeatFind = aDocFind->second.find(aFeat->name()); if (aFeatFind == aDocFind->second.end()) { return "Document '" + theDocName + "' feature '" + aFeat->name() + "' not found"; @@ -300,7 +351,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, std::list::iterator aRes = allResults.begin(); for(; aRes != allResults.end(); aRes++) { // recoursively store features of sub-documents - if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { + if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { DocumentPtr aDoc = std::dynamic_pointer_cast(*aRes)->partDoc(); if (aDoc.get()) { std::string anError = storeFeatures((*aRes)->data()->name(), aDoc, theStore, theCompare); @@ -321,7 +372,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, aLostName = aLostIter->first; } } - return "For document '" + theDocName + + return "For document '" + theDocName + "' the number of features is decreased, there is no feature '" + aLostName + "'"; } }