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