1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <STEPControl_Writer.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_Macros.hxx>
18 #include <STEPControl_ActorWrite.hxx>
19 #include <STEPControl_Controller.hxx>
20 #include <StepData_StepModel.hxx>
21 #include <TopExp_Explorer.hxx>
22 #include <TopoDS_Shape.hxx>
23 #include <Transfer_FinderProcess.hxx>
24 #include <XSControl_TransferWriter.hxx>
25 #include <XSControl_WorkSession.hxx>
27 //=======================================================================
28 //function : STEPControl_Writer
30 //=======================================================================
31 STEPControl_Writer::STEPControl_Writer ()
33 STEPControl_Controller::Init();
34 SetWS (new XSControl_WorkSession);
38 //=======================================================================
39 //function : STEPControl_Writer
42 //=======================================================================
44 STEPControl_Writer::STEPControl_Writer
45 (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
47 STEPControl_Controller::Init();
52 //=======================================================================
56 //=======================================================================
58 void STEPControl_Writer::SetWS(const Handle(XSControl_WorkSession)& WS,
59 const Standard_Boolean scratch)
62 thesession->SelectNorm("STEP");
63 thesession->InitTransferReader(0);
64 Handle(StepData_StepModel) model = Model (scratch);
68 //=======================================================================
71 //=======================================================================
73 Handle(XSControl_WorkSession) STEPControl_Writer::WS () const
79 //=======================================================================
82 //=======================================================================
84 Handle(StepData_StepModel) STEPControl_Writer::Model
85 (const Standard_Boolean newone)
87 DeclareAndCast(StepData_StepModel,model,thesession->Model());
88 if (newone || model.IsNull())
89 model = GetCasted(StepData_StepModel,thesession->NewModel());
94 //=======================================================================
95 //function : SetTolerance
97 //=======================================================================
99 void STEPControl_Writer::SetTolerance (const Standard_Real Tol)
101 DeclareAndCast(STEPControl_ActorWrite,act,WS()->NormAdaptor()->ActorWrite());
102 if (!act.IsNull()) act->SetTolerance (Tol);
106 //=======================================================================
107 //function : UnsetTolerance
109 //=======================================================================
111 void STEPControl_Writer::UnsetTolerance ()
117 //=======================================================================
118 //function : Transfer
120 //=======================================================================
122 IFSelect_ReturnStatus STEPControl_Writer::Transfer
123 (const TopoDS_Shape& sh,
124 const STEPControl_StepModelType mode,
125 const Standard_Boolean compgraph,
126 const Message_ProgressRange& theProgress)
128 Standard_Integer mws = -1;
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;
137 if (mws < 0) return IFSelect_RetError; // cas non reconnu
138 thesession->TransferWriter()->SetTransferMode (mws);
140 return thesession->TransferWriteShape(sh, compgraph, theProgress);
144 //=======================================================================
147 //=======================================================================
149 IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString filename)
151 return thesession->SendAll(filename);
155 //=======================================================================
156 //function : PrintStatsTransfer
158 //=======================================================================
160 void STEPControl_Writer::PrintStatsTransfer
161 (const Standard_Integer what, const Standard_Integer mode) const
163 thesession->TransferWriter()->PrintStats (what,mode);