From 6bc36af9f0f0553dd83bcc7ad0443ff62a22bd99 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 24 Jan 2017 15:55:19 +0300 Subject: [PATCH] Customize behavior of RestoreShape() function - to optionally suppress its dumping into Python script with DumpStudy functionality. --- src/GEOMImpl/GEOMImpl_IInsertOperations.cxx | 9 ++++++++- src/GEOM_SWIG/geomBuilder.py | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index 6b12c9bf2..8da09ad37 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -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); diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index b46ff1c66..197429e4e 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -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") -- 2.39.2