0023911: Invalid output of command Xdump
authorapn <apn@opencascade.com>
Thu, 23 Oct 2014 10:42:17 +0000 (14:42 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 23 Oct 2014 12:20:47 +0000 (16:20 +0400)
Improved output of Xdump command using Draw_Interpretor.

Improved output of Xdump command using Standard_SStream.

OStream is used instead of SStream.

Test cases for issue CR23911

src/XCAFDoc/XCAFDoc_ShapeTool.cdl
src/XCAFDoc/XCAFDoc_ShapeTool.cxx
src/XDEDRAW/XDEDRAW.cxx
tests/bugs/xde/bug23047_1
tests/bugs/xde/bug23047_2
tests/bugs/xde/bug23911 [new file with mode: 0755]

index 6db5d84..51631c0 100644 (file)
@@ -91,8 +91,8 @@ uses
     SequenceOfHAsciiString from TColStd,
     GraphNode from XCAFDoc,
     AttributeSequence from TDF,
-    DataMapOfShapeLabel from XCAFDoc
-    
+    DataMapOfShapeLabel from XCAFDoc,
+    OStream from Standard
 is
     GetID (myclass)   
     ---C++: return const &  
@@ -369,12 +369,13 @@ is
     BaseLabel(me) returns Label from TDF;
        ---Purpose: returns the label under which shapes are stored
     
-    Dump(me; deep : Boolean from Standard = Standard_False);
+    Dump(me; theDumpLog: out OStream from Standard; deep : Boolean from Standard = Standard_False);
     
-    DumpShape(myclass; L:  Label from TDF;
+    DumpShape(myclass; theDumpLog: out OStream from Standard;
+                      L:  Label from TDF;
                       level :Integer from Standard = 0;
                       deep : Boolean from Standard = Standard_False);
-    ---Purpose: Print in cout type of shape found on <L> label
+    ---Purpose: Print to ostream <theDumpLog> type of shape found on <L> label
     --          and the entry of <L>, with <level> tabs before.
     --          If <deep>, print also TShape and Location addresses
         
index f96d65f..3a063cc 100644 (file)
@@ -1172,30 +1172,31 @@ TDF_Label XCAFDoc_ShapeTool::BaseLabel () const
 //purpose  : recursive part of Dump()
 //=======================================================================
 
-static void DumpAssembly(const TDF_Label L,
+static void DumpAssembly(Standard_OStream& theDumpLog,
+                        const TDF_Label L,
                         const Standard_Integer level,
                         const Standard_Boolean deep)
 {
   for (Standard_Integer i=0; i<level; i++)
-    cout<<"\t";
+    theDumpLog<<"\t";
   
   TCollection_AsciiString Entry;
   TDF_Tool::Entry(L, Entry);
 
-  cout<<"ASSEMBLY "<<Entry;
+  theDumpLog<<"ASSEMBLY "<<Entry;
   Handle(TDataStd_Name) Name;
   if (L.FindAttribute(TDataStd_Name::GetID(), Name))
-    cout<<" "<<Name->Get();
+    theDumpLog<<" "<<Name->Get();
   
   if (deep) {
     TopoDS_Shape S;
     XCAFDoc_ShapeTool::GetShape(L, S);
-    cout<<"("<<*(void**)&S.TShape();
+    theDumpLog<<"("<<*(void**)&S.TShape();
     if (! S.Location().IsIdentity())
-      cout<<", "<< *(void**)&S.Location();
-    cout<<") ";
+      theDumpLog<<", "<< *(void**)&S.Location();
+    theDumpLog<<") ";
   }
-  cout<<endl;
+  theDumpLog<<endl;
   
   Handle(TDataStd_TreeNode) Node;
   TDF_ChildIDIterator NodeIterator(L, XCAFDoc::ShapeRefGUID());
@@ -1203,10 +1204,10 @@ static void DumpAssembly(const TDF_Label L,
     Node = Handle(TDataStd_TreeNode)::DownCast(NodeIterator.Value());
     if (Node->HasFather()) {
       if (Node->Father()->Label().HasChild())
-       DumpAssembly(Node->Father()->Label(), level+1, deep);
+       DumpAssembly(theDumpLog, Node->Father()->Label(), level+1, deep);
       else {
-       XCAFDoc_ShapeTool::DumpShape(Node->Father()->Label(), level+1, deep);
-         cout<<endl;
+       XCAFDoc_ShapeTool::DumpShape(theDumpLog, Node->Father()->Label(), level+1, deep);
+         theDumpLog<<endl;
        }
     }
   }
@@ -1217,25 +1218,25 @@ static void DumpAssembly(const TDF_Label L,
 //purpose  : 
 //=======================================================================
 
-void XCAFDoc_ShapeTool::Dump(const Standard_Boolean deep) const
+void XCAFDoc_ShapeTool::Dump(Standard_OStream& theDumpLog, const Standard_Boolean deep) const
 {
   Standard_Integer level = 0;
 //   TopTools_SequenceOfShape SeqShapes;
   TDF_LabelSequence SeqLabels;
   GetShapes( SeqLabels);
 
-  if (SeqLabels.Length()>0) cout<<endl;
+  if (SeqLabels.Length()>0) theDumpLog<<endl;
   Standard_Integer i;
   for (i=1; i<=SeqLabels.Length(); i++) {
-    DumpAssembly(SeqLabels.Value(i), level, deep);
+    DumpAssembly(theDumpLog, SeqLabels.Value(i), level, deep);
   }
 
   SeqLabels.Clear();
   GetFreeShapes(SeqLabels);
-  cout<<endl<<"Free Shapes: "<<SeqLabels.Length()<<endl;
+  theDumpLog<<endl<<"Free Shapes: "<<SeqLabels.Length()<<endl;
   for (i = 1; i<=SeqLabels.Length(); i++) {
-    DumpShape(SeqLabels.Value(i), level, deep);
-    cout<<endl;
+    DumpShape(theDumpLog, SeqLabels.Value(i), level, deep);
+    theDumpLog<<endl;
   }
 }
 
@@ -1244,29 +1245,29 @@ void XCAFDoc_ShapeTool::Dump(const Standard_Boolean deep) const
 //purpose  : 
 //=======================================================================
 
-void XCAFDoc_ShapeTool::DumpShape(const TDF_Label& L,const Standard_Integer level,const Standard_Boolean deep) 
+void XCAFDoc_ShapeTool::DumpShape(Standard_OStream& theDumpLog, const TDF_Label& L,const Standard_Integer level,const Standard_Boolean deep)
 {
   TopoDS_Shape S;
   if(! XCAFDoc_ShapeTool::GetShape(L, S) ) return;
   for (Standard_Integer i=0; i<level; i++)
-    cout<<"\t";
+    theDumpLog<<"\t";
   
-  if (S.ShapeType() == TopAbs_COMPOUND) cout<<"ASSEMBLY";
-  else TopAbs::Print(S.ShapeType(), cout);
+  if (S.ShapeType() == TopAbs_COMPOUND) theDumpLog<<"ASSEMBLY";
+  else TopAbs::Print(S.ShapeType(), theDumpLog);
   
   TCollection_AsciiString Entry;
   TDF_Tool::Entry(L, Entry);
-  cout<<"  "<<Entry;
+  theDumpLog<<"  "<<Entry;
   //cout<<endl;
   Handle(TDataStd_Name) Name;
   if (L.FindAttribute(TDataStd_Name::GetID(),Name)) 
-    cout<<" "<<Name->Get();
+    theDumpLog<<" "<<Name->Get();
   
   if (deep) {
-    cout<<"("<<*(void**)&S.TShape();
+    theDumpLog<<"("<<*(void**)&S.TShape();
     if (! S.Location().IsIdentity())
-      cout<<", "<< *(void**)&S.Location();
-    cout<<") ";
+      theDumpLog<<", "<< *(void**)&S.Location();
+    theDumpLog<<") ";
   }
 }
 
index aadc90f..7f87d1d 100644 (file)
@@ -225,7 +225,9 @@ static Standard_Integer dump (Draw_Interpretor& di, Standard_Integer argc, const
   Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
   Standard_Boolean deep = Standard_False;
   if ( (argc==3) && (Draw::Atoi(argv[2])==1) ) deep = Standard_True;
-  myAssembly->Dump(deep);
+  Standard_SStream aDumpLog;
+  myAssembly->Dump(aDumpLog, deep);
+  di<<aDumpLog;
   return 0;
 }
 
index 76d5b6c..3c67e9c 100755 (executable)
@@ -1,6 +1,3 @@
-puts "TODO ?OCC23047 ALL: Tcl Exception: can't read"
-puts "TODO ?OCC23047 ALL: Faulty OCC23047"
-puts "TODO ?OCC23047 ALL: TEST INCOMPLETE"
 puts "================"
 puts "OCC23047"
 puts "================"
index 6494c02..8fa3f30 100755 (executable)
@@ -1,5 +1,3 @@
-puts "TODO ?OCC23047 ALL: Tcl Exception: can't read"
-puts "TODO ?OCC23047 ALL: TEST INCOMPLETE"
 puts "================"
 puts "OCC23047"
 puts "================"
diff --git a/tests/bugs/xde/bug23911 b/tests/bugs/xde/bug23911
new file mode 100755 (executable)
index 0000000..82bced5
--- /dev/null
@@ -0,0 +1,35 @@
+puts "============"
+puts "OCC23911"
+puts "============"
+puts ""
+#######################################################################
+# Invalid output of command Xdump
+#######################################################################
+
+XNewDoc D
+box b 1 1 1
+ttranslate b 1 0 0
+XAddShape D b
+
+set Log [Xdump D]
+
+set status 0
+
+if {[llength ${Log}] < 1} {
+   puts "Error: Invalid output of command Xdump"
+   set status 1
+}
+
+if { [regexp "ASSEMBLY" ${Log}] != 1 } {
+   puts "Error: Invalid output of command Xdump"
+   set status 1
+}
+
+if { [regexp "SOLID" ${Log}] != 1 } {
+   puts "Error: Invalid output of command Xdump"
+   set status 1
+}
+
+if { ${status} == 0 } {
+   puts "OK: Good output of command Xdump"
+}