summaryrefslogtreecommitdiff
path: root/src/IGESData/IGESData_UndefinedEntity.cxx
blob: ae06d2fc619c6e4e4d1f61bc9ec8763b028fab61 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#include <IGESData_UndefinedEntity.ixx>
#include <IGESData_LineFontEntity.hxx>
#include <IGESData_LevelListEntity.hxx>
#include <IGESData_ViewKindEntity.hxx>
#include <IGESData_TransfEntity.hxx>
#include <IGESData_LabelDisplayEntity.hxx>
#include <IGESData_ColorEntity.hxx>

#include <Interface_Macros.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_AsciiString.hxx>

// MGE 23/07/98
#include <Message_Msg.hxx>


//=======================================================================
//function : IGESData_UndefinedEntity
//purpose  : 
//=======================================================================

IGESData_UndefinedEntity::IGESData_UndefinedEntity ()
{
  thecont = new Interface_UndefinedContent;
}


//=======================================================================
//function : UndefinedContent
//purpose  : 
//=======================================================================

Handle(Interface_UndefinedContent) IGESData_UndefinedEntity::UndefinedContent () const
{
  return thecont;
}


//=======================================================================
//function : ChangeableContent
//purpose  : 
//=======================================================================

Handle(Interface_UndefinedContent) IGESData_UndefinedEntity::ChangeableContent ()
{
  return thecont;
}


//=======================================================================
//function : SetNewContent
//purpose  : 
//=======================================================================

void IGESData_UndefinedEntity::SetNewContent
  (const Handle(Interface_UndefinedContent)& cont)
{
  thecont = cont;
}


//  ....           (Re)definitions specifiques a UndefinedEntity           ....


//=======================================================================
//function : IsOKDirPart
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_UndefinedEntity::IsOKDirPart () const
{
  return (thedstat == 0);
}


//=======================================================================
//function : DirStatus
//purpose  : 
//=======================================================================

Standard_Integer IGESData_UndefinedEntity::DirStatus () const
{
  return thedstat;
}


//=======================================================================
//function : SetOKDirPart
//purpose  : 
//=======================================================================

void IGESData_UndefinedEntity::SetOKDirPart ()
{
  thedstat = 0;
}


//=======================================================================
//function : DefLineFont
//purpose  : 
//=======================================================================

IGESData_DefType IGESData_UndefinedEntity::DefLineFont () const
{
  Standard_Integer st = ((thedstat/4) & 3);
  if (st == 0) return IGESData_IGESEntity::DefLineFont();
  else if (st == 1) return IGESData_ErrorVal;
  else return IGESData_ErrorRef;
}


//=======================================================================
//function : DefLevel
//purpose  : 
//=======================================================================

IGESData_DefList IGESData_UndefinedEntity::DefLevel () const
{
  Standard_Integer st = ((thedstat/16) & 3);
  if (st == 0) return IGESData_IGESEntity::DefLevel();
  else if (st == 1) return IGESData_ErrorOne;
  else return IGESData_ErrorSeveral;
}


//=======================================================================
//function : DefView
//purpose  : 
//=======================================================================

IGESData_DefList IGESData_UndefinedEntity::DefView () const
{
  Standard_Integer st = ((thedstat/64) & 3);
  if (st == 0) return IGESData_IGESEntity::DefView();
  else if (st == 1) return IGESData_ErrorOne;
  else return IGESData_ErrorSeveral;
}


//=======================================================================
//function : DefColor
//purpose  : 
//=======================================================================

IGESData_DefType IGESData_UndefinedEntity::DefColor () const
{
  Standard_Integer st = ((thedstat/256) & 3);
  if (st == 0) return IGESData_IGESEntity::DefColor();
  else if (st == 1) return IGESData_ErrorVal;
  else return IGESData_ErrorRef;
}


//=======================================================================
//function : HasSubScriptNumber
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_UndefinedEntity::HasSubScriptNumber () const
{
  Standard_Integer st = ((thedstat/1024) & 1);
  if (st == 0) return IGESData_IGESEntity::HasSubScriptNumber();
  else return Standard_False;
}


//   ReadDir verifie les donnees, s il y a des erreurs les note (status),
//   genere un nouveau DirPart sans ces erreurs, et appelle ReadDir de base


