0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IGESData / IGESData_IGESDumper.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
15#include <IGESData_ColorEntity.hxx>
16#include <IGESData_IGESDumper.hxx>
17#include <IGESData_IGESEntity.hxx>
18#include <IGESData_IGESModel.hxx>
19#include <IGESData_LabelDisplayEntity.hxx>
20#include <IGESData_LevelListEntity.hxx>
21#include <IGESData_LineFontEntity.hxx>
22#include <IGESData_Protocol.hxx>
7fd59977 23#include <IGESData_SpecificLib.hxx>
24#include <IGESData_SpecificModule.hxx>
c04c30b3 25#include <IGESData_TransfEntity.hxx>
26#include <IGESData_ViewKindEntity.hxx>
42cf5bc1 27#include <Interface_EntityIterator.hxx>
28#include <Interface_InterfaceError.hxx>
29#include <Interface_Macros.hxx>
30#include <Interface_MSG.hxx>
42cf5bc1 31#include <TCollection_HAsciiString.hxx>
7fd59977 32
b311480e 33IGESData_IGESDumper::IGESData_IGESDumper
7fd59977 34 (const Handle(IGESData_IGESModel)& model,
35 const Handle(IGESData_Protocol)& protocol)
36 : thelib (protocol)
37 { themodel = model; }
38
39
40 void IGESData_IGESDumper::PrintDNum
0ebe5b0a 41 (const Handle(IGESData_IGESEntity)& ent, Standard_OStream& S) const
7fd59977 42{
43// Affichage garanti sur 12 caracteres 12345/D24689
44 Standard_Integer num = 0;
45 if (!ent.IsNull()) {
0ebe5b0a 46 if (themodel.IsNull()) S <<" D??? ";
47 else if ( (num = themodel->Number(ent)) == 0) S <<" 0:D?????";
9775fa61 48// throw Interface_InterfaceError("IGESDumper : PrintDNum");
7fd59977 49 else {
0ebe5b0a 50 S <<Interface_MSG::Blanks(num,9)<<num<<":D"<<2*num-1<<Interface_MSG::Blanks(2*num-1,9);
7fd59977 51 }
52 }
0ebe5b0a 53 else S <<" D0(Null) ";
7fd59977 54}
55
56 void IGESData_IGESDumper::PrintShort
0ebe5b0a 57 (const Handle(IGESData_IGESEntity)& ent, Standard_OStream& S) const
7fd59977 58{
59// PrintDNum(ent,S);
60 if (!ent.IsNull()) {
61 Standard_Integer num = 0;
62 if (!themodel.IsNull()) num = themodel->Number(ent);
0ebe5b0a 63 if (num > 0) S <<num<<":D"<<2*num-1;
7fd59977 64 S << " Type:" << ent->TypeNumber() << " Form:" << ent->FormNumber()
65 << Interface_MSG::Blanks (ent->FormNumber(),3)
66 << " Class:"<< Interface_InterfaceModel::ClassName(ent->DynamicType()->Name());
67 }
68}
69
70
71 void IGESData_IGESDumper::Dump
0ebe5b0a 72 (const Handle(IGESData_IGESEntity)& ent, Standard_OStream& S,
7fd59977 73 const Standard_Integer own, const Standard_Integer attached) const
74{
75 Standard_Integer att = attached;
76 Standard_Integer diratt = 1;
77 if (own < 3) diratt = own - 1;
78 if (att == 0) att = diratt; // -1 signifie : ne rien sortir
79
80 if (own < 0) return;
0ebe5b0a 81
82 if (own > 1) S <<"\n";
83 if (ent.IsNull()) { S <<"(Null)"; if (own > 1) S <<"\n"; return; }
7fd59977 84 if (own == 0) { PrintDNum (ent,S); return; } // affichage auxiliaire
85 if (own == 1) { PrintShort (ent,S); return; } // affichage auxiliaire
86
0ebe5b0a 87 if (own > 0) S <<"**** Dump IGES, level "<<own<<" ( ";
7fd59977 88 switch (own) {
89 case 0 : break;
0ebe5b0a 90 case 1 : S <<"D.E. Number + Type + Name"; break;
91 case 2 : S <<"D.E. Number + Type, Name + Transf, View"; break;
92 case 3 : S <<"Complete Directory Part"; break;
93 case 4 : S <<"Directory Part + Parameters, no Arrays"; break;
94 case 5 : S <<"Complete"; break;
95 default : S <<"Complete + Transformed Values"; break;
7fd59977 96 }
0ebe5b0a 97 S <<" ) ****\n";
7fd59977 98
99// **** Entity 1234:D2467 ** Type:102 Form:56 ** CompositeCurve **
0ebe5b0a 100 S <<"\n**** Entity "; PrintShort (ent,S); S << "\n";
7fd59977 101
0ebe5b0a 102 S <<" Directory Part\n";
7fd59977 103// ** Status : Blank:1 Subordinate:2 UseFlag:3 Hierarchy:4
104 if (own >= 2)
105 S <<"** Status Number : Blank:"<<ent->BlankStatus()
106 <<" Subordinate:"<<ent->SubordinateStatus()
107 <<" UseFlag:"<<ent->UseFlag()
108 <<" Hierarchy:"<<ent->HierarchyStatus()<<"\n";
109 if (own >= 1) {
0ebe5b0a 110 if (ent->HasShortLabel()) S <<"**** Label :"<<ent->ShortLabel()->ToCString();
111 if (ent->HasSubScriptNumber()) S <<" SubScript:"<<ent->SubScriptNumber();
112 if (ent->HasShortLabel()) S <<std::endl;
7fd59977 113
114 if (ent->HasTransf())
0ebe5b0a 115 { S <<"** Transf.Matrix :"; PrintDNum(ent->Transf(),S); S <<"\n"; }
7fd59977 116 IGESData_DefList viewkind = ent->DefView();
117 if (viewkind == IGESData_DefOne)
0ebe5b0a 118 { S <<"** View :"; PrintDNum (ent->View(),S); S <<"\n"; }
7fd59977 119 if (viewkind == IGESData_DefSeveral)
0ebe5b0a 120 { S <<"** View (List) :"; PrintDNum (ent->ViewList(),S); S <<"\n"; }
7fd59977 121
122 }
123
124 if (own >= 2) {
125
126 if (ent->HasStructure())
0ebe5b0a 127 { S <<"** Structure :"; PrintDNum (ent->Structure(),S); S <<"\n"; }
7fd59977 128
0ebe5b0a 129 S <<"\n Graphic Attributes\n";
7fd59977 130 if (ent->DefLineFont() == IGESData_DefValue)
0ebe5b0a 131 { S <<"** LineFont Value:"<<ent->RankLineFont()<<"\n"; }
7fd59977 132 else if (ent->DefLineFont() == IGESData_DefReference)
0ebe5b0a 133 { S <<"** LineFont Ref :"; PrintDNum (ent->LineFont(),S); S <<"\n"; }
7fd59977 134
0ebe5b0a 135 if (ent->Level() > 0) S <<"** Level Value :"<<ent->Level()<<"\n";
7fd59977 136 else if (ent->Level() < 0)
0ebe5b0a 137 { S <<"** Level List :"; PrintDNum(ent->LevelList(),S); S <<"\n"; }
7fd59977 138
139 if (ent->HasLabelDisplay())
0ebe5b0a 140 { S <<"** Label Display :"; PrintDNum (ent->LabelDisplay(),S); S <<"\n"; }
7fd59977 141 if (ent->LineWeightNumber() != 0) {
0ebe5b0a 142 S <<"** LineWeight Num:"<<ent->LineWeightNumber();
143 if (diratt > 0) S <<" -> Value:"<<ent->LineWeight();
144 S <<std::endl;
7fd59977 145 }
146 if (ent->DefColor() == IGESData_DefValue)
0ebe5b0a 147 { S <<"** Color Value :"<<ent->RankColor(); }
7fd59977 148 else if (ent->DefColor() == IGESData_DefReference)
0ebe5b0a 149 { S <<"** Color Ref :"; PrintDNum (ent->Color(),S); }
150 S <<std::endl;
7fd59977 151
152 if (own > 3) {
0ebe5b0a 153 S <<"**** Own Data ****\n\n";
7fd59977 154 OwnDump(ent,S,own);
155 }
156 }
157
158// Donnees attachees : Properties, Associativities, et Sharings
159 if (att < 0) return;
160 Interface_EntityIterator iter = ent->Properties();
161 Standard_Integer nb = iter.NbEntities();
162 Standard_Boolean iasuit = (nb > 0);
163 if (nb > 0) {
0ebe5b0a 164 S <<"\n**** Properties (nb:"<<nb<<") ****\n";
7fd59977 165 for (;iter.More(); iter.Next()) {
166 DeclareAndCast(IGESData_IGESEntity,ent2,iter.Value());
167 Dump (ent2,S,att,-1);
168 }
169 }
170 iter = ent->Associativities();
171 nb = iter.NbEntities();
172 if (nb > 0) iasuit = Standard_True;
173 if (nb > 0) {
0ebe5b0a 174 S <<"\n**** Associativities (nb:"<<nb<<") ****\n";
7fd59977 175 for (;iter.More(); iter.Next()) {
176 DeclareAndCast(IGESData_IGESEntity,ent2,iter.Value());
177 Dump(ent2,S,att,-1);
178 }
179 }
180 if (iasuit) { if (att <= 1) S << "\n"; }
0ebe5b0a 181 S <<"\n**** End of Dump ****\n"<<std::endl;
7fd59977 182}
183
184
185
186 void IGESData_IGESDumper::OwnDump
0ebe5b0a 187 (const Handle(IGESData_IGESEntity)& ent, Standard_OStream& S,
7fd59977 188 const Standard_Integer own) const
189{
190 Handle(IGESData_SpecificModule) module; Standard_Integer CN;
191 if (thelib.Select(ent,module,CN))
192 module->OwnDump(CN,ent,*this,S,own);
193 else if (themodel.IsNull())
0ebe5b0a 194 S <<" **** Dump impossible. Type "<<ent->DynamicType()->Name()<<std::endl;
7fd59977 195 else
196 S <<" **** Dump Impossible, n0:id:"<<themodel->Number(ent)<<":D"
0ebe5b0a 197 <<themodel->DNum(ent)<<" Type "<<ent->DynamicType()->Name()<<std::endl;
7fd59977 198}