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