1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 //abv 10.04.99 S4136: eliminate using BRepAPI::Precision()
17 #include <BRepLib.hxx>
18 #include <Dico_DictionaryOfInteger.hxx>
19 #include <Dico_DictionaryOfTransient.hxx>
20 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
21 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
22 #include <IFSelect_CheckCounter.hxx>
23 #include <IFSelect_Functions.hxx>
24 #include <IGESControl_Controller.hxx>
25 #include <IGESControl_Reader.hxx>
26 #include <IGESData_FileProtocol.hxx>
27 #include <IGESData_IGESEntity.hxx>
28 #include <IGESData_IGESModel.hxx>
29 #include <IGESToBRep_Actor.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CheckIterator.hxx>
32 #include <Interface_InterfaceModel.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareFlags.hxx>
35 #include <Interface_Static.hxx>
36 #include <Message_Messenger.hxx>
37 #include <Message_Msg.hxx>
38 #include <OSD_Timer.hxx>
39 #include <ShapeExtend_Explorer.hxx>
40 #include <ShapeFix_ShapeTolerance.hxx>
41 #include <TColStd_HSequenceOfInteger.hxx>
42 #include <TopoDS_Shape.hxx>
43 #include <Transfer_ActorOfTransientProcess.hxx>
44 #include <Transfer_Binder.hxx>
45 #include <Transfer_IteratorOfProcessForTransient.hxx>
46 #include <Transfer_TransferOutput.hxx>
47 #include <Transfer_TransientProcess.hxx>
48 #include <TransferBRep.hxx>
49 #include <XSControl_Controller.hxx>
50 #include <XSControl_TransferReader.hxx>
51 #include <XSControl_WorkSession.hxx>
54 // S3767 dce 18/01/1999
55 //Transfer_Iterator.hxx>
56 // add of stdio.h for NT compilation
57 //=======================================================================
58 //function : IGESControl_Reader
60 //=======================================================================
61 IGESControl_Reader::IGESControl_Reader ()
63 IGESControl_Controller::Init();
64 SetWS (new XSControl_WorkSession);
66 theReadOnlyVisible = Standard_False;
70 //=======================================================================
71 //function : IGESControl_Reader
73 //=======================================================================
75 IGESControl_Reader::IGESControl_Reader
76 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
78 IGESControl_Controller::Init();
81 theReadOnlyVisible = Standard_False;
85 //=======================================================================
86 //function : IGESModel
88 //=======================================================================
90 Handle(IGESData_IGESModel) IGESControl_Reader::IGESModel () const
92 return Handle(IGESData_IGESModel)::DownCast(Model());
97 //=======================================================================
98 //function : NbRootsForTransfer
100 //=======================================================================
102 Standard_Integer IGESControl_Reader::NbRootsForTransfer()
104 if (therootsta) return theroots.Length();
105 therootsta = Standard_True;
107 Handle(IGESData_IGESModel) model = IGESModel();
108 if (model.IsNull()) return 0;
110 Handle(XSControl_WorkSession) session = WS();
111 Handle(Interface_Protocol) protocol = session->Protocol();
112 Handle(XSControl_Controller) controller = session->NormAdaptor();
113 Handle(Transfer_ActorOfTransientProcess) actor = controller->ActorRead(model);
115 Interface_ShareFlags SH (model,protocol);
117 // sln 11.06.2002 OCC448
118 Interface_Static::SetIVal("read.iges.onlyvisible",theReadOnlyVisible);
120 Standard_Integer nb = model->NbEntities();
121 for (Standard_Integer i = 1; i <= nb; i ++) {
122 Handle(IGESData_IGESEntity) ent = model->Entity(i);
123 if ( SH.IsShared(ent) || ! actor->Recognize (ent) ) continue;
124 // on ajoute un traitement pour ne prendre que les entites visibles
125 if ( ! theReadOnlyVisible || ent->BlankStatus() == 0 ) {
126 theroots.Append(ent);
130 return theroots.Length();
133 // #### Reliquat de methodes a reprendre ####
135 //=======================================================================
136 // Function : PrintTransferInfo
137 // Purpose : Print statistics information on transfer using MoniTool message management
138 // Created : 18/01/98 DCE for S3767
140 //=======================================================================
142 void IGESControl_Reader::PrintTransferInfo
143 (const IFSelect_PrintFail failsonly, const IFSelect_PrintCount mode) const
145 Standard_Integer nbWarn = 0, nbFail= 0, nbEntities =0, nbRoots = 0, nbResults = 0;
146 Handle(Transfer_TransientProcess) TP = WS()->MapReader();
147 Handle(Message_Messenger) TF = TP->Messenger();
148 Handle(Interface_InterfaceModel) model = TP->Model();
149 if (! model.IsNull()) {
150 nbEntities = model->NbEntities();
151 nbRoots = TP->NbRoots();
152 //nbResults = TP->NbMapped();
153 Transfer_IteratorOfProcessForTransient iterTrans = TP->RootResult(Standard_True);
154 Handle(Dico_DictionaryOfInteger) dicoCountResult = new Dico_DictionaryOfInteger;
155 Handle(Dico_DictionaryOfInteger) dicoCountMapping = new Dico_DictionaryOfInteger;
156 for (iterTrans.Start(); iterTrans.More() ; iterTrans.Next() ) {
158 // Init for dicoCountResult for IFSelect_ResultCount
159 if ( mode == IFSelect_ResultCount ) {
161 const Handle(Transfer_Binder) aBinder = iterTrans.Value();
162 sprintf(mess,"\t%s",aBinder->ResultTypeName());
163 Standard_Boolean deja;
164 Standard_Integer& nb = dicoCountResult->NewItem(mess,deja);
168 // Init for dicoCountMapping for IFSelect_Mapping
169 else if ( mode == IFSelect_Mapping ) {
171 const Handle(Transfer_Binder) aBinder = iterTrans.Value();
172 DeclareAndCast(IGESData_IGESEntity,igesEnt,iterTrans.Starting());
174 sprintf(mess,"%d\t%d\t%s\t%s", igesEnt->TypeNumber(), igesEnt->FormNumber(),
175 "%d", aBinder->ResultTypeName());
176 //cout << mess << endl;
177 Standard_Boolean deja;
178 Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja);
184 Interface_CheckIterator checkIterator = TP->CheckList(Standard_False);
185 Handle(Dico_DictionaryOfInteger) dicoCount = new Dico_DictionaryOfInteger;
186 Handle(Dico_DictionaryOfTransient) dicoList = new Dico_DictionaryOfTransient;
187 // Init the dicoCount dicoList and nbWarn ,nb Fail.
188 for(checkIterator.Start(); checkIterator.More(); checkIterator.Next() ) {
190 const Handle(Interface_Check) aCheck = checkIterator.Value();
191 Handle(Standard_Transient) ent = model->Value(checkIterator.Number());
192 DeclareAndCast(IGESData_IGESEntity,igesEnt,ent);
193 Standard_Integer type = igesEnt->TypeNumber(), form = igesEnt->FormNumber();
194 Standard_Integer nw = aCheck->NbWarnings(), nf = aCheck->NbFails(), i;
195 for(i = 1; (failsonly==IFSelect_FailAndWarn) && (i<= nw); i++) {
196 sprintf(mess,"\t W\t%d\t%d\t%s",type,form,aCheck->CWarning(i));
197 Standard_Boolean deja;
198 Standard_Integer& nb = dicoCount->NewItem(mess,deja);
201 Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja);
202 DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem);
203 if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; }
204 alist->Append(model->Number(igesEnt)*2-1);
206 for(i = 1; i<= nf; i++) {
207 sprintf(mess,"\t F\t%d\t%d\t%s",type,form,aCheck->CFail(i));
208 // TF << mess << endl;
209 Standard_Boolean deja;
210 Standard_Integer& nb = dicoCount->NewItem(mess,deja);
213 Handle(Standard_Transient)& anitem = dicoList->NewItem(mess,deja);
214 DeclareAndCast(TColStd_HSequenceOfInteger,alist,anitem);
215 if (!deja) { alist = new TColStd_HSequenceOfInteger(); anitem = alist; }
216 alist->Append(model->Number(igesEnt)*2-1);
221 Message_Msg msg3000("IGES_3000"); // *************************
222 TF->Send (msg3000, Message_Info); //smh#14
225 case IFSelect_GeneralInfo : {
226 Message_Msg msg3005("IGES_3005");TF->Send(msg3005, Message_Info);
227 Message_Msg msg3010("IGES_3010");msg3010.Arg(nbEntities);TF->Send(msg3010, Message_Info);
228 Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
229 Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
230 Message_Msg msg3020("IGES_3020");msg3020.Arg(nbWarn);TF->Send(msg3020, Message_Info);
231 Message_Msg msg3025("IGES_3025");msg3025.Arg(nbFail);TF->Send(msg3025, Message_Info);
234 case IFSelect_CountByItem :
235 case IFSelect_ListByItem : {
236 Message_Msg msg3030("IGES_3030");
237 TF->Send(msg3030, Message_Info);
238 Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCount);
239 Dico_IteratorOfDictionaryOfTransient dicoListIter(dicoList);
240 for(dicoCountIter.Start(),dicoListIter.Start();
241 dicoCountIter.More() && dicoListIter.More();
242 dicoCountIter.Next(),dicoListIter.Next()) {
243 TF << dicoCountIter.Value() << dicoCountIter.Name() << endl;
244 if (mode == IFSelect_ListByItem) {
245 DeclareAndCast(TColStd_HSequenceOfInteger, entityList, dicoListIter.Value());
246 Standard_Integer length = entityList->Length();
247 Message_Msg msg3035("IGES_3035");
248 TF->Send(msg3035, Message_Info);
250 sprintf(line,"\t\t\t");
252 Standard_Integer nbInLine =0;
253 for(Standard_Integer i = 1; i <= length ; i++ ) {
254 // IDT_Out << (entityList->Value(i)) << " ";
255 sprintf(line,"\t %d", entityList->Value(i));
257 if (++nbInLine == 6) {
259 sprintf(line,"\n\t\t\t");
268 case IFSelect_ResultCount : {
269 Message_Msg msg3040("IGES_3040");TF->Send(msg3040, Message_Info);
270 Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
271 Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
272 Message_Msg msg3045("IGES_3045");TF->Send(msg3045, Message_Info);
273 Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountResult);
274 for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) {
275 TF << dicoCountIter.Value() << dicoCountIter.Name() << endl;
279 case IFSelect_Mapping : {
280 Message_Msg msg3040("IGES_3050");TF->Send(msg3040, Message_Info);
281 Message_Msg msg3011("IGES_3011");msg3011.Arg(nbRoots);TF->Send(msg3011, Message_Info);
282 Message_Msg msg3015("IGES_3015");msg3015.Arg(nbResults);TF->Send(msg3015, Message_Info);
283 Message_Msg msg3045("IGES_3055");TF->Send(msg3045, Message_Info);
284 // Add failed entities in dicoCountMapping
285 if (nbRoots!=nbResults) {
286 for( Standard_Integer i = 1; i <= nbRoots ; i++) {
287 DeclareAndCast(IGESData_IGESEntity, root, TP->Root(i));
288 if (!TP->IsBound(root)) {
291 sprintf(mess,"%d\t%d \t%s\t%s", root->TypeNumber(), root->FormNumber(),
293 //cout << mess << endl;
294 Standard_Boolean deja;
295 Standard_Integer& nb = dicoCountMapping->NewItem(mess,deja);
301 Dico_IteratorOfDictionaryOfInteger dicoCountIter(dicoCountMapping);
302 for(dicoCountIter.Start(); dicoCountIter.More(); dicoCountIter.Next()) {
304 sprintf(mess, dicoCountIter.Name().ToCString() , dicoCountIter.Value());
305 TF << mess << endl; //dicoCountIter.Value() << dicoCountIter.Name() << endl;