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 | // 22.12.98 dce S3767 |
15 | // 21.12.98 rln, gka S4054 |
16 | //#74 rln,pdn 11.03.99 S4135: Setting minimum and maximum tolerances according to static parameters |
17 | // sln 13.06.2002 OCC448 : Correction in method TransferGeometry to avoid transfering invisiable sub entities |
18 | |
7fd59977 |
19 | #include <BRep_Builder.hxx> |
7fd59977 |
20 | #include <BRepLib.hxx> |
42cf5bc1 |
21 | #include <Geom_Surface.hxx> |
22 | #include <GeomAdaptor_Surface.hxx> |
7fd59977 |
23 | #include <gp_GTrsf.hxx> |
42cf5bc1 |
24 | #include <gp_Trsf.hxx> |
7fd59977 |
25 | #include <gp_Vec.hxx> |
42cf5bc1 |
26 | #include <IGESBasic_Group.hxx> |
27 | #include <IGESBasic_GroupWithoutBackP.hxx> |
28 | #include <IGESBasic_SingularSubfigure.hxx> |
29 | #include <IGESBasic_SubfigureDef.hxx> |
30 | #include <IGESData_IGESEntity.hxx> |
31 | #include <IGESData_IGESModel.hxx> |
32 | #include <IGESData_ToolLocation.hxx> |
33 | #include <IGESToBRep.hxx> |
34 | #include <IGESToBRep_BRepEntity.hxx> |
35 | #include <IGESToBRep_CurveAndSurface.hxx> |
36 | #include <IGESToBRep_TopoCurve.hxx> |
37 | #include <IGESToBRep_TopoSurface.hxx> |
7fd59977 |
38 | #include <Interface_Macros.hxx> |
39 | #include <Interface_Static.hxx> |
42cf5bc1 |
40 | #include <Message_Messenger.hxx> |
41 | #include <Message_Msg.hxx> |
42 | #include <Message_ProgressSentry.hxx> |
43 | #include <Precision.hxx> |
44 | #include <Standard_ErrorHandler.hxx> |
45 | #include <Standard_Failure.hxx> |
7fd59977 |
46 | #include <TopExp_Explorer.hxx> |
47 | #include <TopLoc_Location.hxx> |
48 | #include <TopoDS.hxx> |
49 | #include <TopoDS_Compound.hxx> |
50 | #include <TopoDS_Edge.hxx> |
51 | #include <TopoDS_Shape.hxx> |
7fd59977 |
52 | #include <Transfer_TransientProcess.hxx> |
53 | #include <TransferBRep_ShapeBinder.hxx> |
54 | #include <TransferBRep_ShapeListBinder.hxx> |
7fd59977 |
55 | |
42cf5bc1 |
56 | #include <stdio.h> |
7fd59977 |
57 | //======================================================================= |
58 | //function : IGESToBRep_CurveAndSurface |
cbff1e55 |
59 | //purpose : |
7fd59977 |
60 | //======================================================================= |
7fd59977 |
61 | IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface() |
cbff1e55 |
62 | : myEps (1.e-04), |
63 | myEpsCoeff (1.e-06), |
64 | myEpsGeom (1.e-04), |
65 | myMinTol (-1.0), |
66 | myMaxTol (-1.0), |
67 | myModeIsTopo (Standard_True), |
68 | myModeApprox (Standard_False), |
69 | myContIsOpti (Standard_False), |
70 | myUnitFactor (1.0), |
71 | mySurfaceCurve(0), |
72 | myContinuity (0), |
73 | myUVResolution(0.0), |
74 | myIsResolCom (Standard_False), |
75 | myTP (new Transfer_TransientProcess()) |
7fd59977 |
76 | { |
cbff1e55 |
77 | UpdateMinMaxTol(); |
7fd59977 |
78 | } |
79 | |
80 | |
81 | //======================================================================= |
82 | //function : IGESToBRep_CurveAndSurface |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface |
87 | (const IGESToBRep_CurveAndSurface& other) |
cbff1e55 |
88 | : myEps (other.myEps), |
89 | myEpsCoeff (other.myEpsCoeff), |
90 | myEpsGeom (other.myEpsGeom), |
91 | myMinTol (other.myMinTol), |
92 | myMaxTol (other.myMaxTol), |
93 | myModeIsTopo (other.myModeIsTopo), |
94 | myModeApprox (other.myModeApprox), |
95 | myContIsOpti (other.myContIsOpti), |
96 | myUnitFactor (other.myUnitFactor), |
97 | mySurfaceCurve(other.mySurfaceCurve), |
98 | myContinuity (other.myContinuity), |
99 | mySurface (other.mySurface), |
100 | myUVResolution(other.myUVResolution), |
101 | myIsResolCom (other.myIsResolCom), |
102 | myModel (other.myModel), |
103 | myTP (other.myTP) |
7fd59977 |
104 | { |
7fd59977 |
105 | } |
106 | |
107 | |
108 | //======================================================================= |
109 | //function : IGESToBRep_CurveAndSurface |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | IGESToBRep_CurveAndSurface::IGESToBRep_CurveAndSurface |
114 | (const Standard_Real eps, |
115 | const Standard_Real epsCoeff, |
116 | const Standard_Real epsGeom, |
117 | const Standard_Boolean mode, |
118 | const Standard_Boolean modeapprox, |
119 | const Standard_Boolean optimized) |
cbff1e55 |
120 | : myEps (eps), |
121 | myEpsCoeff (epsCoeff), |
122 | myEpsGeom (epsGeom), |
123 | myMinTol (-1.0), |
124 | myMaxTol (-1.0), |
125 | myModeIsTopo (mode), |
126 | myModeApprox (modeapprox), |
127 | myContIsOpti (optimized), |
128 | myUnitFactor (1.0), |
129 | mySurfaceCurve(0), |
130 | myContinuity (0), |
131 | myUVResolution(0.0), |
132 | myIsResolCom (Standard_False), |
133 | myTP (new Transfer_TransientProcess()) |
134 | { |
7fd59977 |
135 | UpdateMinMaxTol(); |
136 | } |
137 | |
138 | //======================================================================= |
139 | //function : Init |
140 | //purpose : |
141 | //======================================================================= |
142 | |
143 | void IGESToBRep_CurveAndSurface::Init() |
144 | { |
145 | myEps = 1.E-04; |
146 | myEpsCoeff = 1.E-06; |
147 | myEpsGeom = 1.E-04; |
148 | myModeIsTopo = Standard_True; |
149 | myModeApprox = Standard_False; |
150 | myContIsOpti = Standard_False; |
151 | myUnitFactor = 1.; |
152 | mySurfaceCurve = 0; |
153 | myContinuity = 0; |
154 | myTP = new Transfer_TransientProcess(); |
155 | |
156 | mySurface.Nullify(); |
157 | myIsResolCom = Standard_False; |
158 | myUVResolution = 0.; |
159 | UpdateMinMaxTol(); |
160 | } |
161 | |
162 | //======================================================================= |
163 | //function : SetEpsGeom |
164 | //purpose : |
165 | //======================================================================= |
166 | void IGESToBRep_CurveAndSurface::SetEpsGeom(const Standard_Real eps) |
167 | { |
168 | myEpsGeom = eps; |
169 | UpdateMinMaxTol(); |
170 | } |
171 | |
172 | |
173 | //======================================================================= |
174 | //function : UpdateMinMaxTol |
175 | //purpose : |
176 | //======================================================================= |
177 | |
178 | void IGESToBRep_CurveAndSurface::UpdateMinMaxTol() |
179 | { |
180 | //#74 rln 11.03.99 S4135: Setting maximum tolerances according to |
181 | //static parameter |
182 | myMaxTol = Max (Interface_Static::RVal ("read.maxprecision.val"), myEpsGeom * myUnitFactor); |
183 | myMinTol = Precision::Confusion(); |
184 | } |
185 | |
186 | //======================================================================= |
187 | //function : SetModel |
188 | //purpose : |
189 | //======================================================================= |
190 | void IGESToBRep_CurveAndSurface::SetModel(const Handle(IGESData_IGESModel)& model) |
191 | { |
192 | myModel = model; |
193 | Standard_Real unitfactor = myModel->GlobalSection().UnitValue(); |
194 | if (unitfactor != 1.) |
195 | { |
196 | if ( myTP->TraceLevel() > 2 ) |
197 | myTP->Messenger() << "UnitFactor = "<< unitfactor << endl; |
198 | myUnitFactor = unitfactor; |
199 | } |
200 | UpdateMinMaxTol(); |
201 | } |
202 | |
203 | //======================================================================= |
204 | //function : TransferCurveAndSurface |
205 | //purpose : |
206 | //======================================================================= |
207 | |
208 | TopoDS_Shape IGESToBRep_CurveAndSurface::TransferCurveAndSurface |
209 | (const Handle(IGESData_IGESEntity)& start) |
210 | { |
211 | TopoDS_Shape res; |
212 | if (start.IsNull()) { |
213 | Message_Msg msg1005("IGES_1005"); |
214 | SendFail(start, msg1005); |
215 | return res; |
216 | } |
217 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
218 | // Standard_Integer typeNumber = start->TypeNumber(); |
219 | |
220 | if (IGESToBRep::IsTopoCurve(start)) { |
221 | IGESToBRep_TopoCurve TC(*this); |
222 | res = TC.TransferTopoCurve(start); |
223 | } |
224 | else if (IGESToBRep::IsTopoSurface(start)) { |
225 | IGESToBRep_TopoSurface TS(*this); |
226 | res = TS.TransferTopoSurface(start); |
227 | } |
228 | else if (IGESToBRep::IsBRepEntity(start)) { |
229 | IGESToBRep_BRepEntity TS(*this); |
230 | res = TS.TransferBRepEntity(start); |
231 | } |
232 | else { |
233 | Message_Msg msg1015("IGES_1015"); |
234 | SendFail(start, msg1015); |
235 | // AddFail(start, "The IGESEntity is not a curve a Surface or a BRep Entity."); |
236 | } |
237 | // mjm le 12/09/96 |
238 | /* |
239 | if (!res.IsNull()) { |
240 | try { |
241 | OCC_CATCH_SIGNALS |
242 | Standard_Real Eps = GetEpsGeom()*GetUnitFactor(); |
243 | BRepLib::SameParameter(res,Eps); |
244 | } |
245 | catch(Standard_Failure) { |
246 | Message_Msg msg1010("IGES_1010"); |
247 | SendWarning (start,msg1010); |
248 | } |
249 | } |
250 | */ |
251 | return res; |
252 | } |
253 | |
254 | |
255 | |
256 | //======================================================================= |
257 | //function : TransferGeometry |
258 | //purpose : |
259 | //======================================================================= |
260 | |
261 | TopoDS_Shape IGESToBRep_CurveAndSurface::TransferGeometry |
262 | (const Handle(IGESData_IGESEntity)& start) |
263 | { |
264 | // Declaration of messages// |
265 | // DCE 22/12/98 |
266 | //Message_Msg msg1005("IGES_1005"); // Software error : start IsNull. |
267 | //Message_Msg msg1015("IGES_1015"); // invalid type or execption raising (software error). |
268 | //Message_Msg msg1010("IGES_1010"); // Not sameparameter. |
269 | // Message_Msg msg1015("IGES_1015"); |
270 | //Message_Msg msg210 ("XSTEP_210"); |
271 | //Message_Msg msg202 ("XSTEP_202"); |
272 | //////////////////////////// |
273 | TopoDS_Shape res; |
274 | gp_Trsf T408; |
275 | if (start.IsNull()) { |
276 | Message_Msg msg1005("IGES_1005"); // Software error : start IsNull. |
277 | SendFail(start, msg1005); |
278 | return res; |
279 | } |
280 | |
281 | // Read of the DE number and the type number of the entity |
282 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
283 | //Standard_Integer typeNumber = start->TypeNumber(); |
284 | |
285 | // sln 13.06.2002 OCC448: Avoid transfering invisiable sub entities which |
286 | // logicaly depend on the one |
287 | Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible"); |
288 | |
289 | if (IGESToBRep::IsCurveAndSurface(start)) { |
290 | if(onlyvisible && start->BlankStatus() == 1) |
291 | return res; |
292 | try { |
293 | OCC_CATCH_SIGNALS |
294 | res = TransferCurveAndSurface(start); |
295 | } |
296 | catch(Standard_Failure) { |
297 | Message_Msg msg1015("IGES_1015"); |
298 | SendFail(start, msg1015); |
299 | } |
300 | return res; |
301 | } |
302 | |
303 | //408 : SingularSubfigure |
304 | if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) |
305 | { |
306 | if(onlyvisible && start->BlankStatus() == 1) |
307 | return res; |
308 | |
309 | DeclareAndCast(IGESBasic_SingularSubfigure, st408, start); |
310 | Handle (IGESBasic_SubfigureDef) stsub = st408->Subfigure(); |
311 | gp_XYZ trans = st408->Translation(); |
312 | gp_Vec vectr(trans); |
313 | Standard_Real scunit = GetUnitFactor(); |
314 | vectr.Multiply(scunit); |
315 | T408.SetTranslation(vectr); |
316 | if (st408->HasScaleFactor()) { |
317 | Standard_Real scalef = st408->ScaleFactor(); |
318 | T408.SetScaleFactor(scalef); |
319 | } |
320 | if (HasShapeResult(stsub)) { |
321 | res = GetShapeResult(stsub); |
322 | } |
323 | else { |
324 | try { |
325 | OCC_CATCH_SIGNALS |
326 | res = TransferGeometry(stsub); |
327 | } |
328 | catch(Standard_Failure) { |
329 | res.Nullify(); |
330 | Message_Msg msg1015("IGES_1015"); |
331 | SendFail( st408, msg1015); |
332 | } |
333 | if (!res.IsNull()) { |
334 | SetShapeResult(stsub,res); |
335 | } |
336 | } |
337 | } |
338 | |
339 | // 308 : SubfigureDefinition |
340 | else if (start->IsKind(STANDARD_TYPE(IGESBasic_SubfigureDef))) { |
341 | DeclareAndCast(IGESBasic_SubfigureDef, st308, start); |
342 | TopoDS_Compound group; |
343 | BRep_Builder B; |
344 | B.MakeCompound (group); |
345 | if (st308->NbEntities() < 1) { |
346 | Message_Msg msg210 ("XSTEP_210"); |
347 | SendFail( st308, msg210); |
348 | return res; |
349 | } |
350 | Message_ProgressSentry PS ( myTP->GetProgress(), "Subfigure item", 0, st308->NbEntities(), 1 ); |
351 | for (Standard_Integer i=1; i <= st308->NbEntities() && PS.More(); i++, PS.Next()) { |
352 | TopoDS_Shape item; |
353 | if (st308->AssociatedEntity(i).IsNull()) { |
354 | Message_Msg msg1020("IGES_1020"); |
355 | msg1020.Arg(i); |
356 | SendWarning( st308, msg1020); |
357 | continue; |
358 | } |
359 | if(onlyvisible && st308->AssociatedEntity(i)->BlankStatus() == 1 ) |
360 | continue; |
361 | |
362 | if (HasShapeResult(st308->AssociatedEntity(i))) |
363 | { |
364 | item = GetShapeResult(st308->AssociatedEntity(i)); |
365 | } |
366 | else { |
367 | try { |
368 | OCC_CATCH_SIGNALS |
369 | item = TransferGeometry(st308->AssociatedEntity(i)); |
370 | } |
371 | catch(Standard_Failure) { |
372 | item.Nullify(); |
373 | Message_Msg msg1015("IGES_1015"); |
374 | SendFail( st308->AssociatedEntity(i), msg1015); |
375 | } |
376 | } |
377 | if (item.IsNull()) { |
378 | Message_Msg msg1025("IGES_1025"); |
379 | msg1025.Arg(i); |
380 | SendWarning (start,msg1025); |
381 | } |
382 | else { |
383 | B.Add(group, item); |
384 | SetShapeResult (st308->AssociatedEntity(i),item); |
385 | } |
386 | } |
387 | res = group; |
388 | } |
389 | else if (start->IsKind(STANDARD_TYPE(IGESBasic_Group))) { |
390 | if(onlyvisible && start->BlankStatus() == 1) |
391 | return res; |
392 | |
393 | DeclareAndCast(IGESBasic_Group, st402f1, start); |
394 | TopoDS_Compound group; |
395 | BRep_Builder B; |
396 | B.MakeCompound (group); |
397 | if (st402f1->NbEntities() < 1) { |
398 | Message_Msg msg202 ("XSTEP_202"); |
399 | msg202.Arg(st402f1->FormNumber()); |
400 | SendFail(st402f1, msg202); |
401 | return res; |
402 | } |
403 | Message_ProgressSentry PS ( myTP->GetProgress(), "Group item", 0, st402f1->NbEntities(), 1 ); |
404 | Standard_Boolean ProblemInGroup = Standard_False; |
405 | for (Standard_Integer i=1; i <= st402f1->NbEntities() && PS.More(); i++, PS.Next()) { |
406 | TopoDS_Shape item; |
407 | if (st402f1->Entity(i).IsNull()) { |
408 | Message_Msg msg1020("IGES_1020"); |
409 | msg1020.Arg(i); |
410 | SendFail( st402f1, msg1020); |
411 | continue; |
412 | } |
413 | |
414 | if(onlyvisible && st402f1->Entity(i)->BlankStatus() == 1) |
415 | continue; |
416 | |
417 | if (HasShapeResult(st402f1->Entity(i))) { |
418 | item = GetShapeResult(st402f1->Entity(i)); |
419 | } |
420 | else { |
421 | try { |
422 | OCC_CATCH_SIGNALS |
423 | item = TransferGeometry(st402f1->Entity(i)); |
424 | } |
425 | catch(Standard_Failure) { |
426 | item.Nullify(); |
427 | Message_Msg msg1015("IGES_1015"); |
428 | SendFail(st402f1->Entity(i),msg1015); |
429 | } |
430 | } |
431 | if (item.IsNull()) { |
432 | //Message_Msg msg1030("IGES_1030"); |
433 | //msg1030.Arg(st402f1->FormNumber()); |
434 | //msg1030.Arg(i); |
435 | //SendWarning (st402f1,msg1030); |
436 | ProblemInGroup = Standard_True; |
437 | } |
438 | else { |
439 | B.Add(group, item); |
440 | SetShapeResult (st402f1->Entity(i),item); |
441 | } |
442 | } |
443 | res = group; |
444 | if(ProblemInGroup) { |
445 | Message_Msg msg1030("IGES_1030"); |
446 | msg1030.Arg(st402f1->FormNumber()); |
447 | SendWarning (st402f1,msg1030); |
448 | } |
449 | } |
450 | else if (start->IsKind(STANDARD_TYPE(IGESBasic_GroupWithoutBackP))) { |
451 | |
452 | if(onlyvisible && start->BlankStatus() == 1) |
453 | return res; |
454 | |
455 | DeclareAndCast(IGESBasic_GroupWithoutBackP, st402f7, start); |
456 | TopoDS_Compound group; |
457 | //unused Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(st402f7); |
458 | BRep_Builder B; |
459 | B.MakeCompound (group); |
460 | if (st402f7->NbEntities() < 1) { |
461 | Message_Msg msg202 ("XSTEP_202"); |
462 | msg202.Arg(st402f7->FormNumber()); |
463 | SendFail(st402f7, msg202); |
464 | return res; |
465 | } |
466 | Message_ProgressSentry PS ( myTP->GetProgress(), "Group item", 0, st402f7->NbEntities(), 1 ); |
467 | Standard_Boolean ProblemInGroup = Standard_False; |
468 | for (Standard_Integer i=1; i <= st402f7->NbEntities() && PS.More(); i++, PS.Next()) { |
469 | TopoDS_Shape item; |
470 | if (st402f7->Entity(i).IsNull()) { |
471 | Message_Msg msg1020("IGES_1020"); |
472 | msg1020.Arg(i); |
473 | SendFail( st402f7, msg1020); |
474 | continue; |
475 | } |
476 | |
477 | if(onlyvisible && st402f7->Entity(i)->BlankStatus() == 1 ) |
478 | continue; |
479 | |
480 | if (HasShapeResult(st402f7->Entity(i))) { |
481 | item = GetShapeResult(st402f7->Entity(i)); |
482 | } |
483 | else { |
484 | try { |
485 | OCC_CATCH_SIGNALS |
486 | item = TransferGeometry(st402f7->Entity(i)); |
487 | } |
488 | catch(Standard_Failure) { |
489 | item.Nullify(); |
490 | Message_Msg msg1015("IGES_1015"); |
491 | SendFail(st402f7->Entity(i),msg1015); |
492 | } |
493 | } |
494 | if (item.IsNull()) { |
495 | //Message_Msg msg1030("IGES_1030"); |
496 | //msg1030.Arg(st402f7->FormNumber()); |
497 | //msg1030.Arg(i); |
498 | //SendWarning (st402f7,msg1030); |
499 | ProblemInGroup = Standard_True; |
500 | } |
501 | else { |
502 | B.Add(group, item); |
503 | SetShapeResult (st402f7->Entity(i),item); |
504 | } |
505 | } |
506 | res = group; |
507 | if(ProblemInGroup) { |
508 | Message_Msg msg1030("IGES_1030"); |
509 | msg1030.Arg(st402f7->FormNumber()); |
510 | SendWarning (st402f7,msg1030); |
511 | } |
512 | } |
513 | else { |
514 | Message_Msg msg1001("IGES_1001"); |
515 | msg1001.Arg(start->FormNumber()); |
516 | SendFail (start,msg1001); |
517 | return res; |
518 | } |
519 | |
520 | if (start->HasTransf()) { |
521 | gp_Trsf T; |
522 | SetEpsilon(1.E-04); |
523 | if (IGESData_ToolLocation::ConvertLocation(GetEpsilon(),start->CompoundLocation(), |
524 | T,GetUnitFactor())) { |
525 | if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) |
526 | { |
527 | gp_XYZ tra = T.TranslationPart(); |
528 | gp_XYZ trans = T408.TranslationPart(); |
529 | tra.Add(trans); |
530 | T.SetTranslationPart(tra); |
531 | Standard_Real sc = T.ScaleFactor(); |
532 | Standard_Real scalef = T408.ScaleFactor(); |
533 | sc = sc*scalef; |
534 | T.SetScaleFactor(sc); |
535 | } |
536 | TopLoc_Location L(T); |
537 | res.Move(L); |
538 | } |
539 | else { |
540 | Message_Msg msg1035("IGES_1035"); |
541 | SendWarning (start,msg1035); |
542 | } |
543 | } |
544 | else { |
545 | if (start->IsKind(STANDARD_TYPE(IGESBasic_SingularSubfigure))) { |
546 | TopLoc_Location L(T408); |
547 | res.Move(L); |
548 | } |
549 | } |
550 | return res; |
551 | } |
552 | |
553 | |
554 | //======================================================================= |
555 | //function : HasShapeResult |
556 | //purpose : |
557 | //======================================================================= |
558 | |
559 | Standard_Boolean IGESToBRep_CurveAndSurface::HasShapeResult |
560 | (const Handle(IGESData_IGESEntity)& start) const |
561 | { |
562 | DeclareAndCast(TransferBRep_ShapeBinder,binder,myTP->Find(start)); |
563 | if (binder.IsNull()) return Standard_False; |
564 | return binder->HasResult(); |
565 | } |
566 | |
567 | |
568 | //======================================================================= |
569 | //function : GetShapeResult |
570 | //purpose : |
571 | //======================================================================= |
572 | |
573 | TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult |
574 | (const Handle(IGESData_IGESEntity)& start) const |
575 | { |
576 | TopoDS_Shape res; |
577 | |
578 | DeclareAndCast(TransferBRep_ShapeBinder, binder, myTP->Find(start)); |
579 | if (binder.IsNull()) return res; |
580 | if (binder->HasResult()) |
581 | res = binder->Result(); |
582 | return res; |
583 | } |
584 | |
585 | |
586 | //======================================================================= |
587 | //function : SetShapeResult |
588 | //purpose : |
589 | //======================================================================= |
590 | |
591 | void IGESToBRep_CurveAndSurface::SetShapeResult |
592 | (const Handle(IGESData_IGESEntity)& start, |
593 | const TopoDS_Shape& result) |
594 | { |
595 | Handle(TransferBRep_ShapeBinder) binder = new TransferBRep_ShapeBinder; |
596 | myTP->Bind(start,binder); |
597 | binder->SetResult(result); |
598 | } |
599 | |
600 | //======================================================================= |
601 | //function : NbShapeResult |
602 | //purpose : |
603 | //======================================================================= |
604 | |
605 | Standard_Integer IGESToBRep_CurveAndSurface::NbShapeResult |
606 | (const Handle(IGESData_IGESEntity)& start) const |
607 | { |
608 | Standard_Integer nbres = 0; |
609 | DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start)); |
610 | if (binder.IsNull()) return nbres; |
611 | nbres = binder->NbShapes(); |
612 | return nbres; |
613 | } |
614 | |
615 | |
616 | //======================================================================= |
617 | //function : GetShapeResult |
618 | //purpose : |
619 | //======================================================================= |
620 | |
621 | TopoDS_Shape IGESToBRep_CurveAndSurface::GetShapeResult |
622 | (const Handle(IGESData_IGESEntity)& start, const Standard_Integer num) const |
623 | { |
624 | TopoDS_Shape res; |
625 | |
626 | DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start)); |
627 | if (binder.IsNull()) return res; |
628 | |
629 | if (num <= binder->NbShapes()) |
630 | res = binder->Shape(num); |
631 | return res; |
632 | } |
633 | |
634 | |
635 | //======================================================================= |
636 | //function : AddShapeResult |
637 | //purpose : |
638 | //======================================================================= |
639 | |
640 | void IGESToBRep_CurveAndSurface::AddShapeResult |
641 | (const Handle(IGESData_IGESEntity)& start, |
642 | const TopoDS_Shape& result) |
643 | { |
644 | DeclareAndCast(TransferBRep_ShapeListBinder,binder,myTP->Find(start)); |
645 | if (binder.IsNull()){ |
646 | binder = new TransferBRep_ShapeListBinder; |
647 | myTP->Bind(start,binder); |
648 | } |
649 | binder->AddResult(result); |
650 | } |
651 | |
652 | void IGESToBRep_CurveAndSurface::SetSurface(const Handle(Geom_Surface)& theSurface) |
653 | { |
654 | if(mySurface!=theSurface) { |
655 | mySurface = theSurface; |
656 | myIsResolCom = Standard_False; |
657 | myUVResolution = 0.; |
658 | } |
659 | } |
660 | |
661 | Handle(Geom_Surface) IGESToBRep_CurveAndSurface::Surface() const |
662 | { |
663 | return mySurface; |
664 | } |
665 | |
666 | Standard_Real IGESToBRep_CurveAndSurface::GetUVResolution() |
667 | { |
668 | if(!myIsResolCom && !mySurface.IsNull()) { |
669 | myIsResolCom = Standard_True; |
670 | GeomAdaptor_Surface aGAS(mySurface); |
671 | myUVResolution = Min(aGAS.UResolution(1.), aGAS.VResolution(1.)); |
672 | } |
673 | return myUVResolution; |
674 | } |
675 | |
676 | |
677 | |
678 | |
679 | |
680 | |