summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolCopiousData.cxx
blob: dcf29a39a11d65e901c59cfb00b0383ddee94b8d (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
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_CopiousData.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolCopiousData.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>
#include <gp_XY.hxx>

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


//=======================================================================
//function : IGESGeom_ToolCopiousData
//purpose  : 
//=======================================================================

IGESGeom_ToolCopiousData::IGESGeom_ToolCopiousData ()
{
}


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

void IGESGeom_ToolCopiousData::ReadOwnParams(const Handle(IGESGeom_CopiousData)& ent,
                                             const Handle(IGESData_IGESReaderData)& /* IR */,
                                             IGESData_ParamReader& PR) const
{
  // MGE 28/07/98
  // Building of messages

  Standard_Integer aDataType, nbData;
  Standard_Real aZPlane = 0;
  Handle(TColStd_HArray1OfReal) allData;

  Standard_Integer upper;
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Boolean data = Standard_False;

  if (!PR.ReadInteger(PR.Current(), aDataType)){ //szv#4:S4163:12Mar99 `st=` not needed
    //st = PR.ReadInteger(PR.Current(), "Data Type", aDataType);
    Message_Msg Msg85("XSTEP_85");
    PR.SendFail(Msg85);
  }

  Standard_Boolean st = PR.ReadInteger(PR.Current(), nbData);
  //st = PR.ReadInteger(PR.Current(), "Number of n-tuples", nbData);
  if (st && (nbData > 0)) data = Standard_True;
  else {
    Message_Msg Msg86("XSTEP_86");
    PR.SendFail(Msg86);
  }

  if (aDataType == 1){
    if (!PR.ReadReal(PR.Current(), aZPlane)){ //szv#4:S4163:12Mar99 `st=` not needed
      Message_Msg Msg87("XSTEP_87");
      PR.SendFail(Msg87);
    }
  //if (aDataType == 1)  st = PR.ReadReal(PR.Current(), "Z Plane", aZPlane);
  }

  if ( data )
    {
      if (aDataType == 1)            upper = 2*nbData;
      else if (aDataType == 2)       upper = 3*nbData;
      else                           upper = 6*nbData;

      Message_Msg Msg88("XSTEP_88");
      //allData = new TColStd_HArray1OfReal(1, upper) then fill it :
      PR.ReadReals(PR.CurrentList(upper),Msg88, allData); //szv#4:S4163:12Mar99 `st=` not needed
      //st = PR.ReadReals(PR.CurrentList(upper), "Tuples", allData);
    }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(aDataType, aZPlane, allData);
}


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

void IGESGeom_ToolCopiousData::WriteOwnParams(const Handle(IGESGeom_CopiousData)& ent,
                                              IGESData_IGESWriter& IW)  const
{
  Standard_Integer upper = ent->NbPoints();
  Standard_Integer dtype = ent->DataType();
  IW.Send(dtype);
  IW.Send(upper);
  if (ent->DataType() == 1)
    IW.Send(ent->ZPlane());
  for (Standard_Integer I = 1; I <= upper; I++) {
// DataType = 1 : XY , 2 : XYZ , 3 : XYZ*2
    IW.Send( ent->Data(I,1) );
    IW.Send( ent->Data(I,2) );
    if (dtype > 1) IW.Send( ent->Data(I,3) );
    if (dtype <= 2) continue;
    IW.Send( ent->Data(I,4) );
    IW.Send( ent->Data(I,5) );
    IW.Send( ent->Data(I,6) );
  }
}


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

void IGESGeom_ToolCopiousData::OwnShared(const Handle(IGESGeom_CopiousData)& /* ent */,
                                         Interface_EntityIterator& /* iter */) const
{
}


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

void IGESGeom_ToolCopiousData::OwnCopy(const Handle(IGESGeom_CopiousData)& another,
                                       const Handle(IGESGeom_CopiousData)& ent,
                                       Interface_CopyTool& /* TC */) const
{
  Standard_Integer upper;
  Standard_Real    aZPlane   = 0;
  Standard_Integer nbTuples  = another->NbPoints();
  Standard_Integer aDataType = another->DataType();
  Handle(TColStd_HArray1OfReal) allData;

  if      (aDataType == 1)    upper = 2*nbTuples;
  else if (aDataType == 2)    upper = 3*nbTuples;
  else                        upper = 6*nbTuples;

  allData = new TColStd_HArray1OfReal(1, upper);

  if (aDataType == 1)    aZPlane = another->ZPlane();

  for (Standard_Integer I = 1; I <= nbTuples; I++)  {

    switch (aDataType) {
    case 1:
      allData->SetValue(2*I-1, another->Data(I,1));
      allData->SetValue(2*I  , another->Data(I,2));
      break;
    case 2:
      allData->SetValue(3*I-2, another->Data(I,1));
      allData->SetValue(3*I-1, another->Data(I,2));
      allData->SetValue(3*I  , another->Data(I,3));
      break;
    case 3:
      allData->SetValue(6*I-5, another->Data(I,1));
      allData->SetValue(6*I-4, another->Data(I,2));
      allData->SetValue(6*I-3, another->Data(I,3));
      allData->SetValue(6*I-2, another->Data(I,4));
      allData->SetValue(6*I-1, another->Data(I,5));
      allData->SetValue(6*I  , another->Data(I,6));
      break;
    }
  }

  ent->Init(aDataType, aZPlane, allData);
  if (another->IsClosedPath2D()) ent->SetClosedPath2D();
  else  ent->SetPolyline (another->IsPolyline());
}


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

IGESData_DirChecker IGESGeom_ToolCopiousData::DirChecker
  (const Handle(IGESGeom_CopiousData)& ent )  const
{
  IGESData_DirChecker DC(106, 1, 63);
  DC.Structure(IGESData_DefVoid);
  if (ent->FormNumber() <= 3)
    {
      DC.LineFont(IGESData_DefVoid);
      DC.LineWeight(IGESData_DefVoid);
    }
  else
    {
      DC.LineFont(IGESData_DefAny);
      DC.LineWeight(IGESData_DefValue);
    }
  DC.Color(IGESData_DefAny);
  DC.HierarchyStatusIgnored ();
  return DC;
}


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

void IGESGeom_ToolCopiousData::OwnCheck(const Handle(IGESGeom_CopiousData)& ent,
                                        const Interface_ShareTool&,
                                        Handle(Interface_Check)& ach)  const
{
  // MGE 28/07/98
  // Building of messages
  //======================================
  Message_Msg Msg71("XSTEP_71");
  //Message_Msg Msg85("XSTEP_85");
  //======================================

  Standard_Integer fn = ent->FormNumber();
  if ( (fn > 3 && fn < 11) || (fn > 14 && fn < 63)) {
//    Message_Msg Msg71("XSTEP_71");
    ach->SendFail(Msg71);
  }
  Standard_Integer dt = ent->DataType();
  if (dt < 1 || dt > 3) {
    Message_Msg Msg85("XSTEP_85");
    ach->SendFail(Msg85);
  }
  if ((dt == 1 && (fn != 1 && fn != 11 && fn != 63)) ||
      (dt == 2 && (fn != 2 && fn != 12)) || (dt == 3 && (fn != 3 && fn != 13))) {
//    Message_Msg Msg71("XSTEP_71");
    ach->SendFail(Msg71);
  }
}


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

void IGESGeom_ToolCopiousData::OwnDump(const Handle(IGESGeom_CopiousData)& ent,
                                       const IGESData_IGESDumper& /* dumper */,
                                       const Handle(Message_Messenger)& S,
                                       const Standard_Integer level)  const
{
  Standard_Integer nbPnts = ent->NbPoints();
  Standard_Integer dtype  = ent->DataType();
  Standard_Integer i;
  gp_GTrsf loca = ent->Location();
  gp_GTrsf locv = ent->VectorLocation();
  Standard_Boolean yatr = (level > 5 && ent->HasTransf());

  S << "IGESGeom_CopiousData" << endl;

  if (ent->IsPointSet())          S << "Point Set  ";
  else if (ent->IsPolyline())     S << "Polyline  ";
  else if (ent->IsClosedPath2D()) S << "Closed Path 2D  ";
  S << "DataType " << ent->DataType() << "  ";
  S << "Number of T-uples = " << nbPnts << "  ";
  if (dtype == 1) {
    S << "(Points 2D)  ";
    S << "ZPlane = " << ent->ZPlane() << endl;
  }
  else if (dtype == 2)
    S << "(Points 3D)" << endl;
  else if (dtype == 3)
    S << "(Points 3D + Vectors 3D)" << endl;

  if (level > 4) {
    for (i = 1; i <= nbPnts; i ++) {
      gp_XYZ T = ent->Point(i).XYZ();
      if (dtype == 1)
	S << "[" << i << "] (" << T.X() << "," << T.Y() << ")";
      else
	S << "[" << i << "] (" << T.X() << "," << T.Y() << "," << T.Z() << ")";

      if (yatr) {
	loca.Transforms(T);
	S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")";
      }

      if (dtype == 3) {
//	gp_XYZ P = ent->Vector(i).XYZ();
	S << "\n   Vector (" << T.X() << "," << T.Y() << "," << T.Z() << ")";
	if (yatr) {
	  locv.Transforms(T);
	  S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")";
	}
      }
      S << endl;
    }
  }
  else S << " [ for content, ask level > 4 ]";
  S << endl;
}