0031851: Data Exchange, STEP - enable Unicode symbols in STEP export
[occt.git] / src / DDataStd / DDataStd_BasicCommands.cxx
CommitLineData
b311480e 1// Created on: 1997-07-30
2// Created by: Denis PASCAL
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <DDataStd.hxx>
18
19#include <Standard_PCharacter.hxx>
20
21#include <DDF.hxx>
22#include <Draw_Interpretor.hxx>
23#include <Draw_Appli.hxx>
24#include <DrawTrSurf.hxx>
25
26#include <DDF.hxx>
d99f0355 27#include <Message.hxx>
7fd59977 28
29#include <TDF_Data.hxx>
30#include <TDF_Label.hxx>
31#include <TDF_Tool.hxx>
32#include <TDF_AttributeSequence.hxx>
33#include <TDF_AttributeList.hxx>
34#include <TDF_ListIteratorOfAttributeList.hxx>
35
624f732f 36#include <BRep_Tool.hxx>
7fd59977 37#include <DBRep.hxx>
38#include <TopAbs.hxx>
39#include <TopoDS.hxx>
40#include <TopoDS_Vertex.hxx>
41#include <TopoDS_Edge.hxx>
42#include <TopoDS_Wire.hxx>
43#include <TopoDS_Face.hxx>
44#include <TopoDS_Shell.hxx>
45#include <TopoDS_Solid.hxx>
46#include <TopoDS_Shape.hxx>
47
48#include <gp_Pnt.hxx>
49#include <gp_Dir.hxx>
50#include <gp_Pln.hxx>
51
52#include <TCollection_AsciiString.hxx>
53#include <TColStd_HArray1OfReal.hxx>
54
55// LES ATTRIBUTES
56#include <TDataStd.hxx>
624f732f 57#include <TDataXtd_Triangulation.hxx>
7fd59977 58#include <TDataStd_Comment.hxx>
59#include <TDataStd_Name.hxx>
60#include <TDataStd_Integer.hxx>
61#include <TDataStd_Real.hxx>
62#include <TDF_Reference.hxx>
63#include <TDataStd_UAttribute.hxx>
64#include <TDataStd_IntegerArray.hxx>
f7b4312f 65#include <TDataStd_BooleanArray.hxx>
7fd59977 66#include <TDataStd_RealArray.hxx>
f7b4312f 67#include <TDataStd_BooleanList.hxx>
68#include <TDataStd_IntegerList.hxx>
69#include <TDataStd_RealList.hxx>
7fd59977 70#include <TDataStd_Variable.hxx>
71#include <TDataStd_ExtStringArray.hxx>
72#include <TDF_ChildIterator.hxx>
73#include <TDF_Tool.hxx>
74
7fd59977 75#include <TDataStd_NamedData.hxx>
76#include <TColStd_DataMapOfStringInteger.hxx>
77#include <TColStd_DataMapIteratorOfDataMapOfStringInteger.hxx>
78#include <TDataStd_DataMapOfStringReal.hxx>
79#include <TDataStd_DataMapIteratorOfDataMapOfStringReal.hxx>
80#include <TDataStd_DataMapOfStringByte.hxx>
81#include <TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx>
82#include <TDataStd_DataMapOfStringString.hxx>
83#include <TDataStd_DataMapIteratorOfDataMapOfStringString.hxx>
84#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
85#include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger.hxx>
86#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
87#include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal.hxx>
88#include <TColStd_HArray1OfInteger.hxx>
89#include <TColStd_HArray1OfReal.hxx>
90#include <TDataStd_AsciiString.hxx>
91#include <TDataStd_IntPackedMap.hxx>
92#include <TColStd_HPackedMapOfInteger.hxx>
93#include <TColStd_PackedMapOfInteger.hxx>
94#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
95#include <TDataStd_ByteArray.hxx>
f7b4312f 96#include <TDataStd_ListIteratorOfListOfByte.hxx>
97#include <TColStd_ListIteratorOfListOfInteger.hxx>
98#include <TColStd_ListIteratorOfListOfReal.hxx>
1c9cffdb 99#include <TDataStd_ReferenceArray.hxx>
d585e74e 100#include <TDataStd_ExtStringList.hxx>
101#include <TDataStd_ReferenceList.hxx>
102#include <TDF_ListIteratorOfLabelList.hxx>
103#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
8bfae263 104
105#include <algorithm>
106#include <vector>
107
5a1271c8 108#define MAXLENGTH 10
109//#define DEB_DDataStd
7fd59977 110
7fd59977 111//=======================================================================
112//function : DDataStd_SetInteger
fa53efef 113//purpose : SetInteger (DF, entry, value, [,guid])
7fd59977 114//=======================================================================
115
116static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di,
117 Standard_Integer nb,
118 const char** arg)
119{
fa53efef 120 if (nb >= 4) {
7fd59977 121 Handle(TDF_Data) DF;
122 if (!DDF::GetDF(arg[1],DF)) return 1;
123 TDF_Label L;
124 DDF::AddLabel(DF, arg[2], L);
5a1271c8 125 if(nb == 4)
fa53efef 126 TDataStd_Integer::Set(L,Draw::Atoi(arg[3]));
5a1271c8 127 else {
128 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
fa53efef 129 di<<"DDataStd_SetInteger: The format of GUID is invalid\n";
130 return 1;
5a1271c8 131 }
132 Standard_GUID guid(arg[4]);
133 TDataStd_Integer::Set(L, guid, Draw::Atoi(arg[3]));
134 }
7fd59977 135 return 0;
136 }
586db386 137 di << "DDataStd_SetInteger : Error\n";
7fd59977 138 return 1;
139}
140
141//=======================================================================
142//function : DDataStd_SetReal
fa53efef 143//purpose : SetReal (DF, entry, value [,guid])
7fd59977 144//=======================================================================
145
146static Standard_Integer DDataStd_SetReal (Draw_Interpretor& di,
147 Standard_Integer nb,
148 const char** arg)
149{
fa53efef 150 if (nb >= 4) {
7fd59977 151 Handle(TDF_Data) DF;
152 if (!DDF::GetDF(arg[1],DF)) return 1;
153 TDF_Label L;
154 DDF::AddLabel(DF, arg[2], L);
5a1271c8 155 if(nb == 4)
fa53efef 156 TDataStd_Real::Set(L,Draw::Atof(arg[3]));
5a1271c8 157 else {
158 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
fa53efef 159 di<<"DDataStd_SetReal: The format of GUID is invalid\n";
160 return 1;
5a1271c8 161 }
162 Standard_GUID guid(arg[4]);
163 TDataStd_Real::Set(L, guid, Draw::Atof(arg[3]));
164 }
165 return 0;
166 }
586db386 167 di << "DDataStd_SetReal : Error\n";
7fd59977 168 return 1;
169}
170
171
172
173//=======================================================================
174//function : DDataStd_SetReference
175//purpose : SetReference (DF, entry, reference)
176//=======================================================================
177
178static Standard_Integer DDataStd_SetReference (Draw_Interpretor& di,
179 Standard_Integer nb,
180 const char** arg)
181{
182 if (nb == 4) {
183 Handle(TDF_Data) DF;
184 if (!DDF::GetDF(arg[1],DF)) return 1;
185 TDF_Label L;
186 DDF::AddLabel(DF, arg[2], L);
187 TDF_Label LREF;
188 if (!DDF::FindLabel(DF,arg[3],LREF)) return 1;
189 TDF_Reference::Set(L,LREF);
190 return 0;
191 }
586db386 192 di << "DDataStd_SetReference : Error\n";
7fd59977 193 return 1;
194}
195
196
197//=======================================================================
198//function : DDataStd_SetComment
199//purpose : SetComment (DF, entry, Comment)
200//=======================================================================
201
202static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di,
203 Standard_Integer nb,
204 const char** arg)
205{
206 if (nb == 4) {
207 Handle(TDF_Data) DF;
208 if (!DDF::GetDF(arg[1],DF)) return 1;
209 TDF_Label L;
210 DDF::AddLabel(DF, arg[2], L);
d9ff84e8 211 TDataStd_Comment::Set(L,TCollection_ExtendedString(arg[3],Standard_True));
7fd59977 212 return 0;
213 }
586db386 214 di << "DDataStd_SetComment : Error\n";
7fd59977 215 return 1;
216}
217
7fd59977 218//=======================================================================
219//function : DDataStd_GetInteger
fa53efef 220//purpose : GetReal (DF, entry, [drawname][, guid])
7fd59977 221//=======================================================================
222
223static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
224 Standard_Integer nb,
225 const char** arg)
226{
fa53efef 227 if (nb == 3 || nb == 4 || nb == 5) {
7fd59977 228 Handle(TDF_Data) DF;
229 if (!DDF::GetDF(arg[1],DF)) return 1;
230 Handle(TDataStd_Integer) A;
5a1271c8 231 Standard_GUID aGuid;
232 Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000");
233 Standard_Boolean isdrawname(Standard_False);
234 if(nb < 5 ) {
fa53efef 235 if(nb == 4) { //DF, entry, guid
5a1271c8 236 if (Standard_GUID::CheckGUIDFormat(arg[3]))
fa53efef 237 aGuid = Standard_GUID(arg[3]);
5a1271c8 238 }
239 if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
240 isdrawname = Standard_True;
241 aGuid = TDataStd_Integer::GetID();
242 }
243 } else if(nb == 5) {
244 isdrawname = Standard_True;
245 if (Standard_GUID::CheckGUIDFormat(arg[4]))
fa53efef 246 aGuid = Standard_GUID(arg[4]);
5a1271c8 247 else {
fa53efef 248 di<<"DDataStd_GetInteger: The format of GUID is invalid\n";
249 return 1;
5a1271c8 250 }
251 }
252
fa53efef 253 if (!DDF::Find(DF,arg[2],aGuid,A)) return 1;
254 if (nb == 4 && isdrawname) Draw::Set(arg[3],A->Get());
7fd59977 255 else Draw::Set(arg[2],A->Get());
256 di << A->Get();
257 return 0;
258 }
586db386 259 di << "DDataStd_GetInteger : Error\n";
7fd59977 260 return 1;
261}
262
263//=======================================================================
264//function : DDataStd_GetReal
fa53efef 265//purpose : GetReal (DF, entry, [drawname][, guid])
7fd59977 266//=======================================================================
267
268static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di,
269 Standard_Integer nb,
270 const char** arg)
271{
fa53efef 272 if (nb == 3 || nb == 4 || nb == 5) {
7fd59977 273 Handle(TDF_Data) DF;
274 if (!DDF::GetDF(arg[1],DF)) return 1;
275 Handle(TDataStd_Real) A;
5a1271c8 276 Standard_GUID aGuid;
fa53efef 277 Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000");
5a1271c8 278 Standard_Boolean isdrawname(Standard_False);
fa53efef 279 if(nb < 5 ) {
5a1271c8 280 if(nb == 4) {
281 if (Standard_GUID::CheckGUIDFormat(arg[3]))
fa53efef 282 aGuid = Standard_GUID(arg[3]);
5a1271c8 283 }
284 if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
285 isdrawname = Standard_True;
286 aGuid = TDataStd_Real::GetID();
287 }
288 }
289 else if(nb == 5) {
290 isdrawname = Standard_True;
291 if (Standard_GUID::CheckGUIDFormat(arg[4]))
fa53efef 292 aGuid = Standard_GUID(arg[4]);
5a1271c8 293 else {
fa53efef 294 di<<"DDataStd_GetReal: The format of GUID is invalid\n";
295 return 1;
5a1271c8 296 }
297 }
fa53efef 298 if (!DDF::Find(DF,arg[2],aGuid,A)) return 1;
299 if (nb == 4 && isdrawname) Draw::Set(arg[3],A->Get());
7fd59977 300 else Draw::Set(arg[2],A->Get());
301 di << A->Get();
302 return 0;
303 }
586db386 304 di << "DDataStd_GetReal : Error\n";
7fd59977 305 return 1;
306}
307
308
309//=======================================================================
310//function : DDataStd_GetReference
311//purpose : GetShape (DF, entry)
312//=======================================================================
313
314static Standard_Integer DDataStd_GetReference (Draw_Interpretor& di,
315 Standard_Integer nb,
316 const char** arg)
317{
318 if (nb == 3) {
319 Handle(TDF_Data) DF;
320 if (!DDF::GetDF(arg[1],DF)) return 1;
321 Handle(TDF_Reference) REF;
322 if (!DDF::Find(DF,arg[2],TDF_Reference::GetID(),REF)) return 1;
323 TCollection_AsciiString entry; TDF_Tool::Entry(REF->Get(),entry);
324 di << entry.ToCString();
325 return 0;
326 }
586db386 327 di << "DDataStd_GetReference : Error\n";
7fd59977 328 return 1;
329}
330
331//=======================================================================
332//function : DDataStd_GetComment
333//purpose : GetShape (DF, entry)
334//=======================================================================
335
336static Standard_Integer DDataStd_GetComment (Draw_Interpretor& di,
337 Standard_Integer nb,
338 const char** arg)
339{
340 if (nb == 3) {
341 Handle(TDF_Data) DF;
342 if (!DDF::GetDF(arg[1],DF)) return 1;
343 Handle(TDataStd_Comment) A;
344 if (!DDF::Find(DF,arg[2],TDataStd_Comment::GetID(),A)) return 1;
ae9f4b64 345 di << A->Get();
7fd59977 346 return 0;
347 }
586db386 348 di << "DDataStd_GetComment : Error\n";
7fd59977 349 return 1;
350}
351
352
353
354//=======================================================================
355//function :
356//purpose : Self (document,label)
357//=======================================================================
358
359static Standard_Integer DDataStd_Self (Draw_Interpretor& di,
360 Standard_Integer nb,
361 const char** arg)
362{
363 TCollection_AsciiString s;
364 if (nb == 3) {
365 Handle(TDF_Data) DF;
366 if (!DDF::GetDF(arg[1],DF)) return 1;
367 TDF_Label L;
368 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
369// TDataStd::MakeSelfContained(L,removed);
04232180 370// if (removed.IsEmpty()) std::cout << "noone attriburte removed" << std::endl;
7fd59977 371// for (TDF_ListIteratorOfAttributeList it(removed);it.More();it.Next()) {
04232180 372// TDF_Tool::Entry(it.Value()->Label(),s); std::cout << s << " ";
373// std::cout << std::endl;
7fd59977 374// }
375 return 0;
376 }
586db386 377 di << "Self : Error\n";
7fd59977 378 return 0;
379}
380
381
382
383//=======================================================================
384//function : SetUObject (DF, entry, ObjectID)
385//=======================================================================
386// static Standard_Integer DDataStd_SetUObject (Draw_Interpretor&,
387// Standard_Integer nb,
388// const char** arg)
389// {
390// if( nb == 4 ) {
391// Handle(TDF_Data) DF;
392// if (!DDF::GetDF(arg[1],DF)) return 1;
393// TDF_Label label;
394// DDF::AddLabel(DF, arg[2], label);
395
396// Standard_GUID guid(arg[3]); //"00000000-0000-0000-1111-000000000000");
397// TDataStd_UObject::Set(label, guid);
398// return 0;
399// }
400
04232180 401// std::cout << "Wrong arguments" << std::endl;
7fd59977 402// return 1;
403// }
404
405//=======================================================================
406//function : SetUAttribute (DF, entry, LocalID)
407//=======================================================================
408static Standard_Integer DDataStd_SetUAttribute (Draw_Interpretor& di,
409 Standard_Integer nb,
410 const char** arg)
411{
412 if( nb == 4 ) {
413 Handle(TDF_Data) DF;
414 if (!DDF::GetDF(arg[1],DF)) return 1;
415 TDF_Label label;
416 DDF::AddLabel(DF, arg[2], label);
417
418 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
419 TDataStd_UAttribute::Set(label, guid);
420 return 0;
421 }
422
423 di << "Wrong arguments" << "\n";
424 return 1;
425}
426
427//=======================================================================
428//function : GetUAttribute (DF, entry, LoaclID)
429//=======================================================================
430static Standard_Integer DDataStd_GetUAttribute (Draw_Interpretor& di,
431 Standard_Integer nb,
432 const char** arg)
433{
434 if( nb == 4 ) {
435 Handle(TDF_Data) DF;
436 if (!DDF::GetDF(arg[1],DF)) return 1;
437 TDF_Label label;
438 if( !DDF::FindLabel(DF, arg[2], label) ) {
439 di << "No label for entry" << "\n";
440 return 1;
441 }
442 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
443
444 Handle(TDataStd_UAttribute) UA;
445 if( !label.FindAttribute(guid, UA) ) {
446 di << "No UAttribute Attribute on label" << "\n";
447 }
448 else {
7fd59977 449 char *aStrGUID = new char[37];
450 UA->ID().ToCString(aStrGUID);
451 di << aStrGUID;
452 }
453 return 0;
454 }
455
456 di << "Wrong arguments" << "\n";
457 return 1;
458}
459
460
461//=======================================================================
462//function : CheckUObject (DF, entry, ObjectID)
463//=======================================================================
464// static Standard_Integer DDataStd_CheckUObject (Draw_Interpretor&,
465// Standard_Integer nb,
466// const char** arg)
467// {
468// if( nb == 4 ) {
469// Handle(TDF_Data) DF;
470// if (!DDF::GetDF(arg[1],DF)) return 1;
471// TDF_Label label;
472// if( !DDF::FindLabel(DF, arg[2], label) ) {
04232180 473// std::cout << "No label for entry" << std::endl;
7fd59977 474// return 1;
475// }
476// Handle(TDataStd_Object) O;
477// Handle(TDataStd_UObject) UO;
478// Standard_GUID guidUO(arg[3]);
479
480// if( !label.FindAttribute( TDataStd_Object::GetID(), O) ) {
04232180 481// std::cout << "No Object Attribute on label" << std::endl;
7fd59977 482// }
483// else {
04232180 484// std::cout << "UObject is found with ObjectID = ";
7fd59977 485// O->Find(label, guidUO, UO);
04232180 486// UO->ObjectID().ShallowDump(std::cout);
487// std::cout << std::endl;
7fd59977 488// }
489// return 0;
490// }
491
04232180 492// std::cout << "Wrong arguments" << std::endl;
7fd59977 493// return 1;
494// }
495
496
497//=======================================================================
5a1271c8 498//function : SetIntArray (DF, entry , isDelta, [-g Guid,] From, To, elmt1, elmt2, ...
7fd59977 499//=======================================================================
500static Standard_Integer DDataStd_SetIntArray (Draw_Interpretor& di,
8e1e79f0 501 Standard_Integer nb,
7fd59977 502 const char** arg)
8e1e79f0 503{
5a1271c8 504 if (nb >= 6) {
505 Handle(TDF_Data) DF;
506 if (!DDF::GetDF(arg[1],DF)) return 1;
507 TDF_Label label;
508 DDF::AddLabel(DF, arg[2], label);
509 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
510 Standard_GUID guid;
511 Standard_Boolean isGuid(Standard_False);
512 Standard_Character c1(arg[4][0]), c2(arg[4][1]);
513 if(c1 == '-' && c2 == 'g') { //guid
514 if (!Standard_GUID::CheckGUIDFormat(arg[5])) {
515 di<<"DDataStd_SetIntArray: The format of GUID is invalid\n";
516 return 1;
517 }
518 guid = Standard_GUID (arg[5]);
519 isGuid = Standard_True;
8e1e79f0 520 }
5a1271c8 521 Standard_Integer j(4);
522 if(isGuid) j = 6;
523 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
524 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
525 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
526 {
527 di << "DDataStd_SetIntArray: From, To may be wrong\n";
528 return 1;
529 }
530 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
531 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
532 Handle(TDataStd_IntegerArray) A;
533 if(!isGuid)
534 A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
535 else
536 A = TDataStd_IntegerArray::Set(label, guid, From, To, isDelta);
537
538 if ((!isGuid && nb > 6) || (isGuid && nb > 8)) {
539 j = j + 2;
540 for(Standard_Integer i = From; i<=To; i++) {
541 A->SetValue(i, Draw::Atoi(arg[j]) );
542 j++;
543 }
544 }
545 return 0;
546 }
547 di << "DDataStd_SetIntArray: Error\n";
548 return 1;
7fd59977 549}
550
8e1e79f0 551//=======================================================================
552//function : SetIntArrayValue (DF, entry, index, value)
553//=======================================================================
554static Standard_Integer DDataStd_SetIntArrayValue (Draw_Interpretor&,
555 Standard_Integer,
556 const char** arg)
557{
558 // Get document.
559 Handle(TDF_Data) DF;
560 if (!DDF::GetDF(arg[1], DF))
561 return 1;
562
563 // Get label.
564 TDF_Label label;
565 if (!DDF::AddLabel(DF, arg[2], label))
566 return 1;
567
568 // Get index and value.
569 Standard_Integer index = Draw::Atoi(arg[3]);
570 Standard_Integer value = Draw::Atoi(arg[4]);
571
572 // Set new value.
573 Handle(TDataStd_IntegerArray) arr;
574 if (label.FindAttribute(TDataStd_IntegerArray::GetID(), arr))
575 {
576 arr->SetValue(index, value);
577 return 0;
578 }
579
580 return 1;
581}
582
7fd59977 583//=======================================================================
5a1271c8 584//function : GetIntArray (DF, entry [, guid] )
7fd59977 585//=======================================================================
586static Standard_Integer DDataStd_GetIntArray (Draw_Interpretor& di,
5a1271c8 587 Standard_Integer nb,
7fd59977 588 const char** arg)
589{
590
5a1271c8 591 if (nb >= 3)
592 {
593 Handle(TDF_Data) DF;
594 if (!DDF::GetDF(arg[1],DF)) return 1;
595 TDF_Label label;
596 if( !DDF::FindLabel(DF, arg[2], label) ) {
597 di << "No label for entry" << "\n";
598 return 1;
599 }
600 Standard_GUID aGuid;
601 if(nb == 4) {
602 if (Standard_GUID::CheckGUIDFormat(arg[3]))
603 aGuid = Standard_GUID(arg[3]);
604 else {
605 di << "Wrong GUID format" << "\n";
606 return 1;
607 }
608 } else
609 aGuid = TDataStd_IntegerArray::GetID();
610 Handle(TDataStd_IntegerArray) A;
611 if ( !label.FindAttribute(aGuid, A) ) {
612 di << "There is no TDataStd_IntegerArray with the specified GUID under label" << "\n";
613 return 1;
614 }
7fd59977 615
5a1271c8 616 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
5a1271c8 617 di << A->Value(i);
618 if(i<A->Upper())
619 di<<" ";
620 }
621 di<<"\n";
622 return 0;
623 }
624 di << "DDataStd_GetIntArray: Error\n";
625 return 1;
7fd59977 626}
8e1e79f0 627//=======================================================================
628//function : GetIntArrayValue (DF, entry, index)
629//=======================================================================
630static Standard_Integer DDataStd_GetIntArrayValue (Draw_Interpretor& di,
631 Standard_Integer,
632 const char** arg)
633{
634 Handle(TDF_Data) DF;
635 if (!DDF::GetDF(arg[1],DF))
5a1271c8 636 return 1;
8e1e79f0 637
638 TDF_Label label;
639 if (!DDF::FindLabel(DF, arg[2], label)) {
640 di << "No label for entry" << "\n";
641 return 1;
642 }
5a1271c8 643
8e1e79f0 644 Handle(TDataStd_IntegerArray) A;
645 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
646 di << "There is no TDataStd_IntegerArray under label" << "\n";
647 return 1;
648 }
5a1271c8 649
8e1e79f0 650 Standard_Integer index = Draw::Atoi(arg[3]);
651 if (index < A->Lower() || index > A->Upper()) {
586db386 652 di << "Index is out of range\n";
8e1e79f0 653 return 1;
654 } else {
655 di << A->Value(index) << "\n";
656 }
657
658 return 0;
659}
660
7fd59977 661//=======================================================================
662//function : ChangeIntArray (DF, entry, indx, val )
663//=======================================================================
664static Standard_Integer DDataStd_ChangeIntArray (Draw_Interpretor& di,
665 Standard_Integer nb,
666 const char** arg)
667{
668
669 if( nb == 5 ) {
670 Handle(TDF_Data) DF;
671 if (!DDF::GetDF(arg[1],DF)) return 1;
672 TDF_Label label;
673 if( !DDF::FindLabel(DF, arg[2], label) ) {
674 di << "No label for entry" << "\n";
675 return 1;
676 }
677
678 Handle(TDataStd_IntegerArray) A;
679 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
680 di << "There is no TDataStd_IntegerArray at label" << "\n";
681 return 1;
682 }
91322f44 683 Standard_Integer indx = Draw::Atoi(arg[3]);
684 Standard_Integer val = Draw::Atoi(arg[4]);
7fd59977 685 Standard_Integer low = A->Lower(), up = A->Upper();
686 if(low <= indx && indx <= up)
687 A->SetValue(indx, val);
688 else {
689 Handle(TColStd_HArray1OfInteger) Arr = A->Array();
690 Handle(TColStd_HArray1OfInteger) arr;
691 Standard_Integer i;
692 if(indx > up) {
5a1271c8 693 up = indx;
694 arr = new TColStd_HArray1OfInteger(low, up);
695 for(i=low; i<= Arr->Upper(); i++)
696 arr->SetValue(i, Arr->Value(i));
697 for(i=Arr->Upper()+1; i<= up; i++) {
698 if(i == up)
699 arr->SetValue(i, val);
700 else
701 arr->SetValue(i, 0);
702 }
7fd59977 703 } else if(indx < up) {//clip array : indx to be negative
5a1271c8 704 up = abs(indx);
705 arr = new TColStd_HArray1OfInteger(low, up);
706 for(i=low; i< up; i++)
707 arr->SetValue(i, Arr->Value(i));
708 arr->SetValue(up, val);
7fd59977 709 }
710 A->ChangeArray(arr);
711 }
712 return 0;
713 }
586db386 714 di << "DDataStd_ChangeIntArray: Error\n";
7fd59977 715 return 0;
716}
717
718//=======================================================================
719//function : SetIntArrayT (DF, entry , isDelta, From, To) - for testing
720// : huge arrays
721//=======================================================================
722static Standard_Integer DDataStd_SetIntArrayTest (Draw_Interpretor& di,
723 Standard_Integer,
724 const char** arg)
725{
726
727
728 Handle(TDF_Data) DF;
729 if (!DDF::GetDF(arg[1],DF)) return 1;
730 TDF_Label label;
731 DDF::AddLabel(DF, arg[2], label);
dde68833 732 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
91322f44 733 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
7fd59977 734 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
735 Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
736
737 j = 6;
738 Standard_Integer k = 100;
739 for(Standard_Integer i = From; i<=To; i++) {
740 A->SetValue(i, ++k);
741 j++;
742 }
743
744 return 0;
745}
746
747//=======================================================================
5a1271c8 748//function : SetRealArray (DF, entry , isDelta, [-g Guid,] From, To, elmt1, elmt2, ...
7fd59977 749//=======================================================================
750static Standard_Integer DDataStd_SetRealArray (Draw_Interpretor& di,
8e1e79f0 751 Standard_Integer nb,
7fd59977 752 const char** arg)
753{
5a1271c8 754 if (nb >= 6) {
755 Handle(TDF_Data) DF;
756 if (!DDF::GetDF(arg[1],DF)) return 1;
757 TDF_Label label;
758 DDF::AddLabel(DF, arg[2], label);
759 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
760 Standard_GUID guid;
761 Standard_Boolean isGuid(Standard_False);
762 Standard_Character c1(arg[4][0]), c2(arg[4][1]);
763 if(c1 == '-' && c2 == 'g') { //guid
764 if (!Standard_GUID::CheckGUIDFormat(arg[5])) {
765 di<<"DDataStd_SetRealArray: The format of GUID is invalid\n";
766 return 1;
767 }
768 guid = Standard_GUID (arg[5]);
769 isGuid = Standard_True;
8e1e79f0 770 }
5a1271c8 771 Standard_Integer j(4);
772 if(isGuid) j = 6;
773 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
774 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
775 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
776 {
777 di << "DDataStd_SetRealArray: From, To may be wrong\n";
778 return 1;
779 }
780 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
781 di << " Array of Standard_Real with bounds from = " << From << " to = " << To << "\n";
782 Handle(TDataStd_RealArray) A;
783 if(!isGuid)
784 A = TDataStd_RealArray::Set(label, From, To, isDelta);
785 else
786 A = TDataStd_RealArray::Set(label, guid, From, To, isDelta);
787 if ((!isGuid && nb > 6) || (isGuid && nb > 8)) {
788 j = j + 2;
789 for(Standard_Integer i = From; i<=To; i++) {
790 A->SetValue(i, Draw::Atof(arg[j]) );
791 j++;
792 }
793 }
794 return 0;
795 }
796 di << "DDataStd_SetRealArray: Error\n";
797 return 1;
7fd59977 798}
8e1e79f0 799//=======================================================================
800//function : SetRealArrayValue (DF, entry, index value)
801//=======================================================================
802static Standard_Integer DDataStd_SetRealArrayValue (Draw_Interpretor&,
803 Standard_Integer,
804 const char** arg)
805{
806 // Get document.
807 Handle(TDF_Data) DF;
808 if (!DDF::GetDF(arg[1], DF))
809 return 1;
810
811 // Get label.
812 TDF_Label label;
813 if (!DDF::AddLabel(DF, arg[2], label))
814 return 1;
815
816 // Get index and value.
817 Standard_Integer index = Draw::Atoi(arg[3]);
818 Standard_Real value = Draw::Atof(arg[4]);
819
820 // Set new value.
821 Handle(TDataStd_RealArray) realArray;
822 if (label.FindAttribute(TDataStd_RealArray::GetID(), realArray))
823 {
824 realArray->SetValue(index, value);
825 return 0;
826 }
827
828 return 1;
829}
830
7fd59977 831//=======================================================================
5a1271c8 832//function : GetRealArray (DF, entry [, guid])
7fd59977 833//=======================================================================
834static Standard_Integer DDataStd_GetRealArray (Draw_Interpretor& di,
5a1271c8 835 Standard_Integer nb,
7fd59977 836 const char** arg)
837{
5a1271c8 838 if (nb >= 3)
839 {
840 Handle(TDF_Data) DF;
841 if (!DDF::GetDF(arg[1],DF)) return 1;
842 TDF_Label label;
843 if( !DDF::FindLabel(DF, arg[2], label) ) {
844 di << "No label for entry" << "\n";
845 return 1;
846 }
847 Standard_GUID aGuid;
848 if(nb == 4) {
849 if (Standard_GUID::CheckGUIDFormat(arg[3]))
850 aGuid = Standard_GUID(arg[3]);
851 else {
852 di << "Wrong GUID format" << "\n";
853 return 1;
854 }
855 } else
856 aGuid = TDataStd_RealArray::GetID();
7fd59977 857
5a1271c8 858 Handle(TDataStd_RealArray) A;
859 if ( !label.FindAttribute(aGuid, A) ) {
860 di << "There is no TDataStd_RealArray with the specified GUID at the label" << "\n";
861#ifdef DEB_DDataStd
04232180 862 aGuid.ShallowDump(std::cout);
5a1271c8 863#endif
864 return 1;
865 }
7fd59977 866
5a1271c8 867 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
868#ifdef DEB_DDataStd
04232180 869 std::cout << A->Value(i) << std::endl;
5a1271c8 870#endif
871 di << A->Value(i);
872 if(i<A->Upper())
873 di<<" ";
874 }
875 di<<"\n";
876 return 0;
877 }
878 di << "TDataStd_RealArray: Error\n";
879 return 1;
880}
8e1e79f0 881//=======================================================================
882//function : GetRealArrayValue (DF, entry, index)
883//=======================================================================
884static Standard_Integer DDataStd_GetRealArrayValue (Draw_Interpretor& di,
885 Standard_Integer,
886 const char** arg)
887{
888 Handle(TDF_Data) DF;
889 if (!DDF::GetDF(arg[1],DF))
5a1271c8 890 return 1;
8e1e79f0 891
892 TDF_Label label;
893 if (!DDF::FindLabel(DF, arg[2], label)) {
894 di << "No label for entry" << "\n";
895 return 1;
896 }
5a1271c8 897
8e1e79f0 898 Handle(TDataStd_RealArray) A;
899 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
900 di << "There is no TDataStd_RealArray under label" << "\n";
901 return 1;
902 }
5a1271c8 903
8e1e79f0 904 Standard_Integer index = Draw::Atoi(arg[3]);
905 if (index < A->Lower() || index > A->Upper()) {
586db386 906 di << "Index is out of range\n";
8e1e79f0 907 return 1;
908 } else {
909 di << A->Value(index) << "\n";
910 }
911
912 return 0;
913}
914
7fd59977 915//=======================================================================
916//function : ChangeRealArray (DF, entry, indx, val )
917//=======================================================================
918static Standard_Integer DDataStd_ChangeRealArray (Draw_Interpretor& di,
919 Standard_Integer nb,
920 const char** arg)
921{
922
923 if( nb == 5 ) {
924 Handle(TDF_Data) DF;
925 if (!DDF::GetDF(arg[1],DF)) return 1;
926 TDF_Label label;
927 if( !DDF::FindLabel(DF, arg[2], label) ) {
928 di << "No label for entry" << "\n";
929 return 1;
930 }
931
932 Handle(TDataStd_RealArray) A;
933 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
934 di << "There is no TDataStd_RealArray at label" << "\n";
935 return 1;
936 }
91322f44 937 Standard_Integer indx = Draw::Atoi(arg[3]);
938 Standard_Real val = Draw::Atof(arg[4]);
7fd59977 939 Standard_Integer low = A->Lower(), up = A->Upper();
940 if(low <= indx && indx <= up)
941 A->SetValue(indx, val);
942 else {
943 Handle(TColStd_HArray1OfReal) Arr = A->Array();
944 Handle(TColStd_HArray1OfReal) arr;
945 Standard_Integer i;
946 if(indx > up) {
5a1271c8 947 up = indx;
948 arr = new TColStd_HArray1OfReal(low, up);
949 for(i=low; i<= Arr->Upper(); i++)
950 arr->SetValue(i, Arr->Value(i));
951 for(i=Arr->Upper()+1; i<= up; i++) {
952 if(i == up)
953 arr->SetValue(i, val);
954 else
955 arr->SetValue(i, 0);
956 }
7fd59977 957 } else if(indx < up) {//clip array : indx to be negative
5a1271c8 958 up = abs(indx);
959 arr = new TColStd_HArray1OfReal(low, up);
960 for(i=low; i< up; i++)
961 arr->SetValue(i, Arr->Value(i));
962 arr->SetValue(up, val);
7fd59977 963 }
964 A->ChangeArray(arr);
965 }
966 return 0;
967 }
586db386 968 di << "DDataStd_ChangeRealArray: Error\n";
7fd59977 969 return 0;
970}
971
972//=======================================================================
973//function : SetVariable (DF, entry, isConstant[0/1], units)
974//=======================================================================
975static Standard_Integer DDataStd_SetVariable (Draw_Interpretor& di,
976 Standard_Integer nb,
977 const char** arg)
978{
979 if (nb == 5)
980 {
981 Handle(TDF_Data) DF;
982 if (!DDF::GetDF(arg[1],DF)) return 1;
983 TDF_Label label;
984 DDF::AddLabel(DF, arg[2], label);
985
986 Handle(TDataStd_Variable) aV = TDataStd_Variable::Set(label);
987
988 const char* aUnits = arg[4];
989 aV->Unit(Standard_CString(aUnits));
990
dde68833 991 aV->Constant (Draw::Atoi(arg[3]) != 0);
7fd59977 992 return 0;
993 }
994
586db386 995 di << "Wrong arguments\n";
7fd59977 996 return 1;
997}
998
999//=======================================================================
1000//function : GetVariable (DF, entry, [isConstant], [units])
1001//=======================================================================
1002static Standard_Integer DDataStd_GetVariable (Draw_Interpretor& di,
1003 Standard_Integer nb,
1004 const char** arg)
1005{
1006 if (nb == 5)
1007 {
1008 Handle(TDF_Data) DF;
1009 if (!DDF::GetDF(arg[1],DF)) return 1;
1010 TDF_Label label;
1011 DDF::AddLabel(DF, arg[2], label);
1012
1013 Handle(TDataStd_Variable) aV;
1014 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
1015 {
586db386 1016 di << "TDataStd_Variable: no such attribute\n";
7fd59977 1017 }
1018
1019 Draw::Set(arg[3],TCollection_AsciiString(Standard_Integer(aV->IsConstant())).ToCString());
1020 Draw::Set(arg[4],aV->Unit().ToCString());
1021 return 0;
1022 }
1023
586db386 1024 di << "Wrong arguments\n";
7fd59977 1025 return 1;
1026}
1027
1028#include <TDataStd_Relation.hxx>
1029#include <TDataStd_Variable.hxx>
1030//=======================================================================
1031//function : SetRelation (DF, entry, expression, var1[, var2, ...])
1032//=======================================================================
1033static Standard_Integer DDataStd_SetRelation (Draw_Interpretor& di,
1034 Standard_Integer nb, const char** arg)
1035{
1036 if (nb >= 5)
1037 {
1038 Handle(TDF_Data) DF;
1039 if (!DDF::GetDF(arg[1],DF)) return 1;
1040 TDF_Label label;
1041 DDF::AddLabel(DF, arg[2], label);
1042
1043 Standard_CString expr (arg[3]);
1044 Handle(TDataStd_Relation) aR = TDataStd_Relation::Set(label);
1045 aR->SetRelation(expr);
1046 Handle(TDataStd_Variable) aV;
1047
1048 for (Standard_Integer i = 4; i < nb; i++)
1049 {
1050 if (!DDF::FindLabel(DF, arg[i], label))
1051 {
1052 di << "No label for entry" << arg[i] << "\n";
1053 return 1;
1054 }
1055 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
1056 {
586db386 1057 di << "No TDataStd_Variable Attribute on label\n";
7fd59977 1058 return 1;
1059 }
1060 aR->GetVariables().Append(aV);
1061 }
1062 return 0;
1063 }
586db386 1064 di << "Usage: SetRelation (DF, entry, expression, var1[, var2, ...])\n";
7fd59977 1065 return 1;
1066}
1067
1068//=======================================================================
1069//function : DumpRelation (DF, entry)
1070//=======================================================================
1071static Standard_Integer DDataStd_DumpRelation (Draw_Interpretor& di,
1072 Standard_Integer nb, const char** arg)
1073{
1074 if (nb == 3)
1075 {
1076 Handle(TDF_Data) DF;
1077 if (!DDF::GetDF(arg[1],DF)) return 1;
1078
1079 TDF_Label label;
1080 if (!DDF::FindLabel(DF, arg[2], label))
1081 {
1082 di << "No label for entry " << arg[2] << "\n";
1083 return 1;
1084 }
1085 Handle(TDataStd_Relation) aR;
1086 if (!label.FindAttribute(TDataStd_Relation::GetID(), aR))
1087 {
1088 di << "No TDataStd_Relation Attribute on label " << arg[2] << "\n";
1089 return 1;
1090 }
1091
1092 di << "Relation: expression = \"" << aR->GetRelation()
1093 << "\" variables list = (";
1094
1095 Handle(TDF_Attribute) aV;
1096 TCollection_AsciiString anEntry;
1097
1098 TDF_ListIteratorOfAttributeList it;
1099 for (it.Initialize(aR->GetVariables()); it.More(); it.Next())
1100 {
1101 aV = it.Value();
1102 if (!aV.IsNull())
1103 {
1104 label = aV->Label();
1105 TDF_Tool::Entry(label, anEntry);
1106 di << anEntry.ToCString() << " ";
1107 }
1108 }
1109 di << ")";
1110 return 0;
1111 }
586db386 1112 di << "Usage: DumpRelation (DF, entry)\n";
7fd59977 1113 return 1;
1114}
1115
1116#include <TFunction_Function.hxx>
1117//=======================================================================
1118//function : SetFunction (DF, entry, guid, failure)
1119//=======================================================================
1120static Standard_Integer DDataStd_SetFunction (Draw_Interpretor& di,
1121 Standard_Integer nb, const char** arg)
1122{
1123 if (nb == 5)
1124 {
1125 Handle(TDF_Data) DF;
1126 if (!DDF::GetDF(arg[1],DF)) return 1;
1127 TDF_Label label;
1128 DDF::AddLabel(DF, arg[2], label);
1129
1130 Standard_GUID guid (arg[3]);
1131 Handle(TFunction_Function) aF = TFunction_Function::Set(label, guid);
1132
91322f44 1133 int fail = Draw::Atoi(arg[4]);
7fd59977 1134 aF->SetFailure(fail);
1135
1136 return 0;
1137 }
1138
1139 di << "Wrong arguments" << "\n";
1140 return 1;
1141}
1142
1143//=======================================================================
1144//function : GetFunction (DF, entry, guid(out), failure(out))
1145//=======================================================================
1146static Standard_Integer DDataStd_GetFunction (Draw_Interpretor& di,
1147 Standard_Integer nb, const char** arg)
1148{
1149 if (nb == 5)
1150 {
1151 Handle(TDF_Data) DF;
1152 if (!DDF::GetDF(arg[1],DF)) return 1;
1153 TDF_Label label;
1154 if (!DDF::FindLabel(DF, arg[2], label))
1155 {
1156 di << "No label for entry" << "\n";
1157 return 1;
1158 }
1159
1160 Handle(TFunction_Function) aF;
1161 if (!label.FindAttribute(TFunction_Function::GetID(), aF))
1162 {
586db386 1163 di << "No TFunction_Function Attribute on label\n";
7fd59977 1164 }
1165 else
1166 {
1167 char *aStrGUID = new char[37];
1168 aF->GetDriverGUID().ToCString(aStrGUID);
1169 Draw::Set(arg[3],aStrGUID);
1170
1171 Draw::Set(arg[4],TCollection_AsciiString(aF->GetFailure()).ToCString());
1172 }
1173 return 0;
1174 }
1175
1176 di << "Wrong arguments" << "\n";
1177 return 1;
1178}
1179
1180//=======================================================================
5a1271c8 1181//function : SetExtStringArray (DF, entry , isDelta, [-g Guid, ]From, To, elmt1, elmt2, ...
7fd59977 1182//=======================================================================
1183static Standard_Integer DDataStd_SetExtStringArray (Draw_Interpretor& di,
5a1271c8 1184 Standard_Integer nb,
1185 const char** arg)
1186{
1187 if (nb >= 6) {
1188 Handle(TDF_Data) DF;
1189 if (!DDF::GetDF(arg[1],DF)) return 1;
1190 TDF_Label label;
1191 DDF::AddLabel(DF, arg[2], label);
1192 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
7fd59977 1193
5a1271c8 1194 Standard_GUID guid;
1195 Standard_Boolean isGuid(Standard_False);
1196 Standard_Character c1(arg[4][0]), c2(arg[4][1]);
1197 if(c1 == '-' && c2 == 'g') { //guid
1198 if (!Standard_GUID::CheckGUIDFormat(arg[5])) {
1199 di<<"DDataStd_SetExtStringArray: The format of GUID is invalid\n";
1200 return 1;
1201 }
1202 guid = Standard_GUID (arg[5]);
1203 isGuid = Standard_True;
8e1e79f0 1204 }
5a1271c8 1205 Standard_Integer j(4);
1206 if(isGuid) j = 6;
1207 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
1208 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
1209 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
1210 {
1211 di << "DDataStd_SetExtStringArray: From, To may be wrong\n";
1212 return 1;
1213 }
1214 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
1215 di << "Array of ExtString with bounds from = " << From << " to = " << To << "\n";
1216 Handle(TDataStd_ExtStringArray) A;
1217 if(!isGuid)
1218 A = TDataStd_ExtStringArray::Set(label, From, To, isDelta);
1219 else
1220 A = TDataStd_ExtStringArray::Set(label, guid, From, To, isDelta);
7fd59977 1221
5a1271c8 1222 if ((!isGuid && nb > 6) || (isGuid && nb > 8)) {
1223 j = j + 2;
1224 for(Standard_Integer i = From; i<=To; ++i) {
1225 A->SetValue(i, arg[j] );
1226 j++;
1227 }
1228 }
1229 return 0;
1230 }
1231 di << "TDataStd_ExtStringArray: Error\n";
1232 return 1;
7fd59977 1233}
1234
8e1e79f0 1235//=======================================================================
1236//function : SetExtStringArrayValue (DF, entry, index, value)
1237//=======================================================================
1238static Standard_Integer DDataStd_SetExtStringArrayValue (Draw_Interpretor&,
1239 Standard_Integer,
1240 const char** arg)
1241{
1242 // Get document.
1243 Handle(TDF_Data) DF;
1244 if (!DDF::GetDF(arg[1], DF))
1245 return 1;
1246
1247 // Get label.
1248 TDF_Label label;
1249 if (!DDF::AddLabel(DF, arg[2], label))
1250 return 1;
1251
1252 // Get index and value.
1253 Standard_Integer index = Draw::Atoi(arg[3]);
1254
1255 // Set new value.
1256 Handle(TDataStd_ExtStringArray) arr;
1257 if (label.FindAttribute(TDataStd_ExtStringArray::GetID(), arr))
1258 {
1259 arr->SetValue(index, arg[4]);
1260 return 0;
1261 }
1262
1263 return 1;
1264}
1265
7fd59977 1266//=======================================================================
1267//function : GetExtStringArray (DF, entry )
1268//=======================================================================
1269static Standard_Integer DDataStd_GetExtStringArray (Draw_Interpretor& di,
5a1271c8 1270 Standard_Integer nb,
1271 const char** arg)
7fd59977 1272{
5a1271c8 1273 if (nb >= 3)
1274 {
7fd59977 1275
5a1271c8 1276 Handle(TDF_Data) DF;
1277 if (!DDF::GetDF(arg[1],DF)) return 1;
1278 TDF_Label label;
1279 if( !DDF::FindLabel(DF, arg[2], label) ) {
1280 di << "No label for entry" << "\n";
1281 return 1;
1282 }
1283 Standard_GUID aGuid;
1284 if(nb == 4) {
1285 if (Standard_GUID::CheckGUIDFormat(arg[3]))
1286 aGuid = Standard_GUID(arg[3]);
1287 else {
1288 di << "Wrong GUID format" << "\n";
1289 return 1;
1290 }
1291 } else
1292 aGuid = TDataStd_ExtStringArray::GetID();
1293 Handle(TDataStd_ExtStringArray) A;
1294 if ( !label.FindAttribute(aGuid, A) ) {
1295 di << "There is no TDataStd_ExtStringArray with the specified GUID at the label" << "\n";
1296 return 1;
1297 }
7fd59977 1298
5a1271c8 1299 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
ae9f4b64 1300 di << A->Value(i);
5a1271c8 1301 if(i<A->Upper())
1302 di<<" ";
1303 }
1304 di<<"\n";
1305 return 0;
1306 }
1307 di << "DDataStd_GetExtStringArray: Error\n";
1308 return 1;
7fd59977 1309}
1310
8e1e79f0 1311//=======================================================================
1312//function : GetExtStringArrayValue (DF, entry, index)
1313//=======================================================================
1314static Standard_Integer DDataStd_GetExtStringArrayValue (Draw_Interpretor& di,
1315 Standard_Integer,
1316 const char** arg)
1317{
1318 Handle(TDF_Data) DF;
1319 if (!DDF::GetDF(arg[1],DF))
1320 return 1;
1321
1322 TDF_Label label;
1323 if (!DDF::FindLabel(DF, arg[2], label)) {
1324 di << "No label for entry" << "\n";
1325 return 1;
1326 }
1327
1328 Handle(TDataStd_ExtStringArray) A;
1329 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
1330 di << "There is no TDataStd_ExtStringArray under label" << "\n";
1331 return 1;
1332 }
1333
1334 Standard_Integer index = Draw::Atoi(arg[3]);
1335 if (index < A->Lower() || index > A->Upper()) {
586db386 1336 di << "Index is out of range\n";
8e1e79f0 1337 return 1;
1338 } else {
1339 const TCollection_ExtendedString& value = A->Value(index);
e9947e12 1340 di << value ;
8e1e79f0 1341 }
1342
1343 return 0;
1344}
1345
7fd59977 1346//=======================================================================
1347//function : ChangeExtStrArray (DF, entry, indx, val )
1348//=======================================================================
1349static Standard_Integer DDataStd_ChangeExtStrArray (Draw_Interpretor& di,
1350 Standard_Integer nb,
1351 const char** arg)
1352{
1353
1354 if( nb == 5 ) {
1355 Handle(TDF_Data) DF;
1356 if (!DDF::GetDF(arg[1],DF)) return 1;
1357 TDF_Label label;
1358 if( !DDF::FindLabel(DF, arg[2], label) ) {
1359 di << "No label for entry" << "\n";
1360 return 1;
1361 }
1362
1363 Handle(TDataStd_ExtStringArray) A;
1364 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
1365 di << "There is no TDataStd_ExtStringArray at label" << "\n";
1366 return 1;
1367 }
91322f44 1368 Standard_Integer indx = Draw::Atoi(arg[3]);
7fd59977 1369 TCollection_ExtendedString val(arg[4]);
1370 Standard_Integer low = A->Lower(), up = A->Upper();
1371 if(low <= indx && indx <= up)
1372 A->SetValue(indx, val);//TColStd_HArray1OfExtendedString
1373 else {
1374 Handle(TColStd_HArray1OfExtendedString) Arr = A->Array();
1375 Handle(TColStd_HArray1OfExtendedString) arr;
1376 Standard_Integer i;
1377 if(indx > up) {
5a1271c8 1378 up = indx;
1379 arr = new TColStd_HArray1OfExtendedString(low, up);
1380 for(i=low; i<= Arr->Upper(); i++)
1381 arr->SetValue(i, Arr->Value(i));
1382 for(i=Arr->Upper()+1; i<= up; i++) {
1383 if(i == up)
1384 arr->SetValue(i, val);
1385 else
1386 arr->SetValue(i, 0);
1387 }
7fd59977 1388 } else if(indx < up) {//clip array : indx to be negative
5a1271c8 1389 up = abs(indx);
1390 arr = new TColStd_HArray1OfExtendedString(low, up);
1391 for(i=low; i< up; i++)
1392 arr->SetValue(i, Arr->Value(i));
1393 arr->SetValue(up, val);
7fd59977 1394 }
1395 A->ChangeArray(arr);
1396 }
1397 return 0;
1398 }
586db386 1399 di << "DDataStd_ChangeExtStringArray: Error\n";
7fd59977 1400 return 0;
1401}
1402
1403
1404//=======================================================================
1405//function : DDataStd_KeepUTF
1406//purpose : SetUTFName (DF, fatherEntry, fileName)
1407//=======================================================================
1408static Standard_Integer DDataStd_KeepUTF (Draw_Interpretor& di,
1409 Standard_Integer nb,
1410 const char** arg)
1411{
1412 if (nb == 4) {
1413 Handle(TDF_Data) DF;
1414 if (!DDF::GetDF(arg[1],DF)) return 1;
1415 TDF_Label L;
1416 DDF::AddLabel(DF, arg[2], L);
1417 Standard_CString aFileName(arg[3]);
1418
57c28b61 1419#ifdef _MSC_VER
04232180 1420 std::ifstream anIS (aFileName, std::ios::in | std::ios::binary);
7fd59977 1421#else
04232180 1422 std::ifstream anIS (aFileName);
7fd59977 1423#endif
1424 if (!anIS) {
1425 // Can not open file
d99f0355 1426 Message::SendFail() << "Error: can't open file " << aFileName;
7fd59977 1427 return 1;
1428 }
1429 char buf[1024];
1430 char *p;
1431 anIS.getline(buf, 1023,'\n');
1432 // 0xEFBBBF - prefix of UTF8
1433 p = &buf[3]; //skip prefix
1434 TCollection_ExtendedString aES1(p, Standard_True);
1435 TDataStd_Name::Set(L.NewChild(), aES1);
1436
1437
1438 while (anIS.good() && !anIS.eof()) {
1439 anIS.getline(buf, 1023,'\n');
1440 TCollection_ExtendedString aES2(buf, Standard_True);
1441 const TDF_Label& aLab = L.NewChild();
1442 TDataStd_Name::Set(aLab, aES2);
1443 }
1444 return 0;
1445 }
586db386 1446 di << "SetUTFName : String is not kept in DF\n";
7fd59977 1447 return 1;
1448}
1449
1450//=======================================================================
1451//function : DDataStd_GetUTFtoFile
1452//purpose : GetUTF (DF, fatherEntry, fileName)
1453// : all strings from sub-labels of the <fatherEntry> concatenated
1454// : in one, converted to UTF8 and kept in the file
1455//=======================================================================
1456static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di,
1457 Standard_Integer nb,
1458 const char** arg)
1459{
1460 if (nb == 4) {
1461 Handle(TDF_Data) DF;
1462 if (!DDF::GetDF(arg[1],DF)) return 1;
1463 TDF_Label L;
1464 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
1465
1466 TCollection_ExtendedString aES;
1467 Standard_Boolean aF = Standard_False;
1468 TDF_ChildIterator anIt(L);
1469 for(;anIt.More();anIt.Next()) {
1470 const TDF_Label& aLab = anIt.Value();
1471 if(!aLab.IsNull()) {
5a1271c8 1472 Handle(TDataStd_Name) anAtt;
1473 if(aLab.FindAttribute(TDataStd_Name::GetID(), anAtt)) {
1474 if(anAtt->Get().Length()) {
1475 if (aF)
1476 aES +='\n';
1477 aES +=anAtt->Get();
1478 aF = Standard_True;
1479 }
1480 }
7fd59977 1481 }
1482 }
1483
1484 if(!aES.Length()) {
d99f0355 1485 Message::SendFail() << "Data is not found in the Document";
7fd59977 1486 return 1;
1487 }
1488
1489 Standard_CString aFileName(arg[3]);
1490
57c28b61 1491#ifdef _MSC_VER
04232180 1492 std::ofstream anOS (aFileName, std::ios::in | std::ios::binary | std::ios::ate);
7fd59977 1493#else
04232180 1494 std::ofstream anOS (aFileName, std::ios::ate);
7fd59977 1495#endif
1496 if (!anOS) {
1497 // A problem with the stream
0797d9d3 1498#ifdef OCCT_DEBUG
04232180 1499 std::cout << "Error: problem with the file stream, rdstate = " <<anOS.rdstate() <<std::endl;
7fd59977 1500#endif
1501 }
91322f44 1502 unsigned char prefix[4] = {0xEF,0xBB,0xBF, 0x00};
7fd59977 1503 anOS.write( (char*)&prefix[0], 3);
1504 Standard_Integer n = aES.LengthOfCString();
29cb310a 1505 Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(n+1);
7fd59977 1506 n = aES.ToUTF8CString(aCstr);
1507 anOS.write( (char*)&aCstr[0], n);
1508 anOS.close();
1509 return 0;
1510 }
586db386 1511 di << "GetUTF : Data is not extracted to the specified file \n";
7fd59977 1512 return 1;
1513}
1514
1515//=======================================================================
5a1271c8 1516//function : SetByteArray (DF, entry, isDelta, [-g Guid,] From, To, elmt1, elmt2, ... )
7fd59977 1517//=======================================================================
1518static Standard_Integer DDataStd_SetByteArray (Draw_Interpretor& di,
1519 Standard_Integer nb,
1520 const char** arg)
1521{
8e1e79f0 1522 if (nb >= 6) {
7fd59977 1523 Handle(TDF_Data) DF;
1524 if (!DDF::GetDF(arg[1],DF)) return 1;
1525 TDF_Label label;
1526 DDF::AddLabel(DF, arg[2], label);
dde68833 1527 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
5a1271c8 1528 Standard_GUID guid;
1529 Standard_Boolean isGuid(Standard_False);
1530 Standard_Character c1(arg[4][0]), c2(arg[4][1]);
1531 if(c1 == '-' && c2 == 'g') { //guid
1532 if (!Standard_GUID::CheckGUIDFormat(arg[5])) {
1533 di<<"DDataStd_SetByteArray: The format of GUID is invalid\n";
1534 return 1;
1535 }
1536 guid = Standard_GUID (arg[5]);
1537 isGuid = Standard_True;
1538 }
1539 Standard_Integer j(4);
1540 if(isGuid) j = 6;
1541 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
1542 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
1543 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
1544 {
1545 di << "DDataStd_SetByteArray: From, To may be wrong\n";
1546 return 1;
1547 }
1548 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
8e1e79f0 1549 di << "Array of Standard_Byte with bounds from = " << From << " to = " << To << "\n";
5a1271c8 1550 Handle(TDataStd_ByteArray) A;
1551 if(!isGuid)
1552 A = TDataStd_ByteArray::Set(label, From, To, isDelta);
1553 else
1554 A = TDataStd_ByteArray::Set(label, guid, From, To, isDelta);
1555
1556 if ((!isGuid && nb > 6) || (isGuid && nb > 8)) {
1557 j = j + 2;
8e1e79f0 1558 for(Standard_Integer i = From; i<=To; ++i) {
1559 Standard_Integer ival = Draw::Atoi(arg[j]);
1560 if(ival < 0 || 255 < ival) {
d99f0355 1561 Message::SendFail() << "Bad value = " << ival;
8e1e79f0 1562 return 1;
1563 }
1564 A->SetValue(i, (Standard_Byte)ival);
1565 j++;
7fd59977 1566 }
7fd59977 1567 }
1568 return 0;
1569 }
586db386 1570 di << "DDataStd_SetByteArray: Error\n";
7fd59977 1571 return 1;
1572}
1573
8e1e79f0 1574//=======================================================================
1575//function : SetByteArrayValue (DF, entry, index, value)
1576//=======================================================================
1577static Standard_Integer DDataStd_SetByteArrayValue (Draw_Interpretor&,
1578 Standard_Integer,
1579 const char** arg)
1580{
1581 // Get document.
1582 Handle(TDF_Data) DF;
1583 if (!DDF::GetDF(arg[1], DF))
1584 return 1;
1585
1586 // Get label.
1587 TDF_Label label;
1588 if (!DDF::AddLabel(DF, arg[2], label))
1589 return 1;
1590
1591 // Get index and value.
1592 Standard_Integer index = Draw::Atoi(arg[3]);
1593 Standard_Integer value = Draw::Atoi(arg[4]);
1594
1595 // Check the value.
1596 if(value < 0 || 255 < value) {
d99f0355 1597 Message::SendFail() << "Bad value = " << value;
8e1e79f0 1598 return 1;
1599 }
1600
1601 // Set new value.
1602 Handle(TDataStd_ByteArray) arr;
1603 if (label.FindAttribute(TDataStd_ByteArray::GetID(), arr))
1604 {
1605 arr->SetValue(index, (Standard_Byte) value);
1606 return 0;
1607 }
1608
1609 return 1;
1610}
1611
f7b4312f 1612//=======================================================================
5a1271c8 1613//function : SetBooleanArray (DF, entry, [-g Guid,] From, To, elmt1, elmt2, ... )
f7b4312f 1614//=======================================================================
1615static Standard_Integer DDataStd_SetBooleanArray (Draw_Interpretor& di,
1616 Standard_Integer nb,
1617 const char** arg)
1618{
5a1271c8 1619 if (nb >= 5)
f7b4312f 1620 {
1621 Handle(TDF_Data) DF;
1622 if (!DDF::GetDF(arg[1],DF))
5a1271c8 1623 return 1;
f7b4312f 1624
1625 TDF_Label label;
1626 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1627 Standard_GUID guid;
1628 Standard_Boolean isGuid(Standard_False);
1629 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1630 if(c1 == '-' && c2 == 'g') { //guid
1631 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1632 di<<"DDataStd_SetBooleanArray: The format of GUID is invalid\n";
1633 return 1;
1634 }
1635 guid = Standard_GUID (arg[4]);
1636 isGuid = Standard_True;
1637 }
1638 Standard_Integer j(3);
1639 if(isGuid) j = 5;
1640 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
1641 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
1642 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
1643 {
1644 di << "DDataStd_SetBooleanArray: From, To may be wrong\n";
1645 return 1;
1646 }
1647 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
f7b4312f 1648 di << "Array of Standard_Boolean with bounds from = " << From << " to = " << To << "\n";
5a1271c8 1649 Handle(TDataStd_BooleanArray) A;
1650 if(!isGuid)
1651 A = TDataStd_BooleanArray::Set(label, From, To);
1652 else
1653 A = TDataStd_BooleanArray::Set(label, guid, From, To);
1654
1655 if ((!isGuid && nb > 5) || (isGuid && nb > 7)) {
1656 j = j + 2;
8e1e79f0 1657 for(Standard_Integer i = From; i<=To; i++)
f7b4312f 1658 {
8e1e79f0 1659 Standard_Integer ival = Draw::Atoi(arg[j]);
1660 if(ival > 1)
1661 {
d99f0355 1662 Message::SendFail() << "Bad value (" <<i <<") = " << ival<< ". 0 or 1 is expected.";
8e1e79f0 1663 return 1;
1664 }
dde68833 1665 A->SetValue(i, ival != 0);
8e1e79f0 1666 j++;
f7b4312f 1667 }
f7b4312f 1668 }
1669 return 0;
1670 }
586db386 1671 di << "DDataStd_SetBooleanArray: Error\n";
f7b4312f 1672 return 1;
1673}
1674
8e1e79f0 1675//=======================================================================
1676//function : SetBooleanArrayValue (DF, entry, index, value)
1677//=======================================================================
1678static Standard_Integer DDataStd_SetBooleanArrayValue (Draw_Interpretor& di,
1679 Standard_Integer,
1680 const char** arg)
1681{
1682 // Get document.
1683 Handle(TDF_Data) DF;
1684 if (!DDF::GetDF(arg[1], DF))
1685 return 1;
1686
1687 // Get label.
1688 TDF_Label label;
1689 if (!DDF::AddLabel(DF, arg[2], label))
1690 return 1;
1691
1692 // Get index and value.
1693 Standard_Integer index = Draw::Atoi(arg[3]);
1694 Standard_Integer value = Draw::Atoi(arg[4]);
1695
1696 // Check the value.
1697 if (value != 0 && value != 1) {
586db386 1698 di << "DDataStd_SetBooleanArrayValue: Error! The value should be either 0 or 1.\n";
8e1e79f0 1699 return 1;
1700 }
1701
1702 // Set new value.
1703 Handle(TDataStd_BooleanArray) arr;
1704 if (label.FindAttribute(TDataStd_BooleanArray::GetID(), arr))
1705 {
dde68833 1706 arr->SetValue(index, value != 0);
8e1e79f0 1707 return 0;
1708 }
1709
1710 return 1;
1711}
1712
d585e74e 1713//=======================================================================
5a1271c8 1714//function : DDataStd_SetExtStringList (DF, entry, [-g guid,] elmt1, elmt2, ... )
d585e74e 1715//=======================================================================
1716static Standard_Integer DDataStd_SetExtStringList (Draw_Interpretor& di,
1717 Standard_Integer nb,
1718 const char** arg)
1719{
1720 if (nb > 2)
1721 {
1722 Handle(TDF_Data) DF;
1723 if (!DDF::GetDF(arg[1],DF))
5a1271c8 1724 return 1;
d585e74e 1725
1726 TDF_Label label;
1727 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1728 Standard_GUID guid;
1729 Standard_Boolean isGuid(Standard_False);
1730 if(nb > 4) {
1731 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1732 if(c1 == '-' && c2 == 'g') { //guid
1733 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1734 di<<"DDataStd_SetExtStringList: The format of GUID is invalid\n";
1735 return 1;
1736 }
1737 guid = Standard_GUID (arg[4]);
1738 isGuid = Standard_True;
1739 }
1740 }
1741 Standard_Integer j(0);
1742 Handle(TDataStd_ExtStringList) A;
1743 if(!isGuid) {
1744 A = TDataStd_ExtStringList::Set(label);
1745 j = 3;
1746 }
1747 else {
1748 A = TDataStd_ExtStringList::Set(label, guid);
1749 j = 5;
1750 }
1751 for(Standard_Integer i = j; i <= nb - 1; i++)
d585e74e 1752 {
1753 TCollection_ExtendedString aValue(arg[i]);
1754 A->Append(aValue);
1755 }
1756 return 0;
1757 }
586db386 1758 di << "DDataStd_SetExtStringList: Error\n";
d585e74e 1759 return 1;
1760}
1761//
1762//=======================================================================
5a1271c8 1763//function : DDataStd_SetReferenceList (DF, entry, [-g guid] elmt1, elmt2, ... )
d585e74e 1764//=======================================================================
1765static Standard_Integer DDataStd_SetReferenceList (Draw_Interpretor& di,
1766 Standard_Integer nb,
1767 const char** arg)
1768{
1769 if (nb > 2)
1770 {
1771 Handle(TDF_Data) DF;
1772 if (!DDF::GetDF(arg[1],DF))
5a1271c8 1773 return 1;
d585e74e 1774
1775 TDF_Label label;
1776 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1777 Standard_GUID guid;
1778 Standard_Boolean isGuid(Standard_False);
1779 if(nb > 4) {
1780 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1781 if(c1 == '-' && c2 == 'g') { //guid
1782 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1783 di<<"DDataStd_SetReferenceList: The format of GUID is invalid\n";
1784 return 1;
1785 }
1786 guid = Standard_GUID (arg[4]);
1787 isGuid = Standard_True;
d585e74e 1788 }
d585e74e 1789 }
5a1271c8 1790 Standard_Integer j(0);
1791 Handle(TDataStd_ReferenceList) A;
1792 if(!isGuid) {
1793 A = TDataStd_ReferenceList::Set(label);
1794 j = 3;
1795 }
1796 else {
1797 A = TDataStd_ReferenceList::Set(label, guid);
1798 j = 5;
1799 }
1800 for(Standard_Integer i = j; i <= nb - 1; i++)
1801 {
1802 TDF_Label aValueLabel;
1803 DDF::AddLabel(DF, arg[i], aValueLabel);
1804 if(aValueLabel.IsNull()) continue;
1805 A->Append(aValueLabel);
1806 }
1807 return 0;
d585e74e 1808 }
586db386 1809 di << "DDataStd_SetReferenceList: Error\n";
d585e74e 1810 return 1;
1811}
1812
1813
f7b4312f 1814//=======================================================================
5a1271c8 1815//function : SetBooleanList (DF, entry, [-g Guid,] elmt1, elmt2, ... )
f7b4312f 1816//=======================================================================
1817static Standard_Integer DDataStd_SetBooleanList (Draw_Interpretor& di,
1818 Standard_Integer nb,
1819 const char** arg)
1820{
1821 if (nb > 2)
1822 {
1823 Handle(TDF_Data) DF;
1824 if (!DDF::GetDF(arg[1],DF))
1825 return 1;
1826
1827 TDF_Label label;
1828 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1829 Standard_GUID guid;
1830 Standard_Boolean isGuid(Standard_False);
1831 if(nb > 4) {
1832 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1833 if(c1 == '-' && c2 == 'g') { //guid
1834 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1835 di<<"DDataStd_SetBooleanList: The format of GUID is invalid\n";
1836 return 1;
1837 }
1838 guid = Standard_GUID (arg[4]);
1839 isGuid = Standard_True;
1840 }
1841 }
1842 Standard_Integer j(0);
1843 Handle(TDataStd_BooleanList) A;
1844 if(!isGuid) {
1845 A = TDataStd_BooleanList::Set(label);
1846 j = 3;
1847 }
1848 else {
1849 A = TDataStd_BooleanList::Set(label, guid);
1850 j = 5;
1851 }
1852 for(Standard_Integer i = j; i <= nb - 1; i++)
f7b4312f 1853 {
1854 Standard_Integer ival = Draw::Atoi(arg[i]);
1855 if(ival > 1)
1856 {
d99f0355 1857 Message::SendFail() << "Bad value = " << ival<< ". 0 or 1 is expected.";
f7b4312f 1858 return 1;
1859 }
dde68833 1860 A->Append (ival != 0);
f7b4312f 1861 }
1862 return 0;
1863 }
586db386 1864 di << "DDataStd_SetBooleanList: Error\n";
f7b4312f 1865 return 1;
1866}
1867
1868//=======================================================================
5a1271c8 1869//function : SetIntegerList (DF, entry, [-g guid] elmt1, elmt2, ... )
f7b4312f 1870//=======================================================================
1871static Standard_Integer DDataStd_SetIntegerList (Draw_Interpretor& di,
1872 Standard_Integer nb,
1873 const char** arg)
1874{
1875 if (nb > 2)
1876 {
1877 Handle(TDF_Data) DF;
1878 if (!DDF::GetDF(arg[1],DF))
5a1271c8 1879 return 1;
f7b4312f 1880
1881 TDF_Label label;
1882 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1883 Standard_GUID guid;
1884 Standard_Boolean isGuid(Standard_False);
1885 if(nb > 4) {
1886 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1887 if(c1 == '-' && c2 == 'g') { //guid
1888 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1889 di<<"DDataStd_SetIntegerList: The format of GUID is invalid\n";
1890 return 1;
1891 }
1892 guid = Standard_GUID (arg[4]);
1893 isGuid = Standard_True;
1894 }
1895 }
1896 Standard_Integer j(0);
1897 Handle(TDataStd_IntegerList) A;
1898 if(!isGuid) {
1899 A = TDataStd_IntegerList::Set(label);
1900 j = 3;
1901 }
1902 else {
1903 A = TDataStd_IntegerList::Set(label, guid);
1904 j = 5;
1905 }
1906 for(Standard_Integer i = j; i <= nb - 1; i++)
f7b4312f 1907 {
1908 Standard_Integer ival = Draw::Atoi(arg[i]);
1909 A->Append(ival);
1910 }
1911 return 0;
1912 }
586db386 1913 di << "DDataStd_SetIntegerList: Error\n";
f7b4312f 1914 return 1;
1915}
1916
1917//=======================================================================
5a1271c8 1918//function : SetRealList (DF, entry, [-g guid,] elmt1, elmt2, ... )
f7b4312f 1919//=======================================================================
1920static Standard_Integer DDataStd_SetRealList (Draw_Interpretor& di,
1921 Standard_Integer nb,
1922 const char** arg)
1923{
1924 if (nb > 2)
1925 {
1926 Handle(TDF_Data) DF;
1927 if (!DDF::GetDF(arg[1],DF))
5a1271c8 1928 return 1;
f7b4312f 1929
1930 TDF_Label label;
1931 DDF::AddLabel(DF, arg[2], label);
5a1271c8 1932 Standard_GUID guid;
1933 Standard_Boolean isGuid(Standard_False);
1934 if(nb > 4) {
1935 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
1936 if(c1 == '-' && c2 == 'g') { //guid
1937 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
1938 di<<"DDataStd_SetRealList: The format of GUID is invalid\n";
1939 return 1;
1940 }
1941 guid = Standard_GUID (arg[4]);
1942 isGuid = Standard_True;
1943 }
1944 }
1945 Standard_Integer j(0);
1946 Handle(TDataStd_RealList) A;
1947 if(!isGuid) {
1948 A = TDataStd_RealList::Set(label);
1949 j = 3;
1950 }
1951 else {
1952 A = TDataStd_RealList::Set(label, guid);
1953 j = 5;
1954 }
1955 for(Standard_Integer i = j; i <= nb - 1; i++)
f7b4312f 1956 {
1957 Standard_Real fval = Draw::Atof(arg[i]);
1958 A->Append(fval);
1959 }
1960 return 0;
1961 }
586db386 1962 di << "DDataStd_SetRealList: Error\n";
f7b4312f 1963 return 1;
1964}
1965
1ff07227 1966//=======================================================================
1967//function : DDataStd_InsertBeforeExtStringList (DF, entry, index, value )
1968//=======================================================================
1969static Standard_Integer DDataStd_InsertBeforeExtStringList (Draw_Interpretor& di,
1970 Standard_Integer nb,
1971 const char** arg)
1972{
1973 if (nb == 5)
1974 {
1975 Handle(TDF_Data) DF;
1976 if (!DDF::GetDF(arg[1],DF))
1977 return 1;
1978
1979 TDF_Label label;
1980 DDF::AddLabel(DF, arg[2], label);
1981
1982 Handle(TDataStd_ExtStringList) A;
1983 if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
1984 return 1;
1985
1986 Standard_Integer index = Draw::Atoi(arg[3]);
1987 TCollection_ExtendedString value = arg[4];
1988
1989 if (A->InsertBefore(index, value))
1990 return 0;
1991 else
1992 return 1;
1993 }
1994 di << "DDataStd_InsertBeforeExtStringList: Error\n";
1995 return 1;
1996}
1997
1998//=======================================================================
1999//function : DDataStd_InsertAfterExtStringList (DF, entry, index, value )
2000//=======================================================================
2001static Standard_Integer DDataStd_InsertAfterExtStringList (Draw_Interpretor& di,
2002 Standard_Integer nb,
2003 const char** arg)
2004{
2005 if (nb == 5)
2006 {
2007 Handle(TDF_Data) DF;
2008 if (!DDF::GetDF(arg[1],DF))
2009 return 1;
2010
2011 TDF_Label label;
2012 DDF::AddLabel(DF, arg[2], label);
2013
2014 Handle(TDataStd_ExtStringList) A;
2015 if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
2016 return 1;
2017
2018 Standard_Integer index = Draw::Atoi(arg[3]);
2019 TCollection_ExtendedString value = arg[4];
2020
2021 if (A->InsertAfter(index, value))
2022 return 0;
2023 else
2024 return 1;
2025 }
2026 di << "DDataStd_InsertAfterExtStringList: Error\n";
2027 return 1;
2028}
2029
2030//=======================================================================
2031//function : DDataStd_RemoveExtStringList (DF, entry, index )
2032//=======================================================================
2033static Standard_Integer DDataStd_RemoveExtStringList (Draw_Interpretor& di,
2034 Standard_Integer nb,
2035 const char** arg)
2036{
2037 if (nb == 4)
2038 {
2039 Handle(TDF_Data) DF;
2040 if (!DDF::GetDF(arg[1],DF))
2041 return 1;
2042
2043 TDF_Label label;
2044 DDF::AddLabel(DF, arg[2], label);
2045
2046 Handle(TDataStd_ExtStringList) A;
2047 if (!label.FindAttribute(TDataStd_ExtStringList::GetID(), A))
2048 return 1;
2049
2050 Standard_Integer index = Draw::Atoi(arg[3]);
2051
2052 if (A->Remove(index))
2053 return 0;
2054 else
2055 return 1;
2056 }
2057 di << "DDataStd_RemoveExtStringList: Error\n";
2058 return 1;
2059}
2060
2061//=======================================================================
2062//function : DDataStd_InsertBeforeBooleanList (DF, entry, index, value )
2063//=======================================================================
2064static Standard_Integer DDataStd_InsertBeforeBooleanList (Draw_Interpretor& di,
2065 Standard_Integer nb,
2066 const char** arg)
2067{
2068 if (nb == 5)
2069 {
2070 Handle(TDF_Data) DF;
2071 if (!DDF::GetDF(arg[1],DF))
2072 return 1;
2073
2074 TDF_Label label;
2075 DDF::AddLabel(DF, arg[2], label);
2076
2077 Handle(TDataStd_BooleanList) A;
2078 if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
2079 return 1;
2080
2081 Standard_Integer index = Draw::Atoi(arg[3]);
dde68833 2082 Standard_Boolean value = Draw::Atoi(arg[4]) != 0;
1ff07227 2083
2084 if (A->InsertBefore(index, value))
2085 return 0;
2086 else
2087 return 1;
2088 }
2089 di << "DDataStd_InsertBeforeBooleanList: Error\n";
2090 return 1;
2091}
2092
2093//=======================================================================
2094//function : DDataStd_InsertAfterBooleanList (DF, entry, index, value )
2095//=======================================================================
2096static Standard_Integer DDataStd_InsertAfterBooleanList (Draw_Interpretor& di,
2097 Standard_Integer nb,
2098 const char** arg)
2099{
2100 if (nb == 5)
2101 {
2102 Handle(TDF_Data) DF;
2103 if (!DDF::GetDF(arg[1],DF))
2104 return 1;
2105
2106 TDF_Label label;
2107 DDF::AddLabel(DF, arg[2], label);
2108
2109 Handle(TDataStd_BooleanList) A;
2110 if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
2111 return 1;
2112
2113 Standard_Integer index = Draw::Atoi(arg[3]);
dde68833 2114 Standard_Boolean value = Draw::Atoi(arg[4]) != 0;
1ff07227 2115
2116 if (A->InsertAfter(index, value))
2117 return 0;
2118 else
2119 return 1;
2120 }
2121 di << "DDataStd_InsertAfterBooleanList: Error\n";
2122 return 1;
2123}
2124
2125//=======================================================================
2126//function : DDataStd_RemoveBooleanList (DF, entry, index )
2127//=======================================================================
2128static Standard_Integer DDataStd_RemoveBooleanList (Draw_Interpretor& di,
2129 Standard_Integer nb,
2130 const char** arg)
2131{
2132 if (nb == 4)
2133 {
2134 Handle(TDF_Data) DF;
2135 if (!DDF::GetDF(arg[1],DF))
2136 return 1;
2137
2138 TDF_Label label;
2139 DDF::AddLabel(DF, arg[2], label);
2140
2141 Handle(TDataStd_BooleanList) A;
2142 if (!label.FindAttribute(TDataStd_BooleanList::GetID(), A))
2143 return 1;
2144
2145 Standard_Integer index = Draw::Atoi(arg[3]);
2146
2147 if (A->Remove(index))
2148 return 0;
2149 else
2150 return 1;
2151 }
2152 di << "DDataStd_RemoveBooleanList: Error\n";
2153 return 1;
2154}
2155
2156//=======================================================================
2157//function : DDataStd_InsertBeforeIntegerList (DF, entry, index, value )
2158//=======================================================================
2159static Standard_Integer DDataStd_InsertBeforeIntegerList (Draw_Interpretor& di,
2160 Standard_Integer nb,
2161 const char** arg)
2162{
2163 if (nb == 5)
2164 {
2165 Handle(TDF_Data) DF;
2166 if (!DDF::GetDF(arg[1],DF))
2167 return 1;
2168
2169 TDF_Label label;
2170 DDF::AddLabel(DF, arg[2], label);
2171
2172 Handle(TDataStd_IntegerList) A;
2173 if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
2174 return 1;
2175
2176 Standard_Integer index = Draw::Atoi(arg[3]);
2177 Standard_Integer value = (Standard_Integer) Draw::Atoi(arg[4]);
2178
2179 if (A->InsertBeforeByIndex(index, value))
2180 return 0;
2181 else
2182 return 1;
2183 }
2184 di << "DDataStd_InsertBeforeIntegerList: Error\n";
2185 return 1;
2186}
2187
2188//=======================================================================
2189//function : DDataStd_InsertAfterIntegerList (DF, entry, index, value )
2190//=======================================================================
2191static Standard_Integer DDataStd_InsertAfterIntegerList (Draw_Interpretor& di,
2192 Standard_Integer nb,
2193 const char** arg)
2194{
2195 if (nb == 5)
2196 {
2197 Handle(TDF_Data) DF;
2198 if (!DDF::GetDF(arg[1],DF))
2199 return 1;
2200
2201 TDF_Label label;
2202 DDF::AddLabel(DF, arg[2], label);
2203
2204 Handle(TDataStd_IntegerList) A;
2205 if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
2206 return 1;
2207
2208 Standard_Integer index = Draw::Atoi(arg[3]);
2209 Standard_Integer value = (Standard_Integer) Draw::Atoi(arg[4]);
2210
2211 if (A->InsertAfterByIndex(index, value))
2212 return 0;
2213 else
2214 return 1;
2215 }
2216 di << "DDataStd_InsertAfterIntegerList: Error\n";
2217 return 1;
2218}
2219
2220//=======================================================================
2221//function : DDataStd_RemoveIntegerList (DF, entry, index )
2222//=======================================================================
2223static Standard_Integer DDataStd_RemoveIntegerList (Draw_Interpretor& di,
2224 Standard_Integer nb,
2225 const char** arg)
2226{
2227 if (nb == 4)
2228 {
2229 Handle(TDF_Data) DF;
2230 if (!DDF::GetDF(arg[1],DF))
2231 return 1;
2232
2233 TDF_Label label;
2234 DDF::AddLabel(DF, arg[2], label);
2235
2236 Handle(TDataStd_IntegerList) A;
2237 if (!label.FindAttribute(TDataStd_IntegerList::GetID(), A))
2238 return 1;
2239
2240 Standard_Integer index = Draw::Atoi(arg[3]);
2241
2242 if (A->RemoveByIndex(index))
2243 return 0;
2244 else
2245 return 1;
2246 }
2247 di << "DDataStd_RemoveIntegerList: Error\n";
2248 return 1;
2249}
2250
2251//=======================================================================
2252//function : DDataStd_InsertBeforeRealList (DF, entry, index, value )
2253//=======================================================================
2254static Standard_Integer DDataStd_InsertBeforeRealList (Draw_Interpretor& di,
2255 Standard_Integer nb,
2256 const char** arg)
2257{
2258 if (nb == 5)
2259 {
2260 Handle(TDF_Data) DF;
2261 if (!DDF::GetDF(arg[1],DF))
2262 return 1;
2263
2264 TDF_Label label;
2265 DDF::AddLabel(DF, arg[2], label);
2266
2267 Handle(TDataStd_RealList) A;
2268 if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
2269 return 1;
2270
2271 Standard_Integer index = Draw::Atoi(arg[3]);
2272 Standard_Real value = (Standard_Real) Draw::Atof(arg[4]);
2273
2274 if (A->InsertBeforeByIndex(index, value))
2275 return 0;
2276 else
2277 return 1;
2278 }
2279 di << "DDataStd_InsertBeforeRealList: Error\n";
2280 return 1;
2281}
2282
2283//=======================================================================
2284//function : DDataStd_InsertAfterRealList (DF, entry, index, value )
2285//=======================================================================
2286static Standard_Integer DDataStd_InsertAfterRealList (Draw_Interpretor& di,
2287 Standard_Integer nb,
2288 const char** arg)
2289{
2290 if (nb == 5)
2291 {
2292 Handle(TDF_Data) DF;
2293 if (!DDF::GetDF(arg[1],DF))
2294 return 1;
2295
2296 TDF_Label label;
2297 DDF::AddLabel(DF, arg[2], label);
2298
2299 Handle(TDataStd_RealList) A;
2300 if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
2301 return 1;
2302
2303 Standard_Integer index = Draw::Atoi(arg[3]);
2304 Standard_Real value = (Standard_Real) Draw::Atof(arg[4]);
2305
2306 if (A->InsertAfterByIndex(index, value))
2307 return 0;
2308 else
2309 return 1;
2310 }
2311 di << "DDataStd_InsertAfterRealList: Error\n";
2312 return 1;
2313}
2314
2315//=======================================================================
2316//function : DDataStd_RemoveRealList (DF, entry, index )
2317//=======================================================================
2318static Standard_Integer DDataStd_RemoveRealList (Draw_Interpretor& di,
2319 Standard_Integer nb,
2320 const char** arg)
2321{
2322 if (nb == 4)
2323 {
2324 Handle(TDF_Data) DF;
2325 if (!DDF::GetDF(arg[1],DF))
2326 return 1;
2327
2328 TDF_Label label;
2329 DDF::AddLabel(DF, arg[2], label);
2330
2331 Handle(TDataStd_RealList) A;
2332 if (!label.FindAttribute(TDataStd_RealList::GetID(), A))
2333 return 1;
2334
2335 Standard_Integer index = Draw::Atoi(arg[3]);
2336
2337 if (A->RemoveByIndex(index))
2338 return 0;
2339 else
2340 return 1;
2341 }
2342 di << "DDataStd_RemoveRealList: Error\n";
2343 return 1;
2344}
2345
2346//=======================================================================
2347//function : DDataStd_InsertBeforeReferenceList (DF, entry, index, value )
2348//=======================================================================
2349static Standard_Integer DDataStd_InsertBeforeReferenceList (Draw_Interpretor& di,
2350 Standard_Integer nb,
2351 const char** arg)
2352{
2353 if (nb == 5)
2354 {
2355 Handle(TDF_Data) DF;
2356 if (!DDF::GetDF(arg[1],DF))
2357 return 1;
2358
2359 TDF_Label label;
2360 DDF::AddLabel(DF, arg[2], label);
2361
2362 Handle(TDataStd_ReferenceList) A;
2363 if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
2364 return 1;
2365
2366 Standard_Integer index = Draw::Atoi(arg[3]);
2367
2368 TDF_Label refLabel;
2369 if (!DDF::AddLabel(DF, arg[4], refLabel))
2370 return 1;
2371
2372 if (A->InsertBefore(index, refLabel))
2373 return 0;
2374 else
2375 return 1;
2376 }
2377 di << "DDataStd_InsertBeforeReferenceList: Error\n";
2378 return 1;
2379}
2380
2381//=======================================================================
2382//function : DDataStd_InsertAfterReferenceList (DF, entry, index, value )
2383//=======================================================================
2384static Standard_Integer DDataStd_InsertAfterReferenceList (Draw_Interpretor& di,
2385 Standard_Integer nb,
2386 const char** arg)
2387{
2388 if (nb == 5)
2389 {
2390 Handle(TDF_Data) DF;
2391 if (!DDF::GetDF(arg[1],DF))
2392 return 1;
2393
2394 TDF_Label label;
2395 DDF::AddLabel(DF, arg[2], label);
2396
2397 Handle(TDataStd_ReferenceList) A;
2398 if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
2399 return 1;
2400
2401 Standard_Integer index = Draw::Atoi(arg[3]);
2402
2403 TDF_Label refLabel;
2404 if (!DDF::AddLabel(DF, arg[4], refLabel))
2405 return 1;
2406
2407 if (A->InsertAfter(index, refLabel))
2408 return 0;
2409 else
2410 return 1;
2411 }
2412 di << "DDataStd_InsertAfterReferenceList: Error\n";
2413 return 1;
2414}
2415
2416//=======================================================================
2417//function : DDataStd_RemoveReferenceList (DF, entry, index )
2418//=======================================================================
2419static Standard_Integer DDataStd_RemoveReferenceList (Draw_Interpretor& di,
2420 Standard_Integer nb,
2421 const char** arg)
2422{
2423 if (nb == 4)
2424 {
2425 Handle(TDF_Data) DF;
2426 if (!DDF::GetDF(arg[1],DF))
2427 return 1;
2428
2429 TDF_Label label;
2430 DDF::AddLabel(DF, arg[2], label);
2431
2432 Handle(TDataStd_ReferenceList) A;
2433 if (!label.FindAttribute(TDataStd_ReferenceList::GetID(), A))
2434 return 1;
2435
2436 Standard_Integer index = Draw::Atoi(arg[3]);
2437
2438 if (A->Remove(index))
2439 return 0;
2440 else
2441 return 1;
2442 }
2443 di << "DDataStd_RemoveReferenceList: Error\n";
2444 return 1;
2445}
2446
7fd59977 2447//=======================================================================
5a1271c8 2448//function : GetByteArray (DF, entry [, guid] )
7fd59977 2449//=======================================================================
2450static Standard_Integer DDataStd_GetByteArray (Draw_Interpretor& di,
5a1271c8 2451 Standard_Integer nb,
7fd59977 2452 const char** arg)
2453{
5a1271c8 2454 if (nb >= 3)
2455 {
2456 Handle(TDF_Data) DF;
2457 if (!DDF::GetDF(arg[1],DF)) return 1;
2458 TDF_Label label;
2459 if( !DDF::FindLabel(DF, arg[2], label) ) {
2460 di << "No label for entry" << "\n";
2461 return 1;
2462 }
2463 Standard_GUID aGuid;
2464 if(nb == 4) {
2465 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2466 aGuid = Standard_GUID(arg[3]);
2467 else {
2468 di << "Wrong GUID format" << "\n";
2469 return 1;
2470 }
2471 } else
2472 aGuid = TDataStd_ByteArray::GetID();
2473 Handle(TDataStd_ByteArray) A;
2474 if ( !label.FindAttribute(aGuid, A) ) {
2475 di << "There is no TDataStd_ByteArray with the specified GUID at the label" << "\n";
2476 return 1;
2477 }
7fd59977 2478
5a1271c8 2479 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
5a1271c8 2480 di << A->Value(i);
2481 if(i<A->Upper())
2482 di<<" ";
2483 }
2484 di<<"\n";
2485 return 0;
7fd59977 2486 }
5a1271c8 2487 di << "DDataStd_GetByteArray: Error\n";
2488 return 1;
7fd59977 2489}
2490
8e1e79f0 2491//=======================================================================
2492//function : GetByteArrayValue (DF, entry, index)
2493//=======================================================================
2494static Standard_Integer DDataStd_GetByteArrayValue (Draw_Interpretor& di,
2495 Standard_Integer,
2496 const char** arg)
2497{
2498 Handle(TDF_Data) DF;
2499 if (!DDF::GetDF(arg[1],DF))
2500 return 1;
2501
2502 TDF_Label label;
2503 if (!DDF::FindLabel(DF, arg[2], label)) {
2504 di << "No label for entry" << "\n";
2505 return 1;
2506 }
2507
2508 Handle(TDataStd_ByteArray) A;
2509 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
2510 di << "There is no TDataStd_ByteArray under label" << "\n";
2511 return 1;
2512 }
2513
2514 Standard_Integer index = Draw::Atoi(arg[3]);
2515 if (index < A->Lower() || index > A->Upper()) {
586db386 2516 di << "Index is out of range\n";
8e1e79f0 2517 return 1;
2518 } else {
2519 di << A->Value(index) << "\n";
2520 }
2521
2522 return 0;
2523}
2524
f7b4312f 2525//=======================================================================
5a1271c8 2526//function : GetBooleanArray (DF, entry [, guid] )
f7b4312f 2527//=======================================================================
2528static Standard_Integer DDataStd_GetBooleanArray (Draw_Interpretor& di,
5a1271c8 2529 Standard_Integer nb,
f7b4312f 2530 const char** arg)
2531{
5a1271c8 2532 if (nb >= 3)
2533 {
2534 Handle(TDF_Data) DF;
2535 if (!DDF::GetDF(arg[1],DF))
f7b4312f 2536 return 1;
2537
5a1271c8 2538 TDF_Label label;
2539 if ( !DDF::FindLabel(DF, arg[2], label) )
2540 {
2541 di << "No label for entry" << "\n";
2542 return 1;
2543 }
2544 Standard_GUID aGuid;
2545 if(nb == 4) {
2546 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2547 aGuid = Standard_GUID(arg[3]);
2548 else {
2549 di << "Wrong GUID format" << "\n";
2550 return 1;
2551 }
2552 } else
2553 aGuid = TDataStd_BooleanArray::GetID();
2554
2555 Handle(TDataStd_BooleanArray) A;
2556 if ( !label.FindAttribute(aGuid, A) )
2557 {
2558 di << "There is no TDataStd_BooleanArray at label" << "\n";
2559 return 1;
2560 }
2561
2562 for (Standard_Integer i = A->Lower(); i<=A->Upper(); i++)
2563 {
2564 di << (Standard_Integer) A->Value(i);
2565 if (i < A->Upper())
2566 di << " ";
2567 }
2568 di << "\n";
2569 return 0;
f7b4312f 2570 }
5a1271c8 2571 di << "DDataStd_GetBooleanArray: Error\n";
2572 return 1;
f7b4312f 2573}
2574
8e1e79f0 2575//=======================================================================
2576//function : GetBooleanArrayValue (DF, entry, index)
2577//=======================================================================
2578static Standard_Integer DDataStd_GetBooleanArrayValue (Draw_Interpretor& di,
2579 Standard_Integer,
2580 const char** arg)
2581{
2582 Handle(TDF_Data) DF;
2583 if (!DDF::GetDF(arg[1],DF))
2584 return 1;
2585
2586 TDF_Label label;
2587 if (!DDF::FindLabel(DF, arg[2], label)) {
2588 di << "No label for entry" << "\n";
2589 return 1;
2590 }
2591
2592 Handle(TDataStd_BooleanArray) A;
2593 if ( !label.FindAttribute(TDataStd_BooleanArray::GetID(), A) ) {
2594 di << "There is no TDataStd_BooleanArray under label" << "\n";
2595 return 1;
2596 }
2597
2598 Standard_Integer index = Draw::Atoi(arg[3]);
2599 if (index < A->Lower() || index > A->Upper()) {
586db386 2600 di << "Index is out of range\n";
8e1e79f0 2601 return 1;
2602 } else {
2603 di << ((A->Value(index) == Standard_True) ? "True" : "False") << "\n";
2604 }
2605
2606 return 0;
2607}
2608
7fd59977 2609//=======================================================================
2610//function : ChangeByteArray (DF, entry, indx, val )
2611//=======================================================================
2612static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
2613 Standard_Integer nb,
2614 const char** arg)
2615{
2616
2617 if( nb == 5 ) {
2618 Handle(TDF_Data) DF;
2619 if (!DDF::GetDF(arg[1],DF)) return 1;
2620 TDF_Label label;
2621 if( !DDF::FindLabel(DF, arg[2], label) ) {
2622 di << "No label for entry" << "\n";
2623 return 1;
2624 }
2625
2626 Handle(TDataStd_ByteArray) A;
2627 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
2628 di << "There is no TDataStd_ByteArray at label" << "\n";
2629 return 1;
2630 }
91322f44 2631 Standard_Integer indx = Draw::Atoi(arg[3]);
2632 Standard_Integer ival = Draw::Atoi(arg[4]);
7fd59977 2633 if (ival > 255 || ival < 0) {
2634 di << "DDataStd_ChangeByteArray: Bad value = " <<ival << "\n";
5a1271c8 2635 return 1;
7fd59977 2636 }
2637 Standard_Integer low = A->Lower(), up = A->Upper();
2638 if(low <= indx && indx <= up)
8263fcd3 2639 A->SetValue(indx, (Standard_Byte)ival);
7fd59977 2640 else {
2641 Handle(TColStd_HArray1OfByte) Arr = A->InternalArray();
2642 Handle(TColStd_HArray1OfByte) arr;
2643 Standard_Integer i;
2644 if(indx > up) {
5a1271c8 2645 up = indx;
2646 arr = new TColStd_HArray1OfByte(low, up);
2647 for(i=low; i<= Arr->Upper(); i++)
2648 arr->SetValue(i, Arr->Value(i));
2649 for(i=Arr->Upper()+1; i<= up; i++) {
2650 if(i == up)
2651 arr->SetValue(i, (Standard_Byte)ival);
2652 else
2653 arr->SetValue(i, 0);
2654 }
7fd59977 2655 } else if(indx < up) {//clip array : indx to be negative
5a1271c8 2656 up = abs(indx);
2657 arr = new TColStd_HArray1OfByte(low, up);
2658 for(i=low; i< up; i++)
2659 arr->SetValue(i, Arr->Value(i));
2660 arr->SetValue(up, (Standard_Byte)ival);
7fd59977 2661 }
2662 A->ChangeArray(arr);
2663 }
2664 return 0;
2665 }
586db386 2666 di << "DDataStd_ChangeByteArray: Error\n";
7fd59977 2667 return 1;
2668}
f7b4312f 2669
2670//=======================================================================
5a1271c8 2671//function : GetBooleanList (DF, entry [, guid])
f7b4312f 2672//=======================================================================
2673static Standard_Integer DDataStd_GetBooleanList (Draw_Interpretor& di,
d585e74e 2674 Standard_Integer nb,
f7b4312f 2675 const char** arg)
2676{
5a1271c8 2677 if (nb >= 3) {
d585e74e 2678 Handle(TDF_Data) DF;
2679 if (!DDF::GetDF(arg[1],DF))
f7b4312f 2680 return 1;
2681
d585e74e 2682 TDF_Label label;
2683 if ( !DDF::FindLabel(DF, arg[2], label) )
2684 {
2685 di << "No label for entry" << "\n";
2686 return 1;
2687 }
5a1271c8 2688 Standard_GUID aGuid;
2689 if(nb == 4) {
2690 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2691 aGuid = Standard_GUID(arg[3]);
2692 else {
2693 di << "Wrong GUID format" << "\n";
2694 return 1;
2695 }
2696 } else
2697 aGuid = TDataStd_BooleanList::GetID();
2698
d585e74e 2699 Handle(TDataStd_BooleanList) A;
5a1271c8 2700 if ( !label.FindAttribute(aGuid, A) )
d585e74e 2701 {
5a1271c8 2702 di << "There is no TDataStd_BooleanList with the specified Guid at the label" << "\n";
d585e74e 2703 return 1;
2704 }
5a1271c8 2705
d585e74e 2706 const TDataStd_ListOfByte& bList = A->List();
2707 Standard_Boolean isEmpty = (bList.Extent() > 0) ? Standard_False : Standard_True;
2708 if(!isEmpty) {
2709 TDataStd_ListIteratorOfListOfByte itr(bList);
2710 for (; itr.More(); itr.Next())
2711 {
2712 di << (Standard_Integer) itr.Value() << " ";
2713 }
2714 di << "\n";
2715 } else
5a1271c8 2716 di << "List is empty\n";
d585e74e 2717 return 0;
f7b4312f 2718 }
586db386 2719 di << "DDataStd_GetBooleanList: Error\n";
d585e74e 2720 return 1;
f7b4312f 2721}
2722
2723//=======================================================================
5a1271c8 2724//function : GetIntegerList (DF, entry [, guid])
f7b4312f 2725//=======================================================================
2726static Standard_Integer DDataStd_GetIntegerList (Draw_Interpretor& di,
d585e74e 2727 Standard_Integer nb,
f7b4312f 2728 const char** arg)
d585e74e 2729{
5a1271c8 2730 if (nb >= 3) {
d585e74e 2731 Handle(TDF_Data) DF;
2732 if (!DDF::GetDF(arg[1],DF))
f7b4312f 2733 return 1;
2734
d585e74e 2735 TDF_Label label;
2736 if ( !DDF::FindLabel(DF, arg[2], label) )
2737 {
2738 di << "No label for entry" << "\n";
2739 return 1;
2740 }
5a1271c8 2741 Standard_GUID aGuid;
2742 if(nb == 4) {
2743 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2744 aGuid = Standard_GUID(arg[3]);
2745 else {
2746 di << "Wrong GUID format" << "\n";
2747 return 1;
2748 }
2749 } else
2750 aGuid = TDataStd_IntegerList::GetID();
2751
d585e74e 2752 Handle(TDataStd_IntegerList) A;
5a1271c8 2753 if ( !label.FindAttribute(aGuid, A) )
d585e74e 2754 {
5a1271c8 2755 di << "There is no TDataStd_IntegerList with the specified GUID at the label" << "\n";
d585e74e 2756 return 1;
2757 }
5a1271c8 2758
d585e74e 2759 const TColStd_ListOfInteger& iList = A->List();
2760 Standard_Boolean isEmpty = (iList.Extent() > 0) ? Standard_False : Standard_True;
2761 if(!isEmpty) {
2762 TColStd_ListIteratorOfListOfInteger itr(iList);
2763 for (; itr.More(); itr.Next())
2764 {
2765 di << itr.Value() << " ";
2766 }
2767 di << "\n";
2768 } else
586db386 2769 di << "List is empty\n";
d585e74e 2770
2771 return 0;
f7b4312f 2772 }
586db386 2773 di << "DDataStd_GetIntegerList: Error\n";
d585e74e 2774 return 1;
f7b4312f 2775}
2776
2777//=======================================================================
5a1271c8 2778//function : GetRealList (DF, entry [, guid])
f7b4312f 2779//=======================================================================
2780static Standard_Integer DDataStd_GetRealList (Draw_Interpretor& di,
d585e74e 2781 Standard_Integer nb,
f7b4312f 2782 const char** arg)
2783{
5a1271c8 2784 if (nb >= 3) {
d585e74e 2785 Handle(TDF_Data) DF;
2786 if (!DDF::GetDF(arg[1],DF))
f7b4312f 2787 return 1;
2788
d585e74e 2789 TDF_Label label;
2790 if ( !DDF::FindLabel(DF, arg[2], label) )
2791 {
2792 di << "No label for entry" << "\n";
2793 return 1;
2794 }
5a1271c8 2795 Standard_GUID aGuid;
2796 if(nb == 4) {
2797 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2798 aGuid = Standard_GUID(arg[3]);
2799 else {
2800 di << "Wrong GUID format" << "\n";
2801 return 1;
2802 }
2803 } else
2804 aGuid = TDataStd_RealList::GetID();
2805
d585e74e 2806 Handle(TDataStd_RealList) A;
5a1271c8 2807 if ( !label.FindAttribute(aGuid, A) )
d585e74e 2808 {
5a1271c8 2809 di << "There is no TDataStd_RealList with the specified GUID at the label" << "\n";
d585e74e 2810 return 1;
2811 }
5a1271c8 2812
d585e74e 2813 const TColStd_ListOfReal& rList = A->List();
2814 Standard_Boolean isEmpty = (rList.Extent() > 0) ? Standard_False : Standard_True;
2815 if(!isEmpty) {
2816 TColStd_ListIteratorOfListOfReal itr(rList);
2817 for (; itr.More(); itr.Next())
2818 {
2819 di << itr.Value() << " ";
2820 }
2821 di << "\n";
2822 } else
586db386 2823 di << "List is empty\n";
d585e74e 2824 return 0;
f7b4312f 2825 }
586db386 2826 di << "DDataStd_GetRealList: Error\n";
d585e74e 2827 return 1;
f7b4312f 2828}
2829
d585e74e 2830//=======================================================================
5a1271c8 2831//function : DDataStd_GetExtStringList (DF, entry [, guid])
d585e74e 2832//=======================================================================
2833static Standard_Integer DDataStd_GetExtStringList (Draw_Interpretor& di,
2834 Standard_Integer nb,
2835 const char** arg)
2836{
5a1271c8 2837 if (nb >= 3)
d585e74e 2838 {
2839 Handle(TDF_Data) DF;
2840 if (!DDF::GetDF(arg[1],DF))
2841 return 1;
2842
2843 TDF_Label label;
2844 if ( !DDF::FindLabel(DF, arg[2], label) )
2845 {
2846 di << "No label for entry" << "\n";
2847 return 1;
2848 }
5a1271c8 2849 Standard_GUID aGuid;
2850 if(nb == 4) {
2851 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2852 aGuid = Standard_GUID(arg[3]);
2853 else {
2854 di << "Wrong GUID format" << "\n";
2855 return 1;
2856 }
2857 } else
2858 aGuid = TDataStd_ExtStringList::GetID();
d585e74e 2859
2860 Handle(TDataStd_ExtStringList) A;
5a1271c8 2861 if ( !label.FindAttribute(aGuid, A) )
d585e74e 2862 {
2863 di << "There is no TDataStd_ExtStringList at label" << "\n";
2864 return 1;
2865 }
2866
2867 const TDataStd_ListOfExtendedString& aList = A->List();
2868 Standard_Boolean isEmpty = (aList.Extent() > 0) ? Standard_False : Standard_True;
2869 if(!isEmpty) {
2870 TDataStd_ListIteratorOfListOfExtendedString itr(aList);
2871 for (; itr.More(); itr.Next())
2872 {
2873 const TCollection_ExtendedString& aStr = itr.Value();
2874 di << aStr << " ";
2875 }
2876 di << "\n";
2877 }
2878 else {
586db386 2879 di << "List is empty\n";
d585e74e 2880 }
2881 return 0;
2882 }
586db386 2883 di << "DDataStd_GetExtStringList: Error\n";
d585e74e 2884 return 1;
2885}
2886
2887//=======================================================================
5a1271c8 2888//function : DDataStd_GetReferenceList (DF, entry [, guid])
d585e74e 2889//=======================================================================
2890static Standard_Integer DDataStd_GetReferenceList (Draw_Interpretor& di,
2891 Standard_Integer nb,
2892 const char** arg)
2893{
5a1271c8 2894 if (nb >= 3)
d585e74e 2895 {
2896 Handle(TDF_Data) DF;
2897 if (!DDF::GetDF(arg[1],DF))
5a1271c8 2898 return 1;
d585e74e 2899
2900 TDF_Label label;
2901 if ( !DDF::FindLabel(DF, arg[2], label) )
2902 {
2903 di << "No label for entry" << "\n";
2904 return 1;
2905 }
5a1271c8 2906 Standard_GUID aGuid;
2907 if(nb == 4) {
2908 if (Standard_GUID::CheckGUIDFormat(arg[3]))
2909 aGuid = Standard_GUID(arg[3]);
2910 else {
2911 di << "Wrong GUID format" << "\n";
2912 return 1;
2913 }
2914 } else
2915 aGuid = TDataStd_ReferenceList::GetID();
2916
d585e74e 2917 Handle(TDataStd_ReferenceList) A;
5a1271c8 2918 if ( !label.FindAttribute(aGuid, A) )
d585e74e 2919 {
5a1271c8 2920 di << "There is no TDataStd_ReferenceList [with the specified guid] at the label" << "\n";
d585e74e 2921 return 1;
2922 }
5a1271c8 2923
d585e74e 2924 const TDF_LabelList& aList = A->List();
2925 Standard_Boolean isEmpty = (aList.Extent() > 0) ? Standard_False : Standard_True;
2926 if(!isEmpty) {
2927 TDF_ListIteratorOfLabelList itr(aList);
2928 for (; itr.More(); itr.Next())
2929 {
2930 const TDF_Label& aLabel = itr.Value();
2931 if (!aLabel.IsNull()) {
2932 TCollection_AsciiString entry;
2933 TDF_Tool::Entry(aLabel, entry);
2934 di << entry.ToCString() << " ";
2935 }
2936 }
2937 di << "\n";
2938 } else
586db386 2939 di << "List is empty\n";
d585e74e 2940 return 0;
2941 }
586db386 2942 di << "DDataStd_GetReferenceList: Error\n";
d585e74e 2943 return 1;
2944}
2945//
7fd59977 2946//=======================================================================
2947//function : SetIntPackedMap (DF, entry, isDelta, key1, key2, ...
2948//=======================================================================
2949
2950static Standard_Integer DDataStd_SetIntPackedMap (Draw_Interpretor& di,
2951 Standard_Integer nb,
2952 const char** arg)
2953{
2954
2955 if (nb > 4) {
2956 Handle(TDF_Data) DF;
2957 if (!DDF::GetDF(arg[1],DF)) return 1;
2958 TDF_Label aLabel;
2959 DDF::AddLabel(DF, arg[2], aLabel);
dde68833 2960 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
7fd59977 2961 Standard_Integer aNum = nb - 4;
2962 Handle(TDataStd_IntPackedMap) anAtt;
2963 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
2964 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
2965 if(anAtt.IsNull()) {
2966 di << "IntPackedMap attribute is not found or not set" << "\n";
2967 return 1;}
2968
2969 Standard_Integer j = 4;
2970 TColStd_PackedMapOfInteger aMap;
2971 for(Standard_Integer i = 1; i<=aNum; i++) {
91322f44 2972 aMap.Add (Draw::Atoi(arg[j]));
7fd59977 2973 j++;
2974 }
2975 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
2976 anAtt->ChangeMap(aHMap);
04232180 2977 std::cout << "Map extent = " << anAtt->Extent()<<std::endl;
7fd59977 2978 return 0;
2979 }
586db386 2980 di << "DDataStd_SetIntPackedMap : Error\n";
7fd59977 2981 return 1;
2982}
2983
2984//=======================================================================
2985//function : GetIntPackedMap (DF, entry )
2986//=======================================================================
2987
2988static Standard_Integer DDataStd_GetIntPackedMap (Draw_Interpretor& di,
2989 Standard_Integer nb,
2990 const char** arg)
2991{
2992
2993 if (nb == 3) {
2994 Handle(TDF_Data) DF;
2995 if (!DDF::GetDF(arg[1],DF)) return 1;
2996 TDF_Label aLabel;
2997 DDF::AddLabel(DF, arg[2], aLabel);
2998 Handle(TDataStd_IntPackedMap) anAtt;
2999 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) {
3000 di << "IntPackedMap attribute is not found or not set" << "\n";
3001 return 1;}
3002//
3003 const TColStd_PackedMapOfInteger& aMap = anAtt->GetMap();
3004 TColStd_MapIteratorOfPackedMapOfInteger itr(aMap);
3005 for (Standard_Integer j = 1; itr.More(); itr.Next(),j++){
3006 Standard_Integer aKey(itr.Key());
f7b4312f 3007 di << aKey << " ";
7fd59977 3008 }
3009 return 0;
3010 }
586db386 3011 di << "DDataStd_GetIntPackedMap : Error\n";
7fd59977 3012 return 1;
3013}
3014
3015
3016//=======================================================================
3017//function : ChangeIntPackedMap_Add (DF, entry, Key1, Key2,... )
3018//=======================================================================
3019static Standard_Integer DDataStd_ChangeIntPackedMap_Add (Draw_Interpretor& di,
3020 Standard_Integer nb,
3021 const char** arg)
3022{
3023
3024 if( nb >= 4 ) {
3025 Handle(TDF_Data) DF;
3026 if (!DDF::GetDF(arg[1],DF)) return 1;
3027 TDF_Label label;
3028 if( !DDF::FindLabel(DF, arg[2], label) ) {
3029 di << "No label for entry" << "\n";
3030 return 1;
3031 }
3032
3033 Handle(TDataStd_IntPackedMap) A;
3034 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
3035 di << "There is no TDataStd_IntPackedMap at label" << "\n";
3036 return 1;
3037 }
3038
3039 Standard_Integer i, aNum = nb - 3;
3040 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
3041 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
3042 if(!aHMap.IsNull()) {
3043 ahMap->ChangeMap().Assign(aHMap->Map());
3044 for(i=1; i<=aNum;i++) {
5a1271c8 3045 Standard_Integer val = Draw::Atoi(arg[i+2]);
3046 if(!ahMap->Map().Contains(val))
3047 ahMap->ChangeMap().Add(val);
7fd59977 3048 }
3049
3050 A->ChangeMap(ahMap);
3051 }
3052 return 0;
3053 }
586db386 3054 di << "DDataStd_ChangeIntPackedMap_Add: Error\n";
7fd59977 3055 return 0;
3056}
3057
3058
3059//=======================================================================
3060//function : ChangeIntPackedMap_Rem (DF, entry, Key1, Key2,... )
3061//=======================================================================
3062static Standard_Integer DDataStd_ChangeIntPackedMap_Rem (Draw_Interpretor& di,
3063 Standard_Integer nb,
3064 const char** arg)
3065{
3066
3067 if( nb >= 4 ) {
3068 Handle(TDF_Data) DF;
3069 if (!DDF::GetDF(arg[1],DF)) return 1;
3070 TDF_Label label;
3071 if( !DDF::FindLabel(DF, arg[2], label) ) {
3072 di << "No label for entry" << "\n";
3073 return 1;
3074 }
3075
3076 Handle(TDataStd_IntPackedMap) A;
3077 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
3078 di << "There is no TDataStd_IntPackedMap at label" << "\n";
3079 return 1;
3080 }
3081
3082 Standard_Integer i, aNum = nb - 3;
3083 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
3084 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
3085 if(!aHMap.IsNull()) {
3086 ahMap->ChangeMap().Assign(aHMap->Map());
3087 for(i=1; i<=aNum;i++) {
5a1271c8 3088 Standard_Integer val = Draw::Atoi(arg[i+2]);
3089 if(ahMap->Map().Contains(val))
3090 ahMap->ChangeMap().Remove(val);
7fd59977 3091 }
3092
3093 A->ChangeMap(ahMap);
3094 }
3095 return 0;
3096 }
586db386 3097 di << "DDataStd_ChangeIntPackedMap_Rem: Error\n";
7fd59977 3098 return 0;
3099}
3100
3101//=======================================================================
3102//function : ChangeIntPackedMap_AddRem (DF, entry, Key1, Key2,... )
3103// : if Keyi exist in map - remove it, if no - add
3104//=======================================================================
3105static Standard_Integer DDataStd_ChangeIntPackedMap_AddRem (Draw_Interpretor& di,
3106 Standard_Integer nb,
3107 const char** arg)
3108{
3109
3110 if( nb >= 4 ) {
3111 Handle(TDF_Data) DF;
3112 if (!DDF::GetDF(arg[1],DF)) return 1;
3113 TDF_Label label;
3114 if( !DDF::FindLabel(DF, arg[2], label) ) {
3115 di << "No label for entry" << "\n";
3116 return 1;
3117 }
3118
3119 Handle(TDataStd_IntPackedMap) A;
3120 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
3121 di << "There is no TDataStd_IntPackedMap at label" << "\n";
3122 return 1;
3123 }
3124
3125 Standard_Integer i, aNum = nb - 3;
3126 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
3127 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
3128 if(!aHMap.IsNull()) {
3129 ahMap->ChangeMap().Assign(aHMap->Map());
3130 for(i=1; i<=aNum;i++) {
5a1271c8 3131 Standard_Integer val = Draw::Atoi(arg[i+2]);
3132 if(!ahMap->Map().Contains(val))
3133 ahMap->ChangeMap().Add(val);
3134 else
3135 ahMap->ChangeMap().Remove(val);
7fd59977 3136 }
3137
3138 A->ChangeMap(ahMap);
3139 }
3140 return 0;
3141 }
586db386 3142 di << "DDataStd_ChangeIntPackedMap_AddRem: Error\n";
7fd59977 3143 return 0;
3144}
3145
3146//=======================================================================
3147//function : SetIntPHugeMap (DF, entry, isDelta Num)
3148//=======================================================================
3149
3150static Standard_Integer DDataStd_SetIntPHugeMap (Draw_Interpretor& di,
3151 Standard_Integer nb,
3152 const char** arg)
3153{
3154
3155 if (nb > 4) {
3156 Handle(TDF_Data) DF;
3157 if (!DDF::GetDF(arg[1],DF)) return 1;
3158 TDF_Label aLabel;
3159 DDF::AddLabel(DF, arg[2], aLabel);
dde68833 3160 Standard_Boolean isDelta = Draw::Atoi(arg[3]) != 0;
91322f44 3161 Standard_Integer aNum = Draw::Atoi(arg[4]);
7fd59977 3162 Handle(TDataStd_IntPackedMap) anAtt;
3163 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
3164 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
3165 if(anAtt.IsNull()) {
3166 di << "IntPackedMap attribute is not found or not set" << "\n";
3167 return 1;}
3168
3169 TColStd_PackedMapOfInteger aMap;
3170 for(Standard_Integer i = 1; i<=aNum; i++) {
3171 aMap.Add (i);
3172 }
3173 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
3174 anAtt->ChangeMap(aHMap);
04232180 3175 std::cout << "Map extent = " << anAtt->Extent()<<std::endl;
7fd59977 3176 return 0;
3177 }
586db386 3178 di << "DDataStd_SetIntPHugeMap : Error\n";
7fd59977 3179 return 1;
3180}
3181
3182//=======================================================================
3183//function : SetNDataIntegers (DF, entry , Num
3184//=======================================================================
3185
3186static Standard_Integer DDataStd_SetNDataIntegers2 (Draw_Interpretor& di,
3187 Standard_Integer nb,
3188 const char** arg)
3189{
3190
3191 if (nb ==4) {
3192 Handle(TDF_Data) DF;
3193 if (!DDF::GetDF(arg[1],DF)) return 1;
3194 TDF_Label aLabel;
3195 DDF::AddLabel(DF, arg[2], aLabel);
91322f44 3196 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
7fd59977 3197 Handle(TDataStd_NamedData) anAtt;
3198 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3199 anAtt = TDataStd_NamedData::Set(aLabel);
3200 if(anAtt.IsNull()) {
3201 di << "NamedData attribute is not found or not set" << "\n";
3202 return 1;}
3203
3204 j = 1111;
3205 TCollection_ExtendedString aKey("Key_");
5a8d30b8 3206 anAtt->LoadDeferredData();
7fd59977 3207 for(Standard_Integer i = 1; i<=aNumP; i++) {
3208 TCollection_ExtendedString key = aKey + i;
3209 Standard_Integer aVal = j+i;
3210 anAtt->SetInteger(key, aVal);
3211 j +=1;
3212 }
3213 return 0;
3214 }
586db386 3215 di << "DDataStd_SetNDataIntegers2 : Error\n";
7fd59977 3216 return 1;
3217}
3218//================
3219//=======================================================================
3220//function : SetNDataIntArrays2 (DF, entry , key, NumOfArElem )
3221//=======================================================================
3222
3223static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di,
3224 Standard_Integer nb,
3225 const char** arg)
3226{
3227
3228 if (nb == 5) {
3229 Handle(TDF_Data) DF;
3230 if (!DDF::GetDF(arg[1],DF)) return 1;
3231 TDF_Label aLabel;
3232 DDF::AddLabel(DF, arg[2], aLabel);
3233
3234 Standard_Integer j;
3235 TCollection_ExtendedString aKey(arg[3]);
91322f44 3236 Standard_Integer aNum = Draw::Atoi(arg[4]);
7fd59977 3237 if (aNum <= 0) return 1;
3238 Handle(TDataStd_NamedData) anAtt;
3239 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3240 anAtt = TDataStd_NamedData::Set(aLabel);
3241 if(anAtt.IsNull()) {
d99f0355 3242 Message::SendFail() << "NamedData attribute is not found or not set";
7fd59977 3243 return 1;}
3244
3245 j = 15;
3246 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
3247 for(Standard_Integer i = 1; i<=aNum; i++) {
3248 Standard_Integer aVal = j++;
3249 anArr->SetValue(i, aVal);
3250 j++;
3251 }
5a8d30b8 3252 anAtt->LoadDeferredData();
7fd59977 3253 anAtt->SetArrayOfIntegers(aKey, anArr);
3254 return 0;
3255 }
586db386 3256 di << "DDataStd_SetNDataIntArrays2 : Error\n";
7fd59977 3257 return 1;
3258}
3259
3260
3261//=======================================================================
fa53efef 3262//function : SetAsciiString(DF, entry, String[, guid])
7fd59977 3263//=======================================================================
3264
3265static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
3266 Standard_Integer nb,
3267 const char** arg)
3268{
3269
fa53efef 3270 if (nb == 4 || nb == 5) {
7fd59977 3271 Handle(TDF_Data) DF;
3272 if (!DDF::GetDF(arg[1],DF)) return 1;
3273 TDF_Label aLabel;
3274 DDF::AddLabel(DF, arg[2], aLabel);
3275 TCollection_AsciiString aString(arg[3]);
5a1271c8 3276 Standard_GUID aGuid (TDataStd_AsciiString::GetID());
3277 if(nb == 5) {
3278 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
fa53efef 3279 di<<"DDataStd_SetAsciiString: The format of GUID is invalid\n";
3280 return 1;
5a1271c8 3281 }
3282 aGuid = Standard_GUID (arg[4]);
3283 }
fa53efef 3284
3285 Handle(TDataStd_AsciiString) anAtt = TDataStd_AsciiString::Set(aLabel, aGuid, aString);
7fd59977 3286 if(anAtt.IsNull()) {
3287 di << "AsciiString attribute is not found or not set" << "\n";
fa53efef 3288 return 1;
5a1271c8 3289 }
7fd59977 3290
04232180 3291 std::cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << std::endl;
7fd59977 3292 return 0;
3293 }
586db386 3294 di << "DDataStd_SetAsciiString : Error\n";
7fd59977 3295 return 1;
3296}
3297//
3298//=======================================================================
fa53efef 3299//function : GetAsciiString(DF, entry[, guid] )
7fd59977 3300//=======================================================================
3301
3302static Standard_Integer DDataStd_GetAsciiString (Draw_Interpretor& di,
3303 Standard_Integer nb,
3304 const char** arg)
3305{
fa53efef 3306 if (nb == 3 || nb == 4) {
7fd59977 3307 Handle(TDF_Data) DF;
3308 if (!DDF::GetDF(arg[1],DF)) return 1;
fa53efef 3309 TDF_Label aLabel;
3310 DDF::FindLabel(DF, arg[2], aLabel);
3311 if(aLabel.IsNull()) di << "Label is not found" << "\n";
3312 Standard_GUID aGuid (TDataStd_AsciiString::GetID());
3313 if(nb == 4) {
3314 if (!Standard_GUID::CheckGUIDFormat(arg[3])) {
3315 di<<"DDataStd_GetAsciiString: The format of GUID is invalid\n";
3316 return 1;
5a1271c8 3317 }
3318 aGuid = Standard_GUID(arg[3]);
3319 }
3320 Handle(TDataStd_AsciiString) anAtt;
3321 if( !aLabel.FindAttribute(aGuid, anAtt) ) {
d99f0355 3322 Message::SendFail() << "AsciiString attribute is not found or not set";
5a1271c8 3323 return 1;
3324 }
fa53efef 3325
3326#ifdef DEB_DDataStd
04232180 3327 std::cout << "String = " << anAtt->Get().ToCString() << std::endl;
fa53efef 3328#endif
3329 di << anAtt->Get().ToCString();
7fd59977 3330 return 0;
3331 }
586db386 3332 di << "DDataStd_GetAsciiString : Error\n";
7fd59977 3333 return 1;
3334}
3335
3336//=======================================================================
3337//function : SetNDataIntegers (DF, entry , Num, key1, val1, ...
3338//=======================================================================
3339
3340static Standard_Integer DDataStd_SetNDataIntegers (Draw_Interpretor& di,
3341 Standard_Integer nb,
3342 const char** arg)
3343{
3344
3345 if (nb >=6) {
3346 Handle(TDF_Data) DF;
3347 if (!DDF::GetDF(arg[1],DF)) return 1;
3348 TDF_Label aLabel;
3349 DDF::AddLabel(DF, arg[2], aLabel);
3350//
3351// TCollection_ExtendedString aString("123456789 0_abcde");
3352// Standard_Integer aPos = aString.Search(" ");
04232180 3353// std::cout << "From Start = " <<aPos<<std::endl;
7fd59977 3354// aPos = aString.SearchFromEnd(" ");
04232180 3355// std::cout << "From Start = " <<aPos<<std::endl;
7fd59977 3356// TCollection_ExtendedString aValue = aString.Split(aPos);
04232180 3357// std::cout << "Value = |"<<aValue<<std::endl;
3358// std::cout << "aKey = " << aString << "|"<<std::endl;
7fd59977 3359//
91322f44 3360 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
7fd59977 3361 Handle(TDataStd_NamedData) anAtt;
3362 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3363 anAtt = TDataStd_NamedData::Set(aLabel);
3364 if(anAtt.IsNull()) {
3365 di << "NamedData attribute is not found or not set" << "\n";
3366 return 1;}
3367
3368 j = 4;
5a8d30b8 3369 anAtt->LoadDeferredData();
7fd59977 3370 for(Standard_Integer i = 1; i<=aNumP; i++) {
3371 TCollection_ExtendedString aKey(arg[j]);
91322f44 3372 Standard_Integer aVal = Draw::Atoi(arg[j+1]);
7fd59977 3373 anAtt->SetInteger(aKey, aVal);
3374 j +=2;
3375 }
3376 return 0;
3377 }
586db386 3378 di << "DDataStd_SetNDataIntegers : Error\n";
7fd59977 3379 return 1;
3380}
3381
3382
3383//=======================================================================
3384//function : GetNDIntegers(DF, entry )
3385//=======================================================================
3386static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di,
3387 Standard_Integer nb,
3388 const char** arg)
3389{
3390
3391 if (nb == 3) {
3392 Handle(TDF_Data) DF;
3393 if (!DDF::GetDF(arg[1],DF)) return 1;
3394 TDF_Label aLabel;
3395 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3396
3397
3398 Handle(TDataStd_NamedData) anAtt;
d99f0355 3399 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3400 {
3401 Message::SendFail() << "NamedData attribute is not found or not set";
3402 return 1;
3403 }
3404
04232180 3405 std::cout <<std::endl;
3406 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3407 anAtt->LoadDeferredData();
7fd59977 3408 const TColStd_DataMapOfStringInteger& aMap = anAtt->GetIntegersContainer();
3409 TColStd_DataMapIteratorOfDataMapOfStringInteger itr(aMap);
3410 for (; itr.More(); itr.Next()){
3411 TCollection_ExtendedString aKey(itr.Key());
7fd59977 3412 Standard_Integer aValue = itr.Value();
ae9f4b64 3413 di << "Key = " << aKey << " Value = " << aValue << "\n";
7fd59977 3414 }
3415
3416 return 0;
3417 }
586db386 3418 di << "DDataStd_GetNDIntegers : Error\n";
7fd59977 3419 return 1;
3420}
3421
3422//=======================================================================
3423//function : GetNDInteger(DF, entry, key [drawname])
3424//=======================================================================
3425static Standard_Integer DDataStd_GetNDInteger (Draw_Interpretor& di,
5a1271c8 3426 Standard_Integer nb,
3427 const char** arg)
3428{
7fd59977 3429
3430 if (nb >=4) {
3431 Handle(TDF_Data) DF;
3432 if (!DDF::GetDF(arg[1],DF)) return 1;
3433 TDF_Label aLabel;
3434 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3435
3436
3437 Handle(TDataStd_NamedData) anAtt;
d99f0355 3438 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3439 {
3440 Message::SendFail() << "NamedData attribute is not found or not set";
3441 return 1;
3442 }
7fd59977 3443
04232180 3444 std::cout <<std::endl;
3445 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3446 anAtt->LoadDeferredData();
7fd59977 3447 if(!anAtt->HasInteger(arg[3])) {
04232180 3448 std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
7fd59977 3449 return 1;
3450 } else {
04232180 3451 std::cout << "Key = " << arg[3] << " Value = " <<anAtt->GetInteger(arg[3])<<std::endl;
7fd59977 3452 if(nb == 5)
5a1271c8 3453 Draw::Set(arg[4], anAtt->GetInteger(arg[3]));
7fd59977 3454 return 0;
3455 }
3456 }
586db386 3457 di << "DDataStd_SetNDataIntegers : Error\n";
7fd59977 3458 return 1;
3459}
3460
3461//========================== REALS ======================================
3462//=======================================================================
3463//function : SetNDataReals (DF, entry , Num, key1, val1, ...
3464//=======================================================================
3465
3466static Standard_Integer DDataStd_SetNDataReals (Draw_Interpretor& di,
3467 Standard_Integer nb,
3468 const char** arg)
3469{
3470
3471 if (nb >=6) {
3472 Handle(TDF_Data) DF;
3473 if (!DDF::GetDF(arg[1],DF)) return 1;
3474 TDF_Label aLabel;
3475 DDF::AddLabel(DF, arg[2], aLabel);
3476
91322f44 3477 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
7fd59977 3478 Handle(TDataStd_NamedData) anAtt;
3479 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3480 anAtt = TDataStd_NamedData::Set(aLabel);
d99f0355 3481 if(anAtt.IsNull())
3482 {
3483 Message::SendFail() << "NamedData attribute is not found or not set";
3484 return 1;
3485 }
7fd59977 3486
3487 j = 4;
5a8d30b8 3488 anAtt->LoadDeferredData();
7fd59977 3489 for(Standard_Integer i = 1; i<=aNumP; i++) {
3490 TCollection_ExtendedString aKey(arg[j]);
91322f44 3491 Standard_Real aVal = Draw::Atof(arg[j+1]);
7fd59977 3492 anAtt->SetReal(aKey, aVal);
3493 j +=2;
3494 }
3495 return 0;
3496 }
586db386 3497 di << "DDataStd_SetNDataReals : Error\n";
7fd59977 3498 return 1;
3499}
3500
3501//=======================================================================
3502//function : GetNDReals(DF, entry )
3503//=======================================================================
3504static Standard_Integer DDataStd_GetNDReals (Draw_Interpretor& di,
3505 Standard_Integer nb,
3506 const char** arg)
3507{
3508
3509 if (nb == 3) {
3510 Handle(TDF_Data) DF;
3511 if (!DDF::GetDF(arg[1],DF)) return 1;
3512 TDF_Label aLabel;
3513 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3514
04232180 3515 std::cout <<std::endl;
3516 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
7fd59977 3517 Handle(TDataStd_NamedData) anAtt;
d99f0355 3518 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3519 {
3520 Message::SendFail() << "NamedData attribute is not found or not set";
3521 return 1;
3522 }
7fd59977 3523
5a8d30b8 3524 anAtt->LoadDeferredData();
7fd59977 3525 const TDataStd_DataMapOfStringReal& aMap = anAtt->GetRealsContainer();
3526 TDataStd_DataMapIteratorOfDataMapOfStringReal itr(aMap);
3527 for (; itr.More(); itr.Next()){
3528 TCollection_ExtendedString aKey(itr.Key());
7fd59977 3529 Standard_Real aValue = itr.Value();
ae9f4b64 3530 di << "Key = " << aKey << " Value = " << aValue << "\n";
7fd59977 3531 }
3532 return 0;
3533 }
586db386 3534 di << "DDataStd_GetNDReals : Error\n";
7fd59977 3535 return 1;
3536}
3537
3538//=======================================================================
3539//function : GetNDReal(DF, entry, key [drawname])
3540//=======================================================================
3541static Standard_Integer DDataStd_GetNDReal (Draw_Interpretor& di,
3542 Standard_Integer nb,
3543 const char** arg)
3544{
3545
3546 if (nb >=4) {
3547 Handle(TDF_Data) DF;
3548 if (!DDF::GetDF(arg[1],DF)) return 1;
3549 TDF_Label aLabel;
3550 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3551
3552
3553 Handle(TDataStd_NamedData) anAtt;
d99f0355 3554 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3555 {
3556 Message::SendFail() << "NamedData attribute is not found or not set";
3557 return 1;
3558 }
7fd59977 3559
04232180 3560 std::cout <<std::endl;
3561 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3562 anAtt->LoadDeferredData();
7fd59977 3563 if(!anAtt->HasReal(arg[3])) {
d99f0355 3564 Message::SendFail() << "There is no data specified by Key = " << arg[3];
7fd59977 3565 return 1;
3566 } else {
04232180 3567 std::cout << "Key = " << arg[3] << " Value = " <<anAtt->GetReal(arg[3])<<std::endl;
7fd59977 3568 if(nb == 5)
5a1271c8 3569 Draw::Set(arg[4], anAtt->GetReal(arg[3]));
7fd59977 3570 return 0;
3571 }
3572 }
586db386 3573 di << "DDataStd_GetNDReal : Error\n";
7fd59977 3574 return 1;
3575}
3576
3577//======================= Strings =======================================
3578//=======================================================================
3579//function : SetNDataStrings (DF, entry , Num, key1, val1, ...
3580//=======================================================================
3581
3582static Standard_Integer DDataStd_SetNDataStrings (Draw_Interpretor& di,
3583 Standard_Integer nb,
3584 const char** arg)
3585{
3586
3587 if (nb >=6) {
3588 Handle(TDF_Data) DF;
3589 if (!DDF::GetDF(arg[1],DF)) return 1;
3590 TDF_Label aLabel;
3591 DDF::AddLabel(DF, arg[2], aLabel);
3592
91322f44 3593 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
7fd59977 3594 Handle(TDataStd_NamedData) anAtt;
3595 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3596 anAtt = TDataStd_NamedData::Set(aLabel);
3597 if(anAtt.IsNull()) {
3598 di << "NamedData attribute is not found or not set" << "\n";
3599 return 1;}
3600
3601 j = 4;
5a8d30b8 3602 anAtt->LoadDeferredData();
7fd59977 3603 for(Standard_Integer i = 1; i<=aNumP; i++) {
3604 TCollection_ExtendedString aKey(arg[j]);
3605 TCollection_ExtendedString aVal(arg[j+1]);
3606 anAtt->SetString(aKey, aVal);
3607 j +=2;
3608 }
3609 return 0;
3610 }
586db386 3611 di << "DDataStd_SetNDataStrings : Error\n";
7fd59977 3612 return 1;
3613}
3614
3615//=======================================================================
3616//function : GetNDStrings(DF, entry )
3617//=======================================================================
8bfae263 3618namespace
3619{
3620 typedef std::pair<TCollection_ExtendedString, TCollection_ExtendedString>
3621 DDataStd_GetNDStrings_Property;
3622
3623 bool isLess(
3624 const DDataStd_GetNDStrings_Property& theProperty1,
3625 const DDataStd_GetNDStrings_Property& theProperty2)
3626 {
3627 return theProperty1.first.IsLess(theProperty2.first);
3628 }
3629}
3630
7fd59977 3631static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di,
3632 Standard_Integer nb,
3633 const char** arg)
3634{
3635
3636 if (nb == 3) {
3637 Handle(TDF_Data) DF;
3638 if (!DDF::GetDF(arg[1],DF)) return 1;
3639 TDF_Label aLabel;
3640 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3641
3642
3643 Handle(TDataStd_NamedData) anAtt;
d99f0355 3644 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3645 {
3646 Message::SendFail() << "NamedData attribute is not found or not set";
3647 return 1;
3648 }
3649
04232180 3650 std::cout <<std::endl;
3651 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3652 anAtt->LoadDeferredData();
7fd59977 3653 const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer();
8bfae263 3654
3655 std::vector<DDataStd_GetNDStrings_Property> aProperties;
3656 for (TDataStd_DataMapIteratorOfDataMapOfStringString aIt (aMap); aIt.More(); aIt.Next())
3657 {
3658 aProperties.push_back(DDataStd_GetNDStrings_Property (aIt.Key(), aIt.Value()));
3659 }
3660 std::sort (aProperties.begin(), aProperties.end(), isLess);
3661
3662 for (std::vector<DDataStd_GetNDStrings_Property>::size_type aI = 0; aI < aProperties.size(); ++aI)
3663 {
3664 di << "Key = " << aProperties[aI].first << " Value = " << aProperties[aI].second << "\n";
3665 }
3666
3667 return 0;
7fd59977 3668 }
586db386 3669 di << "DDataStd_GetNDStrings : Error\n";
7fd59977 3670 return 1;
3671}
3672
3673//=======================================================================
3674//function : GetNDString(DF, entry, key [drawname])
3675//=======================================================================
3676static Standard_Integer DDataStd_GetNDString (Draw_Interpretor& di,
3677 Standard_Integer nb,
3678 const char** arg)
3679{
3680
3681 if (nb >=4) {
3682 Handle(TDF_Data) DF;
3683 if (!DDF::GetDF(arg[1],DF)) return 1;
3684 TDF_Label aLabel;
3685 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3686
3687
3688 Handle(TDataStd_NamedData) anAtt;
3689 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
3690 di << "NamedData attribute is not found or not set" << "\n";
3691 return 1;}
3692
04232180 3693 std::cout <<std::endl;
3694 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3695 anAtt->LoadDeferredData();
d99f0355 3696 if (!anAtt->HasString(arg[3]))
3697 {
3698 Message::SendFail() << "There is no data specified by Key = " << arg[3];
7fd59977 3699 return 1;
d99f0355 3700 }
3701 else
3702 {
ae9f4b64 3703 TCollection_AsciiString aValue (anAtt->GetString(arg[3]));
04232180 3704 std::cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << std::endl;
7fd59977 3705 if(nb == 5)
5a1271c8 3706 Draw::Set(arg[4], aValue.ToCString());
7fd59977 3707 return 0;
3708 }
3709 }
586db386 3710 di << "DDataStd_GetNDString : Error\n";
7fd59977 3711 return 1;
3712}
3713
3714//=========================== Bytes =====================================
3715//=======================================================================
3716//function : SetNDataBytes (DF, entry , Num, key1, val1, ...
3717//=======================================================================
3718
3719static Standard_Integer DDataStd_SetNDataBytes (Draw_Interpretor& di,
3720 Standard_Integer nb,
3721 const char** arg)
3722{
3723
3724 if (nb >=6) {
3725 Handle(TDF_Data) DF;
3726 if (!DDF::GetDF(arg[1],DF)) return 1;
3727 TDF_Label aLabel;
3728 DDF::AddLabel(DF, arg[2], aLabel);
3729
91322f44 3730 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
7fd59977 3731 Handle(TDataStd_NamedData) anAtt;
3732 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3733 anAtt = TDataStd_NamedData::Set(aLabel);
d99f0355 3734 if(anAtt.IsNull())
3735 {
3736 Message::SendFail() << "NamedData attribute is not found or not set";
3737 return 1;
3738 }
7fd59977 3739
3740 j = 4;
5a8d30b8 3741 anAtt->LoadDeferredData();
7fd59977 3742 for(Standard_Integer i = 1; i<=aNumP; i++) {
3743 TCollection_ExtendedString aKey(arg[j]);
91322f44 3744 Standard_Byte aVal = (Standard_Byte)Draw::Atoi(arg[j+1]);
7fd59977 3745 anAtt->SetByte(aKey, aVal);
3746 j +=2;
3747 }
3748 return 0;
3749 }
586db386 3750 di << "DDataStd_SetNDataBytes : Error\n";
7fd59977 3751 return 1;
3752}
3753
3754//=======================================================================
3755//function : GetNDBytes(DF, entry )
3756//=======================================================================
3757static Standard_Integer DDataStd_GetNDBytes (Draw_Interpretor& di,
3758 Standard_Integer nb,
3759 const char** arg)
3760{
3761
3762 if (nb == 3) {
3763 Handle(TDF_Data) DF;
3764 if (!DDF::GetDF(arg[1],DF)) return 1;
3765 TDF_Label aLabel;
3766 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3767
3768
3769 Handle(TDataStd_NamedData) anAtt;
d99f0355 3770 if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3771 {
3772 Message::SendFail() << "NamedData attribute is not found or not set";
3773 return 1;
3774 }
3775
04232180 3776 std::cout <<std::endl;
3777 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3778 anAtt->LoadDeferredData();
7fd59977 3779 const TDataStd_DataMapOfStringByte& aMap = anAtt->GetBytesContainer();
3780 TDataStd_DataMapIteratorOfDataMapOfStringByte itr(aMap);
ae9f4b64 3781 for (; itr.More(); itr.Next())
3782 {
7fd59977 3783 TCollection_ExtendedString aKey(itr.Key());
7fd59977 3784 Standard_Byte aValue = itr.Value();
ae9f4b64 3785 std::cout << "Key = " << aKey << " Value = " <<aValue<<std::endl;
3786 }
7fd59977 3787 return 0;
3788 }
586db386 3789 di << "DDataStd_GetNDBytes : Error\n";
7fd59977 3790 return 1;
3791}
3792
3793//=======================================================================
3794//function : GetNDByte(DF, entry, key [drawname])
3795//=======================================================================
3796static Standard_Integer DDataStd_GetNDByte (Draw_Interpretor& di,
3797 Standard_Integer nb,
3798 const char** arg)
3799{
3800
3801 if (nb >=4) {
3802 Handle(TDF_Data) DF;
3803 if (!DDF::GetDF(arg[1],DF)) return 1;
3804 TDF_Label aLabel;
3805 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3806
3807
3808 Handle(TDataStd_NamedData) anAtt;
d99f0355 3809 if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3810 {
3811 Message::SendFail() << "NamedData attribute is not found or not set";
3812 return 1;
3813 }
7fd59977 3814
04232180 3815 std::cout <<std::endl;
3816 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3817 anAtt->LoadDeferredData();
d99f0355 3818 if (!anAtt->HasByte(arg[3]))
3819 {
3820 Message::SendFail() << "There is no data specified by Key = " << arg[3];
7fd59977 3821 return 1;
d99f0355 3822 }
3823 else
3824 {
04232180 3825 std::cout << "Key = " << arg[3] << " Value = " <<anAtt->GetByte(arg[3])<< std::endl;
7fd59977 3826 if(nb == 5)
5a1271c8 3827 Draw::Set(arg[4], anAtt->GetByte(arg[3]));
7fd59977 3828 return 0;
3829 }
3830 }
586db386 3831 di << "DDataStd_GetNDByte : Error\n";
7fd59977 3832 return 1;
3833}
3834//======================== IntArrays ====================================
3835//=======================================================================
3836//function : SetNDataIntArrays (DF, entry , key, NumOfArElem, val1, val2,... )
3837//=======================================================================
3838
3839static Standard_Integer DDataStd_SetNDataIntAr (Draw_Interpretor& di,
3840 Standard_Integer nb,
3841 const char** arg)
3842{
3843
3844 if (nb >=6) {
3845 Handle(TDF_Data) DF;
3846 if (!DDF::GetDF(arg[1],DF)) return 1;
3847 TDF_Label aLabel;
3848 DDF::AddLabel(DF, arg[2], aLabel);
3849
3850 Standard_Integer j;
3851 TCollection_ExtendedString aKey(arg[3]);
91322f44 3852 Standard_Integer aNum = Draw::Atoi(arg[4]);
7fd59977 3853 if (aNum <= 0) return 1;
3854 Handle(TDataStd_NamedData) anAtt;
3855 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3856 anAtt = TDataStd_NamedData::Set(aLabel);
d99f0355 3857 if (anAtt.IsNull())
3858 {
3859 Message::SendFail() << "NamedData attribute is not found or not set";
3860 return 1;
3861 }
7fd59977 3862
3863 j = 5;
3864 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
3865 for(Standard_Integer i = 1; i<=aNum; i++) {
91322f44 3866 Standard_Integer aVal = Draw::Atoi(arg[j]);
7fd59977 3867 anArr->SetValue(i, aVal);
3868 j++;
3869 }
5a8d30b8 3870 anAtt->LoadDeferredData();
7fd59977 3871 anAtt->SetArrayOfIntegers(aKey, anArr);
3872 return 0;
3873 }
586db386 3874 di << "DDataStd_SetNDataIntArrays : Error\n";
7fd59977 3875 return 1;
3876}
3877
3878
3879//=======================================================================
3880//function : GetNDIntArrays(DF, entry )
3881//=======================================================================
3882static Standard_Integer DDataStd_GetNDIntArrays (Draw_Interpretor& di,
3883 Standard_Integer nb,
3884 const char** arg)
3885{
3886
3887 if (nb == 3) {
3888 Handle(TDF_Data) DF;
3889 if (!DDF::GetDF(arg[1],DF)) return 1;
3890 TDF_Label aLabel;
3891 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3892
3893
3894 Handle(TDataStd_NamedData) anAtt;
d99f0355 3895 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3896 {
3897 Message::SendFail() << "NamedData attribute is not found or not set";
3898 return 1;
3899 }
3900
04232180 3901 std::cout <<std::endl;
3902 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3903 anAtt->LoadDeferredData();
7fd59977 3904 const TDataStd_DataMapOfStringHArray1OfInteger& aMap = anAtt->GetArraysOfIntegersContainer();
3905 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger itr(aMap);
3906 for (; itr.More(); itr.Next()){
3907 TCollection_ExtendedString aKey(itr.Key());
ae9f4b64 3908 std::cout << "Key = " << aKey<< std::endl;
7fd59977 3909 Handle(TColStd_HArray1OfInteger) anArrValue = itr.Value();
3910 if(!anArrValue.IsNull()) {
5a1271c8 3911 Standard_Integer lower = anArrValue->Lower();
3912 Standard_Integer upper = anArrValue->Upper();
3913 for(Standard_Integer i = lower; i<=upper;i++) {
3914 Standard_Integer aValue = anArrValue->Value(i);
04232180 3915 std::cout << "\tValue("<<i<<") = " <<aValue<<std::endl;
5a1271c8 3916 }
7fd59977 3917 } else
04232180 3918 std::cout << "\tthe specified array is Null "<<std::endl;
7fd59977 3919 }
3920 return 0;
3921 }
586db386 3922 di << "DDataStd_GetNDIntArrays : Error\n";
7fd59977 3923 return 1;
3924}
3925
3926//=======================================================================
3927//function : GetNDIntArray(DF, entry, key )
3928//=======================================================================
3929static Standard_Integer DDataStd_GetNDIntArray (Draw_Interpretor& di,
3930 Standard_Integer nb,
3931 const char** arg)
3932{
3933
3934 if (nb >=4) {
3935 Handle(TDF_Data) DF;
3936 if (!DDF::GetDF(arg[1],DF)) return 1;
3937 TDF_Label aLabel;
3938 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
3939
3940
3941 Handle(TDataStd_NamedData) anAtt;
d99f0355 3942 if (!aLabel.FindAttribute (TDataStd_NamedData::GetID(), anAtt))
3943 {
3944 Message::SendFail() << "NamedData attribute is not found or not set";
3945 return 1;
3946 }
7fd59977 3947
04232180 3948 std::cout <<std::endl;
3949 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 3950 anAtt->LoadDeferredData();
d99f0355 3951 if (!anAtt->HasArrayOfIntegers(arg[3]))
3952 {
3953 Message::SendFail() << "There is no data specified by Key = " << arg[3];
7fd59977 3954 return 1;
d99f0355 3955 }
3956 else
3957 {
04232180 3958 std::cout << "Key = " << arg[3] <<std::endl;
7fd59977 3959
3960 Handle(TColStd_HArray1OfInteger) anArrValue = anAtt->GetArrayOfIntegers(arg[3]);
3961 if(!anArrValue.IsNull()) {
5a1271c8 3962 Standard_Integer lower = anArrValue->Lower();
3963 Standard_Integer upper = anArrValue->Upper();
3964 for(Standard_Integer i = lower; i<=upper;i++) {
3965 Standard_Integer aValue = anArrValue->Value(i);
04232180 3966 std::cout << "\tValue("<<i<<") = " <<aValue<<std::endl;
5a1271c8 3967 }
7fd59977 3968 } else
04232180 3969 std::cout << "\tthe specified array is Null or not found"<<std::endl;
7fd59977 3970 return 0;
3971 }
3972 }
586db386 3973 di << "DDataStd_SetNDataIntArray : Error\n";
7fd59977 3974 return 1;
3975}
3976//============================= RealArrays ==============================
3977//=======================================================================
3978//function : SetNDataRealArrays (DF entry key NumOfArElem val1 val2... )
3979//=======================================================================
3980
3981static Standard_Integer DDataStd_SetNDataRealAr (Draw_Interpretor& di,
3982 Standard_Integer nb,
3983 const char** arg)
3984{
3985
3986 if (nb >=6) {
3987 Handle(TDF_Data) DF;
3988 if (!DDF::GetDF(arg[1],DF)) return 1;
3989 TDF_Label aLabel;
3990 DDF::AddLabel(DF, arg[2], aLabel);
3991
3992 Standard_Integer j;
3993 TCollection_ExtendedString aKey(arg[3]);
91322f44 3994 Standard_Integer aNum = Draw::Atoi(arg[4]);
7fd59977 3995 if (aNum <= 0) return 1;
3996 Handle(TDataStd_NamedData) anAtt;
3997 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
3998 anAtt = TDataStd_NamedData::Set(aLabel);
d99f0355 3999 if (anAtt.IsNull())
4000 {
4001 Message::SendFail() << "NamedData attribute is not found or not set";
4002 return 1;
4003 }
4004
7fd59977 4005 j = 5;
4006 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1, aNum);
4007 for(Standard_Integer i = 1; i<=aNum; i++) {
91322f44 4008 Standard_Real aVal = Draw::Atof(arg[j]);
7fd59977 4009 anArr->SetValue(i, aVal);
4010 j++;
4011 }
5a8d30b8 4012 anAtt->LoadDeferredData();
7fd59977 4013 anAtt->SetArrayOfReals(aKey, anArr);
4014 return 0;
4015 }
586db386 4016 di << "DDataStd_SetNDataRealArrays : Error\n";
7fd59977 4017 return 1;
4018}
4019
4020
4021//=======================================================================
4022//function : GetNDRealArrays(DF, entry )
4023//=======================================================================
4024static Standard_Integer DDataStd_GetNDRealArrays (Draw_Interpretor& di,
4025 Standard_Integer nb,
4026 const char** arg)
4027{
4028
4029 if (nb == 3) {
4030 Handle(TDF_Data) DF;
4031 if (!DDF::GetDF(arg[1],DF)) return 1;
4032 TDF_Label aLabel;
4033 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
4034
4035
4036 Handle(TDataStd_NamedData) anAtt;
d99f0355 4037 if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
4038 {
4039 Message::SendFail() << "NamedData attribute is not found or not set";
4040 return 1;
4041 }
4042
04232180 4043 std::cout <<std::endl;
4044 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
5a8d30b8 4045 anAtt->LoadDeferredData();
7fd59977 4046 const TDataStd_DataMapOfStringHArray1OfReal& aMap = anAtt->GetArraysOfRealsContainer();
4047 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal itr(aMap);
4048 for (; itr.More(); itr.Next()){
4049 TCollection_ExtendedString aKey(itr.Key());
ae9f4b64 4050 std::cout << "Key = " << aKey << std::endl;
7fd59977 4051 Handle(TColStd_HArray1OfReal) anArrValue = itr.Value();
4052 if(!anArrValue.IsNull()) {
5a1271c8 4053 Standard_Integer lower = anArrValue->Lower();
4054 Standard_Integer upper = anArrValue->Upper();
4055 for(Standard_Integer i = lower; i<=upper;i++) {
4056 Standard_Real aValue = anArrValue->Value(i);
04232180 4057 std::cout << "\tValue("<<i<<") = " <<aValue<<std::endl;
5a1271c8 4058 }
7fd59977 4059 } else
04232180 4060 std::cout << "\tthe specified array is Null "<<std::endl;
7fd59977 4061 }
4062 return 0;
4063 }
586db386 4064 di << "DDataStd_GetNDRealArrays : Error\n";
7fd59977 4065 return 1;
4066}
4067
4068//=======================================================================
4069//function : GetNDRealArray(DF, entry, key )
4070//=======================================================================
4071static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
4072 Standard_Integer nb,
4073 const char** arg)
4074{
4075
4076 if (nb >=4) {
4077 Handle(TDF_Data) DF;
4078 if (!DDF::GetDF(arg[1],DF)) return 1;
4079 TDF_Label aLabel;
4080 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
4081
4082
4083 Handle(TDataStd_NamedData) anAtt;
4084 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
4085 di << "NamedData attribute is not found or not set" << "\n";
4086 return 1;}
4087
04232180 4088 std::cout <<std::endl;
5a8d30b8 4089 std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
4090 anAtt->LoadDeferredData();
7fd59977 4091 if(!anAtt->HasArrayOfReals(arg[3])) {
04232180 4092 std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
7fd59977 4093 return 1;
4094 } else {
04232180 4095 std::cout << "Key = " << arg[3] <<std::endl;
7fd59977 4096
4097 Handle(TColStd_HArray1OfReal) anArrValue = anAtt->GetArrayOfReals(arg[3]);
4098 if(!anArrValue.IsNull()) {
5a1271c8 4099 Standard_Integer lower = anArrValue->Lower();
4100 Standard_Integer upper = anArrValue->Upper();
4101 for(Standard_Integer i = lower; i<=upper;i++) {
4102 Standard_Real aValue = anArrValue->Value(i);
04232180 4103 std::cout << "\tValue("<<i<<") = " <<aValue<<std::endl;
5a1271c8 4104 }
7fd59977 4105 } else
04232180 4106 std::cout << "\tthe specified array is Null or not found"<<std::endl;
7fd59977 4107 return 0;
4108 }
4109 }
586db386 4110 di << "DDataStd_SetNDataRealArray : Error\n";
7fd59977 4111 return 1;
4112}
4113
1c9cffdb 4114//=======================================================================
5a1271c8 4115//function : SetRefArray (DF, entry , [-g Guid,] From, To, elmt1, elmt2, ...
1c9cffdb 4116//=======================================================================
4117static Standard_Integer DDataStd_SetRefArray (Draw_Interpretor& di,
8e1e79f0 4118 Standard_Integer nb,
4119 const char** arg)
4120{
5a1271c8 4121 if (nb >= 5)
4122 {
4123 Handle(TDF_Data) DF;
4124 if (!DDF::GetDF(arg[1],DF)) return 1;
4125 TDF_Label label;
4126 DDF::AddLabel(DF, arg[2], label);
4127 Standard_GUID guid;
4128 Standard_Boolean isGuid(Standard_False);
4129 Standard_Character c1(arg[3][0]), c2(arg[3][1]);
4130 if(c1 == '-' && c2 == 'g') { //guid
4131 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
4132 di<<"DDataStd_SetRefArray: The format of GUID is invalid\n";
4133 return 1;
4134 }
4135 guid = Standard_GUID (arg[4]);
4136 isGuid = Standard_True;
4137 }
4138 Standard_Integer j(3);
4139 if(isGuid) j = 5;
1c9cffdb 4140
5a1271c8 4141 if((strlen(arg[j]) > MAXLENGTH || strlen(arg[j+1]) > MAXLENGTH) ||
4142 !TCollection_AsciiString (arg[j]).IsIntegerValue() ||
4143 !TCollection_AsciiString (arg[j+1]).IsIntegerValue())
4144 {
4145 di << "DDataStd_SetRefArray: From, To may be wrong\n";
4146 return 1;
8e1e79f0 4147 }
5a1271c8 4148 Standard_Integer From = Draw::Atoi(arg[j]), To = Draw::Atoi( arg[j+1] );
4149 di << "RefArray with bounds from = " << From << " to = " << To << "\n";
4150
4151 Handle(TDataStd_ReferenceArray) A;
4152 if(!isGuid)
4153 A = TDataStd_ReferenceArray::Set(label, From, To);
4154 else
4155 A = TDataStd_ReferenceArray::Set(label, guid, From, To);
4156
4157 if ((!isGuid && nb > 5) || (isGuid && nb > 7)) {
4158 j = j + 2;
4159 for(Standard_Integer i = From; i<=To; i++) {
4160 TDF_Label aRefLabel;
4161 DDF::AddLabel(DF, arg[j], aRefLabel);
4162 A->SetValue(i, aRefLabel);
4163 j++;
4164 }
4165 }
4166 return 0;
4167 }
4168 di << "DDataStd_SetRefArray: Error\n";
4169 return 1;
1c9cffdb 4170}
8e1e79f0 4171//=======================================================================
4172//function : SetRefArrayValue (DF, entry, index, value)
4173//=======================================================================
4174static Standard_Integer DDataStd_SetRefArrayValue (Draw_Interpretor&,
4175 Standard_Integer,
4176 const char** arg)
4177{
4178 // Get document.
4179 Handle(TDF_Data) DF;
4180 if (!DDF::GetDF(arg[1], DF))
4181 return 1;
4182
4183 // Get label.
4184 TDF_Label label;
4185 if (!DDF::AddLabel(DF, arg[2], label))
4186 return 1;
4187
4188 // Get index and value.
4189 Standard_Integer index = Draw::Atoi(arg[3]);
4190
4191 // Set new value.
4192 Handle(TDataStd_ReferenceArray) arr;
4193 if (label.FindAttribute(TDataStd_ReferenceArray::GetID(), arr))
4194 {
4195 TDF_Label aRefLabel;
4196 DDF::AddLabel(DF, arg[4], aRefLabel);
4197 arr->SetValue(index, aRefLabel);
4198 return 0;
4199 }
4200
4201 return 1;
4202}
4203
1c9cffdb 4204//=======================================================================
5a1271c8 4205//function : GetRefArray (DF, entry [, guid])
1c9cffdb 4206//=======================================================================
4207static Standard_Integer DDataStd_GetRefArray (Draw_Interpretor& di,
5a1271c8 4208 Standard_Integer nb,
1c9cffdb 4209 const char** arg)
4210{
5a1271c8 4211 if (nb >= 3)
4212 {
4213 Handle(TDF_Data) DF;
4214 if (!DDF::GetDF(arg[1],DF)) return 1;
4215 TDF_Label label;
4216 if( !DDF::FindLabel(DF, arg[2], label) ) {
4217 di << "No label for entry" << "\n";
4218 return 1;
4219 }
4220 Standard_GUID aGuid;
4221 if(nb == 4) {
4222 if (Standard_GUID::CheckGUIDFormat(arg[3]))
4223 aGuid = Standard_GUID(arg[3]);
4224 else {
4225 di << "Wrong GUID format" << "\n";
4226 return 1;
4227 }
4228 } else
4229 aGuid = TDataStd_ReferenceArray::GetID();
1c9cffdb 4230
5a1271c8 4231 Handle(TDataStd_ReferenceArray) A;
4232 if ( !label.FindAttribute(aGuid, A) ) {
4233 di << "There is no TDataStd_ReferenceArray at the label" << "\n";
4234 return 1;
4235 }
1c9cffdb 4236
5a1271c8 4237 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
4238 const TDF_Label& aLabel = A->Value(i);
4239 TCollection_AsciiString entry;
4240 TDF_Tool::Entry(aLabel, entry);
4241 di << entry.ToCString();
4242 if(i<A->Upper())
4243 di<<" ";
4244 }
4245 di<<"\n";
4246 return 0;
4247 }
4248 di << "TDataStd_ReferenceArray: Error\n";
4249 return 1;
4250}
8e1e79f0 4251//=======================================================================
4252//function : GetRefArrayValue (DF, entry, index)
4253//=======================================================================
4254static Standard_Integer DDataStd_GetRefArrayValue (Draw_Interpretor& di,
5a1271c8 4255 Standard_Integer nb,
8e1e79f0 4256 const char** arg)
4257{
5a1271c8 4258 if (nb >= 3)
4259 {
4260 Handle(TDF_Data) DF;
4261 if (!DDF::GetDF(arg[1],DF))
8e1e79f0 4262 return 1;
4263
5a1271c8 4264 TDF_Label label;
4265 if (!DDF::FindLabel(DF, arg[2], label)) {
4266 di << "No label for entry" << "\n";
4267 return 1;
4268 }
4269 Standard_GUID aGuid;
4270 if(nb == 4) {
4271 if (Standard_GUID::CheckGUIDFormat(arg[3]))
4272 aGuid = Standard_GUID(arg[3]);
4273 else {
4274 di << "Wrong GUID format" << "\n";
4275 return 1;
4276 }
4277 } else
4278 aGuid = TDataStd_ReferenceArray::GetID();
8e1e79f0 4279
5a1271c8 4280 Handle(TDataStd_ReferenceArray) A;
4281 if ( !label.FindAttribute(aGuid, A) ) {
4282 di << "There is no TDataStd_ReferenceArray at the label" << "\n";
4283 return 1;
4284 }
4285
4286 Standard_Integer index = Draw::Atoi(arg[3]);
4287 if (index < A->Lower() || index > A->Upper()) {
4288 di << "Index is out of range\n";
4289 return 1;
4290 } else {
4291 const TDF_Label& value = A->Value(index);
4292 TCollection_AsciiString entry;
4293 TDF_Tool::Entry(value, entry);
4294 di << entry.ToCString() << "\n";
4295 }
4296 return 0;
4297 }
4298 di << "TDataStd_ReferenceArray: Error\n";
4299 return 1;
4300}
8e1e79f0 4301
624f732f 4302//=======================================================================
4303//function : DDataStd_SetTriangulation
4304//purpose : SetTriangulation (DF, entry, face)
4305//=======================================================================
4306
4307static Standard_Integer DDataStd_SetTriangulation (Draw_Interpretor& di,
4308 Standard_Integer nb,
4309 const char** arg)
4310{
4311 if (nb == 4)
4312 {
4313 Handle(TDF_Data) DF;
4314 if (!DDF::GetDF(arg[1],DF))
4315 return 1;
4316
4317 TDF_Label L;
4318 if (!DDF::AddLabel(DF, arg[2], L))
4319 return 1;
4320
4321 // Get face.
4322 TopoDS_Shape face = DBRep::Get(arg[3]);
4323 if (face.IsNull() ||
4324 face.ShapeType() != TopAbs_FACE)
4325 {
4326 di << "The face is null or not a face.\n";
4327 return 1;
4328 }
4329
4330 // Get triangulation of the face.
4331 TopLoc_Location loc;
4332 Handle(Poly_Triangulation) tris = BRep_Tool::Triangulation(TopoDS::Face(face), loc);
4333 if (tris.IsNull())
4334 {
4335 di << "No triangulation in the face.\n";
4336 return 1;
4337 }
4338
4339 // Set the attribute.
4340 TDataXtd_Triangulation::Set(L, tris);
4341 return 0;
4342 }
4343 di << "DDataStd_SetTriangulation : Error\n";
4344 return 1;
4345}
4346
4347//=======================================================================
4348//function : DDataStd_DumpTriangulation
4349//purpose : DumpTriangulation (DF, entry)
4350//=======================================================================
4351
4352static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
4353 Standard_Integer nb,
4354 const char** arg)
4355{
4356 if (nb == 3)
4357 {
4358 Handle(TDF_Data) DF;
4359 if (!DDF::GetDF(arg[1],DF))
4360 return 1;
4361
4362 Handle(TDataXtd_Triangulation) PT;
4363 if (!DDF::Find(DF,arg[2], TDataXtd_Triangulation::GetID(), PT))
4364 {
4365 di << "The attribute doesn't exist at the label.\n";
4366 return 1;
4367 }
4368
4369 // Dump of the triangulation.
4370 if (PT->Get().IsNull())
4371 {
4372 di << "No triangulation in the attribute.\n";
4373 return 1;
4374 }
4375
4376 di << "Deflection " << PT->Deflection() <<"\n";
4377 di << "Number of nodes " << PT->NbNodes() << "\n";
4378 di << "Number of triangles " << PT->NbTriangles() << "\n";
4379 if (PT->HasUVNodes())
4380 di << "It has 2d-nodes\n";
4381 if (PT->HasNormals())
4382 di << "It has normals\n";
4383
4384 return 0;
4385 }
4386 di << "DDataStd_DumpTriangulation : Error\n";
4387 return 1;
4388}
4389
7fd59977 4390//=======================================================================
4391//function : BasicCommands
4392//purpose :
4393//=======================================================================
4394
4395void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
4396{
4397
4398 static Standard_Boolean done = Standard_False;
4399 if (done) return;
4400 done = Standard_True;
4401
4402 const char* g = "DData : Standard Attribute Commands";
4403
4404
4405 // SET
4406
4407 theCommands.Add ("SetInteger",
fa53efef 4408 "SetInteger (DF, entry, value [,guid])",
7fd59977 4409 __FILE__, DDataStd_SetInteger, g);
4410
4411 theCommands.Add ("SetIntArray",
5a1271c8 4412 "SetIntArray (DF, entry, isDelta, [-g Guid,] From, To [, elmt1, elmt2, ...])",
7fd59977 4413 __FILE__, DDataStd_SetIntArray, g);
8e1e79f0 4414
4415 theCommands.Add ("SetIntArrayValue",
4416 "SetIntArrayValue (DF, entry, index, value)",
4417 __FILE__, DDataStd_SetIntArrayValue, g);
7fd59977 4418
4419 theCommands.Add ("SetReal",
fa53efef 4420 "SetReal (DF, entry, value [,guid])",
7fd59977 4421 __FILE__, DDataStd_SetReal, g);
4422
4423 theCommands.Add ("SetRealArray",
5a1271c8 4424 "SetRealArray (DF, entry, isDelta, [-g Guid,] From, To [, elmt1, elmt2, ...])",
7fd59977 4425 __FILE__, DDataStd_SetRealArray, g);
4426
8e1e79f0 4427 theCommands.Add ("SetRealArrayValue",
4428 "SetRealArrayValue (DF, entry, index, value)",
4429 __FILE__, DDataStd_SetRealArrayValue, g);
4430
7fd59977 4431 theCommands.Add ("SetByteArray",
5a1271c8 4432 "SetByteArray (DF, entry, isDelta, [-g Guid,] From, To [, elmt1, elmt2, ...])",
7fd59977 4433 __FILE__, DDataStd_SetByteArray, g);
4434
8e1e79f0 4435 theCommands.Add ("SetByteArrayValue",
4436 "SetByteArrayValue (DF, entry, index, value)",
4437 __FILE__, DDataStd_SetByteArrayValue, g);
4438
7fd59977 4439 theCommands.Add ("SetExtStringArray",
5a1271c8 4440 "SetExtStringArray (DF, entry, isDelta, [-g Guid,] From, To [, elmt1, elmt2, ...])",
7fd59977 4441 __FILE__, DDataStd_SetExtStringArray, g);
4442
8e1e79f0 4443 theCommands.Add ("SetExtStringArrayValue",
4444 "SetExtStringArrayValue (DF, entry, index, value)",
4445 __FILE__, DDataStd_SetExtStringArrayValue, g);
4446
1c9cffdb 4447 theCommands.Add ("SetRefArray",
5a1271c8 4448 "SetRefArray (DF, entry, [-g Guid,] From, To [, lab1, lab2, ...])",
1c9cffdb 4449 __FILE__, DDataStd_SetRefArray, g);
4450
8e1e79f0 4451 theCommands.Add ("SetRefArrayValue",
4452 "SetRefArrayValue (DF, entry, index, value)",
4453 __FILE__, DDataStd_SetRefArrayValue, g);
4454
7fd59977 4455 theCommands.Add ("SetIntPackedMap",
4456 "SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
4457 __FILE__, DDataStd_SetIntPackedMap, g);
4458
4459 theCommands.Add ("SetReference",
4460 "SetReference (DF, entry, reference)",
4461 __FILE__, DDataStd_SetReference, g);
4462
4463 theCommands.Add ("SetComment",
4464 "SetComment (DF, entry, comment)",
4465 __FILE__, DDataStd_SetComment, g);
4466
4467 theCommands.Add ("SetUAttribute",
4468 "SetUAttribute (DF, entry, LocalID)",
4469 __FILE__, DDataStd_SetUAttribute, g);
4470
4471 theCommands.Add ("SetVariable",
4472 "SetVariable (DF, entry, isConstant[0/1], units)",
4473 __FILE__, DDataStd_SetVariable, g);
4474
4475 theCommands.Add ("SetAsciiString",
4476 "SetAsciiString (DF, entry, String )",
4477 __FILE__, DDataStd_SetAsciiString, g);
4478
f7b4312f 4479 theCommands.Add ("SetBooleanArray",
5a1271c8 4480 "SetBooleanArray (DF, entry, [-g Guid,] From, To [, elmt1, elmt2, ...])",
f7b4312f 4481 __FILE__, DDataStd_SetBooleanArray, g);
4482
8e1e79f0 4483 theCommands.Add ("SetBooleanArrayValue",
4484 "SetBooleanArrayValue (DF, entry, index, value)",
4485 __FILE__, DDataStd_SetBooleanArrayValue, g);
4486
f7b4312f 4487 theCommands.Add ("SetBooleanList",
5a1271c8 4488 "SetBooleanList (DF, entry, [-g Guid,] elmt1, elmt2, ... )",
f7b4312f 4489 __FILE__, DDataStd_SetBooleanList, g);
4490
4491 theCommands.Add ("SetIntegerList",
5a1271c8 4492 "SetIntegerList (DF, entry, [-g Guid,] elmt1, elmt2, ... )",
f7b4312f 4493 __FILE__, DDataStd_SetIntegerList, g);
4494
4495 theCommands.Add ("SetRealList",
5a1271c8 4496 "SetRealList (DF, entry, [-g guid,] elmt1, elmt2, ... )",
f7b4312f 4497 __FILE__, DDataStd_SetRealList, g);
4498
d585e74e 4499 theCommands.Add ("SetExtStringList",
5a1271c8 4500 "SetExtStringList (DF, entry,[-g Guid,] elmt1, elmt2, ... )",
d585e74e 4501 __FILE__, DDataStd_SetExtStringList, g);
4502
4503 theCommands.Add ("SetReferenceList",
5a1271c8 4504 "SetReferenceList (DF, entry, [-g Guid,] elmt1, elmt2, ... )",
d585e74e 4505 __FILE__, DDataStd_SetReferenceList, g);
7fd59977 4506
5a1271c8 4507 theCommands.Add ("SetTriangulation",
624f732f 4508 "SetTriangulation (DF, entry, face) - adds label with passed entry to \
4509 DF and put an attribute with the triangulation from passed face",
4510 __FILE__, DDataStd_SetTriangulation, g);
4511
1ff07227 4512 theCommands.Add ("InsertBeforeExtStringList",
4513 "InsertBeforeExtStringList (DF, entry, index, value )",
4514 __FILE__, DDataStd_InsertBeforeExtStringList, g);
4515
4516 theCommands.Add ("InsertAfterExtStringList",
4517 "InsertAfterExtStringList (DF, entry, index, value )",
4518 __FILE__, DDataStd_InsertAfterExtStringList, g);
4519
4520 theCommands.Add ("RemoveExtStringList",
4521 "RemoveExtStringList (DF, entry, index )",
4522 __FILE__, DDataStd_RemoveExtStringList, g);
4523
4524 theCommands.Add ("InsertBeforeBooleanList",
4525 "InsertBeforeBooleanList (DF, entry, index, value )",
4526 __FILE__, DDataStd_InsertBeforeBooleanList, g);
4527
4528 theCommands.Add ("InsertAfterBooleanList",
4529 "InsertAfterBooleanList (DF, entry, index, value )",
4530 __FILE__, DDataStd_InsertAfterBooleanList, g);
4531
4532 theCommands.Add ("RemoveBooleanList",
4533 "RemoveBooleanList (DF, entry, index )",
4534 __FILE__, DDataStd_RemoveBooleanList, g);
4535
4536 theCommands.Add ("InsertBeforeIntegerList",
4537 "InsertBeforeIntegerList (DF, entry, index, value )",
4538 __FILE__, DDataStd_InsertBeforeIntegerList, g);
4539
4540 theCommands.Add ("InsertAfterIntegerList",
4541 "InsertAfterIntegerList (DF, entry, index, value )",
4542 __FILE__, DDataStd_InsertAfterIntegerList, g);
4543
4544 theCommands.Add ("RemoveIntegerList",
4545 "RemoveIntegerList (DF, entry, index )",
4546 __FILE__, DDataStd_RemoveIntegerList, g);
4547
4548 theCommands.Add ("InsertBeforeRealList",
4549 "InsertBeforeRealList (DF, entry, index, value )",
4550 __FILE__, DDataStd_InsertBeforeRealList, g);
4551
4552 theCommands.Add ("InsertAfterRealList",
4553 "InsertAfterRealList (DF, entry, index, value )",
4554 __FILE__, DDataStd_InsertAfterRealList, g);
4555
4556 theCommands.Add ("RemoveRealList",
4557 "RemoveRealList (DF, entry, index )",
4558 __FILE__, DDataStd_RemoveRealList, g);
4559
4560 theCommands.Add ("InsertBeforeReferenceList",
4561 "InsertBeforeReferenceList (DF, entry, index, value )",
4562 __FILE__, DDataStd_InsertBeforeReferenceList, g);
4563
4564 theCommands.Add ("InsertAfterReferenceList",
4565 "InsertAfterReferenceList (DF, entry, index, value )",
4566 __FILE__, DDataStd_InsertAfterReferenceList, g);
4567
4568 theCommands.Add ("RemoveReferenceList",
4569 "RemoveReferenceList (DF, entry, index )",
4570 __FILE__, DDataStd_RemoveReferenceList, g);
4571
7fd59977 4572 // GET
4573
4574 theCommands.Add ("GetAsciiString",
4575 "GetAsciiString (DF, entry )",
4576 __FILE__, DDataStd_GetAsciiString, g);
4577
4578 theCommands.Add ("GetInteger",
fa53efef 4579 "GetInteger (DF, entry, [drawname][, guid])",
7fd59977 4580 __FILE__, DDataStd_GetInteger, g);
4581
4582 theCommands.Add ("GetIntArray",
5a1271c8 4583 "GetIntArray (DF, entry [, guid])",
7fd59977 4584 __FILE__, DDataStd_GetIntArray, g);
4585
8e1e79f0 4586 theCommands.Add ("GetIntArrayValue",
4587 "GetIntArrayValue (DF, entry, index)",
4588 __FILE__, DDataStd_GetIntArrayValue, g);
4589
7fd59977 4590 theCommands.Add ("GetRealArray",
5a1271c8 4591 "GetRealArray (DF, entry [, guid])",
7fd59977 4592 __FILE__, DDataStd_GetRealArray, g);
4593
8e1e79f0 4594 theCommands.Add ("GetRealArrayValue",
4595 "GetRealArrayValue (DF, entry, index)",
4596 __FILE__, DDataStd_GetRealArrayValue, g);
4597
7fd59977 4598 theCommands.Add ("GetByteArray",
5a1271c8 4599 "GetByteArray (DF, entry [, guid])",
7fd59977 4600 __FILE__, DDataStd_GetByteArray, g);
4601
8e1e79f0 4602 theCommands.Add ("GetByteArrayValue",
4603 "GetByteArrayValue (DF, entry, index)",
4604 __FILE__, DDataStd_GetByteArrayValue, g);
4605
7fd59977 4606 theCommands.Add ("GetExtStringArray",
5a1271c8 4607 "GetExtStringArray (DF, entry [, guid])",
7fd59977 4608 __FILE__, DDataStd_GetExtStringArray, g);
4609
8e1e79f0 4610 theCommands.Add ("GetExtStringArrayValue",
4611 "GetExtStringArrayValue (DF, entry, index)",
4612 __FILE__, DDataStd_GetExtStringArrayValue, g);
4613
1c9cffdb 4614 theCommands.Add ("GetRefArray",
5a1271c8 4615 "GetRefArray (DF, entry [, guid])",
1c9cffdb 4616 __FILE__, DDataStd_GetRefArray, g);
4617
8e1e79f0 4618 theCommands.Add ("GetRefArrayValue",
4619 "GetRefArrayValue (DF, entry, index)",
4620 __FILE__, DDataStd_GetRefArrayValue, g);
4621
7fd59977 4622 theCommands.Add ("GetIntPackedMap",
4623 "GetIntPackedMap (DF, entry )",
4624 __FILE__, DDataStd_GetIntPackedMap, g);
4625
4626 theCommands.Add ("GetReal",
fa53efef 4627 "GetReal (DF, entry, [drawname][, guid])",
7fd59977 4628 __FILE__, DDataStd_GetReal, g);
4629
4630 theCommands.Add ("GetReference",
4631 "GetReference (DF, entry)",
4632 __FILE__, DDataStd_GetReference, g);
4633
4634
4635 theCommands.Add ("GetComment",
4636 "GetComment (DF, entry)",
4637 __FILE__, DDataStd_GetComment, g);
4638
4639 theCommands.Add("Self",
4640 "Self(document, entry)",
4641 __FILE__, DDataStd_Self, g);
4642
4643 theCommands.Add ("GetUAttribute",
4644 "GetUAttribute (DF, entry)",
4645 __FILE__, DDataStd_GetUAttribute, g);
4646
4647 theCommands.Add ("GetVariable",
4648 "GetVariable (DF, entry, [isConstant], [units])",
4649 __FILE__, DDataStd_GetVariable, g);
4650
4651 theCommands.Add ("SetRelation",
4652 "SetRelation (DF, entry, expression, var1[, var2, ...])",
4653 __FILE__, DDataStd_SetRelation, g);
4654
7fd59977 4655 theCommands.Add ("DumpRelation",
4656 "DumpRelation (DF, entry)",
4657 __FILE__, DDataStd_DumpRelation, g);
4658
f7b4312f 4659 theCommands.Add ("GetBooleanArray",
5a1271c8 4660 "GetBooleanArray (DF, entry [, guid])",
f7b4312f 4661 __FILE__, DDataStd_GetBooleanArray, g);
4662
8e1e79f0 4663 theCommands.Add ("GetBooleanArrayValue",
4664 "GetBooleanArrayValue (DF, entry, index)",
4665 __FILE__, DDataStd_GetBooleanArrayValue, g);
4666
f7b4312f 4667 theCommands.Add ("GetBooleanList",
5a1271c8 4668 "GetBooleanList (DF, entry [, guid])",
f7b4312f 4669 __FILE__, DDataStd_GetBooleanList, g);
4670
4671 theCommands.Add ("GetIntegerList",
5a1271c8 4672 "GetIntegerList (DF, entry [, guid])",
f7b4312f 4673 __FILE__, DDataStd_GetIntegerList, g);
4674
4675 theCommands.Add ("GetRealList",
5a1271c8 4676 "GetRealList (DF, entry [, guid])",
f7b4312f 4677 __FILE__, DDataStd_GetRealList, g);
4678
d585e74e 4679 theCommands.Add ("GetExtStringList",
5a1271c8 4680 "GetExtStringList (DF, entry [, guid])",
d585e74e 4681 __FILE__, DDataStd_GetExtStringList, g);
7fd59977 4682
d585e74e 4683 theCommands.Add ("GetReferenceList",
5a1271c8 4684 "GetReferenceList (DF, entry [, guid])",
d585e74e 4685 __FILE__, DDataStd_GetReferenceList, g);
7fd59977 4686
4687// ========================= UTF =====================================
4688 const char* ggg = "UTF Commands";
4689
4690 theCommands.Add ("SetUTFName",
4691 "SetUTFName (DF, entry, fileName)",
4692 __FILE__, DDataStd_KeepUTF, ggg);
4693
4694 theCommands.Add ("GetUTF",
4695 "GetUTF (DF, entry, fileName)",
4696 __FILE__, DDataStd_GetUTFtoFile, ggg);
4697
4698 //======================= NData Commands ========================
4699
4700 const char* gN = "NData Commands";
4701 theCommands.Add ("SetNDataIntegers",
4702 "SetNDataIntegers (DF, entry, NumPairs, key1, val1, ... )",
4703 __FILE__, DDataStd_SetNDataIntegers, gN);
4704
4705 theCommands.Add ("SetNDataReals",
4706 "SetNDataReals (DF, entry, NumPairs, key1, val1, ... )",
4707 __FILE__, DDataStd_SetNDataReals, gN);
4708
4709 theCommands.Add ("SetNDataStrings",
4710 "SetNDataStrings (DF, entry, NumPairs, key1, val1, ... )",
4711 __FILE__, DDataStd_SetNDataStrings, gN);
4712
4713 theCommands.Add ("SetNDataBytes",
4714 "SetNDataBytes (DF, entry, NumPairs, key1, val1, ... )",
4715 __FILE__, DDataStd_SetNDataBytes, gN);
4716
4717 theCommands.Add ("SetNDataIntArrays",
4718 "SetNDataIntArrays (DF entry entry key NumOfArrElems val1 val2... )",
4719 __FILE__, DDataStd_SetNDataIntAr, gN);
4720
4721 theCommands.Add ("SetNDataRealArrays",
4722 "SetNDataRealArrays (DF entry key NumOfArrElems val1 val2... )",
4723 __FILE__, DDataStd_SetNDataRealAr, gN);
4724
4725 // GET
4726
4727 theCommands.Add ("GetNDIntegers",
4728 "GetNDIntegers (DF, entry )",
4729 __FILE__, DDataStd_GetNDIntegers, g);
4730
4731 theCommands.Add ("GetNDInteger",
4732 "GetNDInteger (DF entry key [drawname])",
4733 __FILE__, DDataStd_GetNDInteger, g);
4734
4735 theCommands.Add ("GetNDReals",
4736 "GetNDReals (DF entry )",
4737 __FILE__, DDataStd_GetNDReals, g);
4738
4739 theCommands.Add ("GetNDReal",
4740 "GetNDReal (DF entry key [drawname])",
4741 __FILE__, DDataStd_GetNDReal, g);
4742
4743 theCommands.Add ("GetNDStrings",
4744 "GetNDStrings (DF entry )",
4745 __FILE__, DDataStd_GetNDStrings, g);
4746
4747 theCommands.Add ("GetNDString",
4748 "GetNDString (DF entry key [drawname])",
4749 __FILE__, DDataStd_GetNDString, g);
4750
4751 theCommands.Add ("GetNDBytes",
4752 "GetNDBytes (DF entry )",
4753 __FILE__, DDataStd_GetNDBytes, g);
4754
4755 theCommands.Add ("GetNDByte",
4756 "GetNDByte (DF entry key [drawname])",
4757 __FILE__, DDataStd_GetNDByte, g);
4758
4759 theCommands.Add ("GetNDIntArrays",
4760 "GetNDIntArrays (DF, entry )",
4761 __FILE__, DDataStd_GetNDIntArrays, g);
4762
4763 theCommands.Add ("GetNDIntArray",
4764 "GetNDIntArray (DF entry key )",
4765 __FILE__, DDataStd_GetNDIntArray, g);
4766
4767 theCommands.Add ("GetNDRealArrays",
4768 "GetNDRealArrays (DF entry )",
4769 __FILE__, DDataStd_GetNDRealArrays, g);
4770
4771 theCommands.Add ("GetNDRealArray",
4772 "GetNDRealArray (DF entry key )",
4773 __FILE__, DDataStd_GetNDRealArray, g);
4774
4775//====================== Change =======================
4776 theCommands.Add ("ChangeByteArray",
4777 "ChangeByteArray (DF, entry, indx, value )",
4778 __FILE__, DDataStd_ChangeByteArray, g);
4779
4780 theCommands.Add ("ChangeIntArray",
4781 "ChangeIntArray (DF, entry, indx, value )",
4782 __FILE__, DDataStd_ChangeIntArray, g);
4783
4784 theCommands.Add ("ChangeRealArray",
4785 "ChangeRealArray (DF, entry, indx, value )",
4786 __FILE__, DDataStd_ChangeRealArray, g);
4787
4788 theCommands.Add ("ChangeExtStrArray",
4789 "ChangeExtStrArray (DF, entry, indx, value )",
4790 __FILE__, DDataStd_ChangeExtStrArray, g);
4791
4792 theCommands.Add ("ChangeIntPackedMap_Add",
4793 "ChangeIntPackedMAp_Add (DF, entry, key[,key [...]] )",
4794 __FILE__, DDataStd_ChangeIntPackedMap_Add, g);
4795
4796 theCommands.Add ("ChangeIntPackedMap_Rem",
4797 "ChangeIntPackedMAp_Rem (DF, entry, key[,key [...]] )",
4798 __FILE__, DDataStd_ChangeIntPackedMap_Rem, g);
4799
4800 theCommands.Add ("ChangeIntPackedMap_AddRem",
4801 "ChangeIntPackedMAp_AddRem (DF, entry, key[,key [...]] )",
4802 __FILE__, DDataStd_ChangeIntPackedMap_AddRem, g);
4803
4804//=========================================================
4805 // TFunction commands
4806 const char* gg = "DFunction Commands";
4807
4808 theCommands.Add ("SetFunction",
4809 "SetFunction (DF, entry, guid, failure)",
4810 __FILE__, DDataStd_SetFunction, gg);
4811
4812 theCommands.Add ("GetFunction",
4813 "GetFunction (DF, entry, guid(out), failure(out))",
4814 __FILE__, DDataStd_GetFunction, gg);
4815
4816//=========================================================
4817
624f732f 4818 theCommands.Add ("DumpTriangulation",
4819 "DumpTriangulations (DF, entry) - dumps info about triangulation that \
4820 stored in DF in triangulation attribute of a label with the passed entry",
4821 __FILE__, DDataStd_DumpMesh, g);
7fd59977 4822
4823//======================================================================
4824//======= for internal use
4825
4826 theCommands.Add ("SetNDataIntegers2",
4827 "SetNDataIntegers2 (DF, entry, NumPair )",
4828 __FILE__, DDataStd_SetNDataIntegers2, gN);
4829
4830 theCommands.Add ("SetNDataIntArrays2",
4831 "SetNDataIntArrays2 (DF entry entry key NumOfArrElems)",
4832 __FILE__, DDataStd_SetNDataIntAr2, gN);
4833
4834 theCommands.Add ("SetIntArrayT",
4835 "SetIntArrayT (DF, entry, isDelta, From, To )",
4836 __FILE__, DDataStd_SetIntArrayTest, g);
4837
4838 theCommands.Add ("SetIntPHugeMap",
4839 "SetIntPHugeMap (DF, entry, isDelta Num)",
4840 __FILE__, DDataStd_SetIntPHugeMap, g);
4841
4842//=======
4843
4844}