0028550: Foundation Classes - fix empty message passed to thrown exception
[occt.git] / src / StepToTopoDS / StepToTopoDS_TranslateShell.cxx
1 // Created on: 1995-01-03
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //:   gka 09.04.99: S4136: improving tolerance management
18
19 #include <BRep_Builder.hxx>
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>
29 #include <TopoDS.hxx>
30 #include <TopoDS_Face.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Shell.hxx>
33 #include <Transfer_TransientProcess.hxx>
34
35 // ============================================================================
36 // Method  : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
37 // Purpose : Empty Constructor
38 // ============================================================================
39 StepToTopoDS_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
49 StepToTopoDS_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
60 void StepToTopoDS_TranslateShell::Init
61 (const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
62 {
63   //bug15697
64   if(CFS.IsNull())
65     return;
66   
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 );
84     for (Standard_Integer i = 1; i <= NbFc && PS.More(); i++, PS.Next()) {
85 #ifdef OCCT_DEBUG
86       cout << "Processing Face : " << i << endl;
87 #endif
88       StepFace = CFS->CfsFacesValue(i);
89       Handle(StepShape_FaceSurface) theFS =
90         Handle(StepShape_FaceSurface)::DownCast(StepFace);
91       if (!theFS.IsNull()) {
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         }
101       }
102       else { // Warning : add identifier
103         TP->AddWarning(StepFace, " Face is not of FaceSurface Type; not mapped to TopoDS");
104       }
105     }
106     Sh.Closed (BRep_Tool::IsClosed (Sh));
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
124 const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const 
125 {
126   StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateShell::Value() - no result");
127   return myResult;
128 }
129
130 // ============================================================================
131 // Method  : Error
132 // Purpose : Return the TranslateShell Error code
133 // ============================================================================
134
135 StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
136 {
137   return myError;
138 }
139