0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / IGESControl / IGESControl_Controller.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
7fd59977 14//#58 rln 28.12.98 changing default values for Global Section
15//sln 14.01.2002 OCC51 : verifying whether entry model of method ActorRead is IGESDatat_IGESModel
16
42cf5bc1 17#include <IFSelect_EditForm.hxx>
18#include <IFSelect_SelectModelEntities.hxx>
19#include <IFSelect_SelectModelRoots.hxx>
20#include <IFSelect_SelectType.hxx>
21#include <IFSelect_SignCounter.hxx>
22#include <IFSelect_SignMultiple.hxx>
23#include <IFSelect_SignType.hxx>
24#include <IGESAppli.hxx>
25#include <IGESBasic_SubfigureDef.hxx>
26#include <IGESControl_ActorWrite.hxx>
27#include <IGESControl_AlgoContainer.hxx>
28#include <IGESControl_Controller.hxx>
7fd59977 29#include <IGESData_IGESModel.hxx>
c04c30b3 30#include <IGESData_Protocol.hxx>
7fd59977 31#include <IGESSelect_AutoCorrect.hxx>
32#include <IGESSelect_ComputeStatus.hxx>
42cf5bc1 33#include <IGESSelect_CounterOfLevelNumber.hxx>
34#include <IGESSelect_EditDirPart.hxx>
35#include <IGESSelect_EditHeader.hxx>
7fd59977 36#include <IGESSelect_FloatFormat.hxx>
42cf5bc1 37#include <IGESSelect_IGESName.hxx>
38#include <IGESSelect_IGESTypeForm.hxx>
39#include <IGESSelect_RemoveCurves.hxx>
40#include <IGESSelect_SelectBasicGeom.hxx>
7fd59977 41#include <IGESSelect_SelectBypassGroup.hxx>
42#include <IGESSelect_SelectBypassSubfigure.hxx>
7fd59977 43#include <IGESSelect_SelectFaces.hxx>
44#include <IGESSelect_SelectPCurves.hxx>
7fd59977 45#include <IGESSelect_SelectSubordinate.hxx>
42cf5bc1 46#include <IGESSelect_SelectVisibleStatus.hxx>
47#include <IGESSelect_SetGlobalParameter.hxx>
7fd59977 48#include <IGESSelect_SetLabel.hxx>
42cf5bc1 49#include <IGESSelect_SignColor.hxx>
50#include <IGESSelect_SignLevelNumber.hxx>
51#include <IGESSelect_SignStatus.hxx>
52#include <IGESSelect_UpdateFileName.hxx>
53#include <IGESSelect_WorkLibrary.hxx>
54#include <IGESSolid.hxx>
55#include <IGESToBRep.hxx>
56#include <IGESToBRep_Actor.hxx>
57#include <Interface_InterfaceModel.hxx>
58#include <Interface_Macros.hxx>
59#include <Interface_Static.hxx>
60#include <Standard_Type.hxx>
7fd59977 61#include <TCollection_HAsciiString.hxx>
42cf5bc1 62#include <TopoDS_Shape.hxx>
63#include <Transfer_ActorOfTransientProcess.hxx>
64#include <Transfer_FinderProcess.hxx>
7fd59977 65#include <XSAlgo.hxx>
7fd59977 66#include <XSControl_SelectForTransfer.hxx>
42cf5bc1 67#include <XSControl_WorkSession.hxx>
7fd59977 68
69//szv#4:S4163:12Mar99 never referenced
70//static const Standard_CString thelong = "IGES";
71//static const Standard_CString theshort = "iges";
7fd59977 72//=======================================================================
73//function : IGESControl_Controller
74//purpose :
75//=======================================================================
7fd59977 76IGESControl_Controller::IGESControl_Controller (const Standard_Boolean mod)
77//JR/Hp
78 : XSControl_Controller ((Standard_CString ) (mod ? "FNES" : "IGES") , (Standard_CString ) (mod ? "fnes" : "iges") ) ,
79// : XSControl_Controller ( (mod ? "FNES" : "iges") , (mod ? "fnes" : "iges") ) ,
80 themode (mod)
81{
82 static Standard_Boolean init = Standard_False;
83 if (!init) {
84 IGESSolid::Init();
85 IGESAppli::Init();
86 init = Standard_True;
87 }
88 AddSessionItem (new IGESSelect_RemoveCurves(Standard_True) ,"iges-remove-pcurves");
89 AddSessionItem (new IGESSelect_RemoveCurves(Standard_False),"iges-remove-curves-3d");
90 AddSessionItem (new IGESSelect_SetLabel (0,Standard_True) ,"iges-clear-label");
91 AddSessionItem (new IGESSelect_SetLabel (1,Standard_False),"iges-set-label-dnum");
92
93 AddSessionItem (new IGESSelect_AutoCorrect,"iges-auto-correct","send");
94 AddSessionItem (new IGESSelect_ComputeStatus,"iges-compute-status","send");
95 Handle(IGESSelect_FloatFormat) flf = new IGESSelect_FloatFormat;
96 flf->SetDefault (12);
97 AddSessionItem (flf,"iges-float-digits-12","send");
98
99// -- Sender Product Identification -- (pas un statique ...)
100 Handle(IGESSelect_SetGlobalParameter) set3 = new IGESSelect_SetGlobalParameter(3);
101//#58 rln Handle(TCollection_HAsciiString) pa3 = new TCollection_HAsciiString("MDTV X-STEP");
102 Handle(TCollection_HAsciiString) pa3 =
103 Interface_Static::Static("write.iges.header.product")->HStringValue();
104 set3->SetValue(pa3);
105 AddSessionItem (pa3, "iges-header-val-sender");
106 AddSessionItem (set3,"iges-header-set-sender","send");
107
108 AddSessionItem (new IGESSelect_UpdateFileName,"iges-update-file-name","send");
109
110// -- Receiver -- Acces par Static, ajustable
111 Handle(IGESSelect_SetGlobalParameter) set12 = new IGESSelect_SetGlobalParameter(12);
112// Handle(TCollection_HAsciiString) pa12 = new TCollection_HAsciiString("Unknown");
113 Handle(TCollection_HAsciiString) pa12 =
114 Interface_Static::Static("write.iges.header.receiver")->HStringValue();
115 set12->SetValue(pa12);
116 AddSessionItem (pa12, "iges-header-val-receiver");
117 AddSessionItem (set12,"iges-header-set-receiver","send");
118
119// -- Auteur -- acces par Static (demarre par whoami), ajustable
120 Handle(IGESSelect_SetGlobalParameter) set21 = new IGESSelect_SetGlobalParameter(21);
121// Handle(TCollection_HAsciiString) pa21 = new TCollection_HAsciiString("Unknown");
122 Handle(TCollection_HAsciiString) pa21 =
123 Interface_Static::Static("write.iges.header.author")->HStringValue();
124 set21->SetValue(pa21);
125 AddSessionItem (pa21, "iges-header-val-author");
126 AddSessionItem (set21,"iges-header-set-author","send");
127
128// -- Compagnie (de l auteur) -- acces par Static, ajustable
129 Handle(IGESSelect_SetGlobalParameter) set22 = new IGESSelect_SetGlobalParameter(22);
130// Handle(TCollection_HAsciiString) pa22 = new TCollection_HAsciiString("MATRA-DATAVISION");
131 Handle(TCollection_HAsciiString) pa22 =
132 Interface_Static::Static("write.iges.header.company")->HStringValue();
133 set22->SetValue(pa22);
134 AddSessionItem (pa22, "iges-header-val-company");
135 AddSessionItem (set22,"iges-header-set-company","send");
136 // -- STATICS
137
138 TraceStatic ("read.iges.bspline.approxd1.mode",5);
139 TraceStatic ("read.iges.bspline.continuity",5);
140
141 TraceStatic ("write.iges.header.receiver",2);
142 TraceStatic ("write.iges.header.author",2);
143 TraceStatic ("write.iges.header.company",2);
144 TraceStatic ("write.iges.unit",6);
145 TraceStatic ("write.iges.brep.mode",6);
146
147 theAdaptorLibrary = new IGESSelect_WorkLibrary(themode);
148 theAdaptorProtocol = IGESSelect_WorkLibrary::DefineProtocol();
149
150 Handle(IGESToBRep_Actor) anactiges = new IGESToBRep_Actor;
151 anactiges->SetContinuity(0);
152 theAdaptorRead = anactiges;
153
154 theAdaptorWrite = new IGESControl_ActorWrite;
155 SetModeWrite (0,1);
156 SetModeWriteHelp (0,"Faces");
157 SetModeWriteHelp (1,"BRep");
158}
159void IGESControl_Controller::Customise(Handle(XSControl_WorkSession)& WS)
160{
161 XSControl_Controller::Customise(WS);
162
163
164// --- SELECTIONS, SIGNATURES, COMPTEURS, EDITEURS
165// -- BypassGroup / xst-model-roots
166
167
168 //DeclareAndCast(IFSelect_Selection,xma,SessionItem("xst-model-all"));
169 Handle(IFSelect_SelectModelEntities) xma;
170 Handle(Standard_Transient) xma1 = WS->NamedItem("xst-model-all");
171 if(xma1.IsNull()) xma = new IFSelect_SelectModelEntities;
172 else {
173 xma =Handle(IFSelect_SelectModelEntities)::DownCast(xma1);
174 WS->AddNamedItem ("xst-model-all",xma);
175 }
176
177 //DeclareAndCast(IFSelect_Selection,xmr,SessionItem("xst-model-roots"));
178 Handle(IFSelect_SelectModelRoots) xmr;
179 Handle(Standard_Transient) xmr1 = WS->NamedItem("xst-model-roots");
180 if(!xmr1.IsNull())
181 xmr = Handle(IFSelect_SelectModelRoots)::DownCast(xmr1);
182 else {
183 xmr = new IFSelect_SelectModelRoots;
184 WS->AddNamedItem ("xst-model-roots",xmr);
185 }
186// DeclareAndCast(IFSelect_Selection,xtr,SessionItem("xst-transferrable-roots"));
187 Handle(XSControl_SelectForTransfer) xtr;
188 Handle(Standard_Transient) xtr1 = WS->NamedItem("xst-transferrable-roots");
189 if(!xtr1.IsNull())
190 xtr = Handle(XSControl_SelectForTransfer)::DownCast(xtr1);
191 //st1->SetInput (slr);
192 else {
193 xtr= new XSControl_SelectForTransfer;
194 xtr->SetReader (WS->TransferReader());
195 WS->AddNamedItem ("xst-transferrable-roots",xtr);
196 }
197 if (!xmr.IsNull()) {
198 Handle(IGESSelect_SelectVisibleStatus) visa = new IGESSelect_SelectVisibleStatus;
199 visa->SetInput(xmr);
200 WS->AddNamedItem ("iges-visible-roots",visa);
201 Handle(IGESSelect_SelectVisibleStatus) vist = new IGESSelect_SelectVisibleStatus;
202 vist->SetInput(xtr);
203 WS->AddNamedItem ("iges-visible-transf-roots",vist);
204 Handle(IGESSelect_SelectVisibleStatus) blka = new IGESSelect_SelectVisibleStatus;
205 blka->SetDirect (Standard_False);
206 blka->SetInput(xmr);
207 WS->AddNamedItem ("iges-blanked-roots",blka);
208 Handle(IGESSelect_SelectVisibleStatus) blkt = new IGESSelect_SelectVisibleStatus;
209 blkt->SetDirect (Standard_False);
210 blkt->SetInput(xtr);
211 WS->AddNamedItem ("iges-blanked-transf-roots",blkt);
212 Handle(IGESSelect_SelectSubordinate) indp = new IGESSelect_SelectSubordinate (0);
213 indp->SetInput (xma);
214 WS->AddNamedItem ("iges-status-independant",indp);
215
216 Handle(IGESSelect_SelectBypassGroup) sb = new IGESSelect_SelectBypassGroup;
217 sb->SetInput(xmr);
218 WS->AddNamedItem ("iges-bypass-group",sb);
219 Handle(IGESSelect_SelectBypassSubfigure) sfi = new IGESSelect_SelectBypassSubfigure;
220 sfi->SetInput(xmr);
221 WS->AddNamedItem ("iges-bypass-subfigure",sfi);
222 Handle(IGESSelect_SelectBypassGroup) sfb = new IGESSelect_SelectBypassGroup;
223 sfb->SetInput(sfi);
224 WS->AddNamedItem ("iges-bypass-group-subfigure",sfb);
225 Handle(IGESSelect_SelectBasicGeom) sc3d = new IGESSelect_SelectBasicGeom(1);
226 sc3d->SetInput(sfi);
227 WS->AddNamedItem ("iges-curves-3d",sc3d);
228 Handle(IGESSelect_SelectBasicGeom) sb3d = new IGESSelect_SelectBasicGeom(2);
229 sb3d->SetInput(sfi);
230 WS->AddNamedItem ("iges-basic-curves-3d",sb3d);
231 Handle(IGESSelect_SelectBasicGeom) sbg = new IGESSelect_SelectBasicGeom(0);
232 sbg->SetInput(sfi);
233 WS->AddNamedItem ("iges-basic-geom",sbg);
234 Handle(IGESSelect_SelectBasicGeom) srf = new IGESSelect_SelectBasicGeom(-1);
235 srf->SetInput(sfi);
236 WS->AddNamedItem ("iges-surfaces",srf);
237 Handle(IGESSelect_SelectFaces) sfa = new IGESSelect_SelectFaces;
238 sfa->SetInput(sfi);
239 WS->AddNamedItem ("iges-faces",sfa );
240 Handle(IGESSelect_SelectPCurves) spc = new IGESSelect_SelectPCurves(Standard_True);
241 spc->SetInput(sfa);
242 WS->AddNamedItem ("iges-pcurves",spc);
243
244 Handle(IFSelect_SelectType) snosub = new IFSelect_SelectType
245 (STANDARD_TYPE(IGESBasic_SubfigureDef));
246 snosub->SetDirect(Standard_False);
247 snosub->SetInput(xmr);
248 WS->AddNamedItem ("iges-no-indep-subfigure-def",snosub);
249
250 Handle(IGESSelect_IGESTypeForm) itf = new IGESSelect_IGESTypeForm(Standard_True);
251 WS->AddNamedItem ("iges-type",itf);
252
253 Handle(IGESSelect_SignStatus) sigst = new IGESSelect_SignStatus;
254 Handle(IFSelect_SignMultiple) typsta = new IFSelect_SignMultiple
255 ("IGES Type Form Status");
256 typsta->Add (itf,15);
257 typsta->Add (sigst);
258 WS->AddNamedItem ("iges-type-status",typsta);
259
260 Handle(IFSelect_SignMultiple) typnam = new IFSelect_SignMultiple
261 ("IGES Type Form TypeName");
262 typnam->Add (itf,4);
263 typnam->Add (new IFSelect_SignType(Standard_True));
264 WS->AddNamedItem ("iges-type-name",typnam);
265
266 Handle(IFSelect_SignCounter) itfs = new IFSelect_SignCounter
267 (itf,Standard_False,Standard_True);
268 WS->AddNamedItem ("iges-types",itfs);
269 Handle(IGESSelect_CounterOfLevelNumber) levs =
270 new IGESSelect_CounterOfLevelNumber;
271 WS->AddNamedItem ("iges-levels",levs);
272
273 Handle(IGESSelect_SignLevelNumber) slev = new IGESSelect_SignLevelNumber(Standard_False);
274 WS->AddNamedItem ("iges-level-number",slev);
275 Handle(IGESSelect_IGESName) igna = new IGESSelect_IGESName;
276 WS->AddNamedItem ("iges-name",igna);
277
278 Handle(IGESSelect_SignColor) scol1 = new IGESSelect_SignColor (1);
279 WS->AddNamedItem ("iges-color-number",scol1);
280 Handle(IGESSelect_SignColor) scol2 = new IGESSelect_SignColor (2);
281 WS->AddNamedItem ("iges-color-name",scol2);
282 Handle(IGESSelect_SignColor) scol3 = new IGESSelect_SignColor (3);
283 WS->AddNamedItem ("iges-color-rgb",scol3);
284 Handle(IGESSelect_SignColor) scol4 = new IGESSelect_SignColor (4);
285 WS->AddNamedItem ("iges-color-red",scol4);
286 Handle(IGESSelect_SignColor) scol5 = new IGESSelect_SignColor (5);
287 WS->AddNamedItem ("iges-color-green",scol5);
288 Handle(IGESSelect_SignColor) scol6 = new IGESSelect_SignColor (6);
289 WS->AddNamedItem ("iges-color-blue",scol6);
290
291 Handle(IGESSelect_EditHeader) edhead = new IGESSelect_EditHeader;
292 WS->AddNamedItem ("iges-header-edit",edhead);
293 Handle(IFSelect_EditForm) edheadf = edhead->Form(Standard_False);
294 WS->AddNamedItem ("iges-header",edheadf);
295
296 Handle(IGESSelect_EditDirPart) eddirp = new IGESSelect_EditDirPart;
297 WS->AddNamedItem ("iges-dir-part-edit",eddirp);
298 Handle(IFSelect_EditForm) eddirpf = eddirp->Form(Standard_False);
299 WS->AddNamedItem ("iges-dir-part",eddirpf);
300
301 theSignType = typnam;
302 }
303
304
305}
306
307
308//=======================================================================
309//function : NewModel
310//purpose :
311//=======================================================================
312
313 Handle(Interface_InterfaceModel) IGESControl_Controller::NewModel () const
314{
315// On prend un modele qu on prepare avec les statiques enregistres
316 DeclareAndCast(IGESData_IGESModel,igm,Interface_InterfaceModel::Template("iges"));
317 IGESData_GlobalSection GS = igm->GlobalSection();
318
319 GS.SetReceiveName (Interface_Static::Static("write.iges.header.receiver")->HStringValue());
320 GS.SetUnitFlag (Interface_Static::IVal("write.iges.unit"));
321 GS.SetUnitName (new TCollection_HAsciiString(Interface_Static::CVal("write.iges.unit")));
322 GS.SetAuthorName (Interface_Static::Static("write.iges.header.author")->HStringValue());
323 GS.SetCompanyName (Interface_Static::Static("write.iges.header.company")->HStringValue());
324 igm->SetGlobalSection (GS);
325 return igm;
326}
327
328//=======================================================================
329//function : ActorRead
330//purpose :
331//=======================================================================
332
333 Handle(Transfer_ActorOfTransientProcess) IGESControl_Controller::ActorRead
334 (const Handle(Interface_InterfaceModel)& model) const
335{
336 DeclareAndCast(IGESToBRep_Actor,anactiges,theAdaptorRead);
337 if (anactiges.IsNull()) return theAdaptorRead;
338 //sln 14.01.2002 OCC51 : verifying whether entry model is IGESDatat_IGESModel,
339 // if this condition is false new model is created
340 Handle(Interface_InterfaceModel) aModel;
341 if(model->IsKind(STANDARD_TYPE(IGESData_IGESModel)))
342 aModel = model;
343 else
344 aModel = NewModel();
345 anactiges->SetModel(GetCasted(IGESData_IGESModel,aModel));
346 anactiges->SetContinuity(Interface_Static::IVal("read.iges.bspline.continuity"));
347 return anactiges;
348}
349
350// #### TRANSFERT (ECRITURE SHAPE) ####
351// modetrans : 0 <5.1 (groupe de faces), 1 BREP-5.1
352
353//=======================================================================
354//function : TransferWriteShape
355//purpose :
356//=======================================================================
357
358 IFSelect_ReturnStatus IGESControl_Controller::TransferWriteShape (const TopoDS_Shape& shape,
359 const Handle(Transfer_FinderProcess)& FP,
360 const Handle(Interface_InterfaceModel)& model,
361 const Standard_Integer modetrans) const
362{
363 return XSControl_Controller::TransferWriteShape (shape,FP,model,modetrans);
364}
365
366//=======================================================================
367//function : Init
368//purpose :
369//=======================================================================
370
371 Standard_Boolean IGESControl_Controller::Init ()
372{
373 static Standard_Boolean inic = Standard_False;
374 if (!inic) {
375 Handle(IGESControl_Controller) ADIGES = new IGESControl_Controller(Standard_False);
376 ADIGES->AutoRecord();
377 XSAlgo::Init();
378 IGESToBRep::Init();
379 IGESToBRep::SetAlgoContainer (new IGESControl_AlgoContainer());
380 inic = Standard_True;
381 }
382 return Standard_True;
383}