Salome HOME
Customize behavior of RestoreShape() function - to optionally suppress its dumping...
authorvsr <vsr@opencascade.com>
Tue, 24 Jan 2017 12:55:19 +0000 (15:55 +0300)
committervsr <vsr@opencascade.com>
Tue, 24 Jan 2017 12:55:19 +0000 (15:55 +0300)
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
src/GEOM_SWIG/geomBuilder.py

index 6b12c9bf2efa71826ffed4578e29ec2e4d024dea..8da09ad37d9c11d115763ee844412dd35e68bdd2 100644 (file)
@@ -235,8 +235,15 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::RestoreShape (std::istringstream
   //See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
   //GEOM::TPythonDump(aFunction) << "#";
 
-  GEOM::TPythonDump(aFunction) << result
+  bool ignore = false;
+
+  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";
+  }
 
   SetErrorCode(OK);
 
index b46ff1c6640249fec600b18e7f8094c24f1faf8f..197429e4eb51bb90d7c30bd0290a3f34ed0101ef 100644 (file)
@@ -11684,8 +11684,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             return self.ImportFile(theFileName, theFormatName, theName)
 
         ## Read a shape from the binary stream, containing its bounding representation (BRep).
-        #  @note This method will not be dumped to the python script by DumpStudy functionality.
-        #  @note GEOM.GEOM_Object.GetShapeStream() method can be used to obtain the shape's BRep stream.
+        #
+        #  @note As the byte-stream representing the shape data can be quite large, this method
+        #  is not automatically dumped to the Python script with the DumpStudy functionality;
+        #  so please use this method carefully, only for strong reasons.
+        #  
+        #  @note GEOM.GEOM_Object.GetShapeStream() method can be used to obtain the shape's
+        #  data stream.
+        #
         #  @param theStream The BRep binary stream.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
@@ -11712,6 +11718,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 New GEOM_Object, containing the shape, read from theStream.
             """
             # Example: see GEOM_TestOthers.py
+            if not theStream:
+                # this is the workaround to ignore invalid case when data stream is empty
+                if int(os.getenv("GEOM_IGNORE_RESTORE_SHAPE", "0")) > 0:
+                    print "WARNING: Result of RestoreShape is a NULL shape!"
+                    return None
             anObj = self.InsertOp.RestoreShape(theStream)
             RaiseIfFailed("RestoreShape", self.InsertOp)
             self._autoPublish(anObj, theName, "restored")