0025748: Parallel version of progress indicator
[occt.git] / src / STEPControl / STEPControl_Writer.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
148820b2 14#include <STEPControl_Writer.hxx>
42cf5bc1 15
7fd59977 16#include <Interface_InterfaceModel.hxx>
17#include <Interface_Macros.hxx>
42cf5bc1 18#include <STEPControl_ActorWrite.hxx>
19#include <STEPControl_Controller.hxx>
42cf5bc1 20#include <StepData_StepModel.hxx>
7fd59977 21#include <TopExp_Explorer.hxx>
42cf5bc1 22#include <TopoDS_Shape.hxx>
7fd59977 23#include <Transfer_FinderProcess.hxx>
42cf5bc1 24#include <XSControl_TransferWriter.hxx>
25#include <XSControl_WorkSession.hxx>
7fd59977 26
27//=======================================================================
28//function : STEPControl_Writer
29//purpose :
30//=======================================================================
7fd59977 31STEPControl_Writer::STEPControl_Writer ()
32{
33 STEPControl_Controller::Init();
34 SetWS (new XSControl_WorkSession);
35}
36
37
38//=======================================================================
39//function : STEPControl_Writer
40
41//purpose :
42//=======================================================================
43
44STEPControl_Writer::STEPControl_Writer
45 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
46{
47 STEPControl_Controller::Init();
48 SetWS (WS,scratch);
49}
50
51
52//=======================================================================
53//function : SetWS
54
55//purpose :
56//=======================================================================
57
58void STEPControl_Writer::SetWS(const Handle(XSControl_WorkSession)& WS,
59 const Standard_Boolean scratch)
60{
61 thesession = WS;
62 thesession->SelectNorm("STEP");
63 thesession->InitTransferReader(0);
64 Handle(StepData_StepModel) model = Model (scratch);
65}
66
67
68//=======================================================================
69//function : WS
70//purpose :
71//=======================================================================
72
73Handle(XSControl_WorkSession) STEPControl_Writer::WS () const
74{
75 return thesession;
76}
77
78
79//=======================================================================
80//function : Model
81//purpose :
82//=======================================================================
83
84Handle(StepData_StepModel) STEPControl_Writer::Model
85 (const Standard_Boolean newone)
86{
87 DeclareAndCast(StepData_StepModel,model,thesession->Model());
88 if (newone || model.IsNull())
89 model = GetCasted(StepData_StepModel,thesession->NewModel());
90 return model;
91}
92
93
94//=======================================================================
95//function : SetTolerance
96//purpose :
97//=======================================================================
98
99void STEPControl_Writer::SetTolerance (const Standard_Real Tol)
100{
101 DeclareAndCast(STEPControl_ActorWrite,act,WS()->NormAdaptor()->ActorWrite());
102 if (!act.IsNull()) act->SetTolerance (Tol);
103}
104
105
106//=======================================================================
107//function : UnsetTolerance
108//purpose :
109//=======================================================================
110
111void STEPControl_Writer::UnsetTolerance ()
112{
113 SetTolerance (-1.);
114}
115
116
117//=======================================================================
118//function : Transfer
119//purpose :
120//=======================================================================
121
122IFSelect_ReturnStatus STEPControl_Writer::Transfer
7e785937 123 (const TopoDS_Shape& sh,
124 const STEPControl_StepModelType mode,
125 const Standard_Boolean compgraph,
126 const Message_ProgressRange& theProgress)
7fd59977 127{
128 Standard_Integer mws = -1;
129 switch (mode) {
130 case STEPControl_AsIs : mws = 0; break;
131 case STEPControl_FacetedBrep : mws = 1; break;
132 case STEPControl_ShellBasedSurfaceModel : mws = 2; break;
133 case STEPControl_ManifoldSolidBrep : mws = 3; break;
134 case STEPControl_GeometricCurveSet : mws = 4; break;
135 default : break;
136 }
137 if (mws < 0) return IFSelect_RetError; // cas non reconnu
7f56eba8 138 thesession->TransferWriter()->SetTransferMode (mws);
7fd59977 139
7e785937 140 return thesession->TransferWriteShape(sh, compgraph, theProgress);
7fd59977 141}
142
143
144//=======================================================================
145//function : Write
146//purpose :
147//=======================================================================
148
149IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString filename)
150{
151 return thesession->SendAll(filename);
152}
153
154
155//=======================================================================
156//function : PrintStatsTransfer
157//purpose :
158//=======================================================================
159
160void STEPControl_Writer::PrintStatsTransfer
161 (const Standard_Integer what, const Standard_Integer mode) const
162{
163 thesession->TransferWriter()->PrintStats (what,mode);
164}