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
9 // under the terms of the GNU Lesser General Public 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 #include <BRepToIGES_BRSolid.ixx>
18 #include <BRepToIGES_BRShell.hxx>
19 #include <BRepToIGES_BRWire.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepTools.hxx>
24 #include <IGESBasic_Group.hxx>
25 #include <IGESData_HArray1OfIGESEntity.hxx>
26 #include <IGESData_IGESEntity.hxx>
28 #include <Interface_Macros.hxx>
30 #include <TColStd_HSequenceOfTransient.hxx>
34 #include <TopoDS_Compound.hxx>
35 #include <TopoDS_CompSolid.hxx>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Solid.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Shell.hxx>
41 #include <TopoDS_Vertex.hxx>
42 #include <TopoDS_Wire.hxx>
44 #include <TopAbs_ShapeEnum.hxx>
46 #include <TopExp_Explorer.hxx>
49 // At first only the geometry is translated (point, curve...)
51 //=============================================================================
53 //=============================================================================
55 BRepToIGES_BRSolid::BRepToIGES_BRSolid()
60 //=============================================================================
62 //=============================================================================
64 BRepToIGES_BRSolid::BRepToIGES_BRSolid
65 (const BRepToIGES_BREntity& BR)
66 : BRepToIGES_BREntity(BR)
71 //=============================================================================
73 //=============================================================================
75 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferSolid(const TopoDS_Shape& start)
77 Handle(IGESData_IGESEntity) res;
79 if (start.IsNull()) return res;
81 if (start.ShapeType() == TopAbs_SOLID) {
82 TopoDS_Solid M = TopoDS::Solid(start);
83 res = TransferSolid(M);
85 else if (start.ShapeType() == TopAbs_COMPSOLID) {
86 TopoDS_CompSolid C = TopoDS::CompSolid(start);
87 res = TransferCompSolid(C);
89 else if (start.ShapeType() == TopAbs_COMPOUND) {
90 TopoDS_Compound C = TopoDS::Compound(start);
91 res = TransferCompound(C);
100 //=============================================================================
103 //=============================================================================
105 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferSolid(const TopoDS_Solid& start)
107 Handle(IGESData_IGESEntity) res;
108 if ( start.IsNull()) return res;
111 Handle(IGESData_IGESEntity) IShell;
112 BRepToIGES_BRShell BS(*this);
113 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
115 for (Ex.Init(start,TopAbs_SHELL); Ex.More(); Ex.Next()) {
116 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
118 AddWarning(start," an Shell is a null entity");
121 IShell = BS.TransferShell(S);
122 if (!IShell.IsNull()) Seq->Append(IShell);
127 Standard_Integer nbshells = Seq->Length();
128 Handle(IGESData_HArray1OfIGESEntity) Tab;
129 if ( nbshells >= 1) {
130 Tab = new IGESData_HArray1OfIGESEntity(1,nbshells);
131 for (Standard_Integer itab = 1; itab <= nbshells; itab++) {
132 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
133 Tab->SetValue(itab,item);
141 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
146 SetShapeResult ( start, res );
152 //=============================================================================
154 //=============================================================================
156 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferCompSolid(const TopoDS_CompSolid& start)
158 Handle(IGESData_IGESEntity) res;
159 if ( start.IsNull()) return res;
162 Handle(IGESData_IGESEntity) ISolid;
163 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
165 for (Ex.Init(start,TopAbs_SOLID); Ex.More(); Ex.Next()) {
166 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
168 AddWarning(start," an Solid is a null entity");
171 ISolid = TransferSolid(S);
172 if (!ISolid.IsNull()) Seq->Append(ISolid);
177 Standard_Integer nbsolids = Seq->Length();
178 Handle(IGESData_HArray1OfIGESEntity) Tab;
179 if ( nbsolids >= 1) {
180 Tab = new IGESData_HArray1OfIGESEntity(1,nbsolids);
181 for (Standard_Integer itab = 1; itab <= nbsolids; itab++) {
182 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
183 Tab->SetValue(itab,item);
191 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
196 SetShapeResult ( start, res );
202 //=============================================================================
204 //=============================================================================
206 Handle(IGESData_IGESEntity) BRepToIGES_BRSolid ::TransferCompound(const TopoDS_Compound& start)
208 Handle(IGESData_IGESEntity) res;
209 if ( start.IsNull()) return res;
213 Handle(IGESData_IGESEntity) IShape;
214 BRepToIGES_BRShell BS(*this);
215 BRepToIGES_BRWire BW(*this);
216 Handle(TColStd_HSequenceOfTransient) Seq = new TColStd_HSequenceOfTransient();
219 for (Ex.Init(start, TopAbs_SOLID); Ex.More(); Ex.Next()) {
220 TopoDS_Solid S = TopoDS::Solid(Ex.Current());
222 AddWarning(start," a Solid is a null entity");
225 IShape = TransferSolid(S);
226 if (!IShape.IsNull()) Seq->Append(IShape);
230 // take all isolated Shells
231 for (Ex.Init(start, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next()) {
232 TopoDS_Shell S = TopoDS::Shell(Ex.Current());
234 AddWarning(start," a Shell is a null entity");
237 IShape = BS.TransferShell(S);
238 if (!IShape.IsNull()) Seq->Append(IShape);
243 // take all isolated Faces
244 for (Ex.Init(start, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next()) {
245 TopoDS_Face S = TopoDS::Face(Ex.Current());
247 AddWarning(start," a Face is a null entity");
250 IShape = BS.TransferFace(S);
251 if (!IShape.IsNull()) Seq->Append(IShape);
256 // take all isolated Wires
257 for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
258 TopoDS_Wire S = TopoDS::Wire(Ex.Current());
260 AddWarning(start," a Wire is a null entity");
263 IShape = BW.TransferWire(S);
264 if (!IShape.IsNull()) Seq->Append(IShape);
269 // take all isolated Edges
270 for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
271 TopoDS_Edge S = TopoDS::Edge(Ex.Current());
273 AddWarning(start," an Edge is a null entity");
276 IShape = BW.TransferEdge(S, Standard_False);
277 if (!IShape.IsNull()) Seq->Append(IShape);
282 // take all isolated Vertices
283 for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
284 TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
286 AddWarning(start," a Vertex is a null entity");
289 IShape = BW.TransferVertex(S);
290 if (!IShape.IsNull()) Seq->Append(IShape);
294 // construct the group
295 Standard_Integer nbshapes = Seq->Length();
296 Handle(IGESData_HArray1OfIGESEntity) Tab;
298 Tab = new IGESData_HArray1OfIGESEntity(1,nbshapes);
299 for (Standard_Integer itab = 1; itab <= nbshapes; itab++) {
300 Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
301 Tab->SetValue(itab,item);
309 Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
314 SetShapeResult ( start, res );