//=======================================================================
//function : ReadDir
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_UndefinedEntity::ReadDir
  (const Handle(IGESData_IGESReaderData)& IR, IGESData_DirPart& DP,
   Handle(Interface_Check)& ach)
{
  // MGE 23/07/98
  // =====================================
  //Message_Msg Msg60 ("XSTEP_60");
  //Message_Msg Msg61 ("XSTEP_61");
  //Message_Msg Msg62 ("XSTEP_62");
  //Message_Msg Msg63 ("XSTEP_63");
  //Message_Msg Msg64 ("XSTEP_64");
  //Message_Msg Msg70 ("XSTEP_70");
  //Message_Msg Msg72 ("XSTEP_72");
  // =====================================

  Standard_Integer v[17]; Standard_Character res1[9],res2[9],lab[9],subs[9];
  Standard_Integer max = 2 * IR->NbRecords();    // valeur maxi pour DSectNum
  thedstat = 0;

  Handle(IGESData_IGESEntity) anent; Standard_Boolean iapb;
  DP.Values(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],
	    v[11],v[12],v[13],v[14],v[15],v[16],res1,res2,lab,subs);

  iapb = Standard_False;
  if (v[3] < -max) iapb = Standard_True;
  else if (v[3] < 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((-1-v[3])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_LineFontEntity))) iapb = Standard_True;
  }
  // Sending of message : Line Font Pattern field is incorrect.
  if (iapb) { 
    Message_Msg Msg60 ("XSTEP_60");
    ach->SendFail(Msg60);
    thedstat += 8;
    v[3] = 0;
  }

  iapb = Standard_False;
  if (v[4] < -max) iapb = Standard_True;
  else if (v[4] < 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((-1-v[4])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_LevelListEntity))) iapb = Standard_True;
  }

  // Sending of message : Level field is incorrect.
  if (iapb) { 
    Message_Msg Msg61 ("XSTEP_61");
    ach->SendFail(Msg61);
    thedstat += 32;
    v[3] = 0;
  }

  iapb = Standard_False;
  if (v[5] < 0 || v[5] > max) iapb = Standard_True;
  else if (v[5] > 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((1+v[5])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_ViewKindEntity))) iapb = Standard_True;
  }

  // Sending of message : View field is incorrect.
  if (iapb) { 
    Message_Msg Msg62 ("XSTEP_62");
    ach->SendFail(Msg62);
    thedstat += 128;
    v[5] = 0;
  }

  iapb = Standard_False;
  if (v[6] < 0 || v[6] > max) iapb = Standard_True;
  else if (v[6] > 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((1+v[6])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_TransfEntity))) iapb = Standard_True;
  }
 
  // Sending of message : Transformation Matrix field is incorrect
  if (iapb) { 
    Message_Msg Msg63 ("XSTEP_63");
    ach->SendFail(Msg63);
    thedstat |= 1;
    v[6] = 0;
  }

  iapb = Standard_False;
  if (v[7] < 0 || v[7] > max) iapb = Standard_True;
  else if (v[7] < 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((1+v[7])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_LabelDisplayEntity))) iapb = Standard_True;
  }

  // Sending of message : Label Display Entity  field is incorrect.
  if (iapb) { 
    Message_Msg Msg64 ("XSTEP_64");
    ach->SendFail(Msg64);
    thedstat |= 1;
    v[7] = 0;
  }

  iapb = Standard_False;
  if (v[14] < 0 || v[14] > max) iapb = Standard_True;
  else if (v[14] < 0) {
    anent = GetCasted(IGESData_IGESEntity,IR->BoundEntity((1+v[14])/2));
    if (!anent->IsKind(STANDARD_TYPE(IGESData_ColorEntity)))
      {  thedstat += 512; v[14] = 0;  }
  }
  
  // Sending of message : Color Number field is incorrect.
  if (iapb) { 
    Message_Msg Msg70 ("XSTEP_70");
    ach->SendFail(Msg70);
    thedstat += 512;
    v[14] = 0;
  }

  iapb = Standard_False;
  Standard_Integer i; // svv Jan11 2000 : porting on DEC
  for (i = 0; i < 8; i ++) {
    if (subs[i] == '\0') break;  // fin de ligne
    if (subs[i] != ' ' && (subs[i] < 48 || subs[i] > 57)) iapb = Standard_True;
  }

  // Sending of message : Entity Subscript Number field is incorrect.
  if (iapb) { 
    Message_Msg Msg72 ("XSTEP_72");
    ach->SendFail(Msg72);
    thedstat += 1024;
    for (i = 0; i < 8; i ++) subs[i] = ' ';
  }

//  ...  Fin de cette analyse : si necessaire on reconstruit DP  ...
  if (thedstat == 0) return Standard_True;
  else {
    DP.Init(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],
	     v[11],v[12],v[13],v[14],v[15],v[16],res1,res2,lab,subs);
    return Standard_False;
  }
}


//   Parametres indifferencies : assocs et props ignores

//=======================================================================
//function : ReadOwnParams
//purpose  : 
//=======================================================================

void IGESData_UndefinedEntity::ReadOwnParams
  (const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR)
{
  Standard_Integer nb = PR.NbParams();

  thecont->Reservate(nb,nb);
  for (Standard_Integer i = 1; i <= nb; i ++) {
    Interface_ParamType ptyp = PR.ParamType(i);
/*    if (PR.IsParamEntity(i)) {
      thecont->AddEntity (ptyp,PR.ParamEntity(IR,i));
    }
    else thecont->AddLiteral (ptyp,new TCollection_HAsciiString(PR.ParamValue(i)));
*/
//  On est TOUJOURS en mode litteral, c est bien plus clair !
    thecont->AddLiteral (ptyp,new TCollection_HAsciiString(PR.ParamValue(i)));
  }
  PR.SetCurrentNumber(nb+1);
}


//=======================================================================
//function : WriteOwnParams
//purpose  : 
//=======================================================================

void IGESData_UndefinedEntity::WriteOwnParams(IGESData_IGESWriter& IW) const
{
  Standard_Integer nb = thecont->NbParams();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    Interface_ParamType ptyp = thecont->ParamType(i);
    if (ptyp == Interface_ParamVoid) IW.SendVoid();
    else if (thecont->IsParamEntity(i)) {
      DeclareAndCast(IGESData_IGESEntity,anent,thecont->ParamEntity(i));
      IW.Send(anent);
    }
    else IW.SendString (thecont->ParamValue(i));
  }
}