1 // Created on: 1995-01-30
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.
18 #include <BRep_Tool.hxx>
19 #include <BRepToIGES_BREntity.hxx>
20 #include <BRepToIGES_BRShell.hxx>
21 #include <BRepToIGES_BRSolid.hxx>
22 #include <BRepToIGES_BRWire.hxx>
23 #include <BRepTools.hxx>
24 #include <IGESBasic_Group.hxx>
25 #include <IGESData_HArray1OfIGESEntity.hxx>
26 #include <IGESData_IGESEntity.hxx>
27 #include <Interface_Macros.hxx>
28 #include <TColStd_HSequenceOfTransient.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
31 #include <TopExp_Explorer.hxx>
33 #include <TopoDS_Compound.hxx>
34 #include <TopoDS_CompSolid.hxx>
35 #include <TopoDS_Edge.hxx>
36 #include <TopoDS_Face.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Shell.hxx>
39 #include <TopoDS_Solid.hxx>
40 #include <TopoDS_Vertex.hxx>
41 #include <TopoDS_Wire.hxx>
43 // At first only the geometry is translated (point, curve...)
44 //=============================================================================
46 //=============================================================================
47 BRepToIGES_BRSolid::BRepToIGES_BRSolid()
52 //=============================================================================
54 //=============================================================================
56 BRepToIGES_BRSolid::BRepToIGES_BRSolid
57 (const BRepToIGES_BREntity& BR)
58 : BRepToIGES_BREntity(BR)
63 //=============================================================================
65 //=============================================================================
67 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferSolid(const TopoDS_Shape& start)
69 Handle(IGESData_IGESEntity) res;
71 if (start.IsNull()) return res;
73 if (start.ShapeType() == TopAbs_SOLID) {
74 TopoDS_Solid M = TopoDS::Solid(start);
75 res = TransferSolid(M);
77 else if (start.ShapeType() == TopAbs_COMPSOLID) {
78 TopoDS_CompSolid C = TopoDS::CompSolid(start);
79 res = TransferCompSolid(C);
81 else if (start.ShapeType() == TopAbs_COMPOUND) {
82 TopoDS_Compound C = TopoDS::Compound(start);
83 res = TransferCompound(C);
92 //=============================================================================
95 //=============================================================================
97 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferSolid(const TopoDS_Solid& start)
99 Handle(IGESData_IGESEntity) res;
100 if ( start.IsNull()) return res;
103 Handle(IGESData_IGESEntity) IShell;
104 BRepToIGES_BRShell BS(*this);
105 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
107 for (Ex.Init(start,TopAbs_SHELL); Ex.More(); Ex.Next()) {
108 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
110 AddWarning(start," an Shell is a null entity");
113 IShell = BS.TransferShell(S);
114 if (!IShell.IsNull()) Seq->Append(IShell);
119 Standard_Integer nbshells = Seq->Length();
120 Handle(IGESData_HArray1OfIGESEntity) Tab;
121 if ( nbshells >= 1) {
122 Tab = new IGESData_HArray1OfIGESEntity(1,nbshells);
123 for (Standard_Integer itab = 1; itab <= nbshells; itab++) {
124 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
125 Tab->SetValue(itab,item);
133 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
138 SetShapeResult ( start, res );
144 //=============================================================================
146 //=============================================================================
148 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferCompSolid(const TopoDS_CompSolid& start)
150 Handle(IGESData_IGESEntity) res;
151 if ( start.IsNull()) return res;
154 Handle(IGESData_IGESEntity) ISolid;
155 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
157 for (Ex.Init(start,TopAbs_SOLID); Ex.More(); Ex.Next()) {
158 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
160 AddWarning(start," an Solid is a null entity");
163 ISolid = TransferSolid(S);
164 if (!ISolid.IsNull()) Seq->Append(ISolid);
169 Standard_Integer nbsolids = Seq->Length();
170 Handle(IGESData_HArray1OfIGESEntity) Tab;
171 if ( nbsolids >= 1) {
172 Tab = new IGESData_HArray1OfIGESEntity(1,nbsolids);
173 for (Standard_Integer itab = 1; itab <= nbsolids; itab++) {
174 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
175 Tab->SetValue(itab,item);
183 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
188 SetShapeResult ( start, res );
194 //=============================================================================
196 //=============================================================================
198 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferCompound(const TopoDS_Compound& start)
200 Handle(IGESData_IGESEntity) res;
201 if ( start.IsNull()) return res;
205 Handle(IGESData_IGESEntity) IShape;
206 BRepToIGES_BRShell BS(*this);
207 BRepToIGES_BRWire BW(*this);
208 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
211 for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) {
212 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
214 AddWarning(start," a Solid is a null entity");
217 IShape = TransferSolid(S);
218 if (!IShape.IsNull()) Seq->Append(IShape);
222 // take all isolated Shells
223 for (Ex.Init(start, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next()) {
224 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
226 AddWarning(start," a Shell is a null entity");
229 IShape = BS.TransferShell(S);
230 if (!IShape.IsNull()) Seq->Append(IShape);
235 // take all isolated Faces
236 for (Ex.Init(start, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next()) {
237 TopoDS_Face S = TopoDS::Face(Ex.Current());
239 AddWarning(start," a Face is a null entity");
242 IShape = BS.TransferFace(S);
243 if (!IShape.IsNull()) Seq->Append(IShape);
248 // take all isolated Wires
249 for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
250 TopoDS_Wire S = TopoDS::Wire(Ex.Current());
252 AddWarning(start," a Wire is a null entity");
255 IShape = BW.TransferWire(S);
256 if (!IShape.IsNull()) Seq->Append(IShape);
261 // take all isolated Edges
262 for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
263 TopoDS_Edge S = TopoDS::Edge(Ex.Current());
265 AddWarning(start," an Edge is a null entity");
268 IShape = BW.TransferEdge(S, Standard_False);
269 if (!IShape.IsNull()) Seq->Append(IShape);
274 // take all isolated Vertices
275 for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
276 TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
278 AddWarning(start," a Vertex is a null entity");
281 IShape = BW.TransferVertex(S);
282 if (!IShape.IsNull()) Seq->Append(IShape);
286 // construct the group
287 Standard_Integer nbshapes = Seq->Length();
288 Handle(IGESData_HArray1OfIGESEntity) Tab;
290 Tab = new IGESData_HArray1OfIGESEntity(1,nbshapes);
291 for (Standard_Integer itab = 1; itab <= nbshapes; itab++) {
292 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
293 Tab->SetValue(itab,item);
301 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
306 SetShapeResult ( start, res );