1 // Created on: 1995-04-25
2 // Created by: Marie Jose MARTZ
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // modif le 25/03/96 mjm
18 // implement ShapeCustom::DirectModification for indirect surfaces (out of norm IGES)
19 //:l4 abv 12 Jan 99: CTS22022-2: correct writing reversed shells
20 //:n3 abv 8 Feb 99: PRO17820: BRepTools::OuterWire() -> ShapeAnalysis::OuterWire
22 //S4181 pdn 20.04.99 implementing of writing IGES elementary surfaces.
23 // abv 31.01.00 inheriting from BRepToIGES_BREntity to remove code duplication
24 //eap: Tue Aug 29 11:02:56 2000: Shape Processing moved to upper levels
26 #include <BRep_Tool.hxx>
27 #include <BRepLib.hxx>
28 #include <BRepToIGES_BRWire.hxx>
29 #include <BRepToIGESBRep_Entity.hxx>
30 #include <BRepTools.hxx>
31 #include <BRepTools_WireExplorer.hxx>
32 #include <Geom2d_Curve.hxx>
33 #include <Geom2dToIGES_Geom2dCurve.hxx>
34 #include <Geom_BezierCurve.hxx>
35 #include <Geom_BSplineCurve.hxx>
36 #include <Geom_CartesianPoint.hxx>
37 #include <Geom_Circle.hxx>
38 #include <Geom_ConicalSurface.hxx>
39 #include <Geom_Curve.hxx>
40 #include <Geom_CylindricalSurface.hxx>
41 #include <Geom_Ellipse.hxx>
42 #include <Geom_Hyperbola.hxx>
43 #include <Geom_Parabola.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_RectangularTrimmedSurface.hxx>
46 #include <Geom_SphericalSurface.hxx>
47 #include <Geom_Surface.hxx>
48 #include <Geom_SurfaceOfLinearExtrusion.hxx>
49 #include <Geom_SurfaceOfRevolution.hxx>
50 #include <Geom_ToroidalSurface.hxx>
51 #include <Geom_TrimmedCurve.hxx>
52 #include <GeomToIGES_GeomCurve.hxx>
53 #include <GeomToIGES_GeomSurface.hxx>
55 #include <gp_Circ2d.hxx>
56 #include <gp_Elips2d.hxx>
58 #include <gp_Pnt2d.hxx>
59 #include <gp_Trsf.hxx>
60 #include <gp_Trsf2d.hxx>
62 #include <IGESBasic_Group.hxx>
63 #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx>
64 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
65 #include <IGESData_HArray1OfIGESEntity.hxx>
66 #include <IGESData_IGESEntity.hxx>
67 #include <IGESData_IGESModel.hxx>
68 #include <IGESGeom_CompositeCurve.hxx>
69 #include <IGESGeom_Point.hxx>
70 #include <IGESSolid_EdgeList.hxx>
71 #include <IGESSolid_Face.hxx>
72 #include <IGESSolid_HArray1OfFace.hxx>
73 #include <IGESSolid_HArray1OfLoop.hxx>
74 #include <IGESSolid_HArray1OfShell.hxx>
75 #include <IGESSolid_HArray1OfVertexList.hxx>
76 #include <IGESSolid_Loop.hxx>
77 #include <IGESSolid_ManifoldSolid.hxx>
78 #include <IGESSolid_Shell.hxx>
79 #include <IGESSolid_VertexList.hxx>
80 #include <Interface_Macros.hxx>
81 #include <Interface_Static.hxx>
82 #include <Message_ProgressIndicator.hxx>
83 #include <ShapeAlgo.hxx>
84 #include <ShapeAlgo_AlgoContainer.hxx>
85 #include <TColgp_HArray1OfXYZ.hxx>
86 #include <TColStd_HArray1OfInteger.hxx>
87 #include <TColStd_HSequenceOfTransient.hxx>
88 #include <TColStd_SequenceOfInteger.hxx>
89 #include <TopAbs_Orientation.hxx>
90 #include <TopAbs_ShapeEnum.hxx>
92 #include <TopExp_Explorer.hxx>
93 #include <TopLoc_Location.hxx>
95 #include <TopoDS_Compound.hxx>
96 #include <TopoDS_CompSolid.hxx>
97 #include <TopoDS_Edge.hxx>
98 #include <TopoDS_Face.hxx>
99 #include <TopoDS_Shape.hxx>
100 #include <TopoDS_Shell.hxx>
101 #include <TopoDS_Solid.hxx>
102 #include <TopoDS_Vertex.hxx>
103 #include <TopoDS_Wire.hxx>
104 #include <Transfer_FinderProcess.hxx>
105 #include <Transfer_SimpleBinderOfTransient.hxx>
106 #include <Transfer_TransientMapper.hxx>
107 #include <TransferBRep_OrientedShapeMapper.hxx>
108 #include <TransferBRep_ShapeMapper.hxx>
110 //#include <GeomConvert.hxx>
111 //#include <Geom2dConvert.hxx>
112 //#include <ShapeAnalysis.hxx>
113 //#include <ShapeCustom.hxx>
114 //=======================================================================
115 //function : BRepToIGESBRep_Entity
117 //=======================================================================
118 BRepToIGESBRep_Entity::BRepToIGESBRep_Entity()
121 if (myEdgeList.IsNull())
122 myEdgeList = new IGESSolid_EdgeList;
123 if (myVertexList.IsNull())
124 myVertexList = new IGESSolid_VertexList;
128 //=======================================================================
131 //=======================================================================
133 void BRepToIGESBRep_Entity::Clear()
141 //=============================================================================
142 // TransferVertexList
144 //=============================================================================
146 void BRepToIGESBRep_Entity::TransferVertexList()
149 Standard_Integer nbvertices = myVertices.Extent();
152 Handle(TColgp_HArray1OfXYZ) vertices= new TColgp_HArray1OfXYZ(1,nbvertices);
153 Standard_Real Unit = GetUnit();
156 for (Standard_Integer ivertex = 1; ivertex <= nbvertices; ivertex++) {
157 TopoDS_Shape myshape = myVertices(ivertex);
158 TopoDS_Vertex myvertex = TopoDS::Vertex(myshape);
159 gp_Pnt Point = BRep_Tool::Pnt(myvertex);
161 vertices->SetValue(ivertex, gp_XYZ(X/Unit,Y/Unit,Z/Unit));
164 myVertexList->Init(vertices);
168 //=============================================================================
170 //=============================================================================
171 Standard_Integer BRepToIGESBRep_Entity::IndexVertex(const TopoDS_Vertex& myvertex) const
173 TopoDS_Shape V = myvertex;
174 return myVertices.FindIndex(V);
178 //=============================================================================
181 //=============================================================================
183 Standard_Integer BRepToIGESBRep_Entity::AddVertex(const TopoDS_Vertex& myvertex)
185 if ( myvertex.IsNull()) return 0;
187 TopoDS_Shape V = myvertex;
188 Standard_Integer index = myVertices.FindIndex(V);
190 index = myVertices.Add(V);
197 //=============================================================================
200 //=============================================================================
202 void BRepToIGESBRep_Entity::TransferEdgeList()
205 Handle(IGESSolid_VertexList) TheVertexList = myVertexList;
207 Handle(IGESData_IGESEntity) mycurve;
208 Standard_Integer mystartindex, myendindex;
209 Handle(IGESSolid_VertexList) mystartlist;
210 Handle(IGESSolid_VertexList) myendlist;
212 Standard_Integer nbedges = myEdges.Extent();
215 Handle(IGESData_HArray1OfIGESEntity) Curves=
216 new IGESData_HArray1OfIGESEntity(1,nbedges);
217 Handle(IGESSolid_HArray1OfVertexList) startVertexList =
218 new IGESSolid_HArray1OfVertexList(1,nbedges);
219 Handle(TColStd_HArray1OfInteger) startVertexIndex =
220 new TColStd_HArray1OfInteger(1,nbedges);
221 Handle(IGESSolid_HArray1OfVertexList) endVertexList =
222 new IGESSolid_HArray1OfVertexList(1,nbedges);
223 Handle(TColStd_HArray1OfInteger) endVertexIndex =
224 new TColStd_HArray1OfInteger(1,nbedges);
226 for (Standard_Integer iedge = 1; iedge <= nbedges; iedge++) {
227 TopoDS_Shape myshape = myEdges(iedge);
228 TopoDS_Edge myedge = TopoDS::Edge(myshape);
230 DeclareAndCast(IGESData_IGESEntity, amycurve, myCurves(iedge));
231 Curves->SetValue(iedge, amycurve);
232 TopoDS_Vertex V1, V2;
233 TopExp::Vertices(myedge, V1, V2);
234 // vertices follow the orientation of curve 3d
235 mystartindex = IndexVertex(V1);
236 myendindex = IndexVertex(V2);
237 startVertexIndex->SetValue(iedge, mystartindex);
238 endVertexIndex->SetValue(iedge, myendindex);
239 startVertexList->SetValue(iedge, TheVertexList);
240 endVertexList->SetValue(iedge, TheVertexList);
244 (Curves, startVertexList, startVertexIndex, endVertexList, endVertexIndex);
248 //=============================================================================
250 //=============================================================================
251 Standard_Integer BRepToIGESBRep_Entity::IndexEdge(const TopoDS_Edge& myedge) const
253 TopoDS_Shape E = myedge;
254 return myEdges.FindIndex(E);
258 //=============================================================================
261 //=============================================================================
263 Standard_Integer BRepToIGESBRep_Entity::AddEdge(const TopoDS_Edge& myedge,
264 const Handle(IGESData_IGESEntity)& mycurve3d)
266 if ( myedge.IsNull()) return 0;
268 TopoDS_Shape E = myedge;
269 Handle(IGESData_IGESEntity) C = mycurve3d;
270 Standard_Integer index = myEdges.FindIndex(E);
272 index = myEdges.Add(E);
280 //=======================================================================
281 //function : TransferShape
283 //=======================================================================
284 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferShape
285 (const TopoDS_Shape& start)
287 Handle(IGESData_IGESEntity) res;
288 //TopoDS_Shape theShape;
290 if (start.IsNull()) return res;
292 if (start.ShapeType() == TopAbs_VERTEX) {
293 AddWarning (start, " A Vertex alone is not a IGESBRep Entity");
294 TopoDS_Vertex V = TopoDS::Vertex(start);
295 BRepToIGES_BRWire BW(*this);
296 BW.SetModel(GetModel());
297 res = BW.TransferVertex(V);
300 else if (start.ShapeType() == TopAbs_EDGE) {
301 AddWarning (start, " An Edge alone is not a IGESBRep Entity");
302 TopoDS_Edge E = TopoDS::Edge(start);
303 BRepToIGES_BRWire BW(*this);
304 BW.SetModel(GetModel());
305 res = BW.TransferEdge(E, Standard_False);
308 else if (start.ShapeType() == TopAbs_WIRE) {
309 AddWarning (start, " An Wire alone is not a IGESBRep Entity");
310 TopoDS_Wire W = TopoDS::Wire(start);
311 BRepToIGES_BRWire BW(*this);
312 BW.SetModel(GetModel());
313 res = BW.TransferWire(W);
317 // theShape = ShapeCustom::DirectFaces(start);
318 if (start.ShapeType() == TopAbs_FACE) {
319 TopoDS_Face F = TopoDS::Face(start);
320 res = TransferFace(F);
322 else if (start.ShapeType() == TopAbs_SHELL) {
323 TopoDS_Shell S = TopoDS::Shell(start);
324 res = TransferShell(S);
326 else if (start.ShapeType() == TopAbs_SOLID) {
327 TopoDS_Solid M = TopoDS::Solid(start);
328 res = TransferSolid(M);
330 else if (start.ShapeType() == TopAbs_COMPSOLID) {
331 TopoDS_CompSolid C = TopoDS::CompSolid(start);
332 res = TransferCompSolid(C);
334 else if (start.ShapeType() == TopAbs_COMPOUND) {
335 TopoDS_Compound C = TopoDS::Compound(start);
336 res = TransferCompound(C);
345 TransferVertexList();
351 //=============================================================================
353 //=============================================================================
355 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferEdge (const TopoDS_Edge& myedge)
357 BRepToIGES_BRWire BR(*this);
358 BR.SetModel(GetModel());
359 return BR.TransferEdge (myedge, Standard_True);
363 //=============================================================================
365 //=============================================================================
367 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferEdge (const TopoDS_Edge& myedge,
368 const TopoDS_Face& myface,
369 const Standard_Real Length)
371 Handle(IGESData_IGESEntity) ICurve3d;
372 Handle(IGESData_IGESEntity) ICurve2d;
373 if ( myedge.IsNull()) return ICurve2d;
375 BRepToIGES_BRWire BR(*this);
376 BR.SetModel(GetModel());
377 ICurve2d = BR.TransferEdge (myedge, myface, Length, Standard_True);
379 // curve 3d is obligatory. If it does not exist it is created and stored in "myCurves".
380 // If the edge is degenerated, there is no associated 3d. So "edge-tuple"
383 if (!BRep_Tool::Degenerated(myedge)) {
384 ICurve3d = TransferEdge(myedge);
385 if (ICurve3d.IsNull()) {
386 AddFail (myedge, " Transfer Failed : no Curve 3D ");
388 AddEdge(myedge, ICurve3d);
395 //=============================================================================
397 //=============================================================================
399 Handle(IGESSolid_Loop) BRepToIGESBRep_Entity::TransferWire (const TopoDS_Wire& mywire,
400 const TopoDS_Face& myface,
401 const Standard_Real Length)
403 Handle(IGESSolid_Loop) myLoop = new IGESSolid_Loop;
404 if ( mywire.IsNull()) return myLoop;
405 Handle(IGESData_IGESEntity) Pointeur;
407 TColStd_SequenceOfInteger Seqindex;
408 TColStd_SequenceOfInteger Seqorient;
409 TColStd_SequenceOfInteger Seqtype;
410 Handle(IGESData_IGESEntity) ent2d ;
411 Handle(IGESData_IGESEntity) ent3d ;
412 Handle(TColStd_HSequenceOfTransient) Seq2d = new TColStd_HSequenceOfTransient();
414 BRepTools_WireExplorer WE;
415 //Standard_Integer nbedge = 0; //szv#4:S4163:12Mar99 unused
416 TopExp_Explorer TE(mywire, TopAbs_VERTEX);
418 for ( WE.Init(mywire,myface); WE.More(); WE.Next()) {
419 TopoDS_Edge E = WE.Current();
421 AddWarning(mywire, "an Edge is a null entity");
424 ent2d = TransferEdge(E, myface, Length);
425 Seq2d->Append(ent2d);
426 Standard_Integer myindex;
428 // add Vertices in the Map "myVertices"
429 TopoDS_Vertex V1, V2;
430 TopExp::Vertices(E, V1, V2);
431 //Standard_Integer Ivertex1, Ivertex2; //szv#4:S4163:12Mar99 not needed
432 if (!BRep_Tool::Degenerated(E)) {
434 AddVertex(V1); //szv#4:S4163:12Mar99 `Ivertex1=` not needed
437 AddVertex(V2); //szv#4:S4163:12Mar99 `Ivertex2=` not needed
439 myindex = IndexEdge(E);
443 myindex = AddVertex(V1);
446 Seqindex.Append(myindex);
447 if (E.Orientation() == TopAbs_FORWARD ) Seqorient.Append(1);
448 if (E.Orientation() == TopAbs_REVERSED) Seqorient.Append(0);
453 AddWarning(mywire, " no Vertex associated to the Wire");
455 Standard_Integer nbedges = Seq2d->Length();
456 Handle(TColStd_HArray1OfInteger) types = new TColStd_HArray1OfInteger(1,nbedges);
457 Standard_Integer mytype;
458 Handle(IGESData_HArray1OfIGESEntity) edges = new IGESData_HArray1OfIGESEntity(1,nbedges);
459 Handle(IGESData_IGESEntity) myedge;
460 Handle(TColStd_HArray1OfInteger) index = new TColStd_HArray1OfInteger(1,nbedges);
461 Standard_Integer myindex;
462 Handle(TColStd_HArray1OfInteger) orient = new TColStd_HArray1OfInteger(1,nbedges);
463 Standard_Integer myorient;
464 Handle(TColStd_HArray1OfInteger) nbcurves = new TColStd_HArray1OfInteger(1,nbedges);
465 Standard_Integer mynbcurve;
466 Handle(TColStd_HArray1OfInteger) flag;
467 Handle(IGESBasic_HArray1OfHArray1OfInteger) isoflags =
468 new IGESBasic_HArray1OfHArray1OfInteger(1,nbedges);
469 Standard_Integer myisoflag;
470 Handle(IGESData_HArray1OfIGESEntity) curve;
471 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) curves =
472 new IGESBasic_HArray1OfHArray1OfIGESEntity(1,nbedges);
473 Handle(IGESData_IGESEntity) mycurve;
476 for (Standard_Integer itab = 1; itab <= nbedges; itab++) {
477 mytype = Seqtype.Value(itab);
478 types->SetValue(itab,mytype);
480 Pointeur = myEdgeList;
482 Pointeur = myVertexList;
483 edges->SetValue(itab,Pointeur);
484 myindex = Seqindex.Value(itab);
485 index->SetValue(itab, myindex);
486 myorient = Seqorient.Value(itab);
487 orient->SetValue(itab, myorient);
488 mynbcurve = ( Seq2d->Value(itab).IsNull() ? 0 : 1 ); // abv 31 Jan 00: to be able not to write pcurves: was 1
489 nbcurves->SetValue(itab, mynbcurve);
491 flag = new TColStd_HArray1OfInteger(1,1);
492 flag->SetValue(1,myisoflag);
493 isoflags->SetValue(itab,flag);
494 mycurve = GetCasted(IGESData_IGESEntity, Seq2d->Value(itab));
495 curve = new IGESData_HArray1OfIGESEntity(1,1);
496 curve->SetValue(1,mycurve);
497 curves->SetValue(itab,curve);
500 myLoop->Init(types, edges, index, orient, nbcurves, isoflags, curves);
502 SetShapeResult ( mywire, myLoop );
508 //=============================================================================
511 //=============================================================================
513 Handle(IGESSolid_Face) BRepToIGESBRep_Entity ::TransferFace(const TopoDS_Face& start)
515 Handle(Message_ProgressIndicator) progress = GetTransferProcess()->GetProgress();
516 if ( ! progress.IsNull() ) {
517 if ( progress->UserBreak() ) return 0;
518 progress->Increment();
521 Handle(IGESSolid_Face) myent = new IGESSolid_Face;
522 if ( start.IsNull()) return myent;
523 Handle(IGESData_IGESEntity) ISurf;
524 Standard_Real Length = 1.;
526 // returns the face surface, the face tolerance, the face natural restriction flag.
527 // --------------------------------------------------------------------------------
528 Handle(Geom_Surface) Surf = BRep_Tool::Surface(start);
529 if (!Surf.IsNull()) {
530 Standard_Real U1, U2, V1, V2;
531 BRepTools::UVBounds(start, U1, U2, V1, V2); // to limit the base surfaces
532 GeomToIGES_GeomSurface GS;
533 //S4181 pdn 17.04.99 Boolean flags in order to define write of elementary surfaces added.
534 GS.SetBRepMode(Standard_True);
535 GS.SetAnalyticMode ( Interface_Static::IVal("write.convertsurface.mode") ==0 );
536 GS.SetModel(GetModel());
538 Handle(Geom_Surface) st;
539 if (Surf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
540 DeclareAndCast(Geom_RectangularTrimmedSurface, rectang, Surf);
541 st = rectang->BasisSurface();
546 //S4181 pdn 17.04.99 Geom_Plane translated into GeomToIGES_GeomSurface
547 ISurf = GS.TransferSurface(st, U1, U2, V1, V2);
548 if (ISurf.IsNull()) {
549 AddWarning (start, "the basic surface is a null entity");
552 Length = GS.Length();
556 // returns the wires of start
557 // --------------------------
559 // to explore the face , it is required to set it FORWARD.
560 TopoDS_Face myface = start;
561 Standard_Boolean IsReversed = Standard_False;
562 if (start.Orientation() == TopAbs_REVERSED) {
564 IsReversed = Standard_True;
568 //:n3 TopoDS_Wire Outer = BRepTools::OuterWire(myface);
569 TopoDS_Wire Outer = ShapeAlgo::AlgoContainer()->OuterWire(myface); //:n3
570 Handle(IGESSolid_Loop) OuterLoop = new IGESSolid_Loop;
571 Standard_Boolean OuterLoopFlag = Standard_False;
572 if (!Outer.IsNull()) {
573 OuterLoopFlag = Standard_True;
574 OuterLoop = TransferWire(Outer, myface, Length);
579 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
581 for (Ex.Init(myface,TopAbs_WIRE); Ex.More(); Ex.Next()) {
582 TopoDS_Wire W = TopoDS::Wire(Ex.Current());
583 Handle(IGESSolid_Loop) InnerLoop = new IGESSolid_Loop;
585 AddWarning(start," a Wire is a null entity");
587 else if (!W.IsSame(Outer)) {
588 InnerLoop = TransferWire(W, myface, Length);
589 if (!InnerLoop.IsNull()) Seq->Append(InnerLoop);
593 // all inner edges not in a wire
594 for (Ex.Init(myface,TopAbs_EDGE,TopAbs_WIRE); Ex.More(); Ex.Next()) {
595 TopoDS_Edge E = TopoDS::Edge(Ex.Current());
596 AddWarning ( E, "An edge alone is not transfer as an IGESBRep Entity");
599 Standard_Integer nbent = Seq->Length();
600 Handle(IGESSolid_HArray1OfLoop) TabLoop;
601 TabLoop = new IGESSolid_HArray1OfLoop(1,nbent+1);
602 TabLoop->SetValue(1,OuterLoop);
604 for (Standard_Integer itab = 1; itab <= nbent; itab++) {
605 Handle(IGESSolid_Loop) item = GetCasted(IGESSolid_Loop, Seq->Value(itab));
606 TabLoop->SetValue(itab+1,item);
612 myent-> Init (ISurf, OuterLoopFlag, TabLoop);
614 if (IsReversed) myface.Reverse();
616 SetShapeResult ( start, myent );
622 //=============================================================================
624 //=============================================================================
626 Handle(IGESSolid_Shell) BRepToIGESBRep_Entity ::TransferShell(const TopoDS_Shell& start)
628 Handle(IGESSolid_Shell) myshell = new IGESSolid_Shell;
629 if ( start.IsNull()) return myshell;
632 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
633 TColStd_SequenceOfInteger SeqFlag;
634 Handle(IGESSolid_Face) IFace;
636 for (Ex.Init(start,TopAbs_FACE); Ex.More(); Ex.Next()) {
637 TopoDS_Face F = TopoDS::Face(Ex.Current());
638 if ( start.Orientation() == TopAbs_REVERSED ) F.Reverse(); //:l4 abv 12 Jan 99: CTS22022-2: writing reversed shells
640 AddWarning(start," a Face is a null entity");
643 IFace = TransferFace(F);
644 if (!IFace.IsNull()) {
646 if (F.Orientation() == TopAbs_FORWARD ) SeqFlag.Append(1);
647 if (F.Orientation() == TopAbs_REVERSED) SeqFlag.Append(0);
653 Standard_Integer nbfaces = Seq->Length();
654 Handle(IGESSolid_HArray1OfFace) TabFace = new IGESSolid_HArray1OfFace(1,nbfaces);
655 Handle(TColStd_HArray1OfInteger) TabFlag = new TColStd_HArray1OfInteger(1,nbfaces);
656 for (Standard_Integer itab = 1; itab <= nbfaces; itab++) {
657 Handle(IGESSolid_Face) itemface = GetCasted(IGESSolid_Face, Seq->Value(itab));
658 TabFace->SetValue(itab,itemface);
659 Standard_Integer item = SeqFlag.Value(itab);
660 TabFlag->SetValue(itab, item);
663 myshell->Init(TabFace,TabFlag);
665 SetShapeResult ( start, myshell );
671 //=============================================================================
674 //=============================================================================
676 Handle(IGESSolid_ManifoldSolid) BRepToIGESBRep_Entity ::TransferSolid (const TopoDS_Solid& start)
678 Handle(IGESSolid_ManifoldSolid) mysol = new IGESSolid_ManifoldSolid;
679 if ( start.IsNull()) return mysol;
682 Handle(IGESSolid_Shell) IShell, FirstShell;
683 Standard_Integer ShellFlag = 1;
684 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
685 TColStd_SequenceOfInteger SeqFlag;
687 for (Ex.Init(start,TopAbs_SHELL); Ex.More(); Ex.Next()) {
688 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
690 AddWarning(start," a Shell is a null entity");
693 IShell = TransferShell(S);
694 if (!IShell.IsNull()) {
696 if (S.Orientation() == TopAbs_FORWARD ) SeqFlag.Append(1);
697 if (S.Orientation() == TopAbs_REVERSED) SeqFlag.Append(0);
703 Standard_Integer nbshells = Seq->Length();
704 Handle(IGESSolid_HArray1OfShell) Tab;
705 Handle(TColStd_HArray1OfInteger) TabFlag;
707 Tab = new IGESSolid_HArray1OfShell(1,nbshells-1);
708 TabFlag = new TColStd_HArray1OfInteger(1,nbshells-1);
709 for (Standard_Integer itab = 1; itab <= nbshells; itab++) {
710 Handle(IGESSolid_Shell) itemShell = GetCasted(IGESSolid_Shell, Seq->Value(itab));
711 Standard_Integer item = SeqFlag.Value(itab);
713 FirstShell = itemShell;
717 Tab->SetValue(itab-1,itemShell);
718 TabFlag->SetValue(itab-1, item);
724 FirstShell = GetCasted(IGESSolid_Shell, Seq->Value(1));
725 ShellFlag = SeqFlag.Value(1);
726 Tab.Nullify(); TabFlag.Nullify();
727 mysol->Init(FirstShell, ShellFlag != 0, Tab, TabFlag);
729 else if (nbshells >=2 ) {
730 mysol->Init(FirstShell, ShellFlag != 0, Tab, TabFlag);
733 AddWarning (start, " no Result ");
735 SetShapeResult ( start, mysol );
741 //=============================================================================
744 //=============================================================================
746 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompSolid (const TopoDS_CompSolid& start)
748 Handle(IGESData_IGESEntity) myent;
749 if ( start.IsNull()) return myent;
752 Handle(IGESSolid_ManifoldSolid) ISolid = new IGESSolid_ManifoldSolid;
753 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
755 for (Ex.Init(start,TopAbs_SOLID); Ex.More(); Ex.Next()) {
756 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
758 AddWarning(start," an Solid is a null entity");
761 ISolid = TransferSolid(S);
762 if (!ISolid.IsNull()) Seq->Append(ISolid);
767 Standard_Integer nbsolids = Seq->Length();
768 Handle(IGESData_HArray1OfIGESEntity) Tab;
770 Tab = new IGESData_HArray1OfIGESEntity(1,nbsolids);
771 for (Standard_Integer itab = 1; itab <= nbsolids; itab++) {
772 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
773 Tab->SetValue(itab,item);
780 else if(nbsolids > 1 ){
781 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
786 SetShapeResult ( start, myent );
792 //=============================================================================
795 //=============================================================================
797 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoDS_Compound& start)
799 Handle(IGESData_IGESEntity) res;
800 if ( start.IsNull()) return res;
804 Handle(IGESData_IGESEntity) IShape;
805 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
808 for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) {
809 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
811 AddWarning(start," a Solid is a null entity");
814 IShape = TransferSolid(S);
815 if (!IShape.IsNull()) Seq->Append(IShape);
819 // take all isolated Shells
820 for (Ex.Init(start, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next()) {
821 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
823 AddWarning(start," a Shell is a null entity");
826 IShape = TransferShell(S);
827 if (!IShape.IsNull()) Seq->Append(IShape);
832 // take all isolated Faces
833 for (Ex.Init(start, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next()) {
834 TopoDS_Face S = TopoDS::Face(Ex.Current());
836 AddWarning(start," a Face is a null entity");
839 IShape = TransferFace(S);
840 if (!IShape.IsNull()) Seq->Append(IShape);
845 // take all isolated Wires
846 for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
847 TopoDS_Wire S = TopoDS::Wire(Ex.Current());
849 BRepToIGES_BRWire BW(*this);
850 BW.SetModel(GetModel());
851 IShape = BW.TransferWire(S);
852 if (!IShape.IsNull()) Seq->Append(IShape);
856 // take all isolated Edges
857 for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
858 TopoDS_Edge S = TopoDS::Edge(Ex.Current());
860 BRepToIGES_BRWire BW(*this);
861 BW.SetModel(GetModel());
862 IShape = BW.TransferEdge(S, Standard_False);
863 if (!IShape.IsNull()) Seq->Append(IShape);
867 // take all isolated Vertices
868 for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
869 TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
871 BRepToIGES_BRWire BW(*this);
872 BW.SetModel(GetModel());
873 IShape = BW.TransferVertex(S);
874 if (!IShape.IsNull()) Seq->Append(IShape);
877 // construct the group
878 Standard_Integer nbshapes = Seq->Length();
880 Handle(IGESData_HArray1OfIGESEntity) Tab =
881 new IGESData_HArray1OfIGESEntity(1,nbshapes);
882 for (Standard_Integer itab = 1; itab <= nbshapes; itab++) {
883 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
884 Tab->SetValue(itab,item);
887 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
892 SetShapeResult ( start, res );