+ 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()) return false;
+
+ if (theProcessed.Contains(theFunction->GetEntry())) return false;
+
+ // pass functions, that depends on nonexisting ones
+ bool doNotProcess = false;
+ TDF_LabelSequence aSeq;
+ theFunction->GetDependency(aSeq);
+ Standard_Integer aLen = aSeq.Length();
+ for (Standard_Integer i = 1; i <= aLen && !doNotProcess; i++) {
+ TDF_Label aRefLabel = aSeq.Value(i);
+ Handle(TDF_Reference) aRef;
+ if (!aRefLabel.FindAttribute(TDF_Reference::GetID(), aRef)) {
+ doNotProcess = true;
+ }
+ else {
+ if (aRef.IsNull() || aRef->Get().IsNull()) {
+ doNotProcess = true;
+ }
+ else {
+ Handle(TDataStd_TreeNode) aT;
+ if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) {
+ doNotProcess = true;
+ }
+ else {
+ TDF_Label aDepLabel = aT->Label();
+ Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aDepLabel);
+
+ if (aFunction.IsNull()) doNotProcess = true;
+ else if (!theProcessed.Contains(aDepLabel)) doNotProcess = true;
+ }
+ }
+ }
+ }
+
+ if (doNotProcess) {
+ TCollection_AsciiString anObjEntry;
+ TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry);
+ theIgnoreObjs.insert(anObjEntry);
+ return false;
+ }
+ theProcessed.Add(theFunction->GetEntry());
+
+ TCollection_AsciiString aDescr = theFunction->GetDescription();
+ if(aDescr.Length() == 0) return false;
+
+ //Check if its internal function which doesn't requires 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) == '#') {
+ TCollection_AsciiString anObjEntry;
+ TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry);
+ theIgnoreObjs.insert(anObjEntry);
+ 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);
+
+ //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 );