b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | //======================================================================= |
7fd59977 |
19 | //purpose : Members to transfert any BRepEntity into TopoDS_Shape |
20 | //======================================================================= |
21 | // 21.12.98 rln, gka S4054 |
22 | //#62 rln 10.01.99 PRO17015 |
23 | //:q5 abv 19.03.99 unnecessary includes removed |
24 | //pdn 12.03.99 S4135 Constructing vertex with minimal tolerance |
25 | //:r1 abv 25.03.99 CTS21655.igs, CTS18545.igs: apply FixOrientation to whole face |
26 | //S4181 pdn 20.04.99 implementing of reading IGES elementary surfaces. |
27 | //pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops |
28 | |
29 | #include <Standard_ErrorHandler.hxx> |
30 | #include <IGESToBRep_BRepEntity.ixx> |
31 | #include <IGESToBRep.hxx> |
32 | #include <IGESToBRep_BasicCurve.hxx> |
33 | #include <IGESToBRep_BasicSurface.hxx> |
34 | #include <IGESToBRep_CurveAndSurface.hxx> |
35 | #include <IGESToBRep_TopoCurve.hxx> |
36 | #include <IGESToBRep_TopoSurface.hxx> |
37 | |
38 | #include <BRep_Builder.hxx> |
39 | #include <BRep_Tool.hxx> |
40 | #include <BRepTools.hxx> |
41 | |
42 | #include <Geom_Curve.hxx> |
43 | #include <Geom_TrimmedCurve.hxx> |
44 | |
45 | #include <gp.hxx> |
46 | #include <gp_Pnt.hxx> |
47 | |
48 | #include <IGESBasic_SingleParent.hxx> |
49 | |
50 | #include <IGESData_IGESEntity.hxx> |
51 | #include <IGESData_HArray1OfIGESEntity.hxx> |
52 | #include <IGESData_ToolLocation.hxx> |
53 | |
54 | #include <IGESGeom_Boundary.hxx> |
55 | #include <IGESGeom_BoundedSurface.hxx> |
56 | #include <IGESGeom_CurveOnSurface.hxx> |
57 | #include <IGESGeom_Plane.hxx> |
58 | #include <IGESGeom_TrimmedSurface.hxx> |
59 | |
60 | #include <Interface_Macros.hxx> |
61 | |
62 | #include <Precision.hxx> |
63 | |
64 | #include <TopAbs_ShapeEnum.hxx> |
65 | |
66 | #include <TopExp.hxx> |
67 | |
68 | #include <TopLoc_Location.hxx> |
b311480e |
69 | |
7fd59977 |
70 | #include <TopoDS.hxx> |
71 | #include <TopoDS_Edge.hxx> |
72 | #include <TopoDS_Face.hxx> |
73 | #include <TopoDS_Iterator.hxx> |
74 | #include <TopoDS_Shape.hxx> |
75 | #include <TopoDS_Shell.hxx> |
76 | #include <TopoDS_Solid.hxx> |
77 | #include <TopoDS_Vertex.hxx> |
78 | #include <TopoDS_Wire.hxx> |
79 | |
80 | #include <Transfer_TransientProcess.hxx> |
81 | |
82 | #include <stdio.h> |
83 | #include <gp_Vec2d.hxx>//rln |
84 | |
85 | #include <ShapeExtend_WireData.hxx> |
86 | #include <ShapeBuild_Edge.hxx> |
87 | #include <IGESToBRep_IGESBoundary.hxx> |
88 | #include <Message_Msg.hxx> |
89 | #include <TCollection_HAsciiString.hxx> |
90 | #include <IGESData_IGESModel.hxx> |
91 | //#include <ShapeFix_Face.hxx> |
92 | #include <IGESToBRep_AlgoContainer.hxx> |
93 | #include <IGESToBRep_ToolContainer.hxx> |
94 | #include <Message_ProgressSentry.hxx> |
95 | |
96 | // mjm le 10/10/96 on force la continuity a 0 en attendant de pouvoir |
97 | // travailler sur wire en non plus edge. |
98 | |
99 | |
100 | //======================================================================= |
101 | //function : IGESToBRep_BRepEntity |
102 | //purpose : |
103 | //======================================================================= |
104 | IGESToBRep_BRepEntity::IGESToBRep_BRepEntity() |
105 | :IGESToBRep_CurveAndSurface() |
106 | { |
107 | SetModeTransfer(Standard_False); |
108 | SetContinuity(0); |
109 | } |
110 | |
111 | |
112 | //======================================================================= |
113 | //function : IGESToBRep_BRepEntity |
114 | //purpose : |
115 | //======================================================================= |
116 | IGESToBRep_BRepEntity::IGESToBRep_BRepEntity |
117 | (const IGESToBRep_CurveAndSurface& CS) |
118 | :IGESToBRep_CurveAndSurface(CS) |
119 | { |
120 | SetContinuity(0); |
121 | } |
122 | |
123 | |
124 | //======================================================================= |
125 | //function : IGESToBRep_BRepEntity |
126 | //purpose : |
127 | //======================================================================= |
128 | IGESToBRep_BRepEntity::IGESToBRep_BRepEntity |
129 | (const Standard_Real eps, |
130 | const Standard_Real epsCoeff, |
131 | const Standard_Real epsGeom, |
132 | const Standard_Boolean mode, |
133 | const Standard_Boolean modeapprox, |
134 | const Standard_Boolean optimized) |
135 | :IGESToBRep_CurveAndSurface(eps, epsCoeff, epsGeom, mode, modeapprox, |
136 | optimized) |
137 | { |
138 | SetContinuity(0); |
139 | } |
140 | |
141 | |
142 | //======================================================================= |
143 | //function : TransferBRepEntity |
144 | //purpose : |
145 | //======================================================================= |
146 | TopoDS_Shape IGESToBRep_BRepEntity::TransferBRepEntity |
147 | (const Handle(IGESData_IGESEntity)& start) |
148 | { |
149 | TopoDS_Shape res; |
150 | |
151 | if (start->IsKind(STANDARD_TYPE(IGESSolid_Face))) { |
152 | DeclareAndCast(IGESSolid_Face, st510, start); |
153 | res = TransferFace(st510); |
154 | } |
155 | else if (start->IsKind(STANDARD_TYPE(IGESSolid_Shell))) { |
156 | DeclareAndCast(IGESSolid_Shell, st514, start); |
157 | res = TransferShell(st514); |
158 | } |
159 | else if (start->IsKind(STANDARD_TYPE(IGESSolid_ManifoldSolid))) { |
160 | DeclareAndCast(IGESSolid_ManifoldSolid, st186, start); |
161 | res = TransferManifoldSolid(st186); |
162 | } |
163 | else { |
164 | Message_Msg Msg1005("IGES_1005"); |
165 | SendFail(start,Msg1005); |
166 | } |
167 | return res; |
168 | } |
169 | |
170 | |
171 | //======================================================================= |
172 | //function : TransferVertex |
173 | //purpose : |
174 | //======================================================================= |
175 | TopoDS_Vertex IGESToBRep_BRepEntity::TransferVertex |
176 | (const Handle(IGESSolid_VertexList)& start, |
177 | const Standard_Integer index) |
178 | { |
179 | TopoDS_Vertex res; |
180 | |
181 | Standard_Integer nbshapes = NbShapeResult(start); |
182 | if (nbshapes == 0 ) { |
183 | BRep_Builder B; |
184 | for (Standard_Integer inum = 1; inum <= start->NbVertices(); inum++) { |
185 | gp_Pnt point = start-> Vertex(inum); |
186 | point.Scale(gp_Pnt(0,0,0),GetUnitFactor()); |
187 | TopoDS_Vertex V; |
188 | //pdn 12.03.99 S4135 Constructing vertex with minimal tolerance |
189 | B.MakeVertex(V, point, Precision::Confusion()); |
190 | AddShapeResult(start,V); |
191 | } |
192 | } |
193 | |
194 | TopoDS_Shape Sh = GetShapeResult(start,index); |
195 | if ( Sh.IsNull()) { |
196 | Message_Msg Msg1156("IGES_1156"); //"the Vertex number %d is a null object." FAIL!!! |
197 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
198 | Msg1156.Arg("vertex %d"); |
199 | Msg1156.Arg(index); |
200 | Msg1156.Arg(label); |
201 | SendWarning(start,Msg1156); |
202 | } |
203 | res = TopoDS::Vertex(Sh); |
204 | return res; |
205 | } |
206 | |
207 | |
208 | //======================================================================= |
209 | //function : TransferEdge |
210 | //purpose : |
211 | //======================================================================= |
212 | TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge |
213 | (const Handle(IGESSolid_EdgeList)& start, |
214 | const Standard_Integer index) |
215 | { |
216 | TopoDS_Shape res; |
217 | BRep_Builder B; |
218 | |
219 | Standard_Integer nbshapes = NbShapeResult(start); |
220 | if (nbshapes == 0) { |
221 | IGESToBRep_TopoCurve TC(*this); |
222 | for (Standard_Integer inum = 1; inum <= start->NbEdges(); inum++) { |
223 | |
224 | // Vertices |
225 | // -------- |
226 | Handle(IGESSolid_VertexList) thestartlist = start->StartVertexList(inum); |
227 | Standard_Integer thestartindex = start->StartVertexIndex(inum); |
228 | TopoDS_Vertex V1 = TransferVertex(thestartlist,thestartindex); |
229 | |
230 | Handle(IGESSolid_VertexList) theendlist = start->EndVertexList(inum); |
231 | Standard_Integer theendindex = start->EndVertexIndex(inum); |
232 | TopoDS_Vertex V2 = TransferVertex(theendlist,theendindex); |
233 | |
234 | // Curve |
235 | // ----- |
236 | |
237 | Handle(IGESData_IGESEntity) thecurve = start->Curve(inum); |
238 | if (thecurve.IsNull() || |
239 | !IGESToBRep::IsTopoCurve(thecurve) || |
240 | thecurve->IsKind(STANDARD_TYPE(IGESGeom_CurveOnSurface)) || |
241 | thecurve->IsKind(STANDARD_TYPE(IGESGeom_Boundary)) ) { |
242 | Message_Msg Msg1306("IGES_1306");//one underlying curve is a Null object. |
243 | Msg1306.Arg(inum); |
244 | SendWarning(start,Msg1306); |
245 | TopoDS_Edge Sh; |
246 | AddShapeResult(start,Sh); |
247 | } |
248 | else { |
249 | TopoDS_Shape Sh = TC.TransferTopoCurve(thecurve); |
250 | if (!Sh.IsNull()) { |
251 | if (Sh.ShapeType() == TopAbs_EDGE) { |
252 | TopoDS_Edge edge = TopoDS::Edge(Sh); |
253 | TopoDS_Vertex Vf,Vl; |
254 | TopExp::Vertices (edge, Vf, Vl); |
255 | TopoDS_Edge E; |
256 | B.MakeEdge(E); |
257 | TopLoc_Location loc; |
258 | Standard_Real first, last; |
259 | Handle(Geom_Curve) Crv = BRep_Tool::Curve(edge, loc, first, last); |
260 | Handle(Geom_Curve) newC3d; |
261 | // dams le cas d`une conique, il faut reverser |
262 | // sens de parcours IGES inverse sens de parcours CASCADE. |
263 | if (Crv->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { |
264 | DeclareAndCast(Geom_TrimmedCurve, acurve, Crv); |
265 | newC3d = acurve->BasisCurve(); |
266 | } |
267 | else { |
268 | newC3d = Crv; |
269 | } |
270 | B.UpdateEdge(E,newC3d,loc,0.);//S4054:GetEpsGeom()*GetUnitFactor() |
271 | gp_Pnt p1 = BRep_Tool::Pnt ( V1 ); |
272 | gp_Pnt p2 = BRep_Tool::Pnt ( V2 ); |
273 | gp_Pnt pf = BRep_Tool::Pnt ( Vf ); |
274 | gp_Pnt pl = BRep_Tool::Pnt ( Vl ); |
275 | Standard_Real dist1f = p1.Distance ( pf ); |
276 | Standard_Real dist2f = p2.Distance ( pf ); |
277 | Standard_Real dist1l = p1.Distance ( pl ); |
278 | Standard_Real dist2l = p2.Distance ( pl ); |
279 | if ( E.Closed() || dist1f + dist2l <= dist1l + dist2f ) { |
280 | //:77 if (BRepTools::Compare(V1, Vf)) //the part 'else' only if, in fact, edge should be reversed |
281 | V1.Orientation(TopAbs_FORWARD); |
282 | B.Add(E,V1); |
283 | V2.Orientation(TopAbs_REVERSED); |
284 | B.Add(E,V2); |
285 | B.UpdateVertex(V1, first, E, 0.);//S4054 1.001 * dist1f //:77 GetEpsGeom()*GetUnitFactor(); |
286 | B.UpdateVertex(V2, last, E, 0.);//S4054 1.001 * dist2l //:77 GetEpsGeom()*GetUnitFactor(); |
287 | B.Range (E, first, last); |
288 | } |
289 | // modif mjm du 13/10/97 : Reverse de l`edge ? |
290 | else { |
291 | E.Reverse(); |
292 | V1.Orientation(TopAbs_FORWARD); |
293 | B.Add(E,V1); |
294 | V2.Orientation(TopAbs_REVERSED); |
295 | B.Add(E,V2); |
296 | B.UpdateVertex(V1, last, E, 0.);//S4054 1.001 * dist1l //:77 GetEpsGeom()*GetUnitFactor(); |
297 | B.UpdateVertex(V2, first, E, 0.);//S4054 1.001 * dist2f //:77 GetEpsGeom()*GetUnitFactor(); |
298 | B.Range (E, first, last); |
299 | } |
300 | AddShapeResult(start,E); |
301 | } |
302 | else if (Sh.ShapeType() == TopAbs_WIRE) { |
303 | // pas traite |
304 | Message_Msg Msg1325("IGES_1325"); //"Edge : result of TransferTopoCurve is WIRE" |
305 | Msg1325.Arg(inum); |
306 | SendWarning(start,Msg1325); |
307 | //AddWarning(start,"Edge : result of TransferTopoCurve is WIRE"); |
308 | } |
309 | } |
310 | else { |
311 | Message_Msg Msg1156("IGES_1156"); |
312 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(thecurve); |
313 | Msg1156.Arg("underlying curve"); |
314 | Msg1156.Arg(label); |
315 | SendWarning(start,Msg1156); |
316 | } |
317 | } |
318 | } |
319 | } |
320 | |
321 | TopoDS_Shape Sh = GetShapeResult(start,index); |
322 | if ( Sh.IsNull()) { |
323 | Message_Msg Msg1156("IGES_1156"); |
324 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
325 | Msg1156.Arg("edge %d"); |
326 | Msg1156.Arg(index); |
327 | Msg1156.Arg(label); |
328 | SendWarning(start,Msg1156); |
329 | } |
330 | return Sh; |
331 | } |
332 | |
333 | |
334 | //======================================================================= |
335 | //function : TransferLoop |
336 | //purpose : |
337 | //======================================================================= |
338 | TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const Handle(IGESSolid_Loop)& start, |
339 | const TopoDS_Face& face, |
340 | const gp_Trsf2d& trans, |
341 | const Standard_Real uFact) |
342 | { |
343 | TopoDS_Shape res; |
344 | |
345 | if (!HasShapeResult(start)) { |
346 | TopoDS_Wire mywire; |
347 | Standard_Boolean okCurve = Standard_True, okCurve3d = Standard_True, okCurve2d = Standard_True; |
348 | Handle(ShapeExtend_WireData) sewd; |
349 | Standard_Integer filepreference = 3;//3D is preferred by default |
350 | Standard_Boolean Result = Standard_True; |
351 | |
352 | Handle(IGESToBRep_IGESBoundary) IB = IGESToBRep::AlgoContainer()->ToolContainer()->IGESBoundary(); |
353 | IB->Init (*this, start, face, trans, uFact, filepreference); |
354 | BRep_Builder B; |
355 | ShapeBuild_Edge sbe; |
356 | |
357 | for ( Standard_Integer iedge = 1; iedge <= start->NbEdges(); iedge++ ) { |
358 | Standard_Integer itype = start->EdgeType(iedge); |
359 | Handle(IGESData_IGESEntity) theedge = start->Edge(iedge); |
360 | Standard_Integer indexlist = start->ListIndex(iedge); |
361 | Standard_Boolean orientation = start->Orientation(iedge); |
362 | Standard_Integer nbparam = start->NbParameterCurves(iedge); |
363 | if (theedge.IsNull()) { |
364 | Message_Msg Msg1365("IGES_1365"); //"Loop : one edge is null" |
365 | Msg1365.Arg(iedge); |
366 | SendWarning(start,Msg1365); |
367 | // AddWarning (start,"Loop : one edge is null"); |
368 | } |
369 | else { |
370 | // edge |
371 | // ---- |
372 | Handle(ShapeExtend_WireData) curve3d = new ShapeExtend_WireData; |
373 | |
374 | if (( itype == 1) && (theedge ->IsKind(STANDARD_TYPE(IGESSolid_VertexList)))) { |
375 | DeclareAndCast(IGESSolid_VertexList,thelist,theedge); |
376 | TopoDS_Vertex V1 = TransferVertex(thelist,indexlist); |
377 | TopoDS_Edge E; |
378 | B.MakeEdge(E); |
379 | //szv#4:S4163:12Mar99 SGI warns |
380 | TopoDS_Shape sh = V1.Oriented(TopAbs_FORWARD); |
381 | B.Add(E, TopoDS::Vertex(sh)); |
382 | sh = V1.Oriented(TopAbs_REVERSED); |
383 | B.Add(E, TopoDS::Vertex(sh)); |
384 | B.Degenerated(E, Standard_True); |
385 | curve3d->Add (E); |
386 | } |
387 | else if (( itype == 0) && (theedge ->IsKind(STANDARD_TYPE(IGESSolid_EdgeList)))) { |
388 | DeclareAndCast(IGESSolid_EdgeList,thelist,theedge); |
389 | TopoDS_Shape Sh = TransferEdge(thelist,indexlist); |
390 | curve3d->Add (Sh); |
391 | } |
392 | else { |
393 | Message_Msg Msg1365("IGES_1365"); //"Improper type for the edge" |
394 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
395 | Msg1365.Arg(iedge); |
396 | SendWarning(start,Msg1365); |
397 | //AddWarning (start, "Improper type for the edge"); |
398 | continue; |
399 | } |
400 | if (!orientation) curve3d->Reverse(); |
401 | |
402 | // traitement des courbes 2d. |
403 | // ------------------------- |
404 | Handle(IGESData_HArray1OfIGESEntity) Curves2d; |
405 | |
406 | //Current limitation: |
407 | //2D representation is not translated if: |
408 | //- 3D curve was translated into wire (i.e. if it is 102) |
409 | //- more than 1 2D curve, |
410 | //- 2D curve is 102 |
411 | Handle(TColStd_HSequenceOfTransient) seq2d; |
412 | if (curve3d->NbEdges() == 1 && nbparam == 1 && |
413 | IGESToBRep::IGESCurveToSequenceOfIGESCurve (start->ParametricCurve(iedge, 1), seq2d) == 1) { |
414 | Curves2d = new IGESData_HArray1OfIGESEntity (1, nbparam); |
415 | for (Standard_Integer i = 1; i <= nbparam; i++) |
416 | Curves2d->SetValue (i, start->ParametricCurve(iedge,i)); |
417 | } |
418 | Handle(ShapeExtend_WireData) lsewd;//result of translation of current edge |
419 | Result = Result & IB->Transfer (okCurve, okCurve3d, okCurve2d, |
420 | curve3d, Curves2d, !orientation, |
421 | iedge, lsewd); |
422 | if (iedge == 1) sewd = IB->WireData();//initialization |
423 | if (curve3d->NbEdges() == 1 && lsewd->NbEdges() == 1) {//the condition corresponds to limitation above |
424 | //to keep sharing of edges all geometric representations should be put |
425 | //into the edge from EdgeList |
426 | TopoDS_Edge fromedge = lsewd->Edge(1), toedge = curve3d->Edge(1); |
427 | if (!fromedge.IsSame (toedge)) { |
428 | sbe.RemoveCurve3d (toedge); |
429 | IGESToBRep::TransferPCurve (fromedge, toedge, face); |
430 | sewd->Set (toedge, sewd->Index (fromedge)); |
431 | } |
432 | } |
433 | } |
434 | } |
435 | //IB->Check(Result, Standard_True); |
436 | //pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops |
437 | if(!sewd.IsNull()) { |
438 | //IB.Fix (sewd, Standard_False, Standard_True, Standard_True, Standard_True, Standard_True); |
439 | mywire = sewd->Wire(); |
440 | } |
441 | SetShapeResult(start, mywire); |
442 | } |
443 | |
444 | TopoDS_Shape Sh = GetShapeResult(start); |
445 | if ( Sh.IsNull()) { |
446 | Message_Msg Msg1156("IGES_1156"); //The Loop is null |
447 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
448 | Msg1156.Arg("loop"); |
449 | Msg1156.Arg(label); |
450 | SendWarning(start,Msg1156); |
451 | } |
452 | return Sh; |
453 | } |
454 | |
455 | //======================================================================= |
456 | //function : TransferFace |
457 | //purpose : |
458 | //======================================================================= |
459 | TopoDS_Shape IGESToBRep_BRepEntity::TransferFace |
460 | (const Handle(IGESSolid_Face)& start) |
461 | { |
462 | TopoDS_Shape res; |
463 | |
464 | if (!HasShapeResult(start)) { |
465 | BRep_Builder B; |
466 | TopoDS_Face F; |
467 | Handle(IGESData_IGESEntity) surf = start->Surface(); |
468 | Standard_Integer nbloops = start->NbLoops(); |
469 | Standard_Boolean hasouterloop = start->HasOuterLoop(); |
470 | IGESToBRep_TopoSurface TS(*this); |
471 | |
472 | // surface |
473 | // ------- |
474 | if (surf.IsNull() || |
475 | !IGESToBRep::IsTopoSurface(surf) || |
476 | surf->IsKind(STANDARD_TYPE(IGESGeom_Plane)) || |
477 | surf->IsKind(STANDARD_TYPE(IGESGeom_BoundedSurface)) || |
478 | surf->IsKind(STANDARD_TYPE(IGESGeom_TrimmedSurface)) || |
479 | surf->IsKind(STANDARD_TYPE(IGESBasic_SingleParent)) ){ |
480 | Message_Msg Msg196("XSTEP_196"); //"pas de surface de base pour creer la face" |
481 | SendWarning(start,Msg196); |
482 | // AddWarning(start, "pas de surface de base pour creer la face"); |
483 | TopoDS_Shape Sh; |
484 | SetShapeResult(start,Sh); |
485 | } |
486 | else { |
487 | // si la surface IGES est une surface de revolution , il faudra |
488 | // inverser les courbes 2d (u,v) pour etre en accord avec le parametrage |
489 | // BRep. |
490 | gp_Trsf2d trans; |
491 | Standard_Real uFact; |
492 | TopoDS_Shape myshape = TS.ParamSurface(surf, trans, uFact); |
493 | |
494 | if (!myshape.IsNull()) { |
495 | if (myshape.ShapeType() == TopAbs_FACE) { |
496 | //#62 rln 10.01.99 PRO17015 (reading back IGES written in 'BRep' mode) face #65 |
497 | F = TopoDS::Face (myshape); |
498 | F.EmptyCopy(); |
fdabc211 |
499 | if (nbloops == 0) B.NaturalRestriction (F,Standard_True); |
7fd59977 |
500 | |
501 | // Loops |
502 | // ----- |
503 | for (Standard_Integer iloop = 1; iloop <= nbloops; iloop++){ |
504 | Handle(IGESSolid_Loop) loop = start->Loop(iloop); |
505 | TopoDS_Shape Shape = TransferLoop (loop, F, trans, uFact); |
506 | //pdn 20.04.99 CTS22655 avoid of exceptions in case of empty loops |
507 | if(!Shape.IsNull()) |
508 | B.Add(F,Shape); |
509 | } |
510 | |
511 | // update the face |
512 | BRepTools::Update (F); |
513 | F.Orientable(Standard_True); |
514 | SetShapeResult(start,F); |
515 | } |
516 | } |
517 | else { |
518 | Message_Msg Msg1156("IGES_1156"); //Face : result of TransferTopoSurface is Null |
519 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(surf); |
520 | Msg1156.Arg("surface"); |
521 | Msg1156.Arg(label); |
522 | SendFail(start,Msg1156); |
523 | // AddWarning(start,"Face : result of TransferTopoSurface is Null"); |
524 | TopoDS_Shape Sh; |
525 | SetShapeResult(start,Sh); |
526 | } |
527 | } |
528 | } |
529 | |
530 | |
531 | TopoDS_Shape Sh = GetShapeResult(start); |
532 | if ( Sh.IsNull()) { |
533 | Message_Msg Msg1156("IGES_1156"); //the Face is a Null object. |
534 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
535 | Msg1156.Arg("face"); |
536 | Msg1156.Arg(label); |
537 | SendFail(start,Msg1156); |
538 | // AddWarning (start, "the Face is a Null object."); |
539 | } |
540 | return Sh; |
541 | } |
542 | |
543 | |
544 | //======================================================================= |
545 | //function : TransferShell |
546 | //purpose : |
547 | //======================================================================= |
548 | TopoDS_Shape IGESToBRep_BRepEntity::TransferShell |
549 | (const Handle(IGESSolid_Shell)& start) |
550 | { |
551 | TopoDS_Shape res; |
552 | |
553 | if (!HasShapeResult(start)) { |
554 | TopoDS_Shell S; |
555 | BRep_Builder B; |
556 | B.MakeShell(S); |
557 | Standard_Integer nbfaces = start->NbFaces(); |
558 | if (nbfaces != 0) { |
559 | Standard_Boolean closed = Standard_True; //:39 |
560 | Handle(Message_ProgressIndicator) progress = GetTransferProcess()->GetProgress(); |
561 | if ( ! progress.IsNull() ) progress->SetScale ( "Face", 0, nbfaces, 1 ); |
562 | for (Standard_Integer iface = 1; iface <= nbfaces; iface++) { |
563 | if ( ! progress.IsNull() ) { |
564 | progress->Increment(); |
565 | if ( progress->UserBreak() ) break; |
566 | } |
567 | Handle(IGESSolid_Face) face = start->Face(iface); |
568 | Standard_Boolean orientation = start->Orientation(iface); |
569 | TopoDS_Shape Sh = TransferFace(face); |
570 | if ( Sh.IsNull() ) { //:39 by abv 15.12.97 |
571 | |
572 | closed = Standard_False; |
573 | continue; |
574 | } |
575 | if (!orientation) Sh.Reverse(); |
576 | B.Add(S,Sh); |
577 | } |
578 | if ( ! closed ) { |
579 | Message_Msg Msg1360("IGES_1360"); |
580 | SendFail(start,Msg1360); |
581 | |
582 | } |
583 | //AddWarning ( start, "Shell is not closed" ); //:39 |
584 | S.Closed ( closed ); //:39 |
585 | S.Orientable(Standard_True); |
586 | SetShapeResult(start,S); |
587 | } |
588 | else { |
589 | Message_Msg Msg200("XSTEP_200"); //Number of Faces = 0 |
590 | SendFail(start,Msg200); |
591 | } |
592 | } |
593 | |
594 | TopoDS_Shape Sh = GetShapeResult(start); |
595 | if ( Sh.IsNull()) { |
596 | Message_Msg Msg1156("IGES_1156"); //the Shell is a null object |
597 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
598 | Msg1156.Arg("shell"); |
599 | Msg1156.Arg(label); |
600 | SendFail(start,Msg1156); |
601 | } |
602 | //AddWarning (start, "the Shell is a null object."); |
603 | res = Sh; |
604 | return res; |
605 | } |
606 | |
607 | |
608 | //======================================================================= |
609 | //function : TransferManifoldSolid |
610 | //purpose : |
611 | //======================================================================= |
612 | TopoDS_Shape IGESToBRep_BRepEntity::TransferManifoldSolid |
613 | (const Handle(IGESSolid_ManifoldSolid)& start) |
614 | { |
615 | TopoDS_Shape res; |
616 | |
617 | if (!HasShapeResult(start)) { |
618 | TopoDS_Solid S; |
619 | BRep_Builder B; |
620 | B.MakeSolid(S); |
621 | Handle(IGESSolid_Shell) shell = start->Shell(); |
622 | Standard_Boolean isoriented = start->OrientationFlag(); |
623 | Standard_Integer nbshell = start->NbVoidShells(); |
624 | TopoDS_Shape Sh = TransferShell(shell); |
625 | if (!Sh.IsNull()) { |
626 | if (Sh.ShapeType() == TopAbs_SHELL) { |
627 | TopoDS_Shell Shell = TopoDS::Shell(Sh); |
628 | if (!isoriented) Shell.Reverse(); |
629 | B.Add(S,Shell); |
630 | } |
631 | |
632 | if (nbshell != 0) { |
633 | // progress scope without name, since usually we have single shell in solid |
634 | Message_ProgressSentry PS ( GetTransferProcess()->GetProgress(), 0, 0, nbshell, 1 ); |
635 | for (Standard_Integer ishell=1; ishell<= nbshell && PS.More(); ishell++, PS.Next()) { |
636 | Handle(IGESSolid_Shell) voidshell= start->VoidShell(ishell); |
637 | // Standard_Boolean orientation = start->VoidOrientationFlag(ishell); |
638 | TopoDS_Shape aSh = TransferShell(voidshell); |
639 | if (!aSh.IsNull()) { |
640 | if (aSh.ShapeType() == TopAbs_SHELL) { |
641 | TopoDS_Shell Shell = TopoDS::Shell(aSh); |
642 | if (!isoriented) Shell.Reverse(); |
643 | B.Add(S,Shell); |
644 | } |
645 | } |
646 | else { |
647 | // AddWarning(start,"ManifoldSolid : one VoidShell is Null"); |
648 | TopoDS_Shell Shell; |
649 | B.Add(S,Shell); |
650 | } |
651 | } |
652 | } |
653 | } |
654 | SetShapeResult(start,S); |
655 | } |
656 | |
657 | TopoDS_Shape Sh = GetShapeResult(start); |
658 | if ( Sh.IsNull()) { |
659 | Message_Msg Msg1156("IGES_1156"); //the ManifoldSolid is a null object. |
660 | Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start); |
661 | Msg1156.Arg("solid"); |
662 | Msg1156.Arg(label); |
663 | SendFail(start,Msg1156); |
664 | } |
665 | // AddWarning (start, "the ManifoldSolid is a null object."); |
666 | res = Sh; |
667 | return res; |
668 | } |