]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Added method dump for out the study's content in the file
authorsrn <srn@opencascade.com>
Wed, 6 Apr 2005 10:40:56 +0000 (10:40 +0000)
committersrn <srn@opencascade.com>
Wed, 6 Apr 2005 10:40:56 +0000 (10:40 +0000)
src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx

index cf5702b5966559c11be76351a58d46aed8177dab..9db430603ac7b1ea58705fb5c9cce38b6f3f5fe4 100644 (file)
@@ -1328,3 +1328,81 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath,
   fp.close();
   return true;
 }
+
+void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, 
+           fstream& fp, 
+           const TCollection_AsciiString& Tab,
+           const Handle(SALOMEDSImpl_Study) theStudy);
+//============================================================================
+/*! Function : dump
+ *  Purpose  : 
+ */
+//============================================================================
+void SALOMEDSImpl_Study::dump(const TCollection_AsciiString& theFileName)
+{
+  //Create a file that will contain a main Study script
+  fstream fp;
+  fp.open(theFileName.ToCString(), ios::out);  
+
+#ifdef WIN32 
+  bool isOpened = fp.is_open();
+#else
+  bool isOpened = fp.rdbuf()->is_open();
+#endif
+
+  if(!isOpened) {
+    _errorCode = TCollection_AsciiString("Can't create a file ")+theFileName;
+    cout << "### SALOMEDSImpl_Study::dump Error: " << _errorCode << endl;
+    return;    
+  }
+
+  Handle(SALOMEDSImpl_SObject) aSO = FindObjectID("0:1");
+  fp << "0:1" << endl;
+  Handle(SALOMEDSImpl_ChildIterator) Itr = NewChildIterator(aSO);
+  TCollection_AsciiString aTab("   ");
+  for(; Itr->More(); Itr->Next()) {
+    dumpSO(Itr->Value(), fp, aTab, this);
+  }
+
+  fp.close();
+}
+
+
+void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, 
+           fstream& fp, 
+           const TCollection_AsciiString& Tab,
+           const Handle(SALOMEDSImpl_Study) theStudy)
+{
+  TCollection_AsciiString aTab(Tab), anID(theSO->GetID());
+  fp << aTab << anID << endl;
+  int aLength, i;
+  Handle(TColStd_HSequenceOfTransient) aSeq = theSO->GetAllAttributes();
+  aLength = aSeq->Length();
+  for(i=1; i<=aLength; i++) {
+    Handle(SALOMEDSImpl_GenericAttribute) anAttr = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i));
+    TCollection_AsciiString aType = anAttr->GetClassType();
+    fp << Tab << "  -- " << aType;
+    if(aType == "AttributeReal") {
+      fp << " : " << Handle(SALOMEDSImpl_AttributeReal)::DownCast(anAttr)->Value();
+    }
+    else if(aType == "AttributeInteger") {
+      fp << " : " << Handle(SALOMEDSImpl_AttributeInteger)::DownCast(anAttr)->Value();
+    }
+    else if(aType ==  "AttributeName") {
+      fp << " : " << Handle(SALOMEDSImpl_AttributeName)::DownCast(anAttr)->Value();
+    }
+    else if(aType == "AttributeComment") {
+      fp << " : " << Handle(SALOMEDSImpl_AttributeComment)::DownCast(anAttr)->Value();
+    }
+    fp << endl;
+  }
+
+  Handle(SALOMEDSImpl_ChildIterator) Itr = theStudy->NewChildIterator(theSO);
+  TCollection_AsciiString aNewTab("   ");
+  aNewTab+=aTab;
+  for(; Itr->More(); Itr->Next()) {
+    dumpSO(Itr->Value(), fp, aNewTab, theStudy);
+  }
+
+  return;
+}
index 32bbe1bcb2eb205ad7b47d3f350afb5cb9de9113..2baae207f7c23ba712705f5ab0a6ecd3a58eeddc 100644 (file)
@@ -232,6 +232,8 @@ public:
 
   virtual Handle(TDocStd_Document) GetDocument() { return _doc; } 
 
+  //The method dump creates a txt file that contain a dump of the study, for debug use
+  void dump(const TCollection_AsciiString& theFileName);
 
 public:
   DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study )