summaryrefslogtreecommitdiff
path: root/src/IGESSolid/IGESSolid_ToolEdgeList.cxx
blob: e751cbe168a76ee68b3dd6bd0e1d5c0908d91880 (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
359
360
361
362
363
364
365
366
367
368
369
370
371
//--------------------------------------------------------------------
//
//  File Name : IGESSolid_EdgeList.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESSolid_ToolEdgeList.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESSolid_VertexList.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESSolid_HArray1OfVertexList.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>

// MGE 03/08/98
#include <Message_Msg.hxx>
#include <IGESData_Status.hxx>

//=======================================================================
//function : IGESSolid_ToolEdgeList
//purpose  : 
//=======================================================================

IGESSolid_ToolEdgeList::IGESSolid_ToolEdgeList ()
{
}


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

void IGESSolid_ToolEdgeList::ReadOwnParams(const Handle(IGESSolid_EdgeList)& ent,
                                           const Handle(IGESData_IGESReaderData)& IR,
                                           IGESData_ParamReader& PR) const
{
  // MGE 03/08/98
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Integer length, anint;
  Handle(IGESData_IGESEntity) anent;
  Handle(IGESSolid_VertexList) avert;
  Handle(IGESData_HArray1OfIGESEntity) tempCurves;
  Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList;
  Handle(TColStd_HArray1OfInteger)   tempStartVertexIndex;
  Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList;
  Handle(TColStd_HArray1OfInteger)   tempEndVertexIndex;
  IGESData_Status aStatus;

  Standard_Boolean st = PR.ReadInteger(PR.Current(), length);
  if(!st){
    Message_Msg Msg184("XSTEP_184");
    PR.SendFail(Msg184);
  }
  //st = PR.ReadInteger(PR.Current(), "Number of edges", length);
  if (st && length > 0)
    {
      tempCurves = new IGESData_HArray1OfIGESEntity(1, length);
      tempStartVertexList = new IGESSolid_HArray1OfVertexList(1, length);
      tempStartVertexIndex = new TColStd_HArray1OfInteger(1, length);
      tempEndVertexList = new IGESSolid_HArray1OfVertexList(1, length);
      tempEndVertexIndex = new TColStd_HArray1OfInteger(1, length);
      for (Standard_Integer i=1 ; i<=length ; i++)
	{
          // Curves
          //st = PR.ReadEntity(IR, PR.Current(), Msg185, anent); //szv#4:S4163:12Mar99 moved in if
          //st = PR.ReadEntity(IR, PR.Current(), "Model space curve", anent);
	  if (PR.ReadEntity(IR, PR.Current(), aStatus, anent))
	    tempCurves->SetValue(i, anent);
	  else{
	    Message_Msg Msg185("XSTEP_185");
	    switch(aStatus) {
	    case IGESData_ReferenceError: {  
	      Message_Msg Msg216 ("IGES_216");
	      Msg185.Arg(Msg216.Value());
	      PR.SendFail(Msg185);
	      break; }
	    case IGESData_EntityError: {
	      Message_Msg Msg217 ("IGES_217");
	      Msg185.Arg(Msg217.Value());
	      PR.SendFail(Msg185);
	      break; }
	    default:{
	    }
	    }
	  }
          // Start vertex list
          //st = PR.ReadEntity(IR, PR.Current(), Msg188,
			     //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
          /*
          st = PR.ReadEntity(IR, PR.Current(), "Start vertex list",
			     STANDARD_TYPE(IGESSolid_VertexList), avert);
          */
	  if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
	    tempStartVertexList->SetValue(i, avert);
	  else{
	    Message_Msg Msg188("XSTEP_188");
	    switch(aStatus) {
	    case IGESData_ReferenceError: {  
	      Message_Msg Msg216 ("IGES_216");
	      Msg188.Arg(Msg216.Value());
	      PR.SendFail(Msg188);
	      break; }
	    case IGESData_EntityError: {
	      Message_Msg Msg217 ("IGES_217");
	      Msg188.Arg(Msg217.Value());
	      PR.SendFail(Msg188);
	      break; }
	    case IGESData_TypeError: {
	      Message_Msg Msg218 ("IGES_218");
	      Msg188.Arg(Msg218.Value());
	      PR.SendFail(Msg188);
	      break; }
	    default:{
	    }
	    }
	  }

          // Start vertex index
          //st = PR.ReadInteger(PR.Current(), Msg186, anint); //szv#4:S4163:12Mar99 moved in if
          //st = PR.ReadInteger(PR.Current(), "Start vertex index", anint);
	  if (PR.ReadInteger(PR.Current(), anint))
	    tempStartVertexIndex->SetValue(i, anint);
	  else{
	    Message_Msg Msg186("XSTEP_186");
	    PR.SendFail(Msg186);
	  }

          // End vertex list
          //st = PR.ReadEntity(IR, PR.Current(),Msg189 ,
			     //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
          /*
          st = PR.ReadEntity(IR, PR.Current(), "End vertex list",
			     STANDARD_TYPE(IGESSolid_VertexList), avert);
          */
          if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
	    tempEndVertexList->SetValue(i, avert);
	  else{
	    Message_Msg Msg189("XSTEP_189");
	    switch(aStatus) {
	    case IGESData_ReferenceError: {  
	      Message_Msg Msg216 ("IGES_216");
	      Msg189.Arg(Msg216.Value());
	      PR.SendFail(Msg189);
	      break; }
	    case IGESData_EntityError: {
	      Message_Msg Msg217 ("IGES_217");
	      Msg189.Arg(Msg217.Value());
	      PR.SendFail(Msg189);
	      break; }
	    case IGESData_TypeError: {
	      Message_Msg Msg218 ("IGES_218");
	      Msg189.Arg(Msg218.Value());
	      PR.SendFail(Msg189);
	      break; }
	    default:{
	    }
	    }
	  }
          // End vertex index
          //st = PR.ReadInteger(PR.Current(), Msg187, anint); //szv#4:S4163:12Mar99 moved in if
          //st = PR.ReadInteger(PR.Current(), "End vertex index", anint);
	  if (PR.ReadInteger(PR.Current(), anint))
	    tempEndVertexIndex->SetValue(i, anint);
	  else {
	    Message_Msg Msg187("XSTEP_187");
	    PR.SendFail(Msg187);
	  }
	}
    }
  
  if (st && length <= 0){
    Message_Msg Msg184("XSTEP_184");
    PR.SendFail(Msg184);
  }
  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  if (length > 0) ent->Init
    (tempCurves, tempStartVertexList, tempStartVertexIndex,
     tempEndVertexList, tempEndVertexIndex);
}


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

void IGESSolid_ToolEdgeList::WriteOwnParams(const Handle(IGESSolid_EdgeList)& ent,
                                            IGESData_IGESWriter& IW) const
{
  Standard_Integer length = ent->NbEdges();

  IW.Send(length);
  for (Standard_Integer i = 1; i <= length; i ++)
    {
      IW.Send(ent->Curve(i));
      IW.Send(ent->StartVertexList(i));
      IW.Send(ent->StartVertexIndex(i));
      IW.Send(ent->EndVertexList(i));
      IW.Send(ent->EndVertexIndex(i));
    }
}


//=======================================================================
//function : OwnShared
//purpose  : 
//=======================================================================

void IGESSolid_ToolEdgeList::OwnShared(const Handle(IGESSolid_EdgeList)& ent,
                                       Interface_EntityIterator& iter) const
{
  Standard_Integer length = ent->NbEdges();
  for (Standard_Integer i = 1; i <= length; i ++)
    {
      iter.GetOneItem(ent->Curve(i));
      iter.GetOneItem(ent->StartVertexList(i));
      iter.GetOneItem(ent->EndVertexList(i));
    }
}


//=======================================================================
//function : OwnCopy
//purpose  : 
//=======================================================================

void IGESSolid_ToolEdgeList::OwnCopy(const Handle(IGESSolid_EdgeList)& another,
                                     const Handle(IGESSolid_EdgeList)& ent,
                                     Interface_CopyTool& TC) const
{
  Standard_Integer length;

  length = another->NbEdges();
  Handle(IGESData_HArray1OfIGESEntity) tempCurves =
    new IGESData_HArray1OfIGESEntity(1, length);
  Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList =
    new IGESSolid_HArray1OfVertexList(1, length);
  Handle(TColStd_HArray1OfInteger)   tempStartVertexIndex =
    new TColStd_HArray1OfInteger(1, length);
  Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList =
    new IGESSolid_HArray1OfVertexList(1, length);
  Handle(TColStd_HArray1OfInteger)   tempEndVertexIndex =
    new TColStd_HArray1OfInteger(1, length);

  for (Standard_Integer i=1 ; i<=length ; i++)
    {
      // Curves
      DeclareAndCast(IGESData_IGESEntity, curve,
		     TC.Transferred(another->Curve(i)));
      tempCurves->SetValue(i, curve);

      // Start vertex list
      DeclareAndCast(IGESSolid_VertexList, start,
		     TC.Transferred(another->StartVertexList(i)));
      tempStartVertexList->SetValue(i, start);

      // Start vertex index
      tempStartVertexIndex->SetValue(i, another->StartVertexIndex(i));

      // End vertex list
      DeclareAndCast(IGESSolid_VertexList, end,
		     TC.Transferred(another->EndVertexList(i)));
      tempEndVertexList->SetValue(i, end);

      // End vertex index
      tempEndVertexIndex->SetValue(i, another->EndVertexIndex(i));
    }

  ent->Init (tempCurves, tempStartVertexList, tempStartVertexIndex,
	     tempEndVertexList, tempEndVertexIndex);
}


//=======================================================================
//function : DirChecker
//purpose  : 
//=======================================================================

IGESData_DirChecker IGESSolid_ToolEdgeList::DirChecker
  (const Handle(IGESSolid_EdgeList)& /* ent */ ) const
{
  IGESData_DirChecker DC(504, 1);

  DC.Structure  (IGESData_DefVoid);
  DC.LineFont   (IGESData_DefVoid);
  DC.LineWeight (IGESData_DefVoid);
  DC.Color      (IGESData_DefVoid);

  DC.SubordinateStatusRequired (1);
  DC.HierarchyStatusRequired (1);
  return DC;
}


//=======================================================================
//function : OwnCheck
//purpose  : 
//=======================================================================

void IGESSolid_ToolEdgeList::OwnCheck(const Handle(IGESSolid_EdgeList)& ent,
                                      const Interface_ShareTool&,
                                      Handle(Interface_Check)& ach) const
{
  // MGE 03/08/98
  // Building of messages
  //========================================
  //Message_Msg Msg184("XSTEP_184");
  //========================================

  if (ent->NbEdges() <= 0) {
    Message_Msg Msg184("XSTEP_184");
    ach->SendFail(Msg184);
  }
}


//=======================================================================
//function : OwnDump
//purpose  : 
//=======================================================================

void IGESSolid_ToolEdgeList::OwnDump(const Handle(IGESSolid_EdgeList)& ent,
                                     const IGESData_IGESDumper& dumper,
                                     const Handle(Message_Messenger)& S,
                                     const Standard_Integer level) const
{
  Standard_Integer i, length = ent->NbEdges();

  S << "IGESSolid_EdgeList" << endl;
  S << "Number of edge tuples : " << length << endl;
  switch (level)
    {
    case 4 :
      S << "Curves : ";
      S << "Start Vertex List : ";
      S << "Start Vertex Index : ";
      IGESData_DumpVals(S ,level,1, length,ent->StartVertexIndex);
      S << endl;
      S << "End Vertex List : ";
      S << "End Vertex Index : ";
      IGESData_DumpVals(S ,level,1, length,ent->EndVertexIndex);
      S << endl;
      break;
    case 5 :
    case 6 :
      S<<" Curve - Vertices. Start : (VertexList,Index)  End : (VertexList,Index)"<<endl;
      for (i = 1; i <= length; i ++)
	{
//[123]:Curve : #1234 - Vertices. Start = (#5678 , 3467)  End = (#1234 , 4664)
	  S << "[" << i << "]:Curve : ";
	  dumper.Dump (ent->Curve(i),S, level-5);
	  S <<" - Vertices. Start : (";
	  dumper.Dump (ent->StartVertexList(i),S, 0);
	  S << " , " << ent->StartVertexIndex(i);
	  S << ")  End : (";
	  dumper.Dump (ent->EndVertexList(i),S, 0);
	  S << " , " << ent->EndVertexIndex(i);
	  S << ")"   << endl;
	}
      break;
      default :
	break;
    }
  S << endl;
}