973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | //pdn 11.01.99 including <stdio.h> for compilation on NT |
15 | //#70 rln 03.03.99 syntax correction |
0177fe26 |
16 | // sln 11.06.2002 OCC448 : Initialize "read.onlyvisiable" parameter to control transferring invisible sub entities which logically depend on the grouping entities |
7fd59977 |
17 | |
7fd59977 |
18 | #include <BRep_Builder.hxx> |
19 | #include <BRepLib.hxx> |
42cf5bc1 |
20 | #include <IGESAppli.hxx> |
21 | #include <IGESAppli_Protocol.hxx> |
7fd59977 |
22 | #include <IGESData_FileProtocol.hxx> |
23 | #include <IGESData_GlobalSection.hxx> |
42cf5bc1 |
24 | #include <IGESFile_Read.hxx> |
7fd59977 |
25 | #include <IGESSolid.hxx> |
26 | #include <IGESSolid_Protocol.hxx> |
7fd59977 |
27 | #include <IGESToBRep_Actor.hxx> |
28 | #include <IGESToBRep_CurveAndSurface.hxx> |
42cf5bc1 |
29 | #include <IGESToBRep_Reader.hxx> |
42cf5bc1 |
30 | #include <Interface_CheckIterator.hxx> |
31 | #include <Interface_CheckTool.hxx> |
42cf5bc1 |
32 | #include <Interface_ShareFlags.hxx> |
33 | #include <Interface_Static.hxx> |
34 | #include <Message_Messenger.hxx> |
35 | #include <Message_Msg.hxx> |
7e785937 |
36 | #include <Message_ProgressScope.hxx> |
42cf5bc1 |
37 | #include <OSD_Timer.hxx> |
7fd59977 |
38 | #include <ShapeExtend_Explorer.hxx> |
39 | #include <ShapeFix_ShapeTolerance.hxx> |
42cf5bc1 |
40 | #include <Standard_ErrorHandler.hxx> |
41 | #include <Standard_Failure.hxx> |
42cf5bc1 |
42 | #include <TopoDS_Compound.hxx> |
43 | #include <TopoDS_Shape.hxx> |
42cf5bc1 |
44 | #include <Transfer_TransferOutput.hxx> |
45 | #include <Transfer_TransientProcess.hxx> |
7fd59977 |
46 | #include <TransferBRep.hxx> |
7fd59977 |
47 | #include <XSAlgo.hxx> |
48 | #include <XSAlgo_AlgoContainer.hxx> |
49 | |
42cf5bc1 |
50 | #include <stdio.h> |
51 | //#include <ShapeCustom.hxx> |
57c28b61 |
52 | #ifdef _MSC_VER |
7fd59977 |
53 | #include <stdlib.h> |
54 | #else |
55 | #include <errno.h> |
56 | #endif |
57 | //extern int errno; |
58 | |
59 | static Handle(IGESData_FileProtocol) protocol; |
60 | |
61 | |
62 | //======================================================================= |
63 | //function : IGESToBRep_Reader |
64 | //purpose : |
65 | //======================================================================= |
66 | IGESToBRep_Reader::IGESToBRep_Reader () |
67 | { |
68 | theDone = Standard_False; |
69 | if (protocol.IsNull()) { |
70 | IGESAppli::Init(); IGESSolid::Init(); |
71 | protocol = new IGESData_FileProtocol; |
72 | protocol->Add(IGESAppli::Protocol()); |
73 | protocol->Add(IGESSolid::Protocol()); |
74 | } |
75 | theActor = new IGESToBRep_Actor; |
76 | theProc = new Transfer_TransientProcess; |
77 | } |
78 | |
79 | |
80 | //======================================================================= |
81 | //function : LoadFile |
82 | //purpose : loads a Model from a file |
83 | //======================================================================= |
84 | |
85 | Standard_Integer IGESToBRep_Reader::LoadFile (const Standard_CString filename) |
86 | { |
87 | if ( theProc.IsNull() ) |
88 | theProc = new Transfer_TransientProcess; |
89 | Handle(Message_Messenger) TF = theProc->Messenger(); |
90 | |
91 | // Message for Diagnostic file. |
92 | Message_Msg msg2000("IGES_2000"); |
93 | msg2000.Arg(filename); |
94 | TF->Send (msg2000, Message_Info); |
95 | //Message_Msg msg2001("IGES_2001"); // Date |
96 | Message_Msg msg2005("IGES_2005"); |
97 | msg2005.Arg(theProc->TraceLevel()); |
98 | TF->Send (msg2005, Message_Info); |
99 | ///////////////////////////////////////////////////////// |
100 | Handle(IGESData_IGESModel) model = new IGESData_IGESModel; |
101 | |
102 | OSD_Timer c; c.Reset(); c.Start(); |
103 | char *pfilename=(char *)filename; |
104 | Standard_Integer StatusFile = IGESFile_Read(pfilename,model,protocol); |
105 | if (StatusFile != 0) { |
106 | // Sending of message : IGES file opening error |
107 | Message_Msg Msg2("XSTEP_2"); |
108 | TF->Send (Msg2, Message_Info); |
109 | //Message_Msg Msg3("XSTEP_3"); |
110 | //Message_Msg Msg4("XSTEP_4"); |
111 | //Message_Msg Msg5("XSTEP_5"); |
112 | //Message_Msg Msg6("XSTEP_6"); |
113 | //Message_Msg Msg7("XSTEP_7"); |
114 | // Reasons of the file opening error |
115 | switch(errno) |
116 | { |
117 | case 2 : // Sending of message : No such file or directory |
118 | { |
119 | Message_Msg Msg3("XSTEP_3"); |
120 | TF->Send (Msg3, Message_Info); |
121 | } |
122 | break; |
123 | case 12 : // Sending of message : Not enough space |
124 | { |
125 | Message_Msg Msg4("XSTEP_4"); |
126 | TF->Send (Msg4, Message_Info); |
127 | } |
128 | break; |
129 | case 13 : // Sending of message : Permission Denied |
130 | { |
131 | Message_Msg Msg5("XSTEP_5"); |
132 | TF->Send (Msg5, Message_Info); |
133 | } |
134 | break; |
135 | case 24 : // Sending of message : Too many open files |
136 | { |
137 | Message_Msg Msg6("XSTEP_6"); |
138 | TF->Send (Msg6, Message_Info); |
139 | } |
140 | break; |
141 | default : // Sending of message : No determined |
142 | { |
143 | Message_Msg Msg7("XSTEP_7"); |
144 | TF->Send (Msg7, Message_Info); |
145 | } |
146 | break; |
147 | } |
148 | } |
149 | |
150 | Message_Msg Msg8 ("XSTEP_8"); |
151 | Message_Msg Msg25 ("XSTEP_25"); |
152 | Message_Msg Msg26 ("XSTEP_26"); |
153 | // Nb warning in global section. |
154 | |
155 | Standard_Integer nbWarn = 0,nbFail = 0; |
0177fe26 |
156 | // Add the number of warning on entities : |
7fd59977 |
157 | Interface_CheckTool cht (model,protocol); |
158 | Interface_CheckIterator anIter = cht.CompleteCheckList(); |
159 | for(anIter.Start(); anIter.More(); anIter.Next()) { |
b2fedee6 |
160 | const Handle(Interface_Check)& ach = anIter.Value(); |
7fd59977 |
161 | nbWarn += ach->NbWarnings(); |
162 | nbFail += ach->NbFails(); |
163 | } |
164 | // Messages nbWarn and nbFail; |
165 | Msg25.Arg(nbFail); |
166 | Msg26.Arg(nbWarn); |
167 | TF->Send (Msg25, Message_Info); |
168 | TF->Send (Msg26, Message_Info); |
169 | |
170 | // Message fin de loading iGES file (elapsed time %s) |
171 | char t[20]; |
172 | t[0]='\0'; |
173 | Standard_Real second, cpu; |
174 | Standard_Integer minute, hour; |
175 | c.Show(second, minute, hour,cpu); |
176 | if (hour > 0) |
91322f44 |
177 | Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second); |
7fd59977 |
178 | else if (minute > 0) |
91322f44 |
179 | Sprintf(t,"%dm:%.2fs",minute,second); |
7fd59977 |
180 | else |
91322f44 |
181 | Sprintf(t,"%.2fs",second); |
7fd59977 |
182 | // Sending of message : End of Loading |
183 | Msg8.Arg(t); |
184 | TF->Send (Msg8, Message_Info); |
185 | |
186 | SetModel(model); |
187 | return StatusFile; |
188 | } |
189 | |
190 | |
191 | //======================================================================= |
192 | //function : SetModel |
193 | //purpose : Specifies a Model to work on |
194 | //======================================================================= |
195 | void IGESToBRep_Reader::SetModel (const Handle(IGESData_IGESModel)& model) |
196 | { |
197 | theModel = model; |
198 | theDone = Standard_False; |
199 | theShapes.Clear(); |
200 | if ( theProc.IsNull() ) |
201 | theProc = new Transfer_TransientProcess (theModel->NbEntities()); |
202 | else |
203 | theProc->Clear(); |
204 | } |
205 | |
206 | |
207 | //======================================================================= |
208 | //function : Model |
209 | //purpose : returns the Model to be worked on |
210 | //======================================================================= |
211 | Handle(IGESData_IGESModel) IGESToBRep_Reader::Model () const |
212 | { return theModel; } |
213 | |
214 | |
215 | //======================================================================= |
216 | //function : SetTransientProcess |
217 | //purpose : Specifies a TransferProcess |
218 | //======================================================================= |
219 | void IGESToBRep_Reader::SetTransientProcess |
220 | (const Handle(Transfer_TransientProcess)& TP) |
221 | { theProc = TP; } |
222 | |
223 | //======================================================================= |
224 | //function : TransientProcess |
225 | //purpose : Returns the TransferProcess |
226 | //======================================================================= |
227 | Handle(Transfer_TransientProcess) IGESToBRep_Reader::TransientProcess () const |
228 | { return theProc; } |
229 | |
230 | //======================================================================= |
231 | //function : Actor |
232 | //purpose : returns theActor |
233 | //======================================================================= |
234 | Handle(IGESToBRep_Actor) IGESToBRep_Reader::Actor () const |
235 | { return theActor; } |
236 | |
237 | |
238 | //======================================================================= |
239 | //function : Clear |
240 | //purpose : Clears the result and Done status |
241 | //======================================================================= |
242 | void IGESToBRep_Reader::Clear () |
243 | { |
244 | theDone = Standard_False; |
245 | theShapes.Clear(); |
246 | } |
247 | |
248 | |
249 | //======================================================================= |
250 | //function : Check |
251 | //purpose : Checks the Model |
252 | //======================================================================= |
253 | Standard_Boolean IGESToBRep_Reader::Check |
254 | (const Standard_Boolean withprint) const |
255 | { |
256 | Interface_CheckTool cht (theModel,protocol); |
257 | Interface_CheckIterator chl = cht.CompleteCheckList(); |
0ebe5b0a |
258 | if (withprint |
259 | && !theProc.IsNull() |
260 | && !theProc->Messenger().IsNull()) |
261 | { |
262 | Message_Messenger::StreamBuffer aBuffer = theProc->Messenger()->SendInfo(); |
263 | cht.Print(chl, aBuffer); |
264 | } |
7fd59977 |
265 | return chl.IsEmpty(Standard_True); |
266 | } |
267 | |
268 | |
269 | //======================================================================= |
270 | //function : IsDone |
271 | //purpose : returns True if the last transfert was a success |
272 | //======================================================================= |
273 | Standard_Boolean IGESToBRep_Reader::IsDone () const |
274 | { return theDone; } |
275 | |
276 | |
277 | //======================================================================= |
278 | //function : EncodeRegul |
279 | //purpose : INTERNAL to encode regularity on edges |
280 | //======================================================================= |
281 | |
282 | static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh) |
283 | { |
284 | Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle"); |
285 | if (sh.IsNull()) return Standard_True; |
286 | if (tolang <= 0) return Standard_True; |
287 | try { |
288 | OCC_CATCH_SIGNALS |
289 | BRepLib::EncodeRegularity (sh,tolang); |
290 | } |
a738b534 |
291 | catch(Standard_Failure const&) { |
7fd59977 |
292 | return Standard_False; |
293 | } |
294 | return Standard_True; |
295 | } |
296 | |
297 | //======================================================================= |
298 | //function : UpdateMap |
299 | //purpose : Updates the correspondence map (Transfer_TransientProcess), |
300 | // setting as translation results, the shapes received after |
301 | // modification by modifier (BRepTools_Modifier) |
302 | //warning : BRepTools_Modifier raises exception when it cannot find input |
303 | // shape in its internal list |
304 | //======================================================================= |
305 | |
0177fe26 |
306 | // comment as unused PTV 18.09.2000 |
7fd59977 |
307 | // static void UpdateMap (const Handle(Transfer_TransientProcess)& map, |
308 | // const BRepTools_Modifier& modifier) |
309 | // { |
310 | // Transfer_IteratorOfProcessForTransient iterator = map->CompleteResult(Standard_True); |
311 | // for (iterator.Start(); iterator.More(); iterator.Next()) { |
312 | // const Handle(Transfer_Binder) binder = iterator.Value(); |
313 | // try { //to avoid exception in BRepTools_Modifier |
314 | // OCC_CATCH_SIGNALS |
315 | // if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeBinder))) { |
316 | // DeclareAndCast(TransferBRep_ShapeBinder, shapebinder, binder); |
317 | // if (shapebinder->HasResult()) { |
318 | // TopoDS_Shape result = shapebinder->Result(); |
319 | // TopoDS_Shape modified = modifier.ModifiedShape (result); |
320 | // if (shapebinder->Status() != Transfer_StatusUsed) //to avoid exception |
321 | // shapebinder->SetResult (modified); |
322 | // } |
323 | // } |
324 | // else if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeListBinder))) { |
325 | // DeclareAndCast(TransferBRep_ShapeListBinder, shapelistbinder, binder); |
326 | // for (Standard_Integer i = 1; i <= shapelistbinder->NbShapes(); i++) { |
327 | // TopoDS_Shape result = shapelistbinder->Shape (i); |
328 | // TopoDS_Shape modified = modifier.ModifiedShape (result); |
329 | // shapelistbinder->SetResult (i, modified); |
330 | // } |
331 | // } |
332 | // } |
333 | // catch(Standard_Failure) { |
334 | // continue; |
335 | // } |
336 | // } |
337 | // } |
338 | |
339 | //======================================================================= |
340 | //function : TrimTolerances |
341 | //purpose : Trims tolerances of the shape according to static parameters |
342 | // |
343 | //======================================================================= |
344 | |
345 | static void TrimTolerances (const TopoDS_Shape& shape, |
346 | const Standard_Real tol) |
347 | { |
348 | if( Interface_Static::IVal("read.maxprecision.mode")==1) { |
349 | ShapeFix_ShapeTolerance SFST; |
350 | SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val"))); |
351 | } |
352 | } |
353 | |
354 | //======================================================================= |
355 | //function : TransferRoots |
356 | //purpose : Transfers all Roots Entities |
357 | //======================================================================= |
7e785937 |
358 | void IGESToBRep_Reader::TransferRoots (const Standard_Boolean onlyvisible, |
359 | const Message_ProgressRange& theProgress) |
7fd59977 |
360 | { |
361 | if (theModel.IsNull() || theProc.IsNull()) return; |
362 | |
363 | Handle(Message_Messenger) TF = theProc->Messenger(); |
364 | // Declaration of messages. |
365 | Message_Msg msg2030("IGES_2030"); |
366 | TF->Send (msg2030, Message_Info); |
367 | Message_Msg msg2065("IGES_2065"); |
368 | OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO |
369 | theDone = Standard_False; |
370 | theShapes.Clear(); |
371 | |
372 | Standard_Integer level = theProc->TraceLevel(); |
373 | theProc->SetErrorHandle(Standard_True); |
374 | theProc->SetRootManagement(Standard_True); |
375 | // PrepareTransfer(); -> protocol, actor |
376 | theActor->SetModel(theModel); |
377 | Standard_Integer continuity = Interface_Static::IVal("read.iges.bspline.continuity"); |
378 | theActor->SetContinuity (continuity); |
379 | theProc->SetModel (theModel); |
380 | theProc->SetActor (theActor); |
381 | Transfer_TransferOutput TP (theProc,theModel); |
382 | |
543a9964 |
383 | const Handle(Interface_Protocol) aProtocol = protocol; // to avoid ambiguity |
384 | Interface_ShareFlags SH (theModel, aProtocol); |
7fd59977 |
385 | Standard_Integer nb = theModel->NbEntities(); |
386 | ShapeExtend_Explorer SBE; |
387 | |
388 | |
389 | Standard_Integer precisionMode = Interface_Static::IVal("read.precision.mode"); |
390 | Message_Msg msg2035("IGES_2035"); |
391 | msg2035.Arg(precisionMode); |
392 | TF->Send (msg2035, Message_Info); |
393 | if (precisionMode==1) { |
394 | Message_Msg msg2040("IGES_2040"); |
395 | msg2040.Arg(Interface_Static::RVal("read.precision.val"));//#70 rln 03.03.99 |
396 | TF->Send (msg2040, Message_Info); |
397 | } |
398 | Message_Msg msg2045("IGES_2045"); |
399 | msg2045.Arg(continuity); |
400 | TF->Send (msg2045, Message_Info); |
401 | Message_Msg msg2050("IGES_2050"); |
402 | msg2050.Arg(Interface_Static::IVal("read.surfacecurve.mode")); |
403 | TF->Send (msg2050, Message_Info); |
404 | |
405 | // sln 11.06.2002 OCC448 |
406 | Interface_Static::SetIVal("read.iges.onlyvisible",onlyvisible); |
407 | |
7e785937 |
408 | Message_ProgressScope PS (theProgress, "Root", nb); |
409 | for (Standard_Integer i = 1; i <= nb && PS.More(); i++) |
410 | { |
411 | Message_ProgressRange aRange = PS.Next(); |
7fd59977 |
412 | Handle(IGESData_IGESEntity) ent = theModel->Entity(i); |
413 | if ( SH.IsShared(ent) || ! theActor->Recognize (ent) ) continue; |
414 | if (level > 0) { |
415 | Message_Msg msg2070("IGES_2070"); |
416 | msg2070.Arg(2*i-1); |
417 | msg2070.Arg(ent->TypeNumber()); |
418 | TF->Send (msg2070, Message_Info); |
419 | } |
420 | // on ajoute un traitement pour ne prendre que les entites visibles |
421 | if ( ! onlyvisible || ent->BlankStatus() == 0 ) { |
422 | TopoDS_Shape shape; |
423 | theDone = Standard_True; |
424 | try { |
425 | OCC_CATCH_SIGNALS |
7e785937 |
426 | TP.Transfer (ent, aRange); |
7fd59977 |
427 | shape = TransferBRep::ShapeResult (theProc,ent); |
428 | } |
a738b534 |
429 | catch(Standard_Failure const&) { |
7fd59977 |
430 | Message_Msg msg1005("IGES_1005"); |
431 | TF->Send (msg1005, Message_Info); |
432 | continue; |
433 | } |
434 | if (shape.IsNull()) { |
435 | Message_Msg msg2076("IGES_2076"); |
436 | TF->Send (msg2076, Message_Info); |
437 | } |
438 | else { |
439 | if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) { |
440 | if (!shape.IsNull()) { |
441 | EncodeRegul (shape); |
442 | //#74 rln 03.03.99 S4135 |
443 | TrimTolerances (shape, theActor->UsedTolerance()); |
444 | theShapes.Append(shape); |
445 | } |
446 | } |
447 | } |
448 | } |
449 | } |
450 | char t [20]; |
451 | t[0]='\0'; |
452 | Standard_Real second, cpu; |
453 | Standard_Integer minute, hour; |
454 | c.Show(second, minute, hour,cpu); |
455 | if (hour > 0) |
91322f44 |
456 | Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second); |
7fd59977 |
457 | else if (minute > 0) |
91322f44 |
458 | Sprintf(t,"%dm:%.2fs",minute,second); |
7fd59977 |
459 | else |
91322f44 |
460 | Sprintf(t,"%.2fs",second); |
7fd59977 |
461 | // Sending of message : End of Loading |
462 | msg2065.Arg(t); |
463 | TF->Send (msg2065, Message_Info); |
464 | } |
465 | |
466 | |
467 | //======================================================================= |
468 | //function : Transfer |
469 | //purpose : Transfers an Entity given |
470 | //======================================================================= |
7e785937 |
471 | Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num, |
472 | const Message_ProgressRange& theProgress) |
7fd59977 |
473 | { |
474 | Handle(Message_Messenger) TF = theProc->Messenger(); |
475 | theDone = Standard_False; |
476 | if (theModel.IsNull()) { |
477 | Message_Msg msg2031("IGES_2031"); |
478 | TF->Send (msg2031, Message_Info); |
479 | return Standard_False; |
480 | } |
481 | if (num <= 0 || num > theModel->NbEntities()) { |
482 | Message_Msg msg2032("IGES_2032"); |
483 | msg2032.Arg(num); |
484 | TF->Send (msg2032, Message_Info); |
485 | return Standard_False; |
486 | } |
487 | // declaration of messages |
488 | Message_Msg msg2030("IGES_2030"); |
489 | TF->Send (msg2030, Message_Info); |
490 | Message_Msg msg2065("IGES_2065"); |
491 | OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO |
492 | |
493 | Handle(IGESData_IGESEntity) ent = theModel->Entity(num); |
494 | |
7e785937 |
495 | Message_ProgressScope aPS(theProgress, "OneEnt", 2); |
7fd59977 |
496 | |
497 | XSAlgo::AlgoContainer()->PrepareForTransfer(); |
498 | IGESToBRep_CurveAndSurface CAS; |
499 | CAS.SetModel(theModel); |
500 | Standard_Real eps; |
501 | Standard_Integer Ival = Interface_Static::IVal("read.precision.mode"); |
502 | Message_Msg msg2035("IGES_2035"); |
503 | msg2035.Arg(Ival); |
504 | TF->Send (msg2035, Message_Info); |
505 | if ( Ival == 0) |
506 | eps = theModel->GlobalSection().Resolution(); |
507 | else { |
508 | //mjm : modif du 19/12/97 pour prise en compte effective du parametre |
509 | eps = Interface_Static::RVal("read.precision.val"); |
510 | Message_Msg msg2040("IGES_2040"); |
511 | msg2040.Arg(eps);//#70 rln 03.03.99 |
512 | TF->Send (msg2040, Message_Info); |
513 | |
514 | } |
515 | Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode"); |
516 | CAS.SetModeApprox ( (Ival > 0) ); |
517 | Message_Msg msg2045("IGES_2045"); |
518 | Ival = Interface_Static::IVal("read.iges.bspline.continuity"); |
519 | msg2045.Arg(Ival); |
520 | TF->Send (msg2045, Message_Info); |
521 | CAS.SetContinuity(Ival); |
522 | Message_Msg msg2050("IGES_2050"); |
523 | Ival = Interface_Static::IVal("read.surfacecurve.mode"); |
524 | msg2050.Arg(Ival); |
525 | TF->Send (msg2050, Message_Info); |
526 | CAS.SetSurfaceCurve (Ival); |
527 | |
528 | if (eps > 1.E-08) CAS.SetEpsGeom(eps); |
529 | CAS.SetTransferProcess(theProc); |
530 | |
531 | Standard_Boolean exceptionRaised = Standard_False; |
532 | TopoDS_Shape shape; |
533 | Standard_Integer nbTPitems = theProc->NbMapped(); |
534 | { |
535 | try { |
536 | OCC_CATCH_SIGNALS |
7e785937 |
537 | shape = CAS.TransferGeometry (ent, aPS.Next()); |
538 | if (aPS.UserBreak()) |
539 | return Standard_False; |
7fd59977 |
540 | } |
a738b534 |
541 | catch(Standard_Failure const&) { |
7fd59977 |
542 | Message_Msg msg1015("IGES_1015"); |
543 | TF->Send (msg1015, Message_Info); |
544 | exceptionRaised = Standard_True; |
545 | } |
546 | } |
547 | if (!exceptionRaised) { |
548 | // fixing shape |
549 | // shape = XSAlgo::AlgoContainer()->PerformFixShape ( shape, theProc, eps*CAS.GetUnitFactor(), CAS.GetMaxTol() ); |
550 | |
551 | Handle(Standard_Transient) info; |
552 | shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(), |
553 | "read.iges.resource.name", |
b485ee79 |
554 | "read.iges.sequence", info, |
2a0420be |
555 | aPS.Next(), false, TopAbs_EDGE); |
7e785937 |
556 | if (aPS.UserBreak()) |
557 | return Standard_False; |
558 | |
7fd59977 |
559 | XSAlgo::AlgoContainer()->MergeTransferInfo(theProc, info, nbTPitems); |
560 | |
561 | ShapeExtend_Explorer SBE; |
562 | if (SBE.ShapeType (shape,Standard_True) != TopAbs_SHAPE) { |
563 | TransferBRep::SetShapeResult (theProc,ent,shape); |
564 | theProc->SetRoot (ent); |
565 | if (!shape.IsNull()) { |
566 | theDone = Standard_True; |
567 | EncodeRegul (shape); |
568 | //#74 rln 03.03.99 S4135 |
569 | TrimTolerances (shape, CAS.GetMaxTol()); |
570 | theShapes.Append(shape); |
571 | } |
572 | } |
573 | } |
7fd59977 |
574 | |
575 | char t [20]; |
576 | t[0]='\0'; |
577 | Standard_Real second, cpu; |
578 | Standard_Integer minute, hour; |
579 | c.Show(second, minute, hour,cpu); |
580 | if (hour > 0) |
91322f44 |
581 | Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second); |
7fd59977 |
582 | else if (minute > 0) |
91322f44 |
583 | Sprintf(t,"%dm:%.2fs",minute,second); |
7fd59977 |
584 | else |
91322f44 |
585 | Sprintf(t,"%.2fs",second); |
7fd59977 |
586 | // Sending of message : End of Loading |
587 | msg2065.Arg(t); |
588 | TF->Send (msg2065, Message_Info); |
589 | return Standard_True; |
590 | } |
591 | |
592 | |
593 | //======================================================================= |
594 | //function : UsedTolerance |
595 | //purpose : Returns the used tolerance (input) |
596 | //======================================================================= |
597 | Standard_Real IGESToBRep_Reader::UsedTolerance () const |
598 | { return theActor->UsedTolerance(); } |
599 | |
600 | //======================================================================= |
601 | //function : NbShapes |
602 | //purpose : Returns the count of produced Shapes |
603 | //======================================================================= |
604 | Standard_Integer IGESToBRep_Reader::NbShapes () const |
605 | { return theShapes.Length(); } |
606 | |
607 | |
608 | //======================================================================= |
609 | //function : Shape |
610 | //purpose : Returns a Shape given its rank |
611 | //======================================================================= |
612 | TopoDS_Shape IGESToBRep_Reader::Shape (const Standard_Integer num) const |
613 | { |
614 | TopoDS_Shape res; |
615 | if (num > 0 && num <= theShapes.Length()) res = theShapes.Value(num); |
616 | return res; |
617 | } |
618 | |
619 | |
620 | //======================================================================= |
621 | //function : OneShape |
622 | //purpose : Returns a unique Shape |
623 | //======================================================================= |
624 | TopoDS_Shape IGESToBRep_Reader::OneShape () const |
625 | { |
626 | TopoDS_Shape res; |
627 | Standard_Integer nb = theShapes.Length(); |
628 | if (nb == 0) return res; |
629 | else if (nb == 1) return theShapes.Value(1); |
630 | else { |
631 | TopoDS_Compound C; |
632 | BRep_Builder B; |
633 | B.MakeCompound(C); |
634 | for (Standard_Integer i = 1; i <= nb; i ++) B.Add (C,theShapes.Value(i)); |
635 | return C; |
636 | } |
637 | } |