]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix Shaper #2198 ExportToGeom's shape stream not being dump by GEOM RestoreShape cbr/fix_export_to_geom_dump
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 11 Jul 2017 12:11:06 +0000 (14:11 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 11 Jul 2017 12:11:06 +0000 (14:11 +0200)
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx

index 8da09ad37d9c11d115763ee844412dd35e68bdd2..05d7779547856b4e2016b42fe882b9dfb9eccae7 100644 (file)
@@ -231,18 +231,39 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::RestoreShape (std::istringstream
   //Set function value
   aFunction->SetValue(aShape);
 
-  //Special dump to avoid restored shapes publication.
-  //See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
-  //GEOM::TPythonDump(aFunction) << "#";
+  //Real dump if the stream comes from Shaper
+  std::string firstLine;
+  std::string shaperPrefix = "FromShaperExportToGeom;";
+  std::size_t shaperPrefixSize = shaperPrefix.size();
+
+  //Go back to the start of the istringstream
+  theStream.seekg(0);
+
+  //Get first line
+  std::getline(theStream, firstLine);
+  MESSAGE("firstLine: " << firstLine);
+
+  if (firstLine.substr(0, shaperPrefixSize) == shaperPrefix) {
+    //Special dump for shape stream coming from Shaper
+    std::string partName = firstLine.substr(shaperPrefixSize);
+    MESSAGE("Part from Shaper: " << partName);
+    GEOM::TPythonDump(aFunction) << result << " = geompy.RestoreShape(model.makeShape("
+    << partName.c_str() << ".document()).getShapeStream())";
+  }
+  else {
+    //Special dump to avoid restored shapes publication.
+    //See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
+    //GEOM::TPythonDump(aFunction) << "#";
 
-  bool ignore = false;
+    bool ignore = false;
 
-  if ( const char* env_var = getenv( "GEOM_IGNORE_RESTORE_SHAPE" ) )
-    ignore = atoi( env_var ) > 1;
+    if ( const char* env_var = getenv( "GEOM_IGNORE_RESTORE_SHAPE" ) )
+      ignore = atoi( env_var ) > 1;
 
-  if ( !ignore ) {
-    GEOM::TPythonDump(aFunction) << result
-    << " = geompy.RestoreShape(\"\") # the shape string has not been dump for performance reason";
+    if ( !ignore ) {
+      GEOM::TPythonDump(aFunction) << result
+      << " = geompy.RestoreShape(\"\") # the shape string has not been dump for performance reason";
+    }
   }
 
   SetErrorCode(OK);