0025748: Parallel version of progress indicator
[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>
7e785937 20#include <Message_ProgressScope.hxx>
42cf5bc1 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>
7fd59977 28#include <TopoDS.hxx>
7fd59977 29#include <TopoDS_Face.hxx>
42cf5bc1 30#include <TopoDS_Shape.hxx>
31#include <TopoDS_Shell.hxx>
7fd59977 32#include <Transfer_TransientProcess.hxx>
33
7fd59977 34// ============================================================================
35// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
36// Purpose : Empty Constructor
37// ============================================================================
7fd59977 38StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
d533dafb 39: myError(StepToTopoDS_TranslateShellOther)
7fd59977 40{
41 done = Standard_False;
42}
43
7fd59977 44// ============================================================================
45// Method : Init
46// Purpose : Init with a ConnectedFaceSet and a Tool
47// ============================================================================
48
49void StepToTopoDS_TranslateShell::Init
7e785937 50(const Handle(StepShape_ConnectedFaceSet)& CFS,
51 StepToTopoDS_Tool& aTool,
52 StepToTopoDS_NMTool& NMTool,
53 const Message_ProgressRange& theProgress)
7fd59977 54{
1332f047
A
55 //bug15697
56 if(CFS.IsNull())
57 return;
58
7fd59977 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
7e785937 75 Message_ProgressScope PS ( theProgress, "Face", NbFc);
63c71e2f 76 for (Standard_Integer i = 1; i <= NbFc && PS.More(); i++, PS.Next()) {
0797d9d3 77#ifdef OCCT_DEBUG
04232180 78 std::cout << "Processing Face : " << i << std::endl;
7fd59977 79#endif
80 StepFace = CFS->CfsFacesValue(i);
63c71e2f 81 Handle(StepShape_FaceSurface) theFS =
82 Handle(StepShape_FaceSurface)::DownCast(StepFace);
7fd59977 83 if (!theFS.IsNull()) {
63c71e2f 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 }
7fd59977 93 }
63c71e2f 94 else { // Warning : add identifier
95 TP->AddWarning(StepFace, " Face is not of FaceSurface Type; not mapped to TopoDS");
7fd59977 96 }
97 }
ab860031 98 Sh.Closed (BRep_Tool::IsClosed (Sh));
7fd59977 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
116const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
117{
2d2b3d53 118 StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateShell::Value() - no result");
7fd59977 119 return myResult;
120}
121
122// ============================================================================
123// Method : Error
124// Purpose : Return the TranslateShell Error code
125// ============================================================================
126
127StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
128{
129 return myError;
130}
1332f047 131