1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0023911: Invalid output of command Xdump

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
This commit is contained in:
apn 2014-10-23 14:42:17 +04:00 committed by bugmaster
parent e21b2bc603
commit 0cc44c4730
6 changed files with 71 additions and 37 deletions

View 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

View 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<<") ";
}
}

View 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;
}

View File

@ -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 "================"

View File

@ -1,5 +1,3 @@
puts "TODO ?OCC23047 ALL: Tcl Exception: can't read"
puts "TODO ?OCC23047 ALL: TEST INCOMPLETE"
puts "================"
puts "OCC23047"
puts "================"

35
tests/bugs/xde/bug23911 Executable file
View File

@ -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"
}