+ return aNewDescr;
+}
+
+//=============================================================================
+/*!
+ * ProcessFunction: Dump function description into script
+ */
+//=============================================================================
+bool ProcessFunction(Handle(GEOM_Function)& theFunction,
+ TCollection_AsciiString& theScript,
+ TCollection_AsciiString& theAfterScript,
+ const TVariablesList& theVariables,
+ const bool theIsPublished,
+ TDF_LabelMap& theProcessed,
+ std::set<TCollection_AsciiString>& theIgnoreObjs,
+ bool& theIsDumpCollected)
+{
+ theIsDumpCollected = false;
+
+ if (theFunction.IsNull()) {
+ MESSAGE("Can't process a null function! Return.");
+ return false;
+ }
+
+ TCollection_AsciiString aDescr = theFunction->GetDescription();
+ MESSAGE("The function description: " << aDescr);
+
+ if (theProcessed.Contains(theFunction->GetEntry()))
+ return false;
+
+ // Check if a given function depends on nonexisting ones
+ const FunctionProcessType funcProcessType = GetFunctionProcessingType(theFunction, theProcessed, aDescr);
+ switch (funcProcessType)
+ {
+ case TO_PROCESS:
+ // Just process it
+ break;
+
+ case NOT_PROCESS:
+ {
+ // We don't need this function and its object in a dump
+ AddFuncObjectToIgnored(theFunction, theIgnoreObjs);
+ return false;
+ }
+
+ case UPDATE_DESCRIPTION:
+ // Edge case for a function that was dumped from Python.
+ // Get rid of the parent function description.
+ UpdateFuncFromPythonDescription(aDescr);
+ // A result object is already added by an algo script, then
+ // if we keep it in the dump it will be added twice on the script loading.
+ AddFuncObjectToIgnored(theFunction, theIgnoreObjs);
+ break;
+
+ default:
+ MESSAGE("Wrong type of the function processing!" << funcProcessType);
+ break;
+ }
+
+ theProcessed.Add(theFunction->GetEntry());
+
+ // Check the length only after its fucntion was added to the processed!
+ if(!aDescr.Length())
+ return false;
+
+ // Check if it's an internal function which doesn't require dumping
+ if(aDescr == "None")
+ return false;
+
+ //Check the very specific case of RestoreShape function,
+ //which is not dumped, but the result can be published by the user.
+ //We do not publish such objects to decrease danger of dumped script failure.
+ if(aDescr.Value(1) == '#') {
+ AddFuncObjectToIgnored(theFunction, theIgnoreObjs);
+ return false;
+ }
+
+ // 0020001 PTv, check for critical functions, which require dump of objects
+ if (theIsPublished)
+ {
+ // currently, there is only one function "RestoreGivenSubShapes",
+ // later this check could be replaced by iterations on list of such functions
+ if (aDescr.Search( "RestoreGivenSubShapes" ) != -1)
+ theIsDumpCollected = true;
+ else if (aDescr.Search( "RestoreSubShapes" ) != -1)
+ theIsDumpCollected = true;
+ }
+
+ //Replace parameter by notebook variables
+ ReplaceVariables(aDescr,theVariables);
+ // Check description, because we could lose entire command during variable processing
+ if (aDescr.IsEmpty())
+ return false;
+
+ //Process sketcher functions, replacing string command by calls to Sketcher interface
+ if ( ( aDescr.Search( "MakeSketcherOnPlane" ) != -1 ) || ( aDescr.Search( "MakeSketcher" ) != -1 ) ) {
+ Sketcher_Profile aProfile( aDescr.ToCString());
+ // Make new command for SketcherOnPlane and for Sketcher
+ aDescr = aProfile.GetDump();
+ }
+ if (aDescr.Search( "Make3DSketcher" ) != -1) {
+ aDescr = MakeCommandfor3DSketcher ( aDescr );