0024947: Redesign OCCT legacy type system
[occt.git] / src / IFSelect / IFSelect_Functions.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 Versioning
15
16#include <IFSelect_Functions.ixx>
17#include <IFSelect_Act.hxx>
18#include <IFSelect_SessionPilot.hxx>
19
20#include <TCollection_AsciiString.hxx>
21#include <TCollection_HAsciiString.hxx>
22#include <IFSelect_SignType.hxx>
23#include <IFSelect_SignatureList.hxx>
24#include <IFSelect_IntParam.hxx>
25#include <TColStd_HSequenceOfAsciiString.hxx>
26#include <TColStd_HSequenceOfHAsciiString.hxx>
27#include <TColStd_HSequenceOfTransient.hxx>
28#include <TColStd_MapOfInteger.hxx>
29#include <Interface_Static.hxx>
30#include <Interface_EntityIterator.hxx>
31
32#include <IFSelect_WorkSession.hxx>
33#include <IFSelect_GeneralModifier.hxx>
34#include <IFSelect_Modifier.hxx>
35#include <IFSelect_WorkLibrary.hxx>
36#include <Interface_InterfaceModel.hxx>
37#include <IFSelect_SessionFile.hxx>
38#include <Message_Messenger.hxx>
39#include <Message.hxx>
40
41#include <Interface_Category.hxx>
42#include <Interface_CheckIterator.hxx>
43#include <IFSelect_CheckCounter.hxx>
44#include <IFSelect_SignCounter.hxx>
45#include <IFSelect_GraphCounter.hxx>
46
47#include <IFSelect_Dispatch.hxx>
48#include <IFSelect_DispGlobal.hxx>
49#include <IFSelect_DispPerOne.hxx>
50#include <IFSelect_DispPerCount.hxx>
51#include <IFSelect_DispPerFiles.hxx>
52#include <IFSelect_DispPerSignature.hxx>
53#include <IFSelect_Selection.hxx>
54#include <IFSelect_SelectDeduct.hxx>
55#include <IFSelect_SelectModelEntities.hxx>
56#include <IFSelect_SelectModelRoots.hxx>
57#include <IFSelect_SelectEntityNumber.hxx>
58#include <IFSelect_SelectRoots.hxx>
59#include <IFSelect_SelectDiff.hxx>
60#include <IFSelect_SelectUnion.hxx>
61#include <IFSelect_SelectIntersection.hxx>
62#include <IFSelect_SelectShared.hxx>
63#include <IFSelect_SelectRange.hxx>
64#include <IFSelect_Signature.hxx>
65#include <IFSelect_SelectSignature.hxx>
66#include <IFSelect_SelectErrorEntities.hxx>
67#include <IFSelect_SelectUnknownEntities.hxx>
68#include <IFSelect_SelectIncorrectEntities.hxx>
69#include <IFSelect_SelectSharing.hxx>
70#include <IFSelect_SelectPointed.hxx>
71#include <IFSelect_SelectSuite.hxx>
72#include <IFSelect_ModifReorder.hxx>
73#include <IFSelect_Editor.hxx>
74#include <IFSelect_EditForm.hxx>
75#include <IFSelect_ListEditor.hxx>
76
77#include <Interface_Macros.hxx>
78#include <Interface_Version.hxx>
79#include <Interface_MSG.hxx>
80#include <stdio.h>
81
82
83// Decomposition of a file name in its parts : prefix, root, suffix
84
85static void SplitFileName
86 (const Standard_CString filename,
87 TCollection_AsciiString& prefix,
88 TCollection_AsciiString& fileroot,
89 TCollection_AsciiString& suffix)
90{
91 Standard_Integer nomdeb, nomfin, nomlon;
92 TCollection_AsciiString resfile (filename);
93 nomlon = resfile.Length();
94 nomdeb = resfile.SearchFromEnd ("/");
95 if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT
96 if (nomdeb < 0) nomdeb = 0;
97 nomfin = resfile.SearchFromEnd (".");
98 if (nomfin < nomdeb) nomfin = nomlon + 1;
99
100 if (nomdeb > 0) prefix = resfile.SubString (1,nomdeb);
101 fileroot = resfile.SubString(nomdeb+1,nomfin-1);
102 if (nomfin <= nomlon) suffix = resfile.SubString (nomfin,nomlon);
103}
104
105
106
107// Functions definit un certain nombre de commandes
108// enregistrees dans le Dictionnaire de Activator (par des Act unitaires)
109// Les actions elles-memes sont regroupees en fin de fichier
110
111// Les definitions
112
113static IFSelect_ReturnStatus funstatus
114 (const Handle(IFSelect_SessionPilot)& )
115{
116// **** Version & cie ****
117 //#58 rln
118 Handle(Message_Messenger) sout = Message::DefaultMessenger();
119 sout<<"Processor Version : "<<XSTEP_PROCESSOR_VERSION<<endl;
120 sout<<"OL Version : "<<XSTEP_SYSTEM_VERSION<<endl;
121 sout<<"Configuration : "<<XSTEP_Config<<endl;
122 sout<<"UL Names : "<<XSTEP_ULNames<<endl;
123 return IFSelect_RetVoid;
124}
125
126static IFSelect_ReturnStatus fun1
127 (const Handle(IFSelect_SessionPilot)& pilot)
128{
129 Handle(IFSelect_WorkSession) WS = pilot->Session();
130// **** ToggleHandler ****
131 int hand = !WS->ErrorHandle();
132 Handle(Message_Messenger) sout = Message::DefaultMessenger();
133 if (hand) sout << " -- Mode Catch Error now Active" <<endl;
134 else sout << " -- Mode Catch Error now Inactive" <<endl;
135 WS->SetErrorHandle(hand);
136 return IFSelect_RetDone;
137}
138
7fd59977 139static IFSelect_ReturnStatus fun3
140 (const Handle(IFSelect_SessionPilot)& pilot)
141{
142 Handle(IFSelect_WorkSession) WS = pilot->Session();
143 Standard_Integer argc = pilot->NbWords();
144 const Standard_CString arg1 = pilot->Arg(1);
145// **** XRead / Load ****
146 Handle(Message_Messenger) sout = Message::DefaultMessenger();
147 if (argc < 2) { sout<<"Read/Load : give file name !"<<endl; return IFSelect_RetError; }
148 if (WS->Protocol().IsNull()) { sout<<"Protocol not defined"<<endl; return IFSelect_RetError; }
149 if (WS->WorkLibrary().IsNull()) { sout<<"WorkLibrary not defined"<<endl; return IFSelect_RetError; }
150
151 IFSelect_ReturnStatus status = WS->ReadFile (arg1);
152// status : 0 OK, 1 erreur lecture, 2 Fail(try/catch),
153// -1 fichier non trouve, -2 lecture faite mais resultat vide
154 switch (status) {
155 case IFSelect_RetVoid : sout<<"file:"<<arg1<<" gives empty result"<<endl; break;
156 case IFSelect_RetError : sout<<"file:"<<arg1<<" could not be opened"<<endl; break;
157 case IFSelect_RetDone : sout<<"file:"<<arg1<<" read"<<endl; break;
158 case IFSelect_RetFail : sout<<"file:"<<arg1<<" : error while reading"<<endl; break;
159 case IFSelect_RetStop : sout<<"file:"<<arg1<<" : EXCEPTION while reading"<<endl; break;
160 default : sout<<"file:"<<arg1<<" could not be read"<<endl; break;
161 }
162 if (status != IFSelect_RetDone) return status;
163// sout<<" - clearing list of already written files"<<endl;
164 WS->BeginSentFiles(Standard_True);
165 return status;
166}
167
168static IFSelect_ReturnStatus fun_whatfile
169 (const Handle(IFSelect_SessionPilot)& pilot)
170{
171 TCollection_AsciiString whatcom = IFSelect_Activator::Alias ("whatfile");
172 if (whatcom.Length() > 0) return pilot->ExecuteAlias (whatcom);
173 Handle(Message_Messenger) sout = Message::DefaultMessenger();
174 sout<<"Load File : "<<pilot->Session()->LoadedFile()<<endl;
175 sout<<"No specific whatfile available"<<endl;
176 return IFSelect_RetVoid;
177}
178
179static IFSelect_ReturnStatus fun4
180 (const Handle(IFSelect_SessionPilot)& pilot)
181{
182 Handle(IFSelect_WorkSession) WS = pilot->Session();
183 Standard_Integer argc = pilot->NbWords();
184 const Standard_CString arg1 = pilot->Arg(1);
185// **** Write All ****
186 Handle(Message_Messenger) sout = Message::DefaultMessenger();
187 if (argc < 2) { sout<<"Write All : give file name !"<<endl; return IFSelect_RetError; }
188 return WS->SendAll (arg1);
189}
190
191static IFSelect_ReturnStatus fun5
192 (const Handle(IFSelect_SessionPilot)& pilot)
193{
194 Handle(IFSelect_WorkSession) WS = pilot->Session();
195 Standard_Integer argc = pilot->NbWords();
196 const Standard_CString arg1 = pilot->Arg(1);
197// const Standard_CString arg2 = pilot->Arg(2);
198// **** Write Selected ****
199 Handle(Message_Messenger) sout = Message::DefaultMessenger();
200 if (argc < 3) { sout<<"Write Selected : give file name + givelist !"<<endl; return IFSelect_RetError; }
201 Handle(TColStd_HSequenceOfTransient) result =
202 IFSelect_Functions::GiveList (WS,pilot->CommandPart( 2));
203 if (result.IsNull()) { sout<<"No entity selected"<<endl; return IFSelect_RetError; }
204 else sout<<"Nb Entities selected : "<<result->Length()<<endl;
205 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
206 sp->SetList (result);
207 return WS->SendSelected (arg1,sp);
208}
209
210static IFSelect_ReturnStatus fun6
211 (const Handle(IFSelect_SessionPilot)& pilot)
212{
213 Handle(IFSelect_WorkSession) WS = pilot->Session();
214 Standard_Integer argc = pilot->NbWords();
215 const Standard_CString arg1 = pilot->Arg(1);
216// **** Write Entite(s) ****
217 Handle(Message_Messenger) sout = Message::DefaultMessenger();
218 if (argc < 3) { sout<<"Write Entitie(s) : give file name + n0s entitie(s)!"<<endl; return IFSelect_RetError; }
219 int ko = 0;
220 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
221 for (Standard_Integer ia = 2; ia < argc ; ia ++) {
222 Standard_Integer id = pilot->Number(pilot->Arg(ia));
223 if (id > 0) {
224 Handle(Standard_Transient) item = WS->StartingEntity(id);
225 if (sp->Add(item)) sout<<"Added:no."<<id<<endl;
226 else { sout<<" Fail Add n0."<<id<<endl; ko ++; }
227 }
228 else { sout<<"Not an entity number:"<<pilot->Arg(ia)<<endl; ko ++; }
229 }
230 if (ko > 0) { sout<<ko<<" bad arguments, abandon"<<endl; return IFSelect_RetError; }
231 return WS->SendSelected (arg1,sp);
232}
233
234static IFSelect_ReturnStatus fun7
235 (const Handle(IFSelect_SessionPilot)& pilot)
236{
237 Handle(IFSelect_WorkSession) WS = pilot->Session();
238 Standard_Integer argc = pilot->NbWords();
239 const Standard_CString arg1 = pilot->Arg(1);
240// **** Entity Label ****
241 Handle(Message_Messenger) sout = Message::DefaultMessenger();
242 if (argc < 2) { sout<<"Give entity number"<<endl; return IFSelect_RetError; }
243 if (!WS->HasModel()) { sout<<"No loaded model, abandon"<<endl; return IFSelect_RetError; }
244 Standard_Integer nument = WS->NumberFromLabel (arg1);
245 if (nument <= 0 || nument > WS->NbStartingEntities())
246 { sout<<"Not a suitable number: "<<arg1<<endl; return IFSelect_RetError; }
247 sout<<"N0."<<nument<<" ->Label in Model : ";
248 WS->Model()->PrintLabel(WS->StartingEntity(nument),sout);
249 sout<<endl;
250 return IFSelect_RetVoid;
251}
252
253static IFSelect_ReturnStatus fun8
254 (const Handle(IFSelect_SessionPilot)& pilot)
255{
256 Handle(IFSelect_WorkSession) WS = pilot->Session();
257 Standard_Integer argc = pilot->NbWords();
258 const Standard_CString arg1 = pilot->Arg(1);
259// **** Entity Number ****
260 Handle(Message_Messenger) sout = Message::DefaultMessenger();
261 if (argc < 2) { sout<<"Give label to search"<<endl; return IFSelect_RetError; }
262 if (!WS->HasModel()) { sout<<"No loaded model, abandon"<<endl; return IFSelect_RetError; }
263 Handle(Interface_InterfaceModel) model = WS->Model();
264 Standard_Integer i, cnt = 0;
265 Standard_Boolean exact = Standard_False;
266 sout<<" ** Search Entity Number for Label : "<<arg1<<endl;
267 for (i = model->NextNumberForLabel (arg1, 0, exact) ; i != 0;
268 i = model->NextNumberForLabel (arg1, i, exact)) {
269 cnt ++;
270 sout<<" ** Found n0/id:"; model->Print (model->Value(i),sout); sout<<endl;
271 }
272
273 if (cnt == 0) sout<<" ** No Match"<<endl;
274 else if (cnt == 1) sout<<" ** 1 Match"<<endl;
275 else sout<<cnt<<" Matches"<<endl;
276 return IFSelect_RetVoid;
277}
278
279static IFSelect_ReturnStatus fun9
280 (const Handle(IFSelect_SessionPilot)& pilot)
281{
282// **** List Types ****
283 Handle(IFSelect_WorkSession) WS = pilot->Session();
284 Handle(IFSelect_Signature) signtype = WS->SignType();
285 if (signtype.IsNull()) signtype = new IFSelect_SignType;
286 Handle(IFSelect_SignCounter) counter =
287 new IFSelect_SignCounter(signtype,Standard_False);
288 return pilot->ExecuteCounter (counter,1);
289}
290
291static IFSelect_ReturnStatus funcount
292 (const Handle(IFSelect_SessionPilot)& pilot)
293{
294 Handle(IFSelect_WorkSession) WS = pilot->Session();
295 Standard_Integer argc = pilot->NbWords();
296 const Standard_CString arg0 = pilot->Arg(0);
297 const Standard_CString arg1 = pilot->Arg(1);
298 Standard_Boolean listmode = (arg0[0] == 'l');
299// **** List Counter ****
300
301 Handle(Message_Messenger) sout = Message::DefaultMessenger();
302 if (argc < 2) {
303 sout<<"Designer signature ou compteur, + facultatif selection + facultatif entite"<<endl;
304 sout<<" signature/compteur seul -> tout le modele"<<endl
305 << " sign/compteur + selection -> cette selection, evaluation normale"<<endl
306 <<" sign/compteur + sel + num -> cette selection evaluee sur entite n0 num"<<endl;
307 return IFSelect_RetError;
308 }
309 DeclareAndCast(IFSelect_SignCounter,counter,WS->NamedItem(arg1));
310 if (counter.IsNull()) {
311 DeclareAndCast(IFSelect_Signature,signa,WS->NamedItem(arg1));
312 if (!signa.IsNull()) counter = new IFSelect_SignCounter(signa,Standard_False,listmode);
313 }
314// Handle(IFSelect_Selection) sel;
315// Standard_Integer n3 = 0; if (argc > 3) n3 = WS->NumberFromLabel(arg3);
316// if (argc > 2) sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2));
317// if (counter.IsNull() || (argc > 2 && n3 <= 0 && sel.IsNull()) ) {
318// sout<<"Nom:"<<arg1; if (argc > 2) sout<<" et/ou "<<arg2;
319// sout<<" incorrect (demande: compteur ou signature [selection])"<<endl;
320// return IFSelect_RetError;
321// }
322
323// Ajout : si Selection, on applique un GraphCounter
324// Et en ce cas, on peut en avoir plusieurs : la limite est le mot-cle "on"
325 Standard_Integer onflag = 0;
326 Standard_Integer i; // svv Jan11 2000 : porting on DEC
327 for (i = 2; i < argc; i ++) {
328 if (!strcmp (pilot->Arg(i),"on")) { onflag = i; break; }
329 }
330
331 Handle(IFSelect_Selection) sel = WS->GiveSelection(arg1);
332 DeclareAndCast(IFSelect_SelectDeduct,seld,sel);
333 if (!seld.IsNull()) {
334// Si onflag, faire une SelectSuite
335 if (onflag > 2) {
336 Handle(IFSelect_SelectSuite) suite = new IFSelect_SelectSuite;
337 for (i = 1; i < onflag; i ++) {
338 sel = WS->GiveSelection(pilot->Arg(i));
339 if (!suite->AddInput(sel)) {
340 sout<<"Incorrect definition for applied selection"<<endl;
341 return IFSelect_RetError;
342 }
343 }
344 seld = suite;
345 }
346
347 Handle(IFSelect_GraphCounter) gc = new IFSelect_GraphCounter(Standard_False,listmode);
348 gc->SetApplied (seld);
349 counter = gc;
350 }
351
352 if (counter.IsNull()) {
353 sout<<"Neither Counter nor Signature : "<<arg1<<endl;
354 return IFSelect_RetError;
355 }
356
357 if (onflag == 0) onflag = 1;
358 IFSelect_PrintCount pcm = IFSelect_ListByItem;
359 if (arg0[0] == 'c') pcm = IFSelect_CountByItem;
360 if (arg0[0] == 's') pcm = IFSelect_CountSummary;
361 return pilot->ExecuteCounter (counter,onflag+1, pcm);
362}
363
364static IFSelect_ReturnStatus funsigntype
365 (const Handle(IFSelect_SessionPilot)& pilot)
366{
367 Handle(IFSelect_WorkSession) WS = pilot->Session();
368 Standard_Integer argc = pilot->NbWords();
369 const Standard_CString arg1 = pilot->Arg(1);
370// **** Sign Type ****
371 Handle(IFSelect_Signature) signtype = WS->SignType();
372 Handle(Message_Messenger) sout = Message::DefaultMessenger();
373 if (signtype.IsNull()) sout<<"signtype actually undefined"<<endl;
374 else {
375 Handle(TCollection_HAsciiString) str = WS->Name (signtype);
376 Standard_Integer id = WS->ItemIdent (signtype);
377 sout<<signtype->Label()<<endl;
378 if (str.IsNull()) {
379 if (id > 0) sout<<"signtype : item n0 "<<id<<endl;
380 } else {
381 sout<<"signtype : also named as "<<str->ToCString()<<endl;
382 }
383 }
384 if (argc < 2) sout<<"signtype newitem to change, signtype . to clear"<<endl;
385 else {
386 if (arg1[0] == '.' && arg1[1] == '\0') {
387 signtype.Nullify();
388 sout<<"signtype now cleared"<<endl;
389 } else {
390 signtype = GetCasted(IFSelect_Signature,WS->NamedItem(arg1));
391 if (signtype.IsNull()) { sout<<"Not a Signature : "<<arg1<<endl; return IFSelect_RetError; }
392 else sout<<"signtype now set to "<<arg1<<endl;
393 }
394 WS->SetSignType(signtype);
395 return IFSelect_RetDone;
396 }
397 return IFSelect_RetVoid;
398}
399
400static IFSelect_ReturnStatus funsigncase
401 (const Handle(IFSelect_SessionPilot)& pilot)
402{
403 Handle(IFSelect_WorkSession) WS = pilot->Session();
404 const Standard_CString arg1 = pilot->Arg(1);
405// **** Sign Case ****
406 Handle(IFSelect_Signature) signcase = GetCasted(IFSelect_Signature,WS->NamedItem(arg1));
407 Handle(Message_Messenger) sout = Message::DefaultMessenger();
408 if (signcase.IsNull()) sout<<"Not a Signature : "<<arg1<<endl;
409 else {
410 Standard_Boolean hasmin,hasmax; Standard_Integer valmin,valmax;
411 if (signcase->IsIntCase(hasmin,valmin,hasmax,valmax)) {
412 sout<<"Signature "<<arg1<<" : Integer Case";
413 if (hasmin) sout<<" - Mini:"<<valmin;
414 if (hasmax) sout<<" - Maxi:"<<valmax;
415 sout<<endl;
416 }
417 Handle(TColStd_HSequenceOfAsciiString) caselist = signcase->CaseList();
418 if (caselist.IsNull()) sout<<"Signature "<<arg1<<" : no predefined case, see command count "<<arg1<<endl;
419 else {
420 Standard_Integer i, nb = caselist->Length();
421 sout<<"Signature "<<arg1<<" : "<<nb<<" basic cases :"<<endl;
422 for (i = 1; i <= nb; i ++) sout<<" "<<caselist->Value(i);
423 sout<<endl;
424 }
425 }
426 return IFSelect_RetVoid;
427}
428
429
430static IFSelect_ReturnStatus fun10
431 (const Handle(IFSelect_SessionPilot)& pilot)
432{
433 Handle(IFSelect_WorkSession) WS = pilot->Session();
434 Standard_Integer argc = pilot->NbWords();
435 const Standard_CString arg1 = pilot->Arg(1);
436// **** Entity Status ****
437 Standard_Integer i,nb;
438 Handle(Message_Messenger) sout = Message::DefaultMessenger();
439 if (argc < 2) {
440 nb = Interface_Category::NbCategories();
441 sout<<" Categories defined :"<<nb<<" i.e. :\n";
442 for (i = 0; i <= nb; i ++)
443 sout<<"Cat."<<i<<" : "<<Interface_Category::Name(i)<<"\n";
444 sout<<" On a given entity : give its number"<<endl;
445 return IFSelect_RetVoid;
446 }
447 Standard_Integer num = pilot->Number(arg1);
448 if (num <= 0 || num > WS->NbStartingEntities())
449 { sout<<"Not a suitable entity number : "<<arg1<<endl; return IFSelect_RetError; }
450 Handle(Standard_Transient) ent = WS->StartingEntity(num);
451 WS->PrintEntityStatus(ent,sout);
452 return IFSelect_RetVoid;
453}
454
455static IFSelect_ReturnStatus fun11
456 (const Handle(IFSelect_SessionPilot)& pilot)
457{
458 Handle(IFSelect_WorkSession) WS = pilot->Session();
459// Standard_Integer argc = pilot->NbWords();
460 const Standard_CString arg1 = pilot->Arg(1);
461// **** DumpModel (Data) ****
462 Standard_Integer niv = 0;
463// char arg10 = arg1[0];
464// if (argc < 2) arg10 = '?';
465 Handle(Message_Messenger) sout = Message::DefaultMessenger();
466 switch (arg1[0]) {
467 case '?' :
468 sout<<"? for this help, else give a listing mode (first letter suffices) :\n"
469 <<" general General Statistics\n roots Roots\n"
470 <<" entities All Entities\n"
471 <<" listfails CheckList (fails) per entity\n"
472 <<" messages CheckList (complete) per entity\n"
473 <<" fails CheckList (fails) per message (counting)\n"
474 <<" check CheckList (complete) per message (counting)\n"
475 <<" totalcheck CheckList (complete) per message (listing n0 ents)\n"
476 <<" FAILS CheckList (fails) per message (listing complete)\n"
477 <<" TOTALCHECK CheckList (complete) per message (listing complete)"<<endl;
478 return IFSelect_RetVoid;
479 case 'g' : niv = 0; break;
480 case 'r' : niv = 1; break;
481 case 'e' : niv = 2; break;
482 case 'l' : niv = 3; break;
483 case 'm' : niv = 4; break;
484 case 'c' : niv = 5; break;
485 case 't' : niv = 6; break;
486 case 'T' : niv = 7; break;
487 case 'f' : niv = 8; break;
488 case 'F' : niv =10; break;
489 default : sout<<"Unknown Mode . data tout court pour help"<<endl; return IFSelect_RetError;
490 }
491 WS->TraceDumpModel(niv);
492 return IFSelect_RetVoid;
493}
494
495static IFSelect_ReturnStatus fundumpent
496 (const Handle(IFSelect_SessionPilot)& pilot)
497{
498 Handle(IFSelect_WorkSession) WS = pilot->Session();
499 Standard_Integer argc = pilot->NbWords();
500 Handle(IFSelect_WorkLibrary) WL = WS->WorkLibrary();
501 Standard_Integer levdef=0,levmax=10,level;
502 WL->DumpLevels (levdef,levmax);
503 Handle(Message_Messenger) sout = Message::DefaultMessenger();
504 if (argc < 2 || (argc == 2 && levmax < 0)) {
505 sout<<"Give n0 or id of entity";
506 if (levmax < 0) sout<<" and dump level"<<endl;
507 else sout<<" + optinal, dump level in [0 - "<<levmax<<"] , default = "<<levdef<<endl;
508 for (level = 0; level <= levmax; level ++) {
509 Standard_CString help = WL->DumpHelp (level);
510 if (help[0] != '\0') sout<<level<<" : "<<help<<endl;
511 }
512 return IFSelect_RetError;
513 }
514
515 const Standard_CString arg1 = pilot->Arg(1);
516 const Standard_CString arg2 = pilot->Arg(2);
517 Standard_Integer num = pilot->Number(arg1);
518 if (num == 0) return IFSelect_RetError;
519 level = levdef;
520 if (argc > 2) level = atoi(arg2);
521 Handle(Standard_Transient) ent = WS->StartingEntity(num);
522 if ( ent.IsNull() ) {
523 sout << "No entity with given id " << arg1 << " (" << num << ") is found in the current model" << endl;
524 }
525 else {
526 sout << " -- DUMP Entity n0 " << num << " level " << level << endl;
527 WL->DumpEntity (WS->Model(),WS->Protocol(),ent,sout,level);
528
529 Interface_CheckIterator chl = WS->CheckOne (ent);
530 if (!chl.IsEmpty(Standard_False)) chl.Print(sout,WS->Model(),Standard_False);
531 }
532// sout << flush;
533
534 return IFSelect_RetVoid;
535}
536
537static IFSelect_ReturnStatus funsign
538 (const Handle(IFSelect_SessionPilot)& pilot)
539{
540 Handle(IFSelect_WorkSession) WS = pilot->Session();
541 Standard_Integer argc = pilot->NbWords();
542 const Standard_CString arg1 = pilot->Arg(1);
543 const Standard_CString arg2 = pilot->Arg(2);
544 Handle(Message_Messenger) sout = Message::DefaultMessenger();
545 if (argc < 3) { sout<<" Give signature name + n0 or id of entity"<<endl; return IFSelect_RetError; }
546 DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
547 if (sign.IsNull()) { sout<<"Not a signature : "<<arg1<<endl; return IFSelect_RetError; }
548 Standard_Integer num = pilot->Number(arg2);
549 Handle(Standard_Transient) ent = WS->StartingEntity (num);
550 if (num == 0) return IFSelect_RetError;
551 sout<<"Entity n0 "<<num<<" : "<<WS->SignValue(sign,ent)<<endl;
552 return IFSelect_RetVoid;
553}
554
555static IFSelect_ReturnStatus funqp
556 (const Handle(IFSelect_SessionPilot)& pilot)
557{
558 Handle(IFSelect_WorkSession) WS = pilot->Session();
559 Standard_Integer argc = pilot->NbWords();
560 const Standard_CString arg1 = pilot->Arg(1);
561 const Standard_CString arg2 = pilot->Arg(2);
562 Handle(Message_Messenger) sout = Message::DefaultMessenger();
563 if (argc < 3) { sout<<" Give 2 numeros or labels : dad son"<<endl; return IFSelect_RetError; }
564 Standard_Integer n1 = WS->NumberFromLabel(arg1);
565 Standard_Integer n2 = WS->NumberFromLabel(arg2);
566 sout<<"QueryParent for dad:"<<arg1<<":"<<n1<<" and son:"<<arg2<<":"<<n2<<endl;
567 Standard_Integer qp = WS->QueryParent(WS->StartingEntity(n1),WS->StartingEntity(n2));
568 if (qp < 0) sout<<arg1<<" is not super-entity of "<<arg2<<endl;
569 else if (qp == 0) sout<<arg1<<" is same as "<<arg2<<endl;
570 else sout<<arg1<<" is super-entity of "<<arg2<<" , max level found="<<qp<<endl;
571// sout<<" Trouve "<<qp<<endl;
572 return IFSelect_RetVoid;
573}
574
575
576static IFSelect_ReturnStatus fun12
577 (const Handle(IFSelect_SessionPilot)& pilot)
578{
579 Handle(IFSelect_WorkSession) WS = pilot->Session();
580// **** DumpShare ****
581 WS->DumpShare(); return IFSelect_RetVoid;
582}
583
584static IFSelect_ReturnStatus fun13
585 (const Handle(IFSelect_SessionPilot)& pilot)
586{
587 Handle(IFSelect_WorkSession) WS = pilot->Session();
588// **** ListItems ****
589 WS->ListItems(pilot->Arg(1)); return IFSelect_RetVoid;
590}
591
592static IFSelect_ReturnStatus fun14
593 (const Handle(IFSelect_SessionPilot)& pilot)
594{
595 Handle(IFSelect_WorkSession) WS = pilot->Session();
596 Standard_Integer argc = pilot->NbWords();
597 const Standard_CString arg1 = pilot->Arg(1);
598// **** NewInt ****
599 Handle(Message_Messenger) sout = Message::DefaultMessenger();
600 if (argc < 1) { sout<<"Donner la valeur entiere pour IntParam"<<endl; return IFSelect_RetError; }
601 Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
602 if (argc >= 1) intpar->SetValue(atoi(arg1));
603 return pilot->RecordItem (intpar);
604}
605
606static IFSelect_ReturnStatus fun15
607 (const Handle(IFSelect_SessionPilot)& pilot)
608{
609 Handle(IFSelect_WorkSession) WS = pilot->Session();
610 Standard_Integer argc = pilot->NbWords();
611 const Standard_CString arg1 = pilot->Arg(1);
612 const Standard_CString arg2 = pilot->Arg(2);
613// **** SetInt ****
614 Handle(Message_Messenger) sout = Message::DefaultMessenger();
615 if (argc < 3)
616 { sout<<"Donner 2 arguments : nom Parametre et Valeur"<<endl; return IFSelect_RetError; }
617 Standard_Integer val = atoi(arg2);
618 DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
619 if (!WS->SetIntValue(par,val)) return IFSelect_RetFail;
620 return IFSelect_RetDone;
621}
622
623static IFSelect_ReturnStatus fun16
624 (const Handle(IFSelect_SessionPilot)& pilot)
625{
626 Handle(IFSelect_WorkSession) WS = pilot->Session();
627 Standard_Integer argc = pilot->NbWords();
628 const Standard_CString arg1 = pilot->Arg(1);
629// **** NewText ****
630 Handle(Message_Messenger) sout = Message::DefaultMessenger();
631 if (argc < 1) { sout<<"Donner la valeur texte pour TextParam"<<endl; return IFSelect_RetError; }
632 Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString();
633 if (argc >= 1) textpar->AssignCat(arg1);
634 return pilot->RecordItem (textpar);
635}
636
637static IFSelect_ReturnStatus fun17
638 (const Handle(IFSelect_SessionPilot)& pilot)
639{
640 Handle(IFSelect_WorkSession) WS = pilot->Session();
641 Standard_Integer argc = pilot->NbWords();
642 const Standard_CString arg1 = pilot->Arg(1);
643 const Standard_CString arg2 = pilot->Arg(2);
644// **** SetText ****
645 Handle(Message_Messenger) sout = Message::DefaultMessenger();
646 if (argc < 3)
647 { sout<<"Donner 2 arguments : nom Parametre et Valeur"<<endl; return IFSelect_RetError; }
648 DeclareAndCast(TCollection_HAsciiString,par,WS->NamedItem(arg1));
649 if (!WS->SetTextValue(par,arg2)) return IFSelect_RetFail;
650 return IFSelect_RetDone;
651}
652
653static IFSelect_ReturnStatus fun19
654 (const Handle(IFSelect_SessionPilot)& pilot)
655{
656 Handle(IFSelect_WorkSession) WS = pilot->Session();
657 Standard_Integer argc = pilot->NbWords();
658 const Standard_CString arg1 = pilot->Arg(1);
659// **** DumpSel ****
660 Handle(Message_Messenger) sout = Message::DefaultMessenger();
661 if (argc < 2) { sout<<"Give 1 argument : Selection Name"<<endl; return IFSelect_RetError; }
662 WS->DumpSelection (GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
663 return IFSelect_RetVoid;
664}
665
666static IFSelect_ReturnStatus fun20
667 (const Handle(IFSelect_SessionPilot)& pilot)
668{
669 Handle(IFSelect_WorkSession) WS = pilot->Session();
670 Standard_Integer argc = pilot->NbWords();
671// **** EvalSel ****
672// **** GiveList ****
673// **** GiveShort GivePointed ****
674// **** MakeList ****
675 char mode = pilot->Arg(0)[0]; // givelist/makelist
676 if (mode == 'g') mode = pilot->Arg(0)[4]; // l list s short p pointed
677 Handle(Message_Messenger) sout = Message::DefaultMessenger();
678 if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
679
680// MakeList : sur Pointed existante ou a creer
681 Handle(IFSelect_SelectPointed) pnt;
682 if (mode == 'm') {
683 const Standard_CString arg1 = pilot->Arg(1);
684 Handle(Standard_Transient) item = WS->NamedItem (arg1);
685 pnt = GetCasted(IFSelect_SelectPointed,item);
686 if (!pnt.IsNull()) {
687 sout<<arg1<<":Already existing Selection for List, cleared then filled"<<endl;
688 pnt->Clear();
689 } else if (!item.IsNull()) {
690 sout<<arg1<<":Already existing Item not for a List, command ignored"<<endl;
691 return IFSelect_RetFail;
692 } else {
693 pnt = new IFSelect_SelectPointed;
694 WS->AddNamedItem (arg1,pnt);
695 }
696 }
697
698 Handle(TColStd_HSequenceOfTransient) result =
699 IFSelect_Functions::GiveList (WS,pilot->CommandPart( (mode == 'm' ? 2 : 1) ));
700 if (result.IsNull()) return IFSelect_RetError;
701 Interface_EntityIterator iter (result);
702 sout<<pilot->CommandPart( (mode == 'm' ? 2 : 1) )<<" : ";
703 if (mode == 'l') WS->ListEntities (iter,0);
704 else if (mode == 's' || mode == 'm') WS->ListEntities (iter,2);
705 else if (mode == 'p') {
706 sout<<iter.NbEntities()<<" Entities : ";
707 for (iter.Start(); iter.More(); iter.Next())
708 sout<<" +"<<WS->StartingNumber (iter.Value());
709 sout<<endl;
710 }
711
712 if (!pnt.IsNull()) {
713 pnt->SetList (result);
714 sout<<"List set to a SelectPointed : "<<pilot->Arg(1)<<endl;
715 sout<<"Later editable by command setlist"<<endl;
716 }
717
718 return IFSelect_RetVoid;
719}
720
721static IFSelect_ReturnStatus fun20c
722 (const Handle(IFSelect_SessionPilot)& pilot)
723{
724 Handle(IFSelect_WorkSession) WS = pilot->Session();
725 Standard_Integer argc = pilot->NbWords();
726// **** GiveCount ****
727 Handle(Message_Messenger) sout = Message::DefaultMessenger();
728 if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
729// WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
730 Handle(TColStd_HSequenceOfTransient) result =
731 IFSelect_Functions::GiveList (WS,pilot->CommandPart(1));
732 if (result.IsNull()) return IFSelect_RetError;
733 sout<<pilot->CommandPart(1)<<" : List of "<<result->Length()<<" Entities"<<endl;
734 return IFSelect_RetVoid;
735}
736
737static IFSelect_ReturnStatus funselsuite
738 (const Handle(IFSelect_SessionPilot)& pilot)
739{
740 Handle(IFSelect_WorkSession) WS = pilot->Session();
741 Standard_Integer argc = pilot->NbWords();
742// **** SelSuite ****
743 Handle(Message_Messenger) sout = Message::DefaultMessenger();
744 if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
745// WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
746 Handle(IFSelect_SelectSuite) selsuite = new IFSelect_SelectSuite;
747
748 for (Standard_Integer i = 1; i < argc; i ++) {
749 Handle(IFSelect_Selection) sel = WS->GiveSelection(pilot->Arg(i));
750 if (!selsuite->AddInput(sel)) {
751 sout<<pilot->Arg(i-1)<<" : not a SelectDeduct, no more can be added. Abandon"<<endl;
752 return IFSelect_RetError;
753 }
754 }
755 selsuite->SetLabel (pilot->CommandPart(1));
756 return pilot->RecordItem (selsuite);
757}
758
759
760static IFSelect_ReturnStatus fun21
761 (const Handle(IFSelect_SessionPilot)& pilot)
762{
763 Handle(IFSelect_WorkSession) WS = pilot->Session();
764// **** ClearItems ****
765 WS->ClearItems(); WS->ClearFinalModifiers(); WS->ClearShareOut(Standard_False);
766 return IFSelect_RetDone;
767}
768
769static IFSelect_ReturnStatus fun22
770 (const Handle(IFSelect_SessionPilot)& pilot)
771{
772 Handle(IFSelect_WorkSession) WS = pilot->Session();
773 Standard_Integer argc = pilot->NbWords();
774 const Standard_CString arg1 = pilot->Arg(1);
775// **** ClearData ****
776 Standard_Integer mode = -1;
777 if (argc >= 2) {
778 if (arg1[0] == 'a') mode = 1;
779 if (arg1[0] == 'g') mode = 2;
780 if (arg1[0] == 'c') mode = 3;
781 if (arg1[0] == 'p') mode = 4;
782 if (arg1[0] == '?') mode = -1;
783 }
784 else mode = 0;
785 Handle(Message_Messenger) sout = Message::DefaultMessenger();
786 if (mode <= 0) {
787 if (mode < 0) sout<<"Give a suitable mode";
788 sout<<" Available Modes :\n"
789 <<" a : all data g : graph+check c : check p : selectpointed"<<endl;
790 return (mode < 0 ? IFSelect_RetError : IFSelect_RetVoid);
791 }
792 WS->ClearData (mode);
793 return IFSelect_RetDone;
794}
795
796static IFSelect_ReturnStatus fun24
797 (const Handle(IFSelect_SessionPilot)& pilot)
798{
799 Handle(IFSelect_WorkSession) WS = pilot->Session();
800 Standard_Integer argc = pilot->NbWords();
801// **** Item Label ****
802 Handle(Message_Messenger) sout = Message::DefaultMessenger();
803 TCollection_AsciiString label;
804 if (argc < 2) { sout<<" Give label to search"<<endl; return IFSelect_RetError; }
805 for (int i = 1; i < argc; i ++) {
806 label.AssignCat(pilot->Arg(i));
807 if (i < argc-1) label.AssignCat(" ");
808 }
809 for (int mode = 0; mode <= 2; mode ++) {
810 int nbitems = 0; int id;
811 sout<<"Searching label : "<<label<<". in mode ";
812 if (mode == 0) sout <<" exact" << endl;
813 if (mode == 1) sout <<" same head" << endl;
814 if (mode == 2) sout <<" search if present" << endl;
815 for (id = WS->NextIdentForLabel(label.ToCString(), 0,mode) ; id != 0;
816 id = WS->NextIdentForLabel(label.ToCString(),id,mode)) {
817 sout<<" "<<id; nbitems ++;
818 }
819 sout<<" -- giving " << nbitems << " found" << endl;
820 }
821 return IFSelect_RetVoid;
822}
823
824static IFSelect_ReturnStatus fun25
825 (const Handle(IFSelect_SessionPilot)& pilot)
826{
827 Handle(IFSelect_WorkSession) WS = pilot->Session();
828 Standard_Integer argc = pilot->NbWords();
829 const Standard_CString arg1 = pilot->Arg(1);
830// **** Save (Dump) ****
831 Handle(Message_Messenger) sout = Message::DefaultMessenger();
832 if (argc < 2) { sout<<"Donner nom du Fichier"<<endl; return IFSelect_RetError; }
833 IFSelect_SessionFile dumper(WS,arg1);
834 if (!dumper.IsDone()) return IFSelect_RetFail;
835 return IFSelect_RetDone;
836}
837
838static IFSelect_ReturnStatus fun26
839 (const Handle(IFSelect_SessionPilot)& pilot)
840{
841 Handle(IFSelect_WorkSession) WS = pilot->Session();
842 Standard_Integer argc = pilot->NbWords();
843 const Standard_CString arg1 = pilot->Arg(1);
844// **** Restore (Dump) ****
845 Handle(Message_Messenger) sout = Message::DefaultMessenger();
846 if (argc < 2) { sout<<"Donner nom du Fichier"<<endl; return IFSelect_RetError; }
847 IFSelect_SessionFile dumper(WS);
848 Standard_Integer readstat = dumper.Read(arg1);
849 if (readstat == 0) return IFSelect_RetDone;
850 else if (readstat > 0) sout << "-- Erreur Lecture Fichier "<<arg1<<endl;
851 else sout << "-- Pas pu ouvrir Fichier "<<arg1<<endl;
852 return IFSelect_RetDone;
853}
854
855static IFSelect_ReturnStatus fun27
856 (const Handle(IFSelect_SessionPilot)& pilot)
857{
858 Standard_Integer argc = pilot->NbWords();
859 Handle(IFSelect_WorkSession) WS = pilot->Session();
860 const Standard_CString arg1 = pilot->Arg(1);
861 const Standard_CString arg2 = pilot->Arg(2);
862// **** Param(Value) ****
863 Handle(Message_Messenger) sout = Message::DefaultMessenger();
864 if (argc < 2) {
865 Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items();
866 Standard_Integer i,nb = li->Length();
867 sout<<" List of parameters : "<<nb<<" items : "<<endl;
868 for (i = 1; i <= nb; i ++) {
869 sout<<li->Value(i);
870 sout<<" : "<<Interface_Static::CVal(li->Value(i)->ToCString())<<endl;
871 }
872 return IFSelect_RetVoid;
873 } else if (atoi(arg1) > 0) {
874 Standard_Integer use = atoi (arg1);
875 WS->TraceStatics (use);
876 } else {
877 if (argc > 2) sout<<" FORMER STATUS of Static Parameter "<<arg1<<endl;
878 else sout<<" ACTUAL STATUS of Static Parameter "<<arg1<<endl;
879 if (!Interface_Static::IsPresent(arg1)) { sout<<" Parameter "<<arg1<<" undefined"<<endl; return IFSelect_RetError; }
880 if (!Interface_Static::IsSet(arg1)) sout<<" Parameter "<<arg1<<" not valued"<<endl;
881 else if (argc == 2) Interface_Static::Static (arg1) -> Print(sout);
882 else sout<<" Value : "<<Interface_Static::CVal(arg1)<<endl;
883
884 if (argc == 2) sout<<"To modify, param name_param new_val"<<endl;
885 else {
886 sout<<" New demanded value : "<<arg2;
887 if (Interface_Static::SetCVal (arg1,arg2))
888 { sout<<" OK"<<endl; return IFSelect_RetDone; }
889 else { sout <<" , refused"<<endl; return IFSelect_RetError; }
890 }
891 }
892 return IFSelect_RetVoid;
893}
894
895static IFSelect_ReturnStatus fun28
896 (const Handle(IFSelect_SessionPilot)& pilot)
897{
898 Standard_Integer argc = pilot->NbWords();
899 const Standard_CString arg1 = pilot->Arg(1);
900 const Standard_CString arg2 = pilot->Arg(2);
901 const Standard_CString arg3 = pilot->Arg(3);
902// **** DefParam ****
903 Handle(Message_Messenger) sout = Message::DefaultMessenger();
904 if (argc < 2) {
905 Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items();
906 Standard_Integer i,nb = li->Length();
907 sout<<" List of parameters : "<<nb<<" items :"<<endl;
908 for (i = 1; i <= nb; i ++) sout<<" "<<li->Value(i)->ToCString();
909 sout<<endl<<" defparam name_param to known more about one"<<endl;
910 sout<<" defparam nom_param e options to edit a definition"<<endl;
911
912 } else if (argc == 2) {
913 sout<<" Definition of Parameter : "<<arg1<<endl;
914 Handle(Interface_Static) unst = Interface_Static::Static (arg1);
915 if (unst.IsNull()) sout<<" undefined"<<endl;
916 else unst->Print(sout);
917 return IFSelect_RetVoid;
918
919 } else if (arg2[0] == 'i') {
920// initialisation : arg1=nompar a2='i' a3=family a4=type [a5=val]
921 if (argc < 5) { sout<<" name init family type [valinit]"<<endl; return IFSelect_RetVoid; }
922 char typ = (pilot->Arg(4))[0];
923 Standard_Boolean ok= (argc==5 ? Interface_Static::Init(arg3,arg1,typ) :
924 Interface_Static::Init(arg3,arg1,typ,pilot->Arg(5)));
925 return (ok ? IFSelect_RetDone : IFSelect_RetFail);
926
927 } else if (arg2[0] == 'e') {
928// edition : arg1=nompar arg2='e' arg3=option arg4...=parametres option
929 char comm[100];
930 if (argc < 4) {
931 sout<<" give name and options ! Options (according type), 1 a time\n"
932 <<" imin ival / imax ival / rmin rval / rmax rval /\n"
933 <<" enum stnum / enum stnum match / eval e1 e2 e3 ... (maxi 10)\n"
934 <<endl;
935 return IFSelect_RetVoid;
936 }
937 if (argc > 4) sout<<"Only the command and ONE more arg are considered"<<endl;
938 sprintf(comm,"%s %s",pilot->Arg(3),pilot->Arg(4));
939 sout<<"Editing parameter : "<<arg1<<" , by command : "<<comm<<endl;
940
941 Handle(Interface_Static) unst = Interface_Static::Static (arg1);
942 if (unst.IsNull()) { sout<<arg1<<" undefined"<<endl; return IFSelect_RetError; }
943 if (Interface_Static::Init(unst->Family(),arg1,'&',comm))
944 { sout<<"Editing done"<<endl; return IFSelect_RetDone; }
945 else { sout<<"Command not processed : "<<comm<<endl; return IFSelect_RetFail; }
946 }
947 sout<<"Unknown Option : "<<arg2<<endl;
948 return IFSelect_RetVoid;
949}
950
951static IFSelect_ReturnStatus fun29
952 (const Handle(IFSelect_SessionPilot)& pilot)
953{
954 Handle(IFSelect_WorkSession) WS = pilot->Session();
955// **** SentFiles ****
956 Handle(TColStd_HSequenceOfHAsciiString) list = WS->SentFiles();
957 Handle(Message_Messenger) sout = Message::DefaultMessenger();
958 if (list.IsNull())
959 { sout<<"List of Sent Files not enabled"<<endl; return IFSelect_RetVoid; }
960 Standard_Integer i, nb = list->Length();
961 sout<<" Sent Files : "<<nb<<" : "<<endl;
962 for (i = 1; i <= nb; i ++)
963 sout<<list->Value(i)->ToCString()<<endl;
964 return IFSelect_RetVoid;
965}
966
967static IFSelect_ReturnStatus fun30
968 (const Handle(IFSelect_SessionPilot)& pilot)
969{
970 Handle(IFSelect_WorkSession) WS = pilot->Session();
971 Standard_Integer argc = pilot->NbWords();
972 const Standard_CString arg1 = pilot->Arg(1);
973// **** FilePrefix ****
974 Handle(Message_Messenger) sout = Message::DefaultMessenger();
975 if (argc < 2) {
976 if (WS->FilePrefix().IsNull()) sout<<"Pas de prefixe defini"<<endl;
977 else sout<<"Prefixe : "<<WS->FilePrefix()->ToCString()<<endl;
978 sout<<"Pour changer : filepref newprefix"<<endl;
979 return IFSelect_RetVoid;
980 }
981 WS->SetFilePrefix(arg1);
982 return IFSelect_RetDone;
983}
984
985static IFSelect_ReturnStatus fun31
986 (const Handle(IFSelect_SessionPilot)& pilot)
987{
988 Handle(IFSelect_WorkSession) WS = pilot->Session();
989 Standard_Integer argc = pilot->NbWords();
990 const Standard_CString arg1 = pilot->Arg(1);
991// **** FileExtension ****
992 Handle(Message_Messenger) sout = Message::DefaultMessenger();
993 if (argc < 2) {
994 if (WS->FileExtension().IsNull()) sout<<"Pas d extension definie"<<endl;
995 else sout<<"Extension : "<<WS->FileExtension()->ToCString()<<endl;
996 sout<<"Pour changer : fileext newext"<<endl;
997 return IFSelect_RetVoid;
998 }
999 WS->SetFileExtension(arg1);
1000 return IFSelect_RetDone;
1001}
1002
1003static IFSelect_ReturnStatus fun32
1004 (const Handle(IFSelect_SessionPilot)& pilot)
1005{
1006 Handle(IFSelect_WorkSession) WS = pilot->Session();
1007 Standard_Integer argc = pilot->NbWords();
1008 const Standard_CString arg1 = pilot->Arg(1);
1009 const Standard_CString arg2 = pilot->Arg(2);
1010// **** FileRoot ****
1011 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1012 if (argc < 2) { sout<<"Donner Dispatch et nom de Root"<<endl; return IFSelect_RetError; }
1013 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1014 if (argc < 3) {
1015 if (WS->FileRoot(disp).IsNull()) sout<<"Pas de racine definie pour "<<arg1<<endl;
1016 else sout<<"Racine pour "<<arg1<<" : "<<WS->FileRoot(disp)->ToCString()<<endl;
1017 sout<<"Pour changer : fileroot nomdisp newroot"<<endl;
1018 return IFSelect_RetVoid;
1019 }
1020 if (!WS->SetFileRoot(disp,arg2)) return IFSelect_RetFail;
1021 return IFSelect_RetDone;
1022}
1023
1024static IFSelect_ReturnStatus fun33
1025 (const Handle(IFSelect_SessionPilot)& pilot)
1026{
1027 Handle(IFSelect_WorkSession) WS = pilot->Session();
1028 Standard_Integer argc = pilot->NbWords();
1029 const Standard_CString arg1 = pilot->Arg(1);
1030// **** Default File Root ****
1031 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1032 if (argc < 2) {
1033 if (WS->DefaultFileRoot().IsNull()) sout<<"Pas de racine par defaut definie"<<endl;
1034 else sout<<"Racine par defaut : "<<WS->DefaultFileRoot()->ToCString()<<endl;
1035 sout<<"Pour changer : filedef newdef"<<endl;
1036 return IFSelect_RetVoid;
1037 }
1038 WS->SetDefaultFileRoot(arg1);
1039 return IFSelect_RetDone;
1040}
1041
1042static IFSelect_ReturnStatus fun34
1043 (const Handle(IFSelect_SessionPilot)& pilot)
1044{
1045 Handle(IFSelect_WorkSession) WS = pilot->Session();
1046// **** EvalFile ****
1047 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1048 if (!WS->HasModel())
1049 { sout<<"Pas de Modele charge, abandon"<<endl; return IFSelect_RetFail; }
1050
1051 sout<<"Evaluation avec Memorisation des resultats"<<endl;
1052 WS->EvaluateFile();
1053 Standard_Integer nbf = WS->NbFiles();
1054 for (Standard_Integer i = 1; i <= nbf; i ++) {
1055 Handle(Interface_InterfaceModel) mod = WS->FileModel(i);
1056 if (mod.IsNull())
1057 { sout<<"Modele "<<i<<" Model non genere ..."<<endl; continue; }
1058 TCollection_AsciiString name = WS->FileName(i);
1059 sout<<"Fichier n0 "<<i<<" Nb Entites : "<<mod->NbEntities()<<" Nom: ";
1060 sout<<name<<endl;
1061 }
1062 return IFSelect_RetDone;
1063}
1064
1065static IFSelect_ReturnStatus fun35
1066 (const Handle(IFSelect_SessionPilot)& pilot)
1067{
1068 Handle(IFSelect_WorkSession) WS = pilot->Session();
1069// **** ClearFile ****
1070 WS->ClearFile(); return IFSelect_RetDone;
1071}
1072
1073static IFSelect_ReturnStatus fun36
1074 (const Handle(IFSelect_SessionPilot)& pilot)
1075{
1076 Handle(IFSelect_WorkSession) WS = pilot->Session();
1077 Standard_Integer argc = pilot->NbWords();
1078// **** Split ****
1079 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1080 IFSelect_ReturnStatus stat = IFSelect_RetVoid;
1081 if (argc < 2) sout<<"Split : derniere liste de dispatches definie"<<endl;
1082 else {
1083 WS->ClearShareOut(Standard_True);
1084 for (Standard_Integer i = 1; i < argc; i ++) {
1085 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1086 if (disp.IsNull()) {
1087 sout<<"Pas un dispatch:"<<pilot->Arg(i)<<", Splitt abandonne"<<endl;
1088 stat = IFSelect_RetError;
1089 }
1090 else WS->SetActive(disp,Standard_True);
1091 }
1092 }
1093 if (stat == IFSelect_RetError) return stat;
1094 WS->BeginSentFiles(Standard_True);
1095 if (!WS->SendSplit()) return IFSelect_RetFail;
1096 return IFSelect_RetDone;
1097}
1098
1099static IFSelect_ReturnStatus fun37
1100 (const Handle(IFSelect_SessionPilot)& pilot)
1101{
1102 Handle(IFSelect_WorkSession) WS = pilot->Session();
1103 Standard_Integer argc = pilot->NbWords();
1104 const Standard_CString arg1 = pilot->Arg(1);
1105// **** Remaining Data ****
1106 char mode = '?'; IFSelect_RemainMode numod = IFSelect_RemainDisplay;
1107 if (argc >= 2) mode = arg1[0];
1108 if (mode == 'u') numod = IFSelect_RemainUndo;
1109 else if (mode == 'l') numod = IFSelect_RemainDisplay;
1110 else if (mode == 'c') numod = IFSelect_RemainCompute;
1111 else if (mode == 'f') numod = IFSelect_RemainForget;
1112 else {
1113 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1114 if (argc<2) sout<<"Donner un Mode - ";
1115 sout<<"Modes possibles : l list, c compute, u undo, f forget"<<endl;
1116 if (mode == '?') return IFSelect_RetDone; else return IFSelect_RetError;
1117 }
1118 if (!WS->SetRemaining(numod)) return IFSelect_RetVoid;
1119 return IFSelect_RetDone;
1120}
1121
1122static IFSelect_ReturnStatus fun38
1123 (const Handle(IFSelect_SessionPilot)& pilot)
1124{
1125 Handle(IFSelect_WorkSession) WS = pilot->Session();
1126 Standard_Integer argc = pilot->NbWords();
1127 const Standard_CString arg1 = pilot->Arg(1);
1128 const Standard_CString arg2 = pilot->Arg(2);
1129// **** SetModelContent ****
1130 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1131 if (argc < 3) { sout<<"Donner nom selection et mode (k=keep,r=remove)"<<endl; return IFSelect_RetError; }
1132 Standard_Boolean keepmode;
1133 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1134 if (sel.IsNull())
1135 { sout<<"Pas de Selection de Nom : "<<arg1<<endl; return IFSelect_RetError; }
1136 if (arg2[0] == 'k') { sout<<" -- SetContent keep ..."; keepmode = Standard_True; }
1137 else if (arg2[0] == 'r') { sout<<" -- SetContent remove ..."; keepmode = Standard_False; }
1138 else { sout<<"Donner nom selection et mode (k=keep,r=remove)"<<endl; return IFSelect_RetError; }
1139
1140 if (WS->SetModelContent(sel,keepmode)) sout<<" Done"<<endl;
1141 else sout<<" Result empty, ignored"<<endl;
1142 return IFSelect_RetDone;
1143}
1144
1145static IFSelect_ReturnStatus fun40
1146 (const Handle(IFSelect_SessionPilot)& pilot)
1147{
1148 Handle(IFSelect_WorkSession) WS = pilot->Session();
1149// **** ListModif ****
1150 WS->ListFinalModifiers(Standard_True);
1151 WS->ListFinalModifiers(Standard_False); return IFSelect_RetVoid;
1152}
1153
1154static IFSelect_ReturnStatus fun41
1155 (const Handle(IFSelect_SessionPilot)& pilot)
1156{
1157 Handle(IFSelect_WorkSession) WS = pilot->Session();
1158 Standard_Integer argc = pilot->NbWords();
1159 const Standard_CString arg1 = pilot->Arg(1);
1160// **** Modifier ****
1161 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1162 if (argc < 2) { sout<<"Donner Nom du Modifier"<<endl; return IFSelect_RetError; }
1163 DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1164 if (modif.IsNull())
1165 { sout<<"Pas de Modifier de Nom : "<<arg1<<endl; return IFSelect_RetVoid; }
1166 Handle(IFSelect_IntParam) low,up;
1167
1168 Handle(IFSelect_Dispatch) disp = modif->Dispatch();
1169 sout<<"Modifier : "<<arg1<<" Label : "<<modif->Label()<<endl;
1170 Standard_Integer rank = WS->ModifierRank(modif);
1171 if (modif->IsKind(STANDARD_TYPE(IFSelect_Modifier)))
1172 sout<< "Model Modifier n0." << rank;
1173 else sout<< "File Modifier n0." << rank;
1174 if (disp.IsNull()) sout<<" Applique a tous les Dispatchs" << endl;
1175 else {
1176 sout << " Dispatch : "<<disp->Label();
1177 if (WS->HasName(disp)) sout << " - Nom:"<<WS->Name(disp)->ToCString();
1178 sout<<endl;
1179 }
1180
1181 Handle(IFSelect_Selection) sel = modif->Selection();
1182 if (!sel.IsNull()) sout<<" Selection : "<< sel->Label();
1183 if (WS->HasName(sel)) sout<<" - Nom:"<< WS->Name(sel)->ToCString();
1184 sout<<endl;
1185 return IFSelect_RetVoid;
1186}
1187
1188static IFSelect_ReturnStatus fun42
1189 (const Handle(IFSelect_SessionPilot)& pilot)
1190{
1191 Handle(IFSelect_WorkSession) WS = pilot->Session();
1192 Standard_Integer argc = pilot->NbWords();
1193 const Standard_CString arg1 = pilot->Arg(1);
1194 const Standard_CString arg2 = pilot->Arg(2);
1195// **** ModifSel ****
1196 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1197 if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Selection optionnel\n"
1198 <<"Selection pour Mettre une Selection, sinon Annule"<<endl; return IFSelect_RetError; }
1199 DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1200 if (modif.IsNull())
1201 { sout<<"Pas un nom de Modifier : "<<arg1<<endl; return IFSelect_RetError; }
1202 Handle(IFSelect_Selection) sel;
1203 if (arg2[0] != '\0') {
1204 sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2));
1205 if (sel.IsNull())
1206 { sout<<"Pas un nom de Selection : "<<arg2<<endl; return IFSelect_RetError; }
1207 }
1208 if (!WS->SetItemSelection(modif,sel)) return IFSelect_RetFail;
1209 return IFSelect_RetDone;
1210}
1211
1212static IFSelect_ReturnStatus fun43
1213 (const Handle(IFSelect_SessionPilot)& pilot)
1214{
1215 Handle(IFSelect_WorkSession) WS = pilot->Session();
1216 Standard_Integer argc = pilot->NbWords();
1217 const Standard_CString arg1 = pilot->Arg(1);
1218 const Standard_CString arg2 = pilot->Arg(2);
1219// **** SetAppliedModifier ****
1220 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1221 if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Dispatch ou Transformer optionnel :\n"
1222 <<" - rien : tous Dispatches\n - Dispatch : ce Dispatch seul\n"
1223 <<" - Transformer : pas un Dispatch mais un Transformer"<<endl;
1224 return IFSelect_RetError; }
1225 DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1226 if (modif.IsNull())
1227 { sout<<"Pas un nom de Modifier : "<<arg1<<endl; return IFSelect_RetError; }
1228 Handle(Standard_Transient) item;
1229 if (arg2[0] != '\0') {
1230 item = WS->NamedItem(arg2);
1231 if (item.IsNull())
1232 { sout<<"Pas un nom connu : "<<arg2<<endl; return IFSelect_RetError; }
1233 }
1234 else item = WS->ShareOut();
1235 if (!WS->SetAppliedModifier(modif,item)) return IFSelect_RetFail;
1236 return IFSelect_RetDone;
1237}
1238
1239static IFSelect_ReturnStatus fun44
1240 (const Handle(IFSelect_SessionPilot)& pilot)
1241{
1242 Handle(IFSelect_WorkSession) WS = pilot->Session();
1243 Standard_Integer argc = pilot->NbWords();
1244 const Standard_CString arg1 = pilot->Arg(1);
1245// **** ResetApplied (modifier) ****
1246 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1247 if (argc < 2) { sout<<"Designer un modifier"<<endl; return IFSelect_RetError; }
1248 DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1249 if (modif.IsNull())
1250 { sout<<"Pas un nom de Modifier : "<<arg1<<endl; return IFSelect_RetError; }
1251 if (!WS->ResetAppliedModifier(modif)) return IFSelect_RetFail;
1252 return IFSelect_RetDone;
1253}
1254
1255static IFSelect_ReturnStatus fun45
1256 (const Handle(IFSelect_SessionPilot)& pilot)
1257{
1258 Handle(IFSelect_WorkSession) WS = pilot->Session();
1259 Standard_Integer argc = pilot->NbWords();
1260 const Standard_CString arg1 = pilot->Arg(1);
1261 const Standard_CString arg2 = pilot->Arg(2);
1262 const Standard_CString arg3 = pilot->Arg(3);
1263// **** ModifMove ****
1264 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1265 if (argc < 4) { sout<<"modifmove MF rang1 rang2, M pour Model F pour File"<<endl; return IFSelect_RetError; }
1266 Standard_Boolean formodel;
1267 if (arg1[0] == 'm' || arg1[0] == 'M') formodel = Standard_True;
1268 else if (arg1[0] == 'f' || arg1[0] == 'F') formodel = Standard_False;
1269 else { sout<<"preciser M pour Model, F pour File"<<endl; return IFSelect_RetError; }
1270 Standard_Integer before = atoi(arg2);
1271 Standard_Integer after = atoi(arg3);
1272 if (before == 0 || after == 0) { sout<<"Donner 2 Entiers Positifs"<<endl; return IFSelect_RetError; }
1273 if (!WS->ChangeModifierRank(formodel,before,after)) return IFSelect_RetFail;
1274 return IFSelect_RetDone;
1275}
1276
1277static IFSelect_ReturnStatus fun51
1278 (const Handle(IFSelect_SessionPilot)& pilot)
1279{
1280 Handle(IFSelect_WorkSession) WS = pilot->Session();
1281 Standard_Integer argc = pilot->NbWords();
1282 const Standard_CString arg1 = pilot->Arg(1);
1283 const Standard_CString arg2 = pilot->Arg(2);
1284// **** DispSel ****
1285 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1286 if (argc < 3) { sout<<"Donner Noms Dispatch et Selection Finale"<<endl; return IFSelect_RetError; }
1287 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1288 if (disp.IsNull())
1289 { sout<<"Pas un nom de Dispatch : "<<arg1<<endl; return IFSelect_RetError; }
1290 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg2));
1291 if (sel.IsNull())
1292 { sout<<"Pas un nom de Selection : "<<arg2<<endl; return IFSelect_RetError; }
1293 if (!WS->SetItemSelection(disp,sel)) return IFSelect_RetFail;
1294 return IFSelect_RetDone;
1295}
1296
1297static IFSelect_ReturnStatus fun_dispone
1298 (const Handle(IFSelect_SessionPilot)& pilot)
1299{
1300 Handle(IFSelect_WorkSession) WS = pilot->Session();
1301// **** DispOne ****
1302 Handle(IFSelect_DispPerOne) disp = new IFSelect_DispPerOne;
1303 return pilot->RecordItem(disp);
1304}
1305
1306static IFSelect_ReturnStatus fun_dispglob
1307 (const Handle(IFSelect_SessionPilot)& pilot)
1308{
1309 Handle(IFSelect_WorkSession) WS = pilot->Session();
1310// **** DispGlob ****
1311 Handle(IFSelect_DispGlobal) disp = new IFSelect_DispGlobal;
1312 return pilot->RecordItem(disp);
1313}
1314
1315static IFSelect_ReturnStatus fun_dispcount
1316 (const Handle(IFSelect_SessionPilot)& pilot)
1317{
1318 Handle(IFSelect_WorkSession) WS = pilot->Session();
1319 Standard_Integer argc = pilot->NbWords();
1320 const Standard_CString arg1 = pilot->Arg(1);
1321// **** DispCount ****
1322 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1323 if (argc < 2) { sout<<"Donner Nom IntParam pour Count"<<endl; return IFSelect_RetError; }
1324 DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1325 if (par.IsNull())
1326 { sout<<"Pas un nom de IntParam : "<<arg1<<endl; return IFSelect_RetError; }
1327 Handle(IFSelect_DispPerCount) disp = new IFSelect_DispPerCount;
1328 disp->SetCount (par);
1329 return pilot->RecordItem(disp);
1330}
1331
1332static IFSelect_ReturnStatus fun_dispfiles
1333 (const Handle(IFSelect_SessionPilot)& pilot)
1334{
1335 Handle(IFSelect_WorkSession) WS = pilot->Session();
1336 Standard_Integer argc = pilot->NbWords();
1337 const Standard_CString arg1 = pilot->Arg(1);
1338// **** DispFiles ****
1339 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1340 if (argc < 2) { sout<<"Donner Nom IntParam pour NbFiles"<<endl; return IFSelect_RetError; }
1341 DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1342 if (par.IsNull())
1343 { sout<<"Pas un nom de IntParam : "<<arg1<<endl; return IFSelect_RetError; }
1344 Handle(IFSelect_DispPerFiles) disp = new IFSelect_DispPerFiles;
1345 disp->SetCount (par);
1346 return pilot->RecordItem(disp);
1347}
1348
1349
1350static IFSelect_ReturnStatus fun_dispsign
1351 (const Handle(IFSelect_SessionPilot)& pilot)
1352{
1353 Handle(IFSelect_WorkSession) WS = pilot->Session();
1354 Standard_Integer argc = pilot->NbWords();
1355 const Standard_CString arg1 = pilot->Arg(1);
1356// **** DispFiles ****
1357 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1358 if (argc < 2) { sout<<"Donner Nom Signature"<<endl; return IFSelect_RetError; }
1359 DeclareAndCast(IFSelect_Signature,sig,WS->NamedItem(arg1));
1360 if (sig.IsNull())
1361 { sout<<"Pas un nom de Signature : "<<arg1<<endl; return IFSelect_RetError; }
1362 Handle(IFSelect_DispPerSignature) disp = new IFSelect_DispPerSignature;
1363 disp->SetSignCounter (new IFSelect_SignCounter(sig));
1364 return pilot->RecordItem(disp);
1365}
1366
1367
1368static IFSelect_ReturnStatus fun56
1369 (const Handle(IFSelect_SessionPilot)& pilot)
1370{
1371 Handle(IFSelect_WorkSession) WS = pilot->Session();
1372 Standard_Integer argc = pilot->NbWords();
1373 const Standard_CString arg1 = pilot->Arg(1);
1374// **** Dispatch ****
1375 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1376 if (argc < 2) { sout<<"Donner Nom du Dispatch"<<endl; return IFSelect_RetError; }
1377 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1378 if (disp.IsNull()) { sout<<"Pas un dispatch : "<<arg1<<endl; return IFSelect_RetError; }
1379 Standard_Integer num = WS->DispatchRank(disp);
1380 sout<<"Dispatch de Nom : "<<arg1<<" , en ShareOut, Numero "<<num<<" : ";
1381 Handle(IFSelect_Selection) sel = WS->ItemSelection(disp);
1382 Handle(TCollection_HAsciiString) selname = WS->Name(sel);
1383 if (sel.IsNull()) sout<<"Pas de Selection Finale"<<endl;
1384 else if (selname.IsNull()) sout<<"Selection Finale : #"<<WS->ItemIdent(sel)<<endl;
1385 else sout<<"Selection Finale : "<<selname->ToCString()<<endl;
1386 if (disp->HasRootName()) sout<<"-- Racine nom de fichier : "
1387 <<disp->RootName()->ToCString()<<endl;
1388 return IFSelect_RetVoid;
1389}
1390
1391static IFSelect_ReturnStatus fun57
1392 (const Handle(IFSelect_SessionPilot)& pilot)
1393{
1394 Handle(IFSelect_WorkSession) WS = pilot->Session();
1395 Standard_Integer argc = pilot->NbWords();
1396 const Standard_CString arg1 = pilot->Arg(1);
1397// **** Remove ****
1398 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1399 if (argc < 2) { sout<<"Give Name to Remove !"<<endl; return IFSelect_RetError; }
1400 if (!WS->RemoveNamedItem(arg1)) return IFSelect_RetFail;
1401 return IFSelect_RetDone;
1402}
1403
1404static IFSelect_ReturnStatus fun58
1405 (const Handle(IFSelect_SessionPilot)& pilot)
1406{
1407 Handle(IFSelect_WorkSession) WS = pilot->Session();
1408 Standard_Integer argc = pilot->NbWords();
1409 const Standard_CString arg1 = pilot->Arg(1);
1410// **** EvalDisp ****
1411 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1412 if (argc < 3) { sout<<"evaldisp mode disp [disp ...] : Mode + Name(s) of Dispatch(es). Mode:\n"
1413 <<" 0 brief 1 +forgotten ents 2 +duplicata 3 1+2"<<endl
1414 <<"See also : evaladisp writedisp xsplit"<<endl;
1415 return IFSelect_RetVoid; }
1416 Standard_Boolean OK = Standard_True;
1417 Standard_Integer i , mode = atoi(arg1); sout<<" Mode "<<mode<<"\n";
1418 for (i = 2; i < argc; i ++) {
1419 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1420 if (disp.IsNull())
1421 { sout<<"Not a dispatch:"<<pilot->Arg(i)<<endl; OK = Standard_False; }
1422 }
1423 if (!OK) {
1424 sout<<"Some of the parameters are not correct"<<endl;
1425 return IFSelect_RetError;
1426 }
1427
1428 WS->ClearShareOut(Standard_True);
1429 for (i = 2; i < argc; i ++) {
1430 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1431 WS->SetActive(disp,Standard_True);
1432 }
1433// WS->EvaluateDispatch(disp,mode);
1434 WS->EvaluateComplete(mode);
1435 return IFSelect_RetVoid;
1436}
1437
1438
1439static IFSelect_ReturnStatus fun_evaladisp
1440 (const Handle(IFSelect_SessionPilot)& pilot)
1441{
1442 Handle(IFSelect_WorkSession) WS = pilot->Session();
1443 Standard_Integer argc = pilot->NbWords();
1444 const Standard_CString arg1 = pilot->Arg(1);
1445// **** EvalADisp [GiveList] ****
1446 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1447 if (argc < 3) { sout<<"evaladisp mode(=0-1-2-3) disp [givelist] : Mode + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch. Mode:\n"
1448 <<" 0 brief 1 +forgotten ents 2 +duplicata 3 1+2"<<endl
1449 <<"See also : writedisp"<<endl;
1450 return IFSelect_RetVoid; }
1451 if (arg1[1] != '\0') { sout<<"first parameter : mode, must be a number between 0 and 3"<<endl; return IFSelect_RetError; }
1452 Standard_Integer mode = atoi(arg1); sout<<" Mode "<<mode<<"\n";
1453// DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2)));
1454 Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True);
1455 if (disp.IsNull())
1456 { sout<<"Not a dispatch:"<<pilot->Arg(2)<<endl; return IFSelect_RetError; }
1457 Handle(IFSelect_Selection) selsav = disp->FinalSelection();
1458 Handle(IFSelect_Selection) sel;
1459 if (argc > 3) {
1460 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1461 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1462 (pilot->Session(),pilot->CommandPart(3));
1463 Standard_Integer nb = (list.IsNull() ? 0 : list->Length());
1464 if (nb > 0) { sp->AddList (list); sel = sp; }
1465 }
1466
1467 if (sel.IsNull() && selsav.IsNull())
1468 { sout<<"No Selection nor GiveList defined"<<endl; return IFSelect_RetError; }
1469 if (sel.IsNull() && !selsav.IsNull()) {
1470 if (argc > 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<<endl;
1471 sel = selsav;
1472 }
1473 disp->SetFinalSelection(sel);
1474// WS->ClearShareOut(Standard_True);
1475// WS->SetActive(disp,Standard_True);
1476 WS->EvaluateDispatch(disp,mode);
1477 disp->SetFinalSelection(selsav);
1478
1479 return IFSelect_RetVoid;
1480}
1481
1482static IFSelect_ReturnStatus fun_writedisp
1483 (const Handle(IFSelect_SessionPilot)& pilot)
1484{
1485 Handle(IFSelect_WorkSession) WS = pilot->Session();
1486 Standard_Integer argc = pilot->NbWords();
1487 const Standard_CString arg1 = pilot->Arg(1);
1488// **** EvalADisp [GiveList] ****
1489 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1490 if (argc < 3) { sout<<"writedisp filename disp [givelist] : FileName + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch.\n"
1491 <<"FileName : rootname.ext will gives rootname_1.ext etc...\n"
1492 <<" path/rootname.ext gives path/rootname_1.ext etc...\n"
1493 <<"See also : evaladisp"<<endl;
1494 return IFSelect_RetVoid; }
1495 TCollection_AsciiString prefix,rootname,suffix;
1496 SplitFileName (arg1,prefix,rootname,suffix);
1497 if (rootname.Length() == 0 || suffix.Length() == 0) {
1498 sout<<"Empty Root Name or Extension"<<endl;
1499 return IFSelect_RetError;
1500 }
1501
1502// DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2)));
1503 Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True);
1504 if (disp.IsNull())
1505 { sout<<"Not a dispatch:"<<pilot->Arg(2)<<endl; return IFSelect_RetError; }
1506 Handle(IFSelect_Selection) selsav = disp->FinalSelection();
1507 Handle(IFSelect_Selection) sel;
1508 if (argc > 3) {
1509 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1510 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1511 (pilot->Session(),pilot->CommandPart(3));
1512 Standard_Integer nb = (list.IsNull() ? 0 : list->Length());
1513 if (nb > 0) { sp->AddList (list); sel = sp; }
1514 }
1515
1516 if (sel.IsNull() && selsav.IsNull())
1517 { sout<<"No Selection nor GiveList defined"<<endl; return IFSelect_RetError; }
1518 if (sel.IsNull() && !selsav.IsNull()) {
1519 if (argc > 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<<endl;
1520 sel = selsav;
1521 }
1522
1523 WS->ClearShareOut(Standard_True);
1524 disp->SetFinalSelection(sel);
1525 WS->SetActive(disp,Standard_True);
1526 WS->BeginSentFiles(Standard_True);
1527
1528 WS->SetFilePrefix (prefix.ToCString());
1529 WS->SetFileExtension (suffix.ToCString());
1530 WS->SetFileRoot(disp,rootname.ToCString());
1531
1532 Standard_Boolean OK = WS->SendSplit();
1533 disp->SetFinalSelection(selsav);
1534 return (OK ? IFSelect_RetDone : IFSelect_RetFail);
1535}
1536
1537
1538static IFSelect_ReturnStatus fun59
1539 (const Handle(IFSelect_SessionPilot)& pilot)
1540{
1541 Handle(IFSelect_WorkSession) WS = pilot->Session();
1542 Standard_Integer argc = pilot->NbWords();
1543 const Standard_CString arg1 = pilot->Arg(1);
1544// **** EvalComplete ****
1545 Standard_Integer mode = 0;
1546 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1547 if (argc < 2) sout << " -- mode par defaut 0\n";
1548 else { mode = atoi(arg1); sout << " -- mode : " << mode << endl; }
1549 WS->EvaluateComplete(mode); return IFSelect_RetVoid;
1550}
1551
1552static IFSelect_ReturnStatus fun60
1553 (const Handle(IFSelect_SessionPilot)& pilot)
1554{
1555 Handle(IFSelect_WorkSession) WS = pilot->Session();
1556// **** LastRunCheckList ****
1557 Interface_CheckIterator chlist = WS->LastRunCheckList();
1558 Handle(IFSelect_CheckCounter) counter = new IFSelect_CheckCounter(0);
1559 counter->Analyse(chlist,WS->Model(),Standard_False);
1560 counter->PrintCount (Message::DefaultMessenger());
1561 return IFSelect_RetVoid;
1562}
1563
1564static IFSelect_ReturnStatus fun61
1565 (const Handle(IFSelect_SessionPilot)& pilot)
1566{
1567 Handle(IFSelect_WorkSession) WS = pilot->Session();
1568 Standard_Integer argc = pilot->NbWords();
1569 const Standard_CString arg1 = pilot->Arg(1);
1570// **** RunTransformer ****
1571 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1572 if (argc < 2) { sout<<"Donner Nom de Transformer"<<endl; return IFSelect_RetError; }
1573 DeclareAndCast(IFSelect_Transformer,tsf,WS->NamedItem(arg1));
1574 Standard_Integer effect = WS->RunTransformer(tsf);
1575 switch (effect) {
1576 case -4 : sout<<"Edition sur place, nouveau Protocole, erreur recalcul graphe"<<endl; break;
1577 case -3 : sout<<"Erreur, Transformation ignoree"<<endl; break;
1578 case -2 : sout<<"Erreur sur edition sur place, risque de corruption (verifier)"<<endl; break;
1579 case -1 : sout<<"Erreur sur edition locale, risque de corruption (verifier)"<<endl; break;
1580 case 0 :
1581 if (tsf.IsNull()) sout<<"Erreur, pas un Transformer: "<<arg1<<endl;
1582 else sout<<"Execution non faite"<<endl;
1583 break;
1584 case 1 : sout<<"Transformation locale (graphe non touche)"<<endl; break;
1585 case 2 : sout<<"Edition sur place (graphe recalcule)"<<endl; break;
1586 case 3 : sout<<"Modele reconstruit"<<endl; break;
1587 case 4 : sout<<"Edition sur place, nouveau Protocole"<<endl; break;
1588 case 5 : sout<<"Nouveau Modele avec nouveau Protocole"<<endl; break;
1589 default : break;
1590 }
1591 return ((effect > 0) ? IFSelect_RetDone : IFSelect_RetFail);
1592}
1593
1594static IFSelect_ReturnStatus fun62
1595 (const Handle(IFSelect_SessionPilot)& pilot)
1596{
1597 Handle(IFSelect_WorkSession) WS = pilot->Session();
1598// **** TransformStandard Copy ****
1599 return pilot->RecordItem(WS->NewTransformStandard(Standard_True));
1600}
1601
1602static IFSelect_ReturnStatus fun63
1603 (const Handle(IFSelect_SessionPilot)& pilot)
1604{
1605 Handle(IFSelect_WorkSession) WS = pilot->Session();
1606// **** TransformStandard OntheSpot ****
1607 return pilot->RecordItem(WS->NewTransformStandard(Standard_False));
1608}
1609
1610static IFSelect_ReturnStatus fun6465
1611 (const Handle(IFSelect_SessionPilot)& pilot)
1612{
1613 Handle(IFSelect_WorkSession) WS = pilot->Session();
1614 Standard_Integer argc = pilot->NbWords();
1615 const Standard_CString arg1 = pilot->Arg(1);
1616// **** Run Modifier avec Standard Copy ****
1617// **** Run Modifier avec OnTheSpot ****
1618 Standard_Boolean runcopy = (pilot->Arg(0)[3] == 'c');
1619// soit c est un nom, sinon c est une commande
1620 Handle(IFSelect_Modifier) modif;
1621 if (WS->NameIdent(arg1) > 0)
1622 modif = GetCasted(IFSelect_Modifier,WS->NamedItem(arg1));
1623 else {
1624 pilot->RemoveWord(0); // c etait la commande run
1625 pilot->Perform();
1626 modif = GetCasted(IFSelect_Modifier,pilot->RecordedItem());
1627 }
1628 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1629 if (modif.IsNull())
1630 { sout<<"Pas un nom de Modifier : "<<arg1<<endl; return IFSelect_RetError; }
1631
1632 Handle(TColStd_HSequenceOfTransient) list;
1633 Handle(IFSelect_SelectPointed) sp;
1634 if (argc > 2) {
1635 list = IFSelect_Functions::GiveList (WS,pilot->CommandPart(2));
1636 sp = new IFSelect_SelectPointed;
1637 sp->SetList (list);
1638 }
1639
1640 Standard_Integer effect = 0;
1641 effect = WS->RunModifierSelected (modif,sp,runcopy);
1642// sout<<"Modifier applique sur TransformStandard #"<<WS->ItemIdent(tsf)<<endl;
1643 switch (effect) {
1644 case -4 : sout<<"Edition sur place, nouveau Protocole, erreur recalcul graphe"<<endl; break;
1645 case -3 : sout<<"Erreur, Transformation ignoree"<<endl; break;
1646 case -2 : sout<<"Erreur sur edition sur place, risque de corruption (verifier)"<<endl; break;
1647 case -1 : sout<<"Erreur sur edition locale, risque de corruption (verifier)"<<endl; break;
1648 case 0 :
1649 if (modif.IsNull()) sout<<"Erreur, pas un Modifier: "<<arg1<<endl;
1650 else sout<<"Execution non faite"<<endl;
1651 break;
1652 case 1 : sout<<"Transformation locale (graphe non touche)"<<endl; break;
1653 case 2 : sout<<"Edition sur place (graphe recalcule)"<<endl; break;
1654 case 3 : sout<<"Modele reconstruit"<<endl; break;
1655 case 4 : sout<<"Edition sur place, nouveau Protocole"<<endl; break;
1656 case 5 : sout<<"Nouveau Modele avec nouveau Protocole"<<endl; break;
1657 default : break;
1658 }
1659 return ((effect > 0) ? IFSelect_RetDone : IFSelect_RetFail);
1660}
1661
1662static IFSelect_ReturnStatus fun66
1663 (const Handle(IFSelect_SessionPilot)& pilot)
1664{
1665// **** (xset) ModifReorder ****
1666 char opt = ' ';
1667 Standard_Integer argc = pilot->NbWords();
1668 if (argc >= 2) opt = pilot->Word(1).Value(1);
1669 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1670 if (opt != 'f' && opt != 'l')
1671 { sout<<"Donner option : f -> root-first l -> root-last"<<endl; return IFSelect_RetError; }
1672 return pilot->RecordItem(new IFSelect_ModifReorder(opt == 'l'));
1673}
1674
1675static IFSelect_ReturnStatus fun70
1676 (const Handle(IFSelect_SessionPilot)& pilot)
1677{
1678 Handle(IFSelect_WorkSession) WS = pilot->Session();
1679 Standard_Integer argc = pilot->NbWords();
1680 const Standard_CString arg1 = pilot->Arg(1);
1681// **** SelToggle ****
1682 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1683 if (argc < 2) { sout<<"Donner Nom de Selection"<<endl; return IFSelect_RetError; }
1684 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1685 if (!WS->ToggleSelectExtract(sel))
1686 { sout<<"Pas une SelectExtract : "<<arg1<<endl; return IFSelect_RetFail; }
1687 if (WS->IsReversedSelectExtract(sel)) sout<<arg1<<" a present Reversed"<<endl;
1688 else sout<<arg1<<" a present Directe"<<endl;
1689 return IFSelect_RetDone;
1690}
1691
1692static IFSelect_ReturnStatus fun71
1693 (const Handle(IFSelect_SessionPilot)& pilot)
1694{
1695 Handle(IFSelect_WorkSession) WS = pilot->Session();
1696 Standard_Integer argc = pilot->NbWords();
1697 const Standard_CString arg1 = pilot->Arg(1);
1698 const Standard_CString arg2 = pilot->Arg(2);
1699// **** SelInput ****
1700 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1701 if (argc < 3) { sout<<"Donner Noms Selections cible et input"<<endl; return IFSelect_RetError; }
1702 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1703 DeclareAndCast(IFSelect_Selection,sou,WS->NamedItem(arg2));
1704 if (sel.IsNull() || sou.IsNull())
1705 { sout<<"Incorrect : "<<arg1<<","<<arg2<<endl; return IFSelect_RetError; }
1706 if (!WS->SetInputSelection(sel,sou)) {
1707 sout<<"Nom incorrect ou Selection "<<arg1<<" ni Extract ni Deduct"<<endl;
1708 return IFSelect_RetFail;
1709 }
1710 return IFSelect_RetDone;
1711}
1712
1713static IFSelect_ReturnStatus fun72
1714 (const Handle(IFSelect_SessionPilot)& pilot)
1715{
1716 Handle(IFSelect_WorkSession) WS = pilot->Session();
1717// **** SelModelRoots ****
1718 return pilot->RecordItem (new IFSelect_SelectModelRoots);
1719}
1720
1721static IFSelect_ReturnStatus fun73
1722 (const Handle(IFSelect_SessionPilot)& pilot)
1723{
1724 Handle(IFSelect_WorkSession) WS = pilot->Session();
1725 Standard_Integer argc = pilot->NbWords();
1726 const Standard_CString arg1 = pilot->Arg(1);
1727 const Standard_CString arg2 = pilot->Arg(2);
1728// **** SelRange ****
1729 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1730 if (argc >= 2 && arg1[0] == '?') argc = 1;
1731 if (argc < 2) {
1732 sout<<"Donner la description du SelectRange"
1733 <<" Formes admises :\n <n1> <n2> : Range de <n1> a <n2>\n"
1734 <<" <n1> tout seul : Range n0 <n1>\n from <n1> : Range From <n1>\n"
1735 <<" until <n2> : Range Until <n2>"<<endl;
1736 return IFSelect_RetVoid;
1737 }
1738
1739 Handle(IFSelect_IntParam) low,up;
1740 Handle(IFSelect_SelectRange) sel;
1741// Range From
1742 if (pilot->Word(1).IsEqual("from")) {
1743 if (argc < 3) { sout<<"Forme admise : from <i>"<<endl; return IFSelect_RetError; }
1744 low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1745 sel = new IFSelect_SelectRange;
1746 sel->SetFrom (low);
1747// Range Until
1748 } else if (pilot->Word(1).IsEqual("until")) {
1749 if (argc < 3) { sout<<"Forme admise : until <i>"<<endl; return IFSelect_RetError; }
1750 up = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1751 sel = new IFSelect_SelectRange;
1752 sel->SetUntil (up);
1753// Range One (n-th)
1754 } else if (argc < 3) {
1755 low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1));
1756 sel = new IFSelect_SelectRange;
1757 sel->SetOne (low);
1758// Range (from-to)
1759 } else {
1760 low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1));
1761 up = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1762 sel = new IFSelect_SelectRange;
1763 sel->SetRange (low,up);
1764 }
1765 return pilot->RecordItem (sel);
1766}
1767
1768static IFSelect_ReturnStatus fun74
1769 (const Handle(IFSelect_SessionPilot)& pilot)
1770{
1771 Handle(IFSelect_WorkSession) WS = pilot->Session();
1772// **** SelRoots ****
1773 return pilot->RecordItem (new IFSelect_SelectRoots);
1774}
1775
1776static IFSelect_ReturnStatus fun75
1777 (const Handle(IFSelect_SessionPilot)& pilot)
1778{
1779 Handle(IFSelect_WorkSession) WS = pilot->Session();
1780// **** SelShared ****
1781 return pilot->RecordItem (new IFSelect_SelectShared);
1782}
1783
1784static IFSelect_ReturnStatus fun76
1785 (const Handle(IFSelect_SessionPilot)& pilot)
1786{
1787 Handle(IFSelect_WorkSession) WS = pilot->Session();
1788 Standard_Integer argc = pilot->NbWords();
1789 const Standard_CString arg1 = pilot->Arg(1);
1790 const Standard_CString arg2 = pilot->Arg(2);
1791// **** SelDiff ****
1792 Handle(IFSelect_Selection) sel = new IFSelect_SelectDiff;
1793 if (sel.IsNull()) return IFSelect_RetFail;
1794 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1795 if (argc < 3) sout<<"Diff sans input : ne pas oublier de les definir (ctlmain, ctlsec)!"<<endl;
1796 DeclareAndCast(IFSelect_Selection,selmain,WS->NamedItem(arg1));
1797 DeclareAndCast(IFSelect_Selection,selsec ,WS->NamedItem(arg2));
1798 if (argc >= 2)
1799 if (!WS->SetControl(sel,selmain,Standard_True))
1800 sout<<"Echec ControlMain:"<<arg1<<" , a refaire (ctlmain)"<<endl;
1801 if (argc >= 3)
1802 if (!WS->SetControl(sel,selsec,Standard_False))
1803 sout<<"Echec ControlSecond:"<<arg2<<" , a refaire (ctlsec)"<<endl;
1804 return pilot->RecordItem (sel);
1805}
1806
1807static IFSelect_ReturnStatus fun77
1808 (const Handle(IFSelect_SessionPilot)& pilot)
1809{
1810 Handle(IFSelect_WorkSession) WS = pilot->Session();
1811 Standard_Integer argc = pilot->NbWords();
1812 const Standard_CString arg1 = pilot->Arg(1);
1813 const Standard_CString arg2 = pilot->Arg(2);
1814// **** SelControlMain ****
1815 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1816 if (argc < 3) { sout<<"Donner Noms de Control et MainInput"<<endl; return IFSelect_RetError; }
1817 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1818 DeclareAndCast(IFSelect_Selection,selmain,WS->NamedItem(arg2));
1819 if (WS->SetControl(sel,selmain,Standard_True)) return IFSelect_RetDone;
1820 sout<<"Nom incorrect ou Selection "<<arg1<<" pas de type Control"<<endl;
1821 return IFSelect_RetFail;
1822}
1823
1824static IFSelect_ReturnStatus fun78
1825 (const Handle(IFSelect_SessionPilot)& pilot)
1826{
1827 Handle(IFSelect_WorkSession) WS = pilot->Session();
1828 Standard_Integer argc = pilot->NbWords();
1829 const Standard_CString arg1 = pilot->Arg(1);
1830 const Standard_CString arg2 = pilot->Arg(2);
1831// **** SelControlSecond ****
1832 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1833 if (argc < 3) { sout<<"Donner Noms de Control et SecondInput"<<endl; return IFSelect_RetError; }
1834 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1835 DeclareAndCast(IFSelect_Selection,seldif,WS->NamedItem(arg2));
1836 if (WS->SetControl(sel,seldif,Standard_False)) return IFSelect_RetDone;
1837 sout<<"Nom incorrect ou Selection "<<arg1<<" pas de type Control"<<endl;
1838 return IFSelect_RetFail;
1839}
1840
1841static IFSelect_ReturnStatus fun79
1842 (const Handle(IFSelect_SessionPilot)& pilot)
1843{
1844 Handle(IFSelect_WorkSession) WS = pilot->Session();
1845// **** SelModelAll ****
1846 return pilot->RecordItem (new IFSelect_SelectModelEntities);
1847}
1848
1849static IFSelect_ReturnStatus fun80
1850 (const Handle(IFSelect_SessionPilot)& pilot)
1851{
1852 Handle(IFSelect_WorkSession) WS = pilot->Session();
1853 Standard_Integer argc = pilot->NbWords();
1854 const Standard_CString arg1 = pilot->Arg(1);
1855 const Standard_CString arg2 = pilot->Arg(2);
1856// **** SelCombAdd ****
1857 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1858 if (argc < 3) { sout<<"Donner n0 Combine et une Input"<<endl; return IFSelect_RetError; }
1859 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1860 DeclareAndCast(IFSelect_Selection,seladd,WS->NamedItem(arg2));
1861 if (WS->CombineAdd(sel,seladd)) return IFSelect_RetDone;
1862 sout<<"Nom incorrect ou Selection "<<arg1<<" pas Combine"<<endl;
1863 return IFSelect_RetFail;
1864}
1865
1866static IFSelect_ReturnStatus fun81
1867 (const Handle(IFSelect_SessionPilot)& pilot)
1868{
1869 Handle(IFSelect_WorkSession) WS = pilot->Session();
1870 Standard_Integer argc = pilot->NbWords();
1871 const Standard_CString arg1 = pilot->Arg(1);
1872 const Standard_CString arg2 = pilot->Arg(2);
1873// **** SelCombRem ****
1874 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1875 if (argc < 3) { sout<<"Donner n0 Combine et RANG a supprimer"<<endl; return IFSelect_RetError; }
1876 DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1877 DeclareAndCast(IFSelect_Selection,inp,WS->NamedItem(arg2));
1878 if (WS->CombineRemove(sel,inp)) return IFSelect_RetDone;
1879 sout<<"Nom incorrect ou Selection "<<arg1<<" ni Union ni Intersection"<<endl;
1880 return IFSelect_RetFail;
1881}
1882
1883static IFSelect_ReturnStatus fun82
1884 (const Handle(IFSelect_SessionPilot)& pilot)
1885{
1886 Handle(IFSelect_WorkSession) WS = pilot->Session();
1887 Standard_Integer argc = pilot->NbWords();
1888 const Standard_CString arg1 = pilot->Arg(1);
1889// **** SelEntNumber ****
1890 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1891 if (argc < 2) { sout<<"Donner Nom IntParam pour n0 Entite"<<endl; return IFSelect_RetError; }
1892 DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1893 Handle(IFSelect_SelectEntityNumber) sel = new IFSelect_SelectEntityNumber;
1894 sel->SetNumber(par);
1895 return pilot->RecordItem (sel);
1896}
1897
1898static IFSelect_ReturnStatus fun83
1899 (const Handle(IFSelect_SessionPilot)& pilot)
1900{
1901 Handle(IFSelect_WorkSession) WS = pilot->Session();
1902// **** SelUnion ****
1903 return pilot->RecordItem (new IFSelect_SelectUnion);
1904}
1905
1906static IFSelect_ReturnStatus fun84
1907 (const Handle(IFSelect_SessionPilot)& pilot)
1908{
1909 Handle(IFSelect_WorkSession) WS = pilot->Session();
1910// **** SelIntersection ****
1911 return pilot->RecordItem (new IFSelect_SelectIntersection);
1912}
1913
1914static IFSelect_ReturnStatus fun85
1915 (const Handle(IFSelect_SessionPilot)& pilot)
1916{
1917 Standard_Integer argc = pilot->NbWords();
1918 const Standard_CString arg1 = pilot->Arg(1);
1919// **** SelTextType Exact ****
1920 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1921 if (argc < 2) { sout<<"Donner le TYPE a selectionner"<<endl; return IFSelect_RetError; }
1922 return pilot->RecordItem (new IFSelect_SelectSignature
1923 (new IFSelect_SignType,arg1,Standard_True));
1924}
1925
1926static IFSelect_ReturnStatus fun86
1927 (const Handle(IFSelect_SessionPilot)& pilot)
1928{
1929// **** SelErrorEntities ****
1930 return pilot->RecordItem (new IFSelect_SelectErrorEntities);
1931}
1932
1933static IFSelect_ReturnStatus fun87
1934 (const Handle(IFSelect_SessionPilot)& pilot)
1935{
1936// **** SelUnknownEntities **
1937 return pilot->RecordItem (new IFSelect_SelectUnknownEntities);
1938}
1939
1940static IFSelect_ReturnStatus fun88
1941 (const Handle(IFSelect_SessionPilot)& pilot)
1942{
1943// **** SelSharing ****
1944 return pilot->RecordItem (new IFSelect_SelectSharing);
1945}
1946
1947static IFSelect_ReturnStatus fun89
1948 (const Handle(IFSelect_SessionPilot)& pilot)
1949{
1950 Standard_Integer argc = pilot->NbWords();
1951 const Standard_CString arg1 = pilot->Arg(1);
1952// **** SelTextType Contain **
1953 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1954 if (argc < 2) { sout<<"Donner le TYPE a selectionner"<<endl; return IFSelect_RetError; }
1955 return pilot->RecordItem (new IFSelect_SelectSignature
1956 (new IFSelect_SignType,arg1,Standard_False));
1957}
1958
1959static IFSelect_ReturnStatus fun90
1960 (const Handle(IFSelect_SessionPilot)& pilot)
1961{
1962// **** SelPointed ****
1963 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1964 if (pilot->NbWords() > 1) {
1965 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1966 (pilot->Session(),pilot->CommandPart(1));
1967 if (list.IsNull()) return IFSelect_RetFail;
1968 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1969 sout<<"SelectPointed : "<<list->Length()<<" entities"<<endl;
1970 sp->AddList (list);
1971 }
1972 return pilot->RecordItem (sp);
1973}
1974
1975static IFSelect_ReturnStatus fun91
1976 (const Handle(IFSelect_SessionPilot)& pilot)
1977{
1978 Handle(IFSelect_WorkSession) WS = pilot->Session();
1979 Standard_Integer argc = pilot->NbWords();
1980 const Standard_CString arg1 = pilot->Arg(1);
1981// **** SetPointed (edit) / SetList (edit) ****
1982 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1983 if (argc < 2) {
1984 sout<<"Donner NOM SelectPointed + Option(s) :\n"
1985 <<" aucune : liste des entites pointees\n"
1986 <<" 0: Clear +nn ajout entite nn -nn enleve nn /nn toggle nn"<<endl;
1987 return IFSelect_RetError;
1988 }
1989 DeclareAndCast(IFSelect_SelectPointed,sp,WS->NamedItem(arg1));
1990 if (sp.IsNull()) { sout<<"Pas une SelectPointed:"<<arg1<<endl; return IFSelect_RetError; }
1991 Handle(Interface_InterfaceModel) model = WS->Model(); // pour Print
1992 if (argc == 2) { // listage simple
1993 Standard_Integer nb = sp->NbItems();
1994 sout<<" SelectPointed : "<<arg1<<" : "<<nb<<" Items :"<<endl;
1995 for (Standard_Integer i = 1; i <= nb; i ++) {
1996 Handle(Standard_Transient) pointed = sp->Item(i);
1997 Standard_Integer id = WS->StartingNumber(pointed);
1998 if (id == 0) sout <<" (inconnu)";
1999 else { sout<<" "; model->Print(pointed,sout); }
2000 }
2001 if (nb > 0) sout<<endl;
2002 return IFSelect_RetDone;
2003 }
2004
2005 for (Standard_Integer ia = 2; ia < argc ; ia ++) {
2006 const TCollection_AsciiString argi = pilot->Word(ia);
2007 Standard_Integer id = pilot->Number(&(argi.ToCString())[1]);
2008 if (id == 0) {
2009 if (!argi.IsEqual("0")) sout<<"Incorrect,ignore:"<<argi<<endl;
2010 else { sout<<"Clear SelectPointed"<<endl; sp->Clear(); }
2011 } else if (argi.Value(1) == '-') {
2012 Handle(Standard_Transient) item = WS->StartingEntity(id);
2013 if (sp->Remove(item)) sout<<"Removed:no."<<id;
2014 else sout<<" Echec Remove "<<id;
2015 sout<<": "; model->Print(item,sout); sout<<endl;
2016 } else if (argi.Value(1) == '/') {
2017 Handle(Standard_Transient) item = WS->StartingEntity(id);
2018 if (sp->Remove(item)) sout<<"Toggled:n0."<<id;
2019 else sout<<" Echec Toggle "<<id;
2020 sout<<": "; model->Print(item,sout); sout<<endl;
2021 } else if (argi.Value(1) == '+') {
2022 Handle(Standard_Transient) item = WS->StartingEntity(id);
2023 if (sp->Add(item)) sout<<"Added:no."<<id;
2024 else sout<<" Echec Add "<<id;
2025 sout<<": "; model->Print(item,sout); sout<<endl;
2026 } else {
2027 sout<<"Ignore:"<<argi<<" , donner n0 PRECEDE de + ou - ou /"<<endl;
2028 }
2029 }
2030 return IFSelect_RetDone;
2031}
2032
2033static IFSelect_ReturnStatus fun92
2034 (const Handle(IFSelect_SessionPilot)& pilot)
2035{
2036 Handle(IFSelect_WorkSession) WS = pilot->Session();
2037// **** SelIncorrectEntities ****
2038 WS->ComputeCheck();
2039 return pilot->RecordItem (new IFSelect_SelectIncorrectEntities);
2040}
2041
2042static IFSelect_ReturnStatus fun93
2043 (const Handle(IFSelect_SessionPilot)& pilot)
2044{
2045 Standard_Integer argc = pilot->NbWords();
2046 const Standard_CString arg1 = pilot->Arg(1);
2047 const Standard_CString arg2 = pilot->Arg(2);
2048 Handle(IFSelect_WorkSession) WS = pilot->Session();
2049// **** SelSignature ****
2050 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2051 if (argc < 3) { sout<<"Give name of Signature or Counter, text + option exact(D) else contains"<<endl; return IFSelect_RetError; }
2052 Standard_Boolean exact = Standard_True;
2053 if (argc > 3) { if (pilot->Arg(3)[0] == 'c') exact = Standard_False; }
2054
2055 DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
2056 DeclareAndCast(IFSelect_SignCounter,cnt,WS->NamedItem(arg1));
2057 Handle(IFSelect_SelectSignature) sel;
2058
2059 if (!sign.IsNull()) sel = new IFSelect_SelectSignature (sign,arg2,exact);
2060 else if (!cnt.IsNull()) sel = new IFSelect_SelectSignature (cnt,arg2,exact);
2061 else { sout<<arg1<<":neither Signature nor Counter"<<endl; return IFSelect_RetError; }
2062
2063 return pilot->RecordItem(sel);
2064}
2065
2066static IFSelect_ReturnStatus fun94
2067 (const Handle(IFSelect_SessionPilot)& pilot)
2068{
2069 Standard_Integer argc = pilot->NbWords();
2070 const Standard_CString arg1 = pilot->Arg(1);
2071 Handle(IFSelect_WorkSession) WS = pilot->Session();
2072// **** SignCounter ****
2073 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2074 if (argc < 2) { sout<<"Donner nom signature"<<endl; return IFSelect_RetError; }
2075 DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
2076 if (sign.IsNull()) { sout<<arg1<<":pas une signature"<<endl; return IFSelect_RetError; }
2077 Handle(IFSelect_SignCounter) cnt = new IFSelect_SignCounter (sign,Standard_True,Standard_True);
2078 return pilot->RecordItem(cnt);
2079}
2080
2081static IFSelect_ReturnStatus funbselected
2082 (const Handle(IFSelect_SessionPilot)& pilot)
2083{
2084 Standard_Integer argc = pilot->NbWords();
2085 const Standard_CString arg1 = pilot->Arg(1);
2086 Handle(IFSelect_WorkSession) WS = pilot->Session();
2087// **** NbSelected = GraphCounter ****
2088 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2089 if (argc < 2) { sout<<"Donner nom selection (deduction) a appliquer"<<endl; return IFSelect_RetError; }
2090 DeclareAndCast(IFSelect_SelectDeduct,applied,WS->GiveSelection(arg1));
2091 if (applied.IsNull()) { sout<<arg1<<":pas une SelectDeduct"<<endl; return IFSelect_RetError; }
2092 Handle(IFSelect_GraphCounter) cnt = new IFSelect_GraphCounter (Standard_True,Standard_True);
2093 cnt->SetApplied (applied);
2094 return pilot->RecordItem(cnt);
2095}
2096
2097// #########################################
2098// #### EDITOR - EDITFORM ####
2099// #########################################
2100
2101static IFSelect_ReturnStatus fun_editlist
2102 (const Handle(IFSelect_SessionPilot)& pilot)
2103{
2104 Standard_Integer argc = pilot->NbWords();
2105 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2106 if (argc < 2) { sout<<"Give the name of an EditForm or an Editor"<<endl;
2107 return IFSelect_RetError; }
2108 const Standard_CString arg1 = pilot->Arg(1);
2109 const Standard_CString arg2 = pilot->Arg(2);
2110 Handle(IFSelect_WorkSession) WS = pilot->Session();
2111
2112// EditForm
2113
2114 DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2115 Handle(IFSelect_Editor) edt;
2116 if (!edf.IsNull()) {
2117 sout<<"Print EditForm "<<arg1<<endl;
2118 edt = edf->Editor();
2119 if (argc < 3) {
2120
2121// DEFINITIONS : Editor (direct ou via EditForm)
2122
2123 if (edt.IsNull()) edt = GetCasted(IFSelect_Editor,WS->NamedItem(arg1));
2124 if (edt.IsNull()) return IFSelect_RetVoid;
2125
2126 sout<<"Editor, Label : "<<edt->Label()<<endl;
2127 sout<<endl<<" -- Names (short - complete) + Labels of Values"<<endl;
2128 edt->PrintNames(sout);
2129 sout<<endl<<" -- Definitions --"<<endl;
2130 edt->PrintDefs (sout);
2131 if (!edf.IsNull()) {
2132 edf->PrintDefs(sout);
2133 sout<<endl<<"To display values, add an option : o original f final m modified"<<endl;
2134 }
2135
2136 return IFSelect_RetVoid;
2137
2138 } else {
2139 char opt = arg2[0];
2140 Standard_Integer what = 0;
2141 if (opt == 'o') what = -1;
2142 else if (opt == 'f') what = 1;
2143
2144 edf->PrintValues (sout,what,Standard_False);
2145 }
2146 }
2147
2148 return IFSelect_RetVoid;
2149}
2150
2151static IFSelect_ReturnStatus fun_editvalue
2152 (const Handle(IFSelect_SessionPilot)& pilot)
2153{
2154 Standard_Integer argc = pilot->NbWords();
2155 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2156 if (argc < 3) { sout<<"Give the name of an EditForm + name of Value [+ newvalue or . to nullify]"<<endl;
2157 return IFSelect_RetError; }
2158 const Standard_CString arg1 = pilot->Arg(1);
2159 const Standard_CString arg2 = pilot->Arg(2);
2160 Handle(IFSelect_WorkSession) WS = pilot->Session();
2161 DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2162 if (edf.IsNull())
2163 { sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError; }
2164 Standard_Integer num = edf->NameNumber (arg2);
2165 if (num == 0) sout<<"Unknown Value Name : "<<arg2<<endl;
2166 if (num < 0) sout<<"Not Extracted Value Name : "<<arg2<<endl;
2167 if (num <= 0) return IFSelect_RetError;
2168
2169 Standard_Boolean islist = edf->Editor()->IsList(num);
2170 Standard_CString name = edf->Editor()->Name(num,Standard_True); // vrai nom
2171 Handle(TColStd_HSequenceOfHAsciiString) listr;
2172 Handle(TCollection_HAsciiString) str;
2173 sout<<"Value Name : "<<name<<(edf->IsModified(num) ? "(already edited) : " : " : ");
2174
2175 if (islist) {
2176 listr = edf->EditedList(num);
2177 if (listr.IsNull()) sout<<"(NULL LIST)"<<endl;
2178 else {
2179 Standard_Integer ilist,nblist = listr->Length();
2180 sout<<"(List : "<<nblist<<" Items)"<<endl;
2181 for (ilist = 1; ilist <= nblist; ilist ++) {
2182 str = listr->Value(ilist);
2183 sout<<" ["<<ilist<<"] "<< (str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2184 }
2185 }
2186 if (argc < 4) sout<<"To Edit, options by editval edit-form value-name ?"<<endl;
2187 } else {
2188 str = edf->EditedValue (num);
2189 sout<<(str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2190 }
2191 if (argc < 4) return IFSelect_RetVoid;
2192
2193// Valeur simple ou liste ?
2194 Standard_Integer numarg = 3;
2195 str.Nullify();
2196
2197 const Standard_CString argval = pilot->Arg(numarg);
2198 if (islist) {
2199 if (argval[0] == '?') {
2200 sout<<"To Edit, options"<<endl<<" + val : add value at end (blanks allowed)"
2201 <<endl<<" +nn text : insert val before item nn"<<endl
2202 <<" nn text : replace item nn with a new value"<<endl
2203 <<" -nn : remove item nn"<<endl<<" . : clear the list"<<endl;
2204 return IFSelect_RetVoid;
2205 }
2206 Standard_Boolean stated = Standard_False;
2207 Handle(IFSelect_ListEditor) listed = edf->ListEditor (num);
2208 if (listed.IsNull()) return IFSelect_RetError;
2209 if (argval[0] == '.') { listr.Nullify(); stated = listed->LoadEdited(listr); }
2210 else if (argval[0] == '+') {
2211 Standard_Integer numadd = 0;
2212 if (argval[1] != '\0') numadd = atoi(argval);
2213 stated = listed->AddValue (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numadd);
2214 }
2215 else if (argval[0] == '-') {
2216 Standard_Integer numrem = atoi(argval);
2217 stated = listed->Remove(numrem);
2218 }
2219 else {
2220 Standard_Integer numset = atoi(argval);
2221 if (numset > 0) stated = listed->AddValue
2222 (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numset);
2223 }
2224 if (stated) stated = edf->ModifyList (num,listed,Standard_True);
2225 if (stated) sout<<"List Edition done"<<endl;
2226 else sout<<"List Edition not done, option"<<argval<<endl;
2227 } else {
2228 if (argval[0] == '.' && argval[1] == '\0') str.Nullify();
2229 else str = new TCollection_HAsciiString (pilot->CommandPart(numarg));
2230 if (edf->Modify (num,str,Standard_True)) {
2231 sout<<"Now set to "<<(str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2232 } else {
2233 sout<<"Modify not done"<<endl; return IFSelect_RetFail;
2234 }
2235 }
2236 return IFSelect_RetDone;
2237}
2238
2239static IFSelect_ReturnStatus fun_editclear
2240 (const Handle(IFSelect_SessionPilot)& pilot)
2241{
2242 Standard_Integer argc = pilot->NbWords();
2243 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2244 if (argc < 2) { sout<<"Give the name of an EditForm [+ name of Value else all]"<<endl;
2245 return IFSelect_RetError; }
2246 const Standard_CString arg1 = pilot->Arg(1);
2247 const Standard_CString arg2 = pilot->Arg(2);
2248 Handle(IFSelect_WorkSession) WS = pilot->Session();
2249 DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2250 if (edf.IsNull())
2251 { sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError; }
2252 if (argc < 3) { edf->ClearEdit(); sout<<"All Modifications Cleared"<<endl; }
2253 else {
2254 Standard_Integer num = edf->NameNumber (arg2);
2255 if (num == 0) sout<<"Unknown Value Name : "<<arg2<<endl;
2256 if (num < 0) sout<<"Not Extracted Value Name : "<<arg2<<endl;
2257 if (num <= 0) return IFSelect_RetError;
2258 if (!edf->IsModified(num))
2259 { sout<<"Value "<<arg2<<" was not modified"<<endl; return IFSelect_RetVoid; }
2260 edf->ClearEdit (num);
2261 sout<<"Modification on Value "<<arg2<<" Cleared"<<endl;
2262 }
2263 return IFSelect_RetDone;
2264}
2265
2266static IFSelect_ReturnStatus fun_editapply
2267 (const Handle(IFSelect_SessionPilot)& pilot)
2268{
2269 Standard_Integer argc = pilot->NbWords();
2270 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2271 if (argc < 2) { sout<<"Give the name of an EditForm [+ option keep to re-apply edited values]"<<endl;
2272 return IFSelect_RetError; }
2273 const Standard_CString arg1 = pilot->Arg(1);
2274 const Standard_CString arg2 = pilot->Arg(2);
2275 Handle(IFSelect_WorkSession) WS = pilot->Session();
2276 DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2277 if (edf.IsNull())
2278 { sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError; }
2279
2280 Handle(Standard_Transient) ent = edf->Entity();
2281 Handle(Interface_InterfaceModel) model = edf->Model();
2282 if (!model.IsNull()) {
2283 if (ent.IsNull()) sout<<"Applying modifications on loaded model"<<endl;
2284 else {
2285 sout<<"Applying modifications on loaded entity : ";
2286 model->PrintLabel (ent,sout);
2287 }
2288 }
2289 else sout<<"Applying modifications"<<endl;
2290
2291 if (!edf->ApplyData (edf->Entity(),edf->Model())) {
2292 sout<<"Modifications could not be applied"<<endl;
2293 return IFSelect_RetFail;
2294 }
2295 sout<<"Modifications have been applied"<<endl;
2296
2297 Standard_Boolean stat = Standard_True;
2298 if (argc > 2 && arg2[0] == 'k') stat = Standard_False;
2299 if (stat) {
2300 edf->ClearEdit();
2301 sout<<"Edited values are cleared"<<endl;
2302 }
2303 else sout<<"Edited values are kept for another loading/applying"<<endl;
2304
2305 return IFSelect_RetDone;
2306}
2307
2308static IFSelect_ReturnStatus fun_editload
2309 (const Handle(IFSelect_SessionPilot)& pilot)
2310{
2311 Standard_Integer argc = pilot->NbWords();
2312 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2313 if (argc < 2) { sout<<"Give the name of an EditForm [+ Entity-Ident]"<<endl;
2314 return IFSelect_RetError; }
2315 const Standard_CString arg1 = pilot->Arg(1);
2316 const Standard_CString arg2 = pilot->Arg(2);
2317 Handle(IFSelect_WorkSession) WS = pilot->Session();
2318 DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2319 if (edf.IsNull())
2320 { sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError; }
2321
2322 Standard_Integer num = (argc < 3 ? 0 : pilot->Number (arg2));
2323 Standard_Boolean stat = Standard_False;
2324 if (argc < 3) {
2325 sout<<"EditForm "<<arg1<<" : Loading Model"<<endl;
2326 stat = edf->LoadModel(WS->Model());
2327 } else if (num <= 0) {
2328 sout<<"Not an entity ident : "<<arg2<<endl;
2329 return IFSelect_RetError;
2330 } else {
2331 sout<<"EditForm "<<arg1<<" : Loading Entity "<<arg2<<endl;
2332 stat = edf->LoadData (WS->StartingEntity(num),WS->Model());
2333 }
2334
2335 if (!stat) {
2336 sout<<"Loading not done"<<endl;
2337 return IFSelect_RetFail;
2338 }
2339 sout<<"Loading done"<<endl;
2340 return IFSelect_RetDone;
2341}
2342
2343// #########################################
2344// #### FONCTIONS COMPLEMENTAIRES ####
2345// #########################################
2346
2347 Handle(Standard_Transient) IFSelect_Functions::GiveEntity
2348 (const Handle(IFSelect_WorkSession)& WS,
2349 const Standard_CString name)
2350{
2351 Handle(Standard_Transient) ent; // demarre a Null
2352 Standard_Integer num = GiveEntityNumber(WS,name);
2353 if (num > 0) ent = WS->StartingEntity(num);
2354 return ent;
2355}
2356
2357 Standard_Integer IFSelect_Functions::GiveEntityNumber
2358 (const Handle(IFSelect_WorkSession)& WS,
2359 const Standard_CString name)
2360{
2361 Standard_Integer num = 0;
2362 if (!name || name[0] == '\0') {
2363 char ligne[80]; ligne[0] = '\0';
2364 cin >> ligne;
2365// cin.clear(); cin.getline (ligne,79);
2366 if (ligne[0] == '\0') return 0;
2367 num = WS->NumberFromLabel (ligne);
2368 }
2369 else num = WS->NumberFromLabel (name);
2370 return num;
2371}
2372
2373 Handle(TColStd_HSequenceOfTransient) IFSelect_Functions::GiveList
2374 (const Handle(IFSelect_WorkSession)& WS,
2375 const Standard_CString first, const Standard_CString second)
2376{
2377 return WS->GiveList (first,second);
2378}
2379
2380
2381// Function which returns an EVALUATED DISPATCH
2382// (could be added in WorkSession.cdl ...)
2383// Two modes : returns dispatch as it is, or return with edition
2384// Dispatch Name can be : an immediate name of already recorded Dispatch
2385// Or a name of dispatch + a parameter : dispatch-name(param-value)
2386// According to type of Dispatch : integer , signature name
2387
2388Handle(IFSelect_Dispatch) IFSelect_Functions::GiveDispatch
2389 (const Handle(IFSelect_WorkSession)& WS,
2390 const Standard_CString name, const Standard_Boolean mode)
2391{
2392 DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(name));
2393 if (!disp.IsNull()) return disp; // OK as it is given
2394
2395// Else, let s try special cases
2396 TCollection_AsciiString nam(name);
2397 Standard_Integer paro = nam.Location(1,'(',1,nam.Length());
2398 Standard_Integer parf = nam.Location(1,')',1,nam.Length());
2399 nam.SetValue(paro,'\0'); nam.SetValue(parf,'\0');
2400 if (paro <= 0 &&parf <= 0) return disp;
2401 disp = GetCasted(IFSelect_Dispatch,WS->NamedItem(nam.ToCString()));
2402 if (disp.IsNull()) return disp; // KO anyway
2403
2404// According to the type of dispatch :
2405 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2406 DeclareAndCast(IFSelect_DispPerCount,dc,disp);
2407 if (!dc.IsNull()) {
2408 Standard_Integer nb = atoi( &(nam.ToCString())[paro]);
2409 if (nb <= 0) {
2410 sout<<" DispPerCount, count is not positive"<<endl;
2411 disp.Nullify();
2412 return disp;
2413 }
2414 if (mode) {
2415 Handle(IFSelect_IntParam) val = new IFSelect_IntParam;
2416 val->SetValue(nb);
2417 dc->SetCount (val);
2418 }
2419 return dc;
2420 }
2421 DeclareAndCast(IFSelect_DispPerFiles,dp,disp);
2422 if (!dp.IsNull()) {
2423 Standard_Integer nb = atoi( &(nam.ToCString())[paro]);
2424 if (nb <= 0) {
2425 sout<<" DispPerFiles, count is not positive"<<endl;
2426 disp.Nullify();
2427 return disp;
2428 }
2429 if (mode) {
2430 Handle(IFSelect_IntParam) val = new IFSelect_IntParam;
2431 val->SetValue(nb);
2432 dp->SetCount (val);
2433 }
2434 return dp;
2435 }
2436 DeclareAndCast(IFSelect_DispPerSignature,ds,disp);
2437 if (!ds.IsNull()) {
2438 DeclareAndCast(IFSelect_Signature,sg,WS->NamedItem( &(nam.ToCString())[paro]));
2439 if (sg.IsNull()) {
2440 sout<<"DispPerSignature "<<nam<<" , Signature not valid : "<<&(nam.ToCString())[paro]<<endl;
2441 disp.Nullify();
2442 return disp;
2443 }
2444 if (mode) ds->SetSignCounter (new IFSelect_SignCounter(sg));
2445 return ds;
2446 }
2447 sout<<"Dispatch : "<<name<<" , Parameter : "<<&(nam.ToCString())[paro]<<endl;
2448 return disp;
2449}
2450
2451
2452// #########################################
2453// #### INITIALISATIONS ####
2454// #########################################
2455
2456static int initactor = 0;
2457
2458
2459 void IFSelect_Functions::Init ()
2460{
2461 if (initactor) return; initactor = 1;
2462 IFSelect_Act::SetGroup("DE: General");
2463 IFSelect_Act::AddFunc("xstatus","Lists XSTEP Status : Version, System Name ...",funstatus);
2464 IFSelect_Act::AddFunc("handler","Toggle status catch Handler Error of the session",fun1);
7fd59977 2465 IFSelect_Act::AddFunc("xload","file:string : Read File -> Load Model",fun3);
2466// IFSelect_Act::AddFunc("load","file:string : Read File -> Load Model",fun3);
2467 IFSelect_Act::AddFunc("xread","file:string : Read File -> Load Model",fun3);
2468 IFSelect_Act::AddFunc("whatfile"," -> analyses a file (specific per norm)",fun_whatfile);
2469 IFSelect_Act::AddFunc("writeall","file:string : Write all model (no split)",fun4);
2470 IFSelect_Act::AddFunc("writesel","file:string sel:Selection : Write Selected (no split)",fun5);
2471 IFSelect_Act::AddFunc("writeent","file:string n1ent n2ent...:integer : Write Entite(s) (no split)",fun6);
2472 IFSelect_Act::AddFunc("writent", "file:string n1ent n2ent...:integer : Write Entite(s) (no split)",fun6);
2473 IFSelect_Act::AddFunc("elabel","nument:integer : Displays Label Model of an entity",fun7);
2474 IFSelect_Act::AddFunc("enum","label:string : Displays entities n0.s of which Label Model ends by..",fun8);
2475
2476 IFSelect_Act::AddFunc("listtypes","List nb entities per type. Optional selection name else all model",fun9);
2477 IFSelect_Act::AddFunc("count","Count : counter [selection]",funcount);
2478 IFSelect_Act::AddFunc("listcount","List Counted : counter [selection [nument]]",funcount);
2479 IFSelect_Act::AddFunc("sumcount","Summary Counted : counter [selection [nument]]",funcount);
2480 IFSelect_Act::AddFunc("signtype","Sign Type [newone]",funsigntype);
2481 IFSelect_Act::AddFunc("signcase","signature : displays possible cases",funsigncase);
2482
2483 IFSelect_Act::AddFunc("estatus","ent/nument : displays status of an entity",fun10);
2484 IFSelect_Act::AddFunc("data","Data (DumpModel); whole help : data tout court",fun11);
2485 IFSelect_Act::AddFunc("entity","give n0 ou id of entity [+ level]",fundumpent);
2486 IFSelect_Act::AddFunc("signature","signature name + n0/ident entity",funsign);
2487 IFSelect_Act::AddFunc("queryparent"," give 2 n0s/labels of entities : dad son",funqp);
2488
2489 IFSelect_Act::AddFunc("dumpshare","Dump Share (dispatches, IntParams)",fun12);
2490 IFSelect_Act::AddFunc("listitems","List Items [label else all] ->Type,Label[,Name]",fun13);
2491 IFSelect_Act::AddFSet("integer","value:integer : cree un IntParam",fun14);
2492 IFSelect_Act::AddFunc("setint","name:IntParam newValue:integer : Change valeur IntParam",fun15);
2493 IFSelect_Act::AddFSet("text","value:string : cree un TextParam",fun16);
2494 IFSelect_Act::AddFunc("settext","Name:TextParam newValue:string : Change valeur TextParam",fun17);
2495 IFSelect_Act::AddFunc("dumpsel","Dump Selection suivi du Nom de la Selection a dumper",fun19);
2496 IFSelect_Act::AddFunc("evalsel","name:Selection [num/sel] : Evalue une Selection",fun20);
2497 IFSelect_Act::AddFunc("givelist","num/sel [num/sel ...] : Evaluates GiveList",fun20);
2498 IFSelect_Act::AddFunc("giveshort","num/sel [num/sel ...] : GiveList in short form",fun20);
2499 IFSelect_Act::AddFunc("givepointed","num/sel [num/sel ...] : GiveList to fill a SelectPointed",fun20);
2500 IFSelect_Act::AddFunc("makelist","listname [givelist] : Makes a List(SelectPointed) from GiveList",fun20);
2501 IFSelect_Act::AddFunc("givecount","num/sel [num/sel ...] : Counts GiveList",fun20c);
2502 IFSelect_Act::AddFSet("selsuite","sel sel ... : Creates a SelectSuite",funselsuite);
2503 IFSelect_Act::AddFunc("clearitems","Clears all items (selections, dispatches, etc)",fun21);
2504 IFSelect_Act::AddFunc("cleardata","mode:a-g-c-p : Clears all or some data (model, check...)",fun22);
2505
2506 IFSelect_Act::AddFunc("itemlabel","xxx xxx : liste items having this label",fun24);
2507 IFSelect_Act::AddFunc("xsave","filename:string : sauve items-session",fun25);
2508 IFSelect_Act::AddFunc("xrestore","filename:string : restaure items-session",fun26);
2509 IFSelect_Act::AddFunc("param","nompar:string : displays parameter value; + nompar val : changes it",fun27);
2510 IFSelect_Act::AddFunc("defparam","nompar:string : display def. param; also : nompar edit, nompar init",fun28);
2511
2512 IFSelect_Act::AddFunc("sentfiles","Lists files sent from last Load",fun29);
2513 IFSelect_Act::AddFunc("fileprefix","prefix:string : definit File Prefix",fun30);
2514 IFSelect_Act::AddFunc("fileext","extent:string : definit File Extension",fun31);
2515 IFSelect_Act::AddFunc("fileroot","disp:Dispatch root:string : definit File Root sur un Dispatch",fun32);
2516 IFSelect_Act::AddFunc("filedef","defroot:string : definit File DefaultRoot",fun33);
2517 IFSelect_Act::AddFunc("evalfile","Evaluation du FileNaming et memorisation",fun34);
2518 IFSelect_Act::AddFunc("clearfile","Efface la liste d'EvalFile",fun35);
2519 IFSelect_Act::AddFunc("xsplit","[disp:Dispatch sinon tout] : Split, la grande affaire !",fun36);
2520 IFSelect_Act::AddFunc("remaining","options... : Remaining Entities, help complet par remaining ?",fun37);
2521 IFSelect_Act::AddFunc("setcontent","sel:Selection mode:k ou r : Restreint contenu du modele",fun38);
2522
2523 IFSelect_Act::AddFunc("listmodif","List Final Modifiers",fun40);
2524 IFSelect_Act::AddFunc("dumpmodif","modif:Modifier : Affiche le Statut d'un Modifier",fun41);
2525 IFSelect_Act::AddFunc("modifsel","modif:Modifier [sel:Selection] : Change/Annule Selection de Modifier",fun42);
2526 IFSelect_Act::AddFunc("setapplied","modif:Modifier [name:un item sinon sortie fichier] : Applique un Modifier",fun43);
2527 IFSelect_Act::AddFunc("resetapplied","modif:Modifier : Enleve un Modifier de la sortie fichier",fun44);
2528 IFSelect_Act::AddFunc("modifmove","modif:Modifier M(model)/F(file) avant,apres:integer : Deplace un Modifier (sortie fichier)",fun45);
2529
2530 IFSelect_Act::AddFunc("dispsel","disp:Dispatch sel:Selection -> Selection Finale de Dispatch",fun51);
2531 IFSelect_Act::AddFSet("dispone","cree DispPerOne",fun_dispone);
2532 IFSelect_Act::AddFSet("dispglob","cree DispGlobal",fun_dispglob);
2533 IFSelect_Act::AddFSet("dispcount","count:IntParam : cree DispPerCount",fun_dispcount);
2534 IFSelect_Act::AddFSet("dispfile","files:IntParam : cree DispPerFiles",fun_dispfiles);
2535 IFSelect_Act::AddFSet("dispsign","sign:Signature : cree DispPerSignature",fun_dispsign);
2536 IFSelect_Act::AddFunc("dumpdisp","disp:Dispatch : Affiche le Statut d'un Dispatch",fun56);
2537
2538 IFSelect_Act::AddFunc("xremove","nom : Remove a Control Item de la Session",fun57);
2539 IFSelect_Act::AddFunc("evaldisp","mode=[0-3] disp:Dispatch : Evaluates one or more Dispatch(es)",fun58);
2540 IFSelect_Act::AddFunc("evaladisp","mode=[0-3] disp:Dispatch [givelist] : Evaluates a Dispatch (on a GiveList)",fun_evaladisp);
2541 IFSelect_Act::AddFunc("writedisp","filepattern disp:Dispatch [givelist] : Writes Entities by Splitting by a Dispatch",fun_writedisp);
2542 IFSelect_Act::AddFunc("evalcomplete","Evaluation Complete de la Repartition",fun59);
2543
2544 IFSelect_Act::AddFunc("runcheck","affiche LastRunCheckList (write,modif)",fun60);
2545 IFSelect_Act::AddFunc("runtranformer","transf:Transformer : Applique un Transformer",fun61);
2546 IFSelect_Act::AddFSet("copy","cree TransformStandard, option Copy, vide",fun62);
2547 IFSelect_Act::AddFSet("onthespot","cree TransformStandard, option OntheSpot, vide",fun63);
2548 IFSelect_Act::AddFunc("runcopy","modif:ModelModifier [givelist] : Run <modif> via TransformStandard option Copy",fun6465);
2549 IFSelect_Act::AddFunc("runonthespot","modif:ModelModifier [givelist] : Run <modif> via TransformStandard option OnTheSpot",fun6465);
2550 IFSelect_Act::AddFSet("reorder","[f ou t] reordonne le modele",fun66);
2551
2552 IFSelect_Act::AddFunc("toggle","sel:Selection genre Extract : Toggle Direct/Reverse",fun70);
2553 IFSelect_Act::AddFunc("input","sel:Selection genre Deduct ou Extract input:Selection : Set Input",fun71);
2554 IFSelect_Act::AddFSet("modelroots","cree SelectModelRoots",fun72);
2555 IFSelect_Act::AddFSet("range","options... : cree SelectRange ...; tout court pour help",fun73);
2556 IFSelect_Act::AddFSet("roots","cree SelectRoots (local roots)",fun74);
2557 IFSelect_Act::AddFSet("shared","cree SelectShared",fun75);
2558 IFSelect_Act::AddFSet("diff","[main:Selection diff:Selection] : cree SelectDiff",fun76);
2559 IFSelect_Act::AddFunc("selmain","sel:Selection genre Control main:Selection : Set Main Input",fun77);
2560 IFSelect_Act::AddFunc("selsecond","sel:Selection genre Control sec:Selection : Set Second Input",fun78);
2561 IFSelect_Act::AddFSet("modelall","cree SelectModelAll",fun79);
2562 IFSelect_Act::AddFunc("seladd","sel:Selection genre Combine input:Selection : Add Selection",fun80);
2563 IFSelect_Act::AddFunc("selrem","sel:Selection genre Combine input:Selection : Remove Selection",fun81);
2564 IFSelect_Act::AddFSet("number","num:IntParam : Cree SelectEntityNumber",fun82);
2565
2566 IFSelect_Act::AddFSet("union","cree SelectUnion (vide), cf aussi combadd, combrem",fun83);
2567 IFSelect_Act::AddFSet("intersect","cree SelectIntersection (vide), cf aussi combadd, combrem",fun84);
2568 IFSelect_Act::AddFSet("typexact","type:string : cree SelectTextType Exact",fun85);
2569 IFSelect_Act::AddFSet("errors","cree SelectErrorEntities (from file)",fun86);
2570 IFSelect_Act::AddFSet("unknown","cree SelectUnknownEntities",fun87);
2571 IFSelect_Act::AddFSet("sharing","cree SelectSharing",fun88);
2572 IFSelect_Act::AddFSet("typecontain","type:string : cree SelectTextType Contains",fun89);
2573 IFSelect_Act::AddFSet("pointed","cree SelectPointed [num/sel num/sel]",fun90);
2574 IFSelect_Act::AddFunc("setpointed","sel:SelectPointed : edition SelectPointed. tout court pour help",fun91);
2575 IFSelect_Act::AddFunc("setlist","sel:SelectPointed : edition SelectPointed. tout court pour help",fun91);
2576 IFSelect_Act::AddFSet("incorrect","cree SelectIncorrectEntities (computed)",fun92);
2577
2578 IFSelect_Act::AddFSet("signsel","sign:Signature|cnt:Counter text:string [e(D)|c] : cree SelectSignature",fun93);
2579 IFSelect_Act::AddFSet("signcounter","sign:Signature : cree SignCounter",fun94);
2580 IFSelect_Act::AddFSet("nbselected","applied:Selection : cree GraphCounter(=NbSelected)",funbselected);
2581
2582 IFSelect_Act::AddFunc("editlist","editor or editform : lists defs + values",fun_editlist);
2583 IFSelect_Act::AddFunc("editvalue","editform paramname [newval or .] : lists-changes a value",fun_editvalue);
2584 IFSelect_Act::AddFunc("editclear","editform [paramname] : clears edition on all or one param",fun_editclear);
2585 IFSelect_Act::AddFunc("editload","editform [entity-id] : loads from model or an entity",fun_editload);
2586 IFSelect_Act::AddFunc("editapply","editform [keep] : applies on loaded data",fun_editapply);
2587}