0024157: Parallelization of assembly part of BO
[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
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21//: gka 09.04.99: S4136: improving tolerance management
22
23#include <StepToTopoDS_TranslateShell.ixx>
24
25#include <StepToTopoDS_TranslateFace.hxx>
26
27#include <StepShape_FaceSurface.hxx>
28
29#include <BRep_Builder.hxx>
30#include <TopoDS.hxx>
31#include <TopoDS_Shell.hxx>
32#include <TopoDS_Face.hxx>
33#include <Transfer_TransientProcess.hxx>
34
35#include <Message_ProgressIndicator.hxx>
36#include <Message_ProgressSentry.hxx>
37
38// ============================================================================
39// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
40// Purpose : Empty Constructor
41// ============================================================================
42
43StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
44{
45 done = Standard_False;
46}
47
48// ============================================================================
49// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
50// Purpose : Constructor with a ConnectedFaceSet and a Tool
51// ============================================================================
52
53StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
54(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
55{
56 Init(CFS, T, NMTool);
57}
58
59// ============================================================================
60// Method : Init
61// Purpose : Init with a ConnectedFaceSet and a Tool
62// ============================================================================
63
64void StepToTopoDS_TranslateShell::Init
65(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
66{
1332f047
A
67 //bug15697
68 if(CFS.IsNull())
69 return;
70
7fd59977 71 if (!aTool.IsBound(CFS)) {
72
73 BRep_Builder B;
74 Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
75
76 Standard_Integer NbFc = CFS->NbCfsFaces();
77 TopoDS_Shell Sh;
78 B.MakeShell(Sh);
79 TopoDS_Face F;
80 TopoDS_Shape S;
81 Handle(StepShape_Face) StepFace;
82
83 StepToTopoDS_TranslateFace myTranFace;
84 myTranFace.SetPrecision(Precision()); //gka
85 myTranFace.SetMaxTol(MaxTol());
86
87 Message_ProgressSentry PS ( TP->GetProgress(), "Face", 0, NbFc, 1 );
88 for (Standard_Integer i=1; i<=NbFc && PS.More(); i++, PS.Next()) {
89#ifdef DEBUG
90 cout << "Processing Face : " << i << endl;
91#endif
92 StepFace = CFS->CfsFacesValue(i);
93 Handle(StepShape_FaceSurface) theFS =
94 Handle(StepShape_FaceSurface)::DownCast(StepFace);
95 if (!theFS.IsNull()) {
96 myTranFace.Init(theFS, aTool, NMTool);
97 if (myTranFace.IsDone()) {
98 S = myTranFace.Value();
99 F = TopoDS::Face(S);
100 B.Add(Sh, F);
101 }
102 else { // Warning only + add FaceSurface file Identifier
103 TP->AddWarning(theFS," a Face from Shell not mapped to TopoDS");
104 }
105 }
106 else { // Warning : ajouter identifier
107 TP->AddWarning(StepFace," Face is not of FaceSurface Type; not mapped to TopoDS");
108 }
109 }
110 myResult = Sh;
111 aTool.Bind(CFS, myResult);
112 myError = StepToTopoDS_TranslateShellDone;
113 done = Standard_True;
114 }
115 else {
116 myResult = TopoDS::Shell(aTool.Find(CFS));
117 myError = StepToTopoDS_TranslateShellDone;
118 done = Standard_True;
119 }
120}
121
122// ============================================================================
123// Method : Value
124// Purpose : Return the mapped Shape
125// ============================================================================
126
127const TopoDS_Shape& StepToTopoDS_TranslateShell::Value() const
128{
129 StdFail_NotDone_Raise_if(!done,"");
130 return myResult;
131}
132
133// ============================================================================
134// Method : Error
135// Purpose : Return the TranslateShell Error code
136// ============================================================================
137
138StepToTopoDS_TranslateShellError StepToTopoDS_TranslateShell::Error() const
139{
140 return myError;
141}
1332f047 142