0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / StepToTopoDS / StepToTopoDS_TranslateShell.cxx
CommitLineData
b311480e 1// Created on: 1995-01-03
2// Created by: Frederic MAUPAS
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17//: gka 09.04.99: S4136: improving tolerance management
18
7fd59977 19#include <BRep_Builder.hxx>
42cf5bc1 20#include <Message_ProgressIndicator.hxx>
21#include <Message_ProgressSentry.hxx>
22#include <StdFail_NotDone.hxx>
23#include <StepShape_ConnectedFaceSet.hxx>
24#include <StepShape_FaceSurface.hxx>
25#include <StepToTopoDS_NMTool.hxx>
26#include <StepToTopoDS_Tool.hxx>
27#include <StepToTopoDS_TranslateFace.hxx>
28#include <StepToTopoDS_TranslateShell.hxx>
7fd59977 29#include <TopoDS.hxx>
7fd59977 30#include <TopoDS_Face.hxx>
42cf5bc1 31#include <TopoDS_Shape.hxx>
32#include <TopoDS_Shell.hxx>
7fd59977 33#include <Transfer_TransientProcess.hxx>
34
7fd59977 35// ============================================================================
36// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
37// Purpose : Empty Constructor
38// ============================================================================
7fd59977 39StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
40{
41 done = Standard_False;
42}
43
44// ============================================================================
45// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
46// Purpose : Constructor with a ConnectedFaceSet and a Tool
47// ============================================================================
48
49StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
50(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
51{
52 Init(CFS, T, NMTool);
53}
54
55// ============================================================================
56// Method : Init
57// Purpose : Init with a ConnectedFaceSet and a Tool
58// ============================================================================
59
60void StepToTopoDS_TranslateShell::Init
61(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
62{
1332f047
A
63 //bug15697
64 if(CFS.IsNull())
65 return;
66
7fd59977 67 if (!aTool.IsBound(CFS)) {
68
69 BRep_Builder B;
70 Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
71
72 Standard_Integer NbFc = CFS->NbCfsFaces();
73 TopoDS_Shell Sh;
74 B.MakeShell(Sh);
75 TopoDS_Face F;
76 TopoDS_Shape S;
77 Handle(StepShape_Face) StepFace;
78
79 StepToTopoDS_TranslateFace myTranFace;
80 myTranFace.SetPrecision(Precision()); //gka
81 myTranFace.SetMaxTol(MaxTol());
82
83 Message_ProgressSentry PS ( TP->GetProgress(), "Face", 0, NbFc, 1 );
63c71e2f 84 for (Standard_Integer i = 1; i <= NbFc && PS.More(); i++, PS.Next()) {
0797d9d3 85#ifdef OCCT_DEBUG
04232180 86 std::cout << "Processing Face : " << i << std::endl;
7fd59977 87#endif
88 StepFace = CFS->CfsFacesValue(i);
63c71e2f 89 Handle(StepShape_FaceSurface) theFS =
90 Handle(StepShape_FaceSurface)::DownCast(StepFace);
7fd59977 91 if (!theFS.IsNull()) {
63c71e2f 92 myTranFace.Init(theFS, aTool, NMTool);
93 if (myTranFace.IsDone()) {
94 S = myTranFace.Value();
95 F = TopoDS::Face(S);
96 B.Add(Sh, F);
97 }
98 else { // Warning only + add FaceSurface file Identifier
99 TP->AddWarning(theFS, " a Face from Shell not mapped to TopoDS");
100 }
7fd59977 101 }
63c71e2f 102 else { // Warning : add identifier
103 TP->AddWarning(StepFace, " Face is not of FaceSurface Type; not mapped to TopoDS");
7fd59977 104 }
105 }
ab860031 106 Sh.Closed (BRep_Tool::IsClosed (Sh));
7fd59977 107 myResult = Sh;
108 aTool.Bind(CFS, myResult);
109 myError = StepToTopoDS_TranslateShellDone;
110 done = Standard_True;
111 }
112 else {
113 myResult = TopoDS::Shell(aTool.Find(CFS));
114 myError = StepToTopoDS_TranslateShellDone;
115 done = Standard_True;
116 }
117}
118
119// ============================================================================
120// Method : Value
121// Purpose : Return the mapped Shape
122// ============================================================================
123
124const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
125{
2d2b3d53 126 StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateShell::Value() - no result");
7fd59977 127 return myResult;
128}
129
130// ============================================================================
131// Method : Error
132// Purpose : Return the TranslateShell Error code
133// ============================================================================
134
135StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
136{
137 return myError;
138}
1332f047 139