summaryrefslogtreecommitdiff
path: root/src/IGESData/IGESData_IGESDumper.cxx
blob: f4b5e967a188154881623341799129ab6650e5de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <IGESData_IGESDumper.ixx>
#include <Interface_InterfaceError.hxx>
#include <Interface_Macros.hxx>
#include <Interface_MSG.hxx>
#include <Interface_EntityIterator.hxx>
#include <IGESData_SpecificLib.hxx>
#include <IGESData_SpecificModule.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Message_Messenger.hxx>

    IGESData_IGESDumper::IGESData_IGESDumper
  (const Handle(IGESData_IGESModel)& model,
   const Handle(IGESData_Protocol)& protocol)
      : thelib (protocol)
      {  themodel = model;  }


    void  IGESData_IGESDumper::PrintDNum
  (const Handle(IGESData_IGESEntity)& ent, const Handle(Message_Messenger)& S) const 
{
//   Affichage garanti sur  12 caracteres 12345/D24689
  Standard_Integer num = 0;
  if (!ent.IsNull()) {
    if (themodel.IsNull())                          S<<"    D???    ";
    else if ( (num = themodel->Number(ent)) == 0)   S<<"    0:D?????";
// Interface_InterfaceError::Raise  ("IGESDumper : PrintDNum");
    else {
      S<<Interface_MSG::Blanks(num,9)<<num<<":D"<<2*num-1<<Interface_MSG::Blanks(2*num-1,9);
    }
  }
  else                                              S<<"  D0(Null)  ";
}

    void  IGESData_IGESDumper::PrintShort
  (const Handle(IGESData_IGESEntity)& ent, const Handle(Message_Messenger)& S) const 
{
//  PrintDNum(ent,S);
  if (!ent.IsNull()) {
    Standard_Integer num = 0;
    if (!themodel.IsNull()) num = themodel->Number(ent);
    if (num > 0) S<<num<<":D"<<2*num-1;
    S << "  Type:" << ent->TypeNumber() << "  Form:" << ent->FormNumber()
      << Interface_MSG::Blanks (ent->FormNumber(),3)
      << " Class:"<< Interface_InterfaceModel::ClassName(ent->DynamicType()->Name());
  }
}


    void  IGESData_IGESDumper::Dump
  (const Handle(IGESData_IGESEntity)& ent, const Handle(Message_Messenger)& S,
   const Standard_Integer own, const Standard_Integer attached) const 
{
  Standard_Integer att = attached;
  Standard_Integer diratt = 1;
  if (own < 3) diratt = own - 1;
  if (att == 0)  att = diratt;  // -1 signifie : ne rien sortir

  if (own < 0) return;
  if (own > 1) S<<"\n";
  if (ent.IsNull())  {  S<<"(Null)";  if (own > 1) S<<"\n";  return;  }
  if (own == 0)  {  PrintDNum  (ent,S);  return;  }    // affichage auxiliaire
  if (own == 1)  {  PrintShort (ent,S);  return;  }    // affichage auxiliaire

  if (own > 0) S<<"****    Dump IGES, level "<<own<<" ( ";
  switch (own) {
  case 0 :    break;
  case 1 :    S<<"D.E. Number + Type + Name";  break;
  case 2 :    S<<"D.E. Number + Type, Name + Transf, View";  break;
  case 3 :    S<<"Complete Directory Part";  break;
  case 4 :    S<<"Directory Part + Parameters, no Arrays";  break;
  case 5 :    S<<"Complete";  break;
  default :   S<<"Complete + Transformed Values";  break;
  }
  S<<" )    ****"<<endl;

// ****    Entity 1234:D2467  **  Type:102 Form:56  **  CompositeCurve  **
  S<<"\n"<<"****    Entity ";  PrintShort (ent,S);  S<<endl;

  S<<"              Directory Part"<<"\n";
// **      Status :   Blank:1    Subordinate:2    UseFlag:3    Hierarchy:4
  if (own >= 2)
    S <<"**      Status Number :   Blank:"<<ent->BlankStatus()
      <<"    Subordinate:"<<ent->SubordinateStatus()
      <<"    UseFlag:"<<ent->UseFlag()
      <<"    Hierarchy:"<<ent->HierarchyStatus()<<"\n";
  if (own >= 1) {
    if (ent->HasShortLabel()) S<<"****    Label         :"<<ent->ShortLabel()->ToCString();
    if (ent->HasSubScriptNumber()) S<<"    SubScript:"<<ent->SubScriptNumber();
    if (ent->HasShortLabel())  S<<endl;

    if (ent->HasTransf())
      {  S<<"**      Transf.Matrix :";  PrintDNum(ent->Transf(),S); S<<"\n"; }
    IGESData_DefList  viewkind = ent->DefView();
    if (viewkind == IGESData_DefOne)
      {  S<<"**      View          :";  PrintDNum (ent->View(),S);  S<<"\n"; }
    if (viewkind == IGESData_DefSeveral)
      {  S<<"**      View (List)   :";  PrintDNum (ent->ViewList(),S);  S<<"\n"; }
     
  }

  if (own >= 2) {

    if (ent->HasStructure())
      {  S<<"**      Structure     :"; PrintDNum (ent->Structure(),S);  S<<"\n";  }

    S<<"\n"<<"              Graphic Attributes"<<"\n";
    if (ent->DefLineFont() == IGESData_DefValue)
      {  S<<"**      LineFont Value:"<<ent->RankLineFont()<<"\n"; }
    else if (ent->DefLineFont() == IGESData_DefReference)
      {  S<<"**      LineFont Ref  :";  PrintDNum (ent->LineFont(),S);  S<<"\n"; }

    if (ent->Level() > 0)  S<<"**      Level Value   :"<<ent->Level()<<"\n";
    else if (ent->Level() < 0)
      {  S<<"**      Level List    :";  PrintDNum(ent->LevelList(),S);  S<<"\n"; }

    if (ent->HasLabelDisplay())
      {  S<<"**      Label Display :";  PrintDNum (ent->LabelDisplay(),S);  S<<"\n"; }
    if (ent->LineWeightNumber() != 0) {
      S   <<"**      LineWeight Num:"<<ent->LineWeightNumber();
      if (diratt > 0) S<<"    ->  Value:"<<ent->LineWeight();
      S<<endl;
    }
    if (ent->DefColor() == IGESData_DefValue)
      {  S<<"**      Color Value   :"<<ent->RankColor();  }
    else if (ent->DefColor() == IGESData_DefReference)
      {  S<<"**      Color Ref     :";  PrintDNum (ent->Color(),S); }
    S<<endl;

    if (own > 3) {
      S<<"****             Own Data             ****"<<"\n\n";
      OwnDump(ent,S,own);
    }
  }

//   Donnees attachees : Properties, Associativities, et Sharings
  if (att < 0) return;
  Interface_EntityIterator iter = ent->Properties();
  Standard_Integer nb = iter.NbEntities();
  Standard_Boolean iasuit = (nb > 0);
  if (nb > 0) {
    S<<"\n"<<"****     Properties (nb:"<<nb<<")          ****"<<"\n";
    for (;iter.More(); iter.Next()) {
      DeclareAndCast(IGESData_IGESEntity,ent2,iter.Value());
      Dump (ent2,S,att,-1);
    }
  }
  iter = ent->Associativities();
  nb = iter.NbEntities();
  if (nb > 0) iasuit = Standard_True;
  if (nb > 0) {
    S<<"\n"<<"****   Associativities (nb:"<<nb<<")        ****"<<"\n";
    for (;iter.More(); iter.Next()) {
      DeclareAndCast(IGESData_IGESEntity,ent2,iter.Value());
      Dump(ent2,S,att,-1);
    }
  }
  if (iasuit) {  if (att <= 1) S << "\n";  }
  S<<"\n"<<"****             End of Dump          ****"<<"\n"<<endl;
}



    void  IGESData_IGESDumper::OwnDump
  (const Handle(IGESData_IGESEntity)& ent, const Handle(Message_Messenger)& S,
   const Standard_Integer own) const 
{
  Handle(IGESData_SpecificModule) module;  Standard_Integer CN;
  if (thelib.Select(ent,module,CN))
    module->OwnDump(CN,ent,*this,S,own);
  else if (themodel.IsNull())
    S <<"  ****  Dump impossible. Type "<<ent->DynamicType()->Name()<<endl;
  else
    S <<"  ****  Dump Impossible, n0:id:"<<themodel->Number(ent)<<":D"
      <<themodel->DNum(ent)<<" Type "<<ent->DynamicType()->Name()<<endl;
}