Salome HOME
Task #3015 3.1. To add a mode 'through all' for features ExtrusionCut and ExtrusionFuse
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
index 2935ffb0f6b911abce66b766d8edded2ef185c74..836f33c93016d29eb194e2f6e91a8e379842d9a6 100644 (file)
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Entity.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_FiltersFeature.h>
 #include <ModelAPI_Folder.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
@@ -254,8 +256,7 @@ bool ModelHighAPI_Dumper::DumpStorage::exportTo(const std::string& theFilename,
   if (!aFile.is_open())
     return false;
 
-  // standard header (encoding + imported modules)
-  aFile << "# -*- coding: utf-8 -*-" << std::endl << std::endl;
+  // standard header imported modules
   for (ModulesSet::const_iterator aModIt = theUsedModules.begin();
     aModIt != theUsedModules.end(); ++aModIt) {
     aFile << "from " << *aModIt << " import *" << std::endl;
@@ -289,7 +290,8 @@ static void getShapeAndContext(const AttributeSelectionPtr& theAttrSelect,
     if (theAttrSelect->isGeometricalSelection() &&
         theShape.get() && theShape->shapeType() == GeomAPI_Shape::COMPOUND &&
         theContext.get() && !theShape->isEqual(theContext->shape()) &&
-        theContext->groupName() != ModelAPI_ResultPart::group()) {
+        theContext->groupName() != ModelAPI_ResultPart::group() &&
+        theContext->groupName() != ModelAPI_ResultGroup::group()) {
       GeomAPI_ShapeIterator anIt(theShape);
       theShape = anIt.current();
     }
@@ -1187,6 +1189,19 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ResultPtr& theResult)
   return *this;
 }
 
+ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::list<ResultPtr>& theResults)
+{
+  *this << "[";
+  for (std::list<ResultPtr>::const_iterator anIt = theResults.begin();
+       anIt != theResults.end(); ++anIt) {
+    if (anIt != theResults.begin())
+      *this << ", ";
+    *this << *anIt;
+  }
+  *this << "]";
+  return *this;
+}
+
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ObjectPtr& theObject)
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
@@ -1212,7 +1227,8 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const AttributePtr& theAttr
   // Check the attribute belongs to copied (in multi-translation or multi-rotation) feature.
   // In this case we need to cast explicitly feature to appropriate type.
   AttributeBooleanPtr isCopy = anOwner->boolean("Copy");
-  if (isCopy.get() && isCopy->value()) {
+  AttributeReferencePtr hasParent = anOwner->reference("ParentFeature");
+  if ((isCopy.get() && isCopy->value()) || (hasParent && hasParent->value())) {
     aWrapperPrefix = featureWrapper(anOwner) + "(";
     aWrapperSuffix = ")";
     importModule("SketchAPI");
@@ -1341,6 +1357,14 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
       *this << anAttribute;
     }
 
+    // check selection list is obtained by filters
+    FiltersFeaturePtr aFilters = theAttrSelList->filters();
+    if (aFilters) {
+      if (theAttrSelList->size() > 0)
+        *myDumpStorage << ", ";
+      dumpFeature(aFilters, true);
+    }
+
     *myDumpStorage << "]";
   } else {
     // obtain name of list (the feature may contain several selection lists)