Salome HOME
Issue #1865: Create a field
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
index 2216f59f537b4cc0e4bf1650292e131140097308..1ea7a1f828e4610628a38eba8d95e4238f50a1f4 100644 (file)
@@ -28,6 +28,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Entity.h>
@@ -230,13 +231,13 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theD
     CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aFeatIt);
     if (aCompFeat) // iteratively process composite features
       isOk = process(aCompFeat) && isOk;
-    else if (!isDumped(*aFeatIt)) // dump common feature 
+    else if (!isDumped(*aFeatIt)) // dump common feature
       dumpFeature(*aFeatIt);
   }
   return isOk;
 }
 
-bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite, 
+bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
                                   bool isForce)
 {
   // increase composite features stack
@@ -351,7 +352,7 @@ bool ModelHighAPI_Dumper::exportTo(const std::string& theFileName)
   for (ModulesMap::const_iterator aModIt = myModules.begin();
        aModIt != myModules.end(); ++aModIt) {
     aFile << "from " << aModIt->first << " import ";
-    if (aModIt->second.empty() || 
+    if (aModIt->second.empty() ||
         aModIt->second.find(std::string()) != aModIt->second.end())
       aFile << "*"; // import whole module
     else {
@@ -426,7 +427,7 @@ void ModelHighAPI_Dumper::dumpEntitySetName()
     }
     // set result deflection
     if (!isDefaultDeflection(*aResIt)) {
-      AttributeDoublePtr aDeflectionAttr = 
+      AttributeDoublePtr aDeflectionAttr =
         (*aResIt)->data()->real(ModelAPI_Result::DEFLECTION_ID());
       if(aDeflectionAttr.get() && aDeflectionAttr->isInitialized()) {
         *this << *aResIt;
@@ -646,13 +647,19 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ResultPtr& theResult)
   FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
   int anIndex = 0;
   std::list<ResultPtr> aResults = aFeature->results();
-  for(std::list<ResultPtr>::const_iterator 
+  for(std::list<ResultPtr>::const_iterator
       anIt = aResults.cbegin(); anIt != aResults.cend(); ++anIt, ++anIndex) {
     if(theResult->isSame(*anIt)) {
       break;
     }
   }
-  myDumpBuffer << name(aFeature) << ".result()[" << anIndex << "]";
+
+  myDumpBuffer << name(aFeature);
+  if(anIndex == 0) {
+    myDumpBuffer << ".result()";
+  } else {
+    myDumpBuffer << ".results()[" << anIndex << "]";
+  }
   return *this;
 }
 
@@ -788,7 +795,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     return *this;
   }
 
-  myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" << 
+  myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" <<
     theAttrSelect->namingName() << "\")";
   return *this;
 }
@@ -819,7 +826,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     } else {
       isAdded = true;
     }
-    myDumpBuffer << "model.selection(\"" << 
+    myDumpBuffer << "model.selection(\"" <<
       aShape->shapeTypeStr() << "\", \"" << anAttribute->namingName() << "\")";
   }
 
@@ -827,8 +834,22 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
   return *this;
 }
 
+ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
+  const std::shared_ptr<ModelAPI_AttributeStringArray>& theArray)
+{
+  myDumpBuffer<<"[";
+  for(int anIndex = 0; anIndex < theArray->size(); ++anIndex) {
+    if (anIndex != 0)
+      myDumpBuffer<<", ";
+
+    myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
+  }
+
+  myDumpBuffer<<"]";
+  return *this;
+}
+
 /// Dump std::endl
-MODELHIGHAPI_EXPORT
 ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
                                 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
 {