0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[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
42cf5bc1 14
7fd59977 15#include <Interface_InterfaceModel.hxx>
16#include <Interface_Macros.hxx>
17#include <Message_ProgressIndicator.hxx>
42cf5bc1 18#include <STEPControl_ActorWrite.hxx>
19#include <STEPControl_Controller.hxx>
20#include <STEPControl_Writer.hxx>
21#include <StepData_StepModel.hxx>
7fd59977 22#include <TopExp_Explorer.hxx>
42cf5bc1 23#include <TopoDS_Shape.hxx>
7fd59977 24#include <Transfer_FinderProcess.hxx>
42cf5bc1 25#include <XSControl_TransferWriter.hxx>
26#include <XSControl_WorkSession.hxx>
7fd59977 27
28//=======================================================================
29//function : STEPControl_Writer
30//purpose :
31//=======================================================================
7fd59977 32STEPControl_Writer::STEPControl_Writer ()
33{
34 STEPControl_Controller::Init();
35 SetWS (new XSControl_WorkSession);
36}
37
38
39//=======================================================================
40//function : STEPControl_Writer
41
42//purpose :
43//=======================================================================
44
45STEPControl_Writer::STEPControl_Writer
46 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
47{
48 STEPControl_Controller::Init();
49 SetWS (WS,scratch);
50}
51
52
53//=======================================================================
54//function : SetWS
55
56//purpose :
57//=======================================================================
58
59void STEPControl_Writer::SetWS(const Handle(XSControl_WorkSession)& WS,
60 const Standard_Boolean scratch)
61{
62 thesession = WS;
63 thesession->SelectNorm("STEP");
64 thesession->InitTransferReader(0);
65 Handle(StepData_StepModel) model = Model (scratch);
66}
67
68
69//=======================================================================
70//function : WS
71//purpose :
72//=======================================================================
73
74Handle(XSControl_WorkSession) STEPControl_Writer::WS () const
75{
76 return thesession;
77}
78
79
80//=======================================================================
81//function : Model
82//purpose :
83//=======================================================================
84
85Handle(StepData_StepModel) STEPControl_Writer::Model
86 (const Standard_Boolean newone)
87{
88 DeclareAndCast(StepData_StepModel,model,thesession->Model());
89 if (newone || model.IsNull())
90 model = GetCasted(StepData_StepModel,thesession->NewModel());
91 return model;
92}
93
94
95//=======================================================================
96//function : SetTolerance
97//purpose :
98//=======================================================================
99
100void STEPControl_Writer::SetTolerance (const Standard_Real Tol)
101{
102 DeclareAndCast(STEPControl_ActorWrite,act,WS()->NormAdaptor()->ActorWrite());
103 if (!act.IsNull()) act->SetTolerance (Tol);
104}
105
106
107//=======================================================================
108//function : UnsetTolerance
109//purpose :
110//=======================================================================
111
112void STEPControl_Writer::UnsetTolerance ()
113{
114 SetTolerance (-1.);
115}
116
117
118//=======================================================================
119//function : Transfer
120//purpose :
121//=======================================================================
122
123IFSelect_ReturnStatus STEPControl_Writer::Transfer
124 (const TopoDS_Shape& sh, const STEPControl_StepModelType mode,
125 const Standard_Boolean compgraph)
126{
127 Standard_Integer mws = -1;
128 switch (mode) {
129 case STEPControl_AsIs : mws = 0; break;
130 case STEPControl_FacetedBrep : mws = 1; break;
131 case STEPControl_ShellBasedSurfaceModel : mws = 2; break;
132 case STEPControl_ManifoldSolidBrep : mws = 3; break;
133 case STEPControl_GeometricCurveSet : mws = 4; break;
134 default : break;
135 }
136 if (mws < 0) return IFSelect_RetError; // cas non reconnu
7f56eba8 137 thesession->TransferWriter()->SetTransferMode (mws);
7fd59977 138
139 // for progress indicator.
7f56eba8 140 Handle(Message_ProgressIndicator) progress = WS()->TransferWriter()->FinderProcess()->GetProgress();
7fd59977 141 if ( ! progress.IsNull() ) {
142 Standard_Integer nbfaces=0;
143 for( TopExp_Explorer exp(sh, TopAbs_FACE); exp.More(); exp.Next()) nbfaces++;
144 progress->SetScale ( "Face", 0, nbfaces, 1 );
145 progress->Show();
146 }
147
148 return thesession->TransferWriteShape(sh,compgraph);
149}
150
151
152//=======================================================================
153//function : Write
154//purpose :
155//=======================================================================
156
157IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString filename)
158{
159 return thesession->SendAll(filename);
160}
161
162
163//=======================================================================
164//function : PrintStatsTransfer
165//purpose :
166//=======================================================================
167
168void STEPControl_Writer::PrintStatsTransfer
169 (const Standard_Integer what, const Standard_Integer mode) const
170{
171 thesession->TransferWriter()->PrintStats (what,mode);
172}