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