-
Notifications
You must be signed in to change notification settings - Fork 623
Expand file tree
/
Copy pathIGESControl_Reader.cxx
More file actions
356 lines (327 loc) · 13.1 KB
/
IGESControl_Reader.cxx
File metadata and controls
356 lines (327 loc) · 13.1 KB
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
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// gka 06.01.99 S3767
// abv 10.04.99 S4136: eliminate using BRepAPI::Precision()
#include <BRepLib.hxx>
#include <DEIGES_Parameters.hxx>
#include <DE_ShapeFixParameters.hxx>
#include <IFSelect_CheckCounter.hxx>
#include <IFSelect_Functions.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <IGESData_FileProtocol.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESToBRep_Actor.hxx>
#include <Interface_InterfaceModel.hxx>
#include <MoniTool_Macros.hxx>
#include <Interface_ShareFlags.hxx>
#include <Interface_Static.hxx>
#include <Message_Messenger.hxx>
#include <Message_Msg.hxx>
#include <NCollection_DataMap.hxx>
#include <OSD_Timer.hxx>
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSAlgo_ShapeProcessor.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_WorkSession.hxx>
#include <cstdio>
// S3767 dce 18/01/1999
// Transfer_Iterator.hxx>
// add of stdio.h for NT compilation
//=================================================================================================
IGESControl_Reader::IGESControl_Reader()
{
IGESControl_Controller::Init();
SetWS(new XSControl_WorkSession);
SetNorm("IGES");
int onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
theReadOnlyVisible = (onlyvisible == 1);
}
//=================================================================================================
IGESControl_Reader::IGESControl_Reader(const occ::handle<XSControl_WorkSession>& WS,
const bool scratch)
{
IGESControl_Controller::Init();
SetWS(WS, scratch);
SetNorm("IGES");
int onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
theReadOnlyVisible = (onlyvisible == 1);
}
//=================================================================================================
occ::handle<IGESData_IGESModel> IGESControl_Reader::IGESModel() const
{
return occ::down_cast<IGESData_IGESModel>(Model());
}
//=================================================================================================
int IGESControl_Reader::NbRootsForTransfer()
{
if (therootsta)
return theroots.Length();
therootsta = true;
occ::handle<IGESData_IGESModel> model = IGESModel();
if (model.IsNull())
return 0;
occ::handle<XSControl_WorkSession> session = WS();
occ::handle<Interface_Protocol> protocol = session->Protocol();
occ::handle<XSControl_Controller> controller = session->NormAdaptor();
occ::handle<Transfer_ActorOfTransientProcess> actor = controller->ActorRead(model);
Interface_ShareFlags SH(model, protocol);
// sln 11.06.2002 OCC448
Interface_Static::SetIVal("read.iges.onlyvisible", theReadOnlyVisible);
int nb = model->NbEntities();
for (int i = 1; i <= nb; i++)
{
occ::handle<IGESData_IGESEntity> ent = model->Entity(i);
if (SH.IsShared(ent) || !actor->Recognize(ent))
continue;
// add processing to take only visible entities
if (!theReadOnlyVisible || ent->BlankStatus() == 0)
{
theroots.Append(ent);
}
}
return theroots.Length();
}
// #### Remainder of methods to be reworked ####
//=======================================================================
// Function : PrintTransferInfo
// Purpose : Print statistics information on transfer using MoniTool message management
// Created : 18/01/98 DCE for S3767
// Modified :
//=======================================================================
void IGESControl_Reader::PrintTransferInfo(const IFSelect_PrintFail failsonly,
const IFSelect_PrintCount mode) const
{
int nbWarn = 0, nbFail = 0, nbEntities = 0, nbRoots = 0, nbResults = 0;
const occ::handle<Transfer_TransientProcess>& TP = WS()->TransferReader()->TransientProcess();
occ::handle<Message_Messenger> TF = TP->Messenger();
const occ::handle<Interface_InterfaceModel>& model = TP->Model();
if (!model.IsNull())
{
nbEntities = model->NbEntities();
nbRoots = TP->NbRoots();
// nbResults = TP->NbMapped();
Transfer_IteratorOfProcessForTransient iterTrans = TP->RootResult(true);
NCollection_DataMap<TCollection_AsciiString, int> aMapCountResult;
NCollection_DataMap<TCollection_AsciiString, int> aMapCountMapping;
for (iterTrans.Start(); iterTrans.More(); iterTrans.Next())
{
nbResults++;
// Init for dicoCountResult for IFSelect_ResultCount
if (mode == IFSelect_ResultCount)
{
char mess[300];
const occ::handle<Transfer_Binder>& aBinder = iterTrans.Value();
Sprintf(mess, "\t%s", aBinder->ResultTypeName());
(*aMapCountResult.TryBound(mess, 0))++;
}
// Init for dicoCountMapping for IFSelect_Mapping
else if (mode == IFSelect_Mapping)
{
char mess[300];
const occ::handle<Transfer_Binder>& aBinder = iterTrans.Value();
DeclareAndCast(IGESData_IGESEntity, igesEnt, iterTrans.Starting());
Sprintf(mess,
"%d\t%d\t%s\t%s",
igesEnt->TypeNumber(),
igesEnt->FormNumber(),
"%d",
aBinder->ResultTypeName());
// std::cout << mess << std::endl;
(*aMapCountMapping.TryBound(mess, 0))++;
}
}
Interface_CheckIterator checkIterator = TP->CheckList(false);
NCollection_DataMap<TCollection_AsciiString, int> aMapCount;
NCollection_DataMap<TCollection_AsciiString, occ::handle<NCollection_HSequence<int>>> aMapList;
// Init the dicoCount dicoList and nbWarn ,nb Fail.
for (checkIterator.Start(); checkIterator.More(); checkIterator.Next())
{
char mess[300];
const occ::handle<Interface_Check>& aCheck = checkIterator.Value();
occ::handle<Standard_Transient> ent = model->Value(checkIterator.Number());
DeclareAndCast(IGESData_IGESEntity, igesEnt, ent);
int type = igesEnt->TypeNumber(), form = igesEnt->FormNumber();
int nw = aCheck->NbWarnings(), nf = aCheck->NbFails(), i;
for (i = 1; (failsonly == IFSelect_FailAndWarn) && (i <= nw); i++)
{
Sprintf(mess, "\t W\t%d\t%d\t%s", type, form, aCheck->CWarning(i));
(*aMapCount.TryBound(mess, 0))++;
occ::handle<NCollection_HSequence<int>>* pList = aMapList.ChangeSeek(mess);
if (!pList)
{
pList = aMapList.Bound(mess, new NCollection_HSequence<int>());
}
(*pList)->Append(model->Number(igesEnt) * 2 - 1);
}
for (i = 1; i <= nf; i++)
{
Sprintf(mess, "\t F\t%d\t%d\t%s", type, form, aCheck->CFail(i));
// TF << mess << std::endl;
(*aMapCount.TryBound(mess, 0))++;
occ::handle<NCollection_HSequence<int>>* pList = aMapList.ChangeSeek(mess);
if (!pList)
{
pList = aMapList.Bound(mess, new NCollection_HSequence<int>());
}
(*pList)->Append(model->Number(igesEnt) * 2 - 1);
}
nbWarn += nw;
nbFail += nf;
}
Message_Msg msg3000("IGES_3000"); // *************************
TF->Send(msg3000, Message_Info); // smh#14
switch (mode)
{
case IFSelect_GeneralInfo: {
Message_Msg msg3005("IGES_3005");
TF->Send(msg3005, Message_Info);
Message_Msg msg3010("IGES_3010");
msg3010.Arg(nbEntities);
TF->Send(msg3010, Message_Info);
Message_Msg msg3011("IGES_3011");
msg3011.Arg(nbRoots);
TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");
msg3015.Arg(nbResults);
TF->Send(msg3015, Message_Info);
Message_Msg msg3020("IGES_3020");
msg3020.Arg(nbWarn);
TF->Send(msg3020, Message_Info);
Message_Msg msg3025("IGES_3025");
msg3025.Arg(nbFail);
TF->Send(msg3025, Message_Info);
break;
}
case IFSelect_CountByItem:
case IFSelect_ListByItem: {
Message_Msg msg3030("IGES_3030");
TF->Send(msg3030, Message_Info);
NCollection_DataMap<TCollection_AsciiString, int>::Iterator aMapCountIter(aMapCount);
NCollection_DataMap<TCollection_AsciiString,
occ::handle<NCollection_HSequence<int>>>::Iterator
aMapListIter(aMapList);
for (; aMapCountIter.More() && aMapListIter.More();
aMapCountIter.Next(), aMapListIter.Next())
{
Message_Messenger::StreamBuffer aSender = TF->SendInfo();
aSender << aMapCountIter.Value() << aMapCountIter.Key() << std::endl;
if (mode == IFSelect_ListByItem)
{
const occ::handle<NCollection_HSequence<int>>& entityList = aMapListIter.Value();
int length = entityList->Length();
Message_Msg msg3035("IGES_3035");
TF->Send(msg3035, Message_Info);
char line[80];
Sprintf(line, "\t\t\t");
aSender << line;
int nbInLine = 0;
for (int i = 1; i <= length; i++)
{
// IDT_Out << (entityList->Value(i)) << " ";
Sprintf(line, "\t %d", entityList->Value(i));
aSender << line;
if (++nbInLine == 6)
{
nbInLine = 0;
Sprintf(line, "\n\t\t\t");
aSender << line;
}
}
aSender << std::endl;
}
}
break;
}
case IFSelect_ResultCount: {
Message_Msg msg3040("IGES_3040");
TF->Send(msg3040, Message_Info);
Message_Msg msg3011("IGES_3011");
msg3011.Arg(nbRoots);
TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");
msg3015.Arg(nbResults);
TF->Send(msg3015, Message_Info);
Message_Msg msg3045("IGES_3045");
TF->Send(msg3045, Message_Info);
NCollection_DataMap<TCollection_AsciiString, int>::Iterator aMapIter(aMapCountResult);
for (; aMapIter.More(); aMapIter.Next())
{
TF->SendInfo() << aMapIter.Key() << aMapIter.Value() << std::endl;
}
break;
}
case IFSelect_Mapping: {
Message_Msg msg3040("IGES_3050");
TF->Send(msg3040, Message_Info);
Message_Msg msg3011("IGES_3011");
msg3011.Arg(nbRoots);
TF->Send(msg3011, Message_Info);
Message_Msg msg3015("IGES_3015");
msg3015.Arg(nbResults);
TF->Send(msg3015, Message_Info);
Message_Msg msg3045("IGES_3055");
TF->Send(msg3045, Message_Info);
// Add failed entities in dicoCountMapping
if (nbRoots != nbResults)
{
for (int i = 1; i <= nbRoots; i++)
{
DeclareAndCast(IGESData_IGESEntity, root, TP->Root(i));
if (!TP->IsBound(root))
{
char mess[300];
Sprintf(mess,
"%d\t%d \t%s\t%s",
root->TypeNumber(),
root->FormNumber(),
"%d",
"Failed");
// std::cout << mess << std::endl;
(*aMapCountMapping.TryBound(mess, 0))++;
}
}
}
NCollection_DataMap<TCollection_AsciiString, int>::Iterator aMapCountIter(aMapCountMapping);
for (; aMapCountIter.More(); aMapCountIter.Next())
{
char mess[80];
Sprintf(mess, aMapCountIter.Key().ToCString(), aMapCountIter.Value());
// clang-format off
TF->SendInfo() << mess << std::endl; //dicoCountIter.Value() << dicoCountIter.Name() << std::endl;
// clang-format on
}
break;
}
default:
break;
}
}
}
//=================================================================================================
DE_ShapeFixParameters IGESControl_Reader::GetDefaultShapeFixParameters() const
{
return DEIGES_Parameters::GetDefaultShapeFixParameters();
}
//=================================================================================================
ShapeProcess::OperationsFlags IGESControl_Reader::GetDefaultShapeProcessFlags() const
{
ShapeProcess::OperationsFlags aFlags;
aFlags.set(ShapeProcess::Operation::FixShape);
return aFlags;
}