X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Tools.cpp;h=119a0a1ebe7419fde56a05551a71a9065197b255;hb=2054879244f3323c305222c79c57d2db6a487538;hp=23f65ebc61497dc1e3c0066451243f2feb610068;hpb=d34842c50d5f335cca443c78910c16c54139c7d0;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 23f65ebc6..119a0a1eb 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -1,5 +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 @@ -28,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -193,18 +195,43 @@ 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(), theShapeTypeStr.begin(), ::tolower); + std::transform(theShapeTypeStr.begin(), theShapeTypeStr.end(), + theShapeTypeStr.begin(), ::tolower); if(theShapeTypeStr == "compound") { aShapeType = GeomAPI_Shape::COMPOUND; @@ -258,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, @@ -278,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"; @@ -297,7 +350,8 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, ModelAPI_Tools::allResults(aFeat, allResults); std::list::iterator aRes = allResults.begin(); for(; aRes != allResults.end(); aRes++) { - if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { // recoursively store features of sub-documents + // recoursively store features of sub-documents + 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); @@ -318,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 + "'"; } }