// 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
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
{
theAttribute->setValue(theValue);
}
+
+//--------------------------------------------------------------------------------------
void fillAttribute(const char * theValue,
const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
{
theAttribute->setValue(theValue);
}
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::list<std::string> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeStringArray> & 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<ModelHighAPI_Integer> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeIntArray> & 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") {
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<std::string, std::map<std::string, ModelHighAPI_FeatureStore> >& theStore,
for(; allIter != allFeatures.end(); allIter++) {
FeaturePtr aFeat = *allIter;
if (theCompare) {
- std::map<std::string, ModelHighAPI_FeatureStore>::iterator
+ std::map<std::string, ModelHighAPI_FeatureStore>::iterator
aFeatFind = aDocFind->second.find(aFeat->name());
if (aFeatFind == aDocFind->second.end()) {
return "Document '" + theDocName + "' feature '" + aFeat->name() + "' not found";
std::list<ResultPtr>::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<ModelAPI_ResultPart>(*aRes)->partDoc();
if (aDoc.get()) {
std::string anError = storeFeatures((*aRes)->data()->name(), aDoc, theStore, theCompare);
aLostName = aLostIter->first;
}
}
- return "For document '" + theDocName +
+ return "For document '" + theDocName +
"' the number of features is decreased, there is no feature '" + aLostName + "'";
}
}