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