7fd59977 |
1 | //gka 06.01.99 S3767 |
2 | //abv 10.04.99 S4136: eliminate using BRepAPI::Precision() |
3 | #include <IGESControl_Reader.ixx> |
4 | #include <IGESControl_Controller.hxx> |
5 | #include <XSControl_Controller.hxx> |
6 | #include <XSControl_TransferReader.hxx> |
7 | #include <Interface_ShareFlags.hxx> |
8 | |
9 | #include <IFSelect_Functions.hxx> |
10 | #include <Interface_InterfaceModel.hxx> |
11 | #include <IGESData_IGESModel.hxx> |
12 | |
13 | #include <Interface_Static.hxx> |
14 | #include <Interface_Check.hxx> |
15 | |
16 | // S3767 dce 18/01/1999 |
17 | #include <Message_Msg.hxx> |
18 | #include <Transfer_TransientProcess.hxx> |
19 | #include <Transfer_IteratorOfProcessForTransient.hxx> |
20 | #include <Transfer_Binder.hxx> |
21 | #include <TopoDS_Shape.hxx> |
22 | #include <Interface_CheckIterator.hxx> |
23 | #include <Transfer_IteratorOfProcessForTransient.hxx> |
24 | #include <IFSelect_CheckCounter.hxx>//Transfer_Iterator.hxx> |
25 | #include <Dico_DictionaryOfTransient.hxx> |
26 | #include <Dico_DictionaryOfInteger.hxx> |
27 | #include <Dico_IteratorOfDictionaryOfInteger.hxx> |
28 | #include <Dico_IteratorOfDictionaryOfTransient.hxx> |
29 | #include <Interface_Macros.hxx> |
30 | #include <IGESData_IGESEntity.hxx> |
31 | #include <TColStd_HSequenceOfInteger.hxx> |
32 | #include <OSD_Timer.hxx> |
33 | #include <Transfer_TransferOutput.hxx> |
34 | #include <ShapeExtend_Explorer.hxx> |
35 | #include <Message_ProgressSentry.hxx> |
36 | #include <Message_Messenger.hxx> |
37 | #include <Transfer_ActorOfTransientProcess.hxx> |
38 | #include <IGESToBRep_Actor.hxx> |
39 | #include <IGESData_FileProtocol.hxx> |
40 | #include <TransferBRep.hxx> |
41 | #include <ShapeFix_ShapeTolerance.hxx> |
42 | #include <BRepLib.hxx> |
43 | // add of stdio.h for NT compilation |
44 | #include <stdio.h> |
45 | |
46 | |
47 | //======================================================================= |
48 | //function : IGESControl_Reader |
49 | //purpose : |
50 | //======================================================================= |
51 | |
52 | IGESControl_Reader::IGESControl_Reader () |
53 | { |
54 | IGESControl_Controller::Init(); |
55 | SetWS (new XSControl_WorkSession); |
56 | SetNorm("IGES"); |
57 | theReadOnlyVisible = Standard_False; |
58 | } |
59 | |
60 | |
61 | //======================================================================= |
62 | //function : IGESControl_Reader |
63 | //purpose : |
64 | //======================================================================= |
65 | |
66 | IGESControl_Reader::IGESControl_Reader |
67 | (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch) |
68 | { |
69 | IGESControl_Controller::Init(); |
70 | SetWS (WS,scratch); |
71 | SetNorm ("IGES"); |
72 | theReadOnlyVisible = Standard_False; |
73 | } |
74 | |
75 | |
76 | //======================================================================= |
77 | //function : IGESModel |
78 | //purpose : |
79 | //======================================================================= |
80 | |
81 | Handle(IGESData_IGESModel) IGESControl_Reader::IGESModel () const |
82 | { |
83 | return Handle(IGESData_IGESModel)::DownCast(Model()); |
84 | } |
85 | |
86 | |
87 | |
88 | //======================================================================= |
89 | //function : NbRootsForTransfer |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | Standard_Integer IGESControl_Reader::NbRootsForTransfer() |
94 | { |
95 | if (therootsta) return theroots.Length(); |
96 | therootsta = Standard_True; |
97 | |
98 | Handle(IGESData_IGESModel) model = IGESModel(); |
99 | if (model.IsNull()) return 0; |
100 | |
101 | Handle(XSControl_WorkSession) session = WS(); |
102 | Handle(Interface_Protocol) protocol = session->Protocol(); |
103 | Handle(XSControl_Controller) controller = session->NormAdaptor(); |
104 | Handle(Transfer_ActorOfTransientProcess) actor = controller->ActorRead(model); |
105 | |
106 | Interface_ShareFlags SH (model,protocol); |
107 | |
108 | // sln 11.06.2002 OCC448 |
109 | Interface_Static::SetIVal("read.iges.onlyvisible",theReadOnlyVisible); |
110 | |
111 | Standard_Integer nb = model->NbEntities(); |
112 | for (Standard_Integer i = 1; i <= nb; i ++) { |
113 | Handle(IGESData_IGESEntity) ent = model->Entity(i); |
114 | if ( SH.IsShared(ent) || ! actor->Recognize (ent) ) continue; |
115 | // on ajoute un traitement pour ne prendre que les entites visibles |
116 | if ( ! theReadOnlyVisible || ent->BlankStatus() == 0 ) { |
117 | theroots.Append(ent); |
118 | } |
119 | } |
120 | |
121 | return theroots.Length(); |
122 | } |
123 | |
124 | // #### Reliquat de methodes a reprendre #### |
125 | |
126 | //======================================================================= |
127 | // Function : PrintTransferInfo |
128 | // Purpose : Print statistics information on transfer using MoniTool message management |
129 | // Created : 18/01/98 DCE for S3767 |
130 | // Modified : |
131 | //======================================================================= |
132 | |
133 | void IGESControl_Reader::PrintTransferInfo |
134 | (const IFSelect_PrintFail failsonly, const IFSelect_PrintCount mode) const |
135 | { |
136 | Standard_Integer nbWarn = 0, nbFail= 0, nbEntities =0, nbRoots = 0, nbResults = 0; |
137 | Handle(Transfer_TransientProcess) TP = WS()->MapReader(); |
138 | Handle(Message_Messenger) TF = TP->Messenger(); |
139 | Handle(Interface_InterfaceModel) model = TP->Model(); |
140 | if (! model.IsNull()) { |
141 | nbEntities = model->NbEntities(); |
142 | nbRoots = TP->NbRoots(); |
143 | //nbResults = TP->NbMapped(); |
144 | Transfer_IteratorOfProcessForTransient iterTrans = TP->RootResult(Standard_True); |
145 | Handle(Dico_DictionaryOfInteger) dicoCountResult = new Dico_DictionaryOfInteger; |
146 | Handle(Dico_DictionaryOfInteger) dicoCountMapping = new Dico_DictionaryOfInteger; |
147 | for (iterTrans.Start(); iterTrans.More() ; iterTrans.Next() ) { |
148 | nbResults++; |
149 | // Init for dicoCountResult for IFSelect_ResultCount |
150 | if ( mode == IFSelect_ResultCount ) { |
151 | char mess[300]; |
152 | const Handle(Transfer_Binder) aBinder = iterTrans.Value(); |
153 | sprintf(mess,"\t%s",aBinder->ResultTypeName()); |
154 | Standard_Boolean deja; |
155 | Standard_Integer& nb = dicoCountResult->NewItem(mess,deja); |
156 | if (!deja) nb = 0; |
157 | nb ++; |
158 | } |
159 | // Init for dicoCountMapping for IFSelect_Mapping |
160 | else if ( mode == IFSelect_Mapping ) { |
161 | char mess[300]; |
162 | const Handle(Transfer_Binder) aBinder = iterTrans.Value(); |
163 | DeclareAndCast(IGESData_IGESEntity,igesEnt,iterTrans.Starting()); |
164 | |
165 | sprintf(mess,"%d\t%d\t%s\t%s", igesEnt->TypeNumber(), igesEnt->FormNumber(), |
166 | "%d", aBinder->ResultTypeName()); |
167 | //cout << mess << endl; |
168 | Standard_Boolean deja; |
169 | Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja); |
170 | if (!deja) nb = 0; |
171 | nb ++; |
172 | } |
173 | } |
174 | |
175 | Interface_CheckIterator checkIterator = TP->CheckList(Standard_False); |
176 | Handle(Dico_DictionaryOfInteger) dicoCount = new Dico_DictionaryOfInteger; |
177 | Handle(Dico_DictionaryOfTransient) dicoList = new Dico_DictionaryOfTransient; |
178 | // Init the dicoCount dicoList and nbWarn ,nb Fail. |
179 | for(checkIterator.Start(); checkIterator.More(); checkIterator.Next() ) { |
180 | char mess[300]; |
181 | const Handle(Interface_Check) aCheck = checkIterator.Value(); |
182 | Handle(Standard_Transient) ent = model->Value(checkIterator.Number()); |
183 | DeclareAndCast(IGESData_IGESEntity,igesEnt,ent); |
184 | Standard_Integer type = igesEnt->TypeNumber(), form = igesEnt->FormNumber(); |
185 | Standard_Integer nw = aCheck->NbWarnings(), nf = aCheck->NbFails(), i; |
186 | for(i = 1; (failsonly==IFSelect_FailAndWarn) && (i<= nw); i++) { |
187 | sprintf(mess,"\t W\t%d\t%d\t%s",type,form,aCheck->CWarning(i)); |
188 | Standard_Boolean deja; |
189 | Standard_Integer& nb = dicoCount->NewItem(mess,deja); |
190 | if (!deja) nb = 0; |
191 | nb ++; |
192 | Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja); |
193 | DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem); |
194 | if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; } |
195 | alist->Append(model->Number(igesEnt)*2-1); |
196 | } |
197 | for(i = 1; i<= nf; i++) { |
198 | sprintf(mess,"\t F\t%d\t%d\t%s",type,form,aCheck->CFail(i)); |
199 | // TF << mess << endl; |
200 | Standard_Boolean deja; |
201 | Standard_Integer& nb = dicoCount->NewItem(mess,deja); |
202 | if (!deja) nb = 0; |
203 | nb ++; |
204 | Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja); |
205 | DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem); |
206 | if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; } |
207 | alist->Append(model->Number(igesEnt)*2-1); |
208 | } |
209 | nbWarn += nw; |
210 | nbFail += nf; |
211 | } |
212 | Message_Msg msg3000("IGES_3000"); // ************************* |
213 | TF->Send (msg3000, Message_Info); //smh#14 |
214 | |
215 | switch (mode) { |
216 | case IFSelect_GeneralInfo : { |
217 | Message_Msg msg3005("IGES_3005");TF->Send(msg3005, Message_Info); |
218 | Message_Msg msg3010("IGES_3010");msg3010.Arg(nbEntities);TF->Send(msg3010, Message_Info); |
219 | Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info); |
220 | Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info); |
221 | Message_Msg msg3020("IGES_3020");msg3020.Arg(nbWarn);TF->Send(msg3020, Message_Info); |
222 | Message_Msg msg3025("IGES_3025");msg3025.Arg(nbFail);TF->Send(msg3025, Message_Info); |
223 | break; |
224 | } |
225 | case IFSelect_CountByItem : |
226 | case IFSelect_ListByItem : { |
227 | Message_Msg msg3030("IGES_3030"); |
228 | TF->Send(msg3030, Message_Info); |
229 | Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCount); |
230 | Dico_IteratorOfDictionaryOfTransient dicoListIter(dicoList); |
231 | for(dicoCountIter.Start(),dicoListIter.Start(); |
232 | dicoCountIter.More() && dicoListIter.More(); |
233 | dicoCountIter.Next(),dicoListIter.Next()) { |
234 | TF << dicoCountIter.Value() << dicoCountIter.Name() << endl; |
235 | if (mode == IFSelect_ListByItem) { |
236 | DeclareAndCast(TColStd_HSequenceOfInteger, entityList, dicoListIter.Value()); |
237 | Standard_Integer length = entityList->Length(); |
238 | Message_Msg msg3035("IGES_3035"); |
239 | TF->Send(msg3035, Message_Info); |
240 | char line[80]; |
241 | sprintf(line,"\t\t\t"); |
242 | TF << line ; |
243 | Standard_Integer nbInLine =0; |
244 | for(Standard_Integer i = 1; i <= length ; i++ ) { |
245 | // IDT_Out << (entityList->Value(i)) << " "; |
246 | sprintf(line,"\t %d", entityList->Value(i)); |
247 | TF << line ; |
248 | if (++nbInLine == 6) { |
249 | nbInLine = 0; |
250 | sprintf(line,"\n\t\t\t"); |
251 | TF << line ; |
252 | } |
253 | } |
254 | TF << endl ; |
255 | } |
256 | } |
257 | break; |
258 | } |
259 | case IFSelect_ResultCount : { |
260 | Message_Msg msg3040("IGES_3040");TF->Send(msg3040, Message_Info); |
261 | Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info); |
262 | Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info); |
263 | Message_Msg msg3045("IGES_3045");TF->Send(msg3045, Message_Info); |
264 | Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountResult); |
265 | for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) { |
266 | TF << dicoCountIter.Value() << dicoCountIter.Name() << endl; |
267 | } |
268 | break; |
269 | } |
270 | case IFSelect_Mapping : { |
271 | Message_Msg msg3040("IGES_3050");TF->Send(msg3040, Message_Info); |
272 | Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info); |
273 | Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info); |
274 | Message_Msg msg3045("IGES_3055");TF->Send(msg3045, Message_Info); |
275 | // Add failed entities in dicoCountMapping |
276 | if (nbRoots!=nbResults) { |
277 | for( Standard_Integer i = 1; i <= nbRoots ; i++) { |
278 | DeclareAndCast(IGESData_IGESEntity, root, TP->Root(i)); |
279 | if (!TP->IsBound(root)) { |
280 | char mess[300]; |
281 | |
282 | sprintf(mess,"%d\t%d \t%s\t%s", root->TypeNumber(), root->FormNumber(), |
283 | "%d", "Failed"); |
284 | //cout << mess << endl; |
285 | Standard_Boolean deja; |
286 | Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja); |
287 | if (!deja) nb = 0; |
288 | nb ++; |
289 | } |
290 | } |
291 | } |
292 | Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountMapping); |
293 | for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) { |
294 | char mess[80]; |
295 | sprintf(mess, dicoCountIter.Name().ToCString() , dicoCountIter.Value()); |
296 | TF << mess << endl; //dicoCountIter.Value() << dicoCountIter.Name() << endl; |
297 | } |
298 | break; |
299 | } |
300 | default: break; |
301 | } |
302 | } |
303 | } |