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