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_ProgressScope.hxx>
21 #include <StdFail_NotDone.hxx>
22 #include <StepShape_ConnectedFaceSet.hxx>
23 #include <StepShape_FaceSurface.hxx>
24 #include <StepToTopoDS_NMTool.hxx>
25 #include <StepToTopoDS_Tool.hxx>
26 #include <StepToTopoDS_TranslateFace.hxx>
27 #include <StepToTopoDS_TranslateShell.hxx>
28 #include <TopoDS.hxx>
29 #include <TopoDS_Face.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Shell.hxx>
32 #include <Transfer_TransientProcess.hxx>
33 
34 // ============================================================================
35 // Method  : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
36 // Purpose : Empty Constructor
37 // ============================================================================
StepToTopoDS_TranslateShell()38 StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
39 : myError(StepToTopoDS_TranslateShellOther)
40 {
41   done = Standard_False;
42 }
43 
44 // ============================================================================
45 // Method  : Init
46 // Purpose : Init with a ConnectedFaceSet and a Tool
47 // ============================================================================
48 
Init(const Handle (StepShape_ConnectedFaceSet)& CFS,StepToTopoDS_Tool & aTool,StepToTopoDS_NMTool & NMTool,const Message_ProgressRange & theProgress)49 void StepToTopoDS_TranslateShell::Init
50 (const Handle(StepShape_ConnectedFaceSet)& CFS,
51  StepToTopoDS_Tool& aTool,
52  StepToTopoDS_NMTool& NMTool,
53  const Message_ProgressRange& theProgress)
54 {
55   //bug15697
56   if(CFS.IsNull())
57     return;
58 
59   if (!aTool.IsBound(CFS)) {
60 
61     BRep_Builder B;
62     Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
63 
64     Standard_Integer NbFc = CFS->NbCfsFaces();
65     TopoDS_Shell Sh;
66     B.MakeShell(Sh);
67     TopoDS_Face F;
68     TopoDS_Shape S;
69     Handle(StepShape_Face) StepFace;
70 
71     StepToTopoDS_TranslateFace myTranFace;
72     myTranFace.SetPrecision(Precision()); //gka
73     myTranFace.SetMaxTol(MaxTol());
74 
75     Message_ProgressScope PS ( theProgress, "Face", NbFc);
76     for (Standard_Integer i = 1; i <= NbFc && PS.More(); i++, PS.Next()) {
77 #ifdef OCCT_DEBUG
78       std::cout << "Processing Face : " << i << std::endl;
79 #endif
80       StepFace = CFS->CfsFacesValue(i);
81       Handle(StepShape_FaceSurface) theFS =
82         Handle(StepShape_FaceSurface)::DownCast(StepFace);
83       if (!theFS.IsNull()) {
84         myTranFace.Init(theFS, aTool, NMTool);
85         if (myTranFace.IsDone()) {
86           S = myTranFace.Value();
87           F = TopoDS::Face(S);
88           B.Add(Sh, F);
89         }
90         else { // Warning only + add FaceSurface file Identifier
91           TP->AddWarning(theFS, " a Face from Shell not mapped to TopoDS");
92         }
93       }
94       else { // Warning : add identifier
95         TP->AddWarning(StepFace, " Face is not of FaceSurface Type; not mapped to TopoDS");
96       }
97     }
98     Sh.Closed (BRep_Tool::IsClosed (Sh));
99     myResult = Sh;
100     aTool.Bind(CFS, myResult);
101     myError  = StepToTopoDS_TranslateShellDone;
102     done     = Standard_True;
103   }
104   else {
105     myResult = TopoDS::Shell(aTool.Find(CFS));
106     myError  = StepToTopoDS_TranslateShellDone;
107     done     = Standard_True;
108   }
109 }
110 
111 // ============================================================================
112 // Method  : Value
113 // Purpose : Return the mapped Shape
114 // ============================================================================
115 
Value() const116 const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
117 {
118   StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateShell::Value() - no result");
119   return myResult;
120 }
121 
122 // ============================================================================
123 // Method  : Error
124 // Purpose : Return the TranslateShell Error code
125 // ============================================================================
126 
Error() const127 StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
128 {
129   return myError;
130 }
131 
132