0015697: External Contribution on OCC DE Improvement
[occt.git] / src / StepToTopoDS / StepToTopoDS_TranslateShell.cxx
CommitLineData
7fd59977 1// File: StepToTopoDS_TranslateShell.cxx
2// Created: Tue Jan 3 14:01:53 1995
3// Author: Frederic MAUPAS
4// <fma@stylox>
5//: gka 09.04.99: S4136: improving tolerance management
6
7#include <StepToTopoDS_TranslateShell.ixx>
8
9#include <StepToTopoDS_TranslateFace.hxx>
10
11#include <StepShape_FaceSurface.hxx>
12
13#include <BRep_Builder.hxx>
14#include <TopoDS.hxx>
15#include <TopoDS_Shell.hxx>
16#include <TopoDS_Face.hxx>
17#include <Transfer_TransientProcess.hxx>
18
19#include <Message_ProgressIndicator.hxx>
20#include <Message_ProgressSentry.hxx>
21
22// ============================================================================
23// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
24// Purpose : Empty Constructor
25// ============================================================================
26
27StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
28{
29 done = Standard_False;
30}
31
32// ============================================================================
33// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
34// Purpose : Constructor with a ConnectedFaceSet and a Tool
35// ============================================================================
36
37StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
38(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
39{
40 Init(CFS, T, NMTool);
41}
42
43// ============================================================================
44// Method : Init
45// Purpose : Init with a ConnectedFaceSet and a Tool
46// ============================================================================
47
48void StepToTopoDS_TranslateShell::Init
49(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
50{
1332f047
A
51 //bug15697
52 if(CFS.IsNull())
53 return;
54
7fd59977 55 if (!aTool.IsBound(CFS)) {
56
57 BRep_Builder B;
58 Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
59
60 Standard_Integer NbFc = CFS->NbCfsFaces();
61 TopoDS_Shell Sh;
62 B.MakeShell(Sh);
63 TopoDS_Face F;
64 TopoDS_Shape S;
65 Handle(StepShape_Face) StepFace;
66
67 StepToTopoDS_TranslateFace myTranFace;
68 myTranFace.SetPrecision(Precision()); //gka
69 myTranFace.SetMaxTol(MaxTol());
70
71 Message_ProgressSentry PS ( TP->GetProgress(), "Face", 0, NbFc, 1 );
72 for (Standard_Integer i=1; i<=NbFc && PS.More(); i++, PS.Next()) {
73#ifdef DEBUG
74 cout << "Processing Face : " << i << endl;
75#endif
76 StepFace = CFS->CfsFacesValue(i);
77 Handle(StepShape_FaceSurface) theFS =
78 Handle(StepShape_FaceSurface)::DownCast(StepFace);
79 if (!theFS.IsNull()) {
80 myTranFace.Init(theFS, aTool, NMTool);
81 if (myTranFace.IsDone()) {
82 S = myTranFace.Value();
83 F = TopoDS::Face(S);
84 B.Add(Sh, F);
85 }
86 else { // Warning only + add FaceSurface file Identifier
87 TP->AddWarning(theFS," a Face from Shell not mapped to TopoDS");
88 }
89 }
90 else { // Warning : ajouter identifier
91 TP->AddWarning(StepFace," Face is not of FaceSurface Type; not mapped to TopoDS");
92 }
93 }
94 myResult = Sh;
95 aTool.Bind(CFS, myResult);
96 myError = StepToTopoDS_TranslateShellDone;
97 done = Standard_True;
98 }
99 else {
100 myResult = TopoDS::Shell(aTool.Find(CFS));
101 myError = StepToTopoDS_TranslateShellDone;
102 done = Standard_True;
103 }
104}
105
106// ============================================================================
107// Method : Value
108// Purpose : Return the mapped Shape
109// ============================================================================
110
111const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
112{
113 StdFail_NotDone_Raise_if(!done,"");
114 return myResult;
115}
116
117// ============================================================================
118// Method : Error
119// Purpose : Return the TranslateShell Error code
120// ============================================================================
121
122StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
123{
124 return myError;
125}
1332f047 126