1 // Created on: 1997-07-30
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <DDataStd.hxx>
24 #include <Standard_PCharacter.hxx>
27 #include <Draw_Interpretor.hxx>
28 #include <Draw_Appli.hxx>
29 #include <DrawTrSurf.hxx>
33 #include <TDF_Data.hxx>
34 #include <TDF_Label.hxx>
35 #include <TDF_Tool.hxx>
36 #include <TDF_AttributeSequence.hxx>
37 #include <TDF_AttributeList.hxx>
38 #include <TDF_ListIteratorOfAttributeList.hxx>
43 #include <TopoDS_Vertex.hxx>
44 #include <TopoDS_Edge.hxx>
45 #include <TopoDS_Wire.hxx>
46 #include <TopoDS_Face.hxx>
47 #include <TopoDS_Shell.hxx>
48 #include <TopoDS_Solid.hxx>
49 #include <TopoDS_Shape.hxx>
55 #include <TCollection_AsciiString.hxx>
56 #include <TColStd_HArray1OfReal.hxx>
59 #include <TDataStd.hxx>
60 #include <TDataStd_Comment.hxx>
61 #include <TDataStd_Name.hxx>
62 #include <TDataStd_Integer.hxx>
63 #include <TDataStd_Real.hxx>
64 #include <TDF_Reference.hxx>
65 #include <TDataStd_UAttribute.hxx>
66 #include <TDataStd_IntegerArray.hxx>
67 #include <TDataStd_BooleanArray.hxx>
68 #include <TDataStd_RealArray.hxx>
69 #include <TDataStd_BooleanList.hxx>
70 #include <TDataStd_IntegerList.hxx>
71 #include <TDataStd_RealList.hxx>
72 #include <TDataStd_Variable.hxx>
73 #include <TDataStd_ExtStringArray.hxx>
74 #include <TDF_ChildIterator.hxx>
75 #include <TDF_Tool.hxx>
77 #include <TDataStd_NamedData.hxx>
78 #include <TColStd_DataMapOfStringInteger.hxx>
79 #include <TColStd_DataMapIteratorOfDataMapOfStringInteger.hxx>
80 #include <TDataStd_DataMapOfStringReal.hxx>
81 #include <TDataStd_DataMapIteratorOfDataMapOfStringReal.hxx>
82 #include <TDataStd_DataMapOfStringByte.hxx>
83 #include <TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx>
84 #include <TDataStd_DataMapOfStringString.hxx>
85 #include <TDataStd_DataMapIteratorOfDataMapOfStringString.hxx>
86 #include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
87 #include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger.hxx>
88 #include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
89 #include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal.hxx>
90 #include <TColStd_HArray1OfInteger.hxx>
91 #include <TColStd_HArray1OfReal.hxx>
92 #include <TDataStd_AsciiString.hxx>
93 #include <TDataStd_IntPackedMap.hxx>
94 #include <TColStd_HPackedMapOfInteger.hxx>
95 #include <TColStd_PackedMapOfInteger.hxx>
96 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
97 #include <TDataStd_ByteArray.hxx>
98 #include <TDataStd_ListIteratorOfListOfByte.hxx>
99 #include <TColStd_ListIteratorOfListOfInteger.hxx>
100 #include <TColStd_ListIteratorOfListOfReal.hxx>
102 #include <Standard_Macro.hxx>
104 #define ROUNDMEM(len) (((len)+3)&~0x3)
106 #define ROUNDMEM(len) (len)
109 //=======================================================================
110 //function : DDataStd_SetInteger
111 //purpose : SetInteger (DF, entry, value)
112 //=======================================================================
114 static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di,
120 if (!DDF::GetDF(arg[1],DF)) return 1;
122 DDF::AddLabel(DF, arg[2], L);
123 TDataStd_Integer::Set(L,Draw::Atoi(arg[3]));
126 di << "DDataStd_SetInteger : Error" << "\n";
130 //=======================================================================
131 //function : DDataStd_SetReal
132 //purpose : SetReal (DF, entry, value)
133 //=======================================================================
135 static Standard_Integer DDataStd_SetReal (Draw_Interpretor& di,
141 if (!DDF::GetDF(arg[1],DF)) return 1;
143 DDF::AddLabel(DF, arg[2], L);
144 TDataStd_Real::Set(L,Draw::Atof(arg[3]));
147 di << "DDataStd_SetReal : Error" << "\n";
153 //=======================================================================
154 //function : DDataStd_SetReference
155 //purpose : SetReference (DF, entry, reference)
156 //=======================================================================
158 static Standard_Integer DDataStd_SetReference (Draw_Interpretor& di,
164 if (!DDF::GetDF(arg[1],DF)) return 1;
166 DDF::AddLabel(DF, arg[2], L);
168 if (!DDF::FindLabel(DF,arg[3],LREF)) return 1;
169 TDF_Reference::Set(L,LREF);
172 di << "DDataStd_SetReference : Error" << "\n";
177 //=======================================================================
178 //function : DDataStd_SetComment
179 //purpose : SetComment (DF, entry, Comment)
180 //=======================================================================
182 static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di,
188 if (!DDF::GetDF(arg[1],DF)) return 1;
190 DDF::AddLabel(DF, arg[2], L);
191 TDataStd_Comment::Set(L,arg[3]);
194 di << "DDataStd_SetComment : Error" << "\n";
200 //=======================================================================
201 //function : DDataStd_GetInteger
202 //purpose : GetReal (DF, entry, [drawname])
203 //=======================================================================
205 static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
209 if (nb == 3 || nb == 4) {
211 if (!DDF::GetDF(arg[1],DF)) return 1;
212 Handle(TDataStd_Integer) A;
213 if (!DDF::Find(DF,arg[2],TDataStd_Integer::GetID(),A)) return 1;
214 if (nb == 4) Draw::Set(arg[3],A->Get());
215 else Draw::Set(arg[2],A->Get());
219 di << "DDataStd_GetInteger : Error" << "\n";
223 //=======================================================================
224 //function : DDataStd_GetReal
225 //purpose : GetReal (DF, entry, [drawname])
226 //=======================================================================
228 static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di,
232 if (nb == 3 || nb == 4) {
234 if (!DDF::GetDF(arg[1],DF)) return 1;
235 Handle(TDataStd_Real) A;
236 if (!DDF::Find(DF,arg[2],TDataStd_Real::GetID(),A)) return 1;
237 if (nb == 4) Draw::Set(arg[3],A->Get());
238 else Draw::Set(arg[2],A->Get());
242 di << "DDataStd_GetReal : Error" << "\n";
247 //=======================================================================
248 //function : DDataStd_GetReference
249 //purpose : GetShape (DF, entry)
250 //=======================================================================
252 static Standard_Integer DDataStd_GetReference (Draw_Interpretor& di,
258 if (!DDF::GetDF(arg[1],DF)) return 1;
259 Handle(TDF_Reference) REF;
260 if (!DDF::Find(DF,arg[2],TDF_Reference::GetID(),REF)) return 1;
261 TCollection_AsciiString entry; TDF_Tool::Entry(REF->Get(),entry);
262 di << entry.ToCString();
265 di << "DDataStd_GetReference : Error" << "\n";
269 //=======================================================================
270 //function : DDataStd_GetComment
271 //purpose : GetShape (DF, entry)
272 //=======================================================================
274 static Standard_Integer DDataStd_GetComment (Draw_Interpretor& di,
280 if (!DDF::GetDF(arg[1],DF)) return 1;
281 Handle(TDataStd_Comment) A;
282 if (!DDF::Find(DF,arg[2],TDataStd_Comment::GetID(),A)) return 1;
283 TCollection_AsciiString s(A->Get(),'?');
287 di << "DDataStd_GetComment : Error" << "\n";
293 //=======================================================================
295 //purpose : Self (document,label)
296 //=======================================================================
298 static Standard_Integer DDataStd_Self (Draw_Interpretor& di,
302 TCollection_AsciiString s;
305 if (!DDF::GetDF(arg[1],DF)) return 1;
307 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
308 // TDataStd::MakeSelfContained(L,removed);
309 // if (removed.IsEmpty()) cout << "noone attriburte removed" << endl;
310 // for (TDF_ListIteratorOfAttributeList it(removed);it.More();it.Next()) {
311 // TDF_Tool::Entry(it.Value()->Label(),s); cout << s << " ";
316 di << "Self : Error" << "\n";
322 //=======================================================================
323 //function : SetUObject (DF, entry, ObjectID)
324 //=======================================================================
325 // static Standard_Integer DDataStd_SetUObject (Draw_Interpretor&,
326 // Standard_Integer nb,
330 // Handle(TDF_Data) DF;
331 // if (!DDF::GetDF(arg[1],DF)) return 1;
333 // DDF::AddLabel(DF, arg[2], label);
335 // Standard_GUID guid(arg[3]); //"00000000-0000-0000-1111-000000000000");
336 // TDataStd_UObject::Set(label, guid);
340 // cout << "Wrong arguments" << endl;
344 //=======================================================================
345 //function : SetUAttribute (DF, entry, LocalID)
346 //=======================================================================
347 static Standard_Integer DDataStd_SetUAttribute (Draw_Interpretor& di,
353 if (!DDF::GetDF(arg[1],DF)) return 1;
355 DDF::AddLabel(DF, arg[2], label);
357 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
358 TDataStd_UAttribute::Set(label, guid);
362 di << "Wrong arguments" << "\n";
366 //=======================================================================
367 //function : GetUAttribute (DF, entry, LoaclID)
368 //=======================================================================
369 static Standard_Integer DDataStd_GetUAttribute (Draw_Interpretor& di,
375 if (!DDF::GetDF(arg[1],DF)) return 1;
377 if( !DDF::FindLabel(DF, arg[2], label) ) {
378 di << "No label for entry" << "\n";
381 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
383 Handle(TDataStd_UAttribute) UA;
384 if( !label.FindAttribute(guid, UA) ) {
385 di << "No UAttribute Attribute on label" << "\n";
388 // UA->ID().ShallowDump(cout);
390 char *aStrGUID = new char[37];
391 UA->ID().ToCString(aStrGUID);
397 di << "Wrong arguments" << "\n";
402 //=======================================================================
403 //function : CheckUObject (DF, entry, ObjectID)
404 //=======================================================================
405 // static Standard_Integer DDataStd_CheckUObject (Draw_Interpretor&,
406 // Standard_Integer nb,
410 // Handle(TDF_Data) DF;
411 // if (!DDF::GetDF(arg[1],DF)) return 1;
413 // if( !DDF::FindLabel(DF, arg[2], label) ) {
414 // cout << "No label for entry" << endl;
417 // Handle(TDataStd_Object) O;
418 // Handle(TDataStd_UObject) UO;
419 // Standard_GUID guidUO(arg[3]);
421 // if( !label.FindAttribute( TDataStd_Object::GetID(), O) ) {
422 // cout << "No Object Attribute on label" << endl;
425 // cout << "UObject is found with ObjectID = ";
426 // O->Find(label, guidUO, UO);
427 // UO->ObjectID().ShallowDump(cout);
433 // cout << "Wrong arguments" << endl;
438 //=======================================================================
439 //function : SetIntArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
440 //=======================================================================
441 static Standard_Integer DDataStd_SetIntArray (Draw_Interpretor& di,
448 if (!DDF::GetDF(arg[1],DF)) return 1;
450 DDF::AddLabel(DF, arg[2], label);
451 Standard_Integer isDelta = Draw::Atoi(arg[3]);
452 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
453 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
454 Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
457 for(Standard_Integer i = From; i<=To; i++) {
458 A->SetValue(i, Draw::Atoi(arg[j]) );
465 //=======================================================================
466 //function : GetIntArray (DF, entry )
467 //=======================================================================
468 static Standard_Integer DDataStd_GetIntArray (Draw_Interpretor& di,
475 if (!DDF::GetDF(arg[1],DF)) return 1;
477 if( !DDF::FindLabel(DF, arg[2], label) ) {
478 di << "No label for entry" << "\n";
482 Handle(TDataStd_IntegerArray) A;
483 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
484 di << "There is no TDataStd_IntegerArray under label" << "\n";
488 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
489 //cout << A->Value(i) << endl;
498 //=======================================================================
499 //function : ChangeIntArray (DF, entry, indx, val )
500 //=======================================================================
501 static Standard_Integer DDataStd_ChangeIntArray (Draw_Interpretor& di,
508 if (!DDF::GetDF(arg[1],DF)) return 1;
510 if( !DDF::FindLabel(DF, arg[2], label) ) {
511 di << "No label for entry" << "\n";
515 Handle(TDataStd_IntegerArray) A;
516 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
517 di << "There is no TDataStd_IntegerArray at label" << "\n";
520 Standard_Integer indx = Draw::Atoi(arg[3]);
521 Standard_Integer val = Draw::Atoi(arg[4]);
522 Standard_Integer low = A->Lower(), up = A->Upper();
523 if(low <= indx && indx <= up)
524 A->SetValue(indx, val);
526 Handle(TColStd_HArray1OfInteger) Arr = A->Array();
527 Handle(TColStd_HArray1OfInteger) arr;
531 arr = new TColStd_HArray1OfInteger(low, up);
532 for(i=low; i<= Arr->Upper(); i++)
533 arr->SetValue(i, Arr->Value(i));
534 for(i=Arr->Upper()+1; i<= up; i++) {
536 arr->SetValue(i, val);
540 } else if(indx < up) {//clip array : indx to be negative
542 arr = new TColStd_HArray1OfInteger(low, up);
543 for(i=low; i< up; i++)
544 arr->SetValue(i, Arr->Value(i));
545 arr->SetValue(up, val);
551 di << "DDataStd_ChangeIntArray: Error" << "\n";
555 //=======================================================================
556 //function : SetIntArrayT (DF, entry , isDelta, From, To) - for testing
558 //=======================================================================
559 static Standard_Integer DDataStd_SetIntArrayTest (Draw_Interpretor& di,
566 if (!DDF::GetDF(arg[1],DF)) return 1;
568 DDF::AddLabel(DF, arg[2], label);
569 Standard_Integer isDelta = Draw::Atoi(arg[3]);
570 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
571 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
572 Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
575 Standard_Integer k = 100;
576 for(Standard_Integer i = From; i<=To; i++) {
584 //=======================================================================
585 //function : SetRealArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
586 //=======================================================================
587 static Standard_Integer DDataStd_SetRealArray (Draw_Interpretor& di,
594 if (!DDF::GetDF(arg[1],DF)) return 1;
596 DDF::AddLabel(DF, arg[2], label);
597 Standard_Integer isDelta = Draw::Atoi(arg[3]);
599 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
600 di << " Array of Standard_Real with bounds from = " << From << " to = " << To << "\n";
601 Handle(TDataStd_RealArray) A = TDataStd_RealArray::Set(label, From, To, isDelta);
604 for(Standard_Integer i = From; i<=To; i++) {
605 A->SetValue(i, Draw::Atof(arg[j]) );
612 //=======================================================================
613 //function : GetRealArray (DF, entry )
614 //=======================================================================
615 static Standard_Integer DDataStd_GetRealArray (Draw_Interpretor& di,
621 if (!DDF::GetDF(arg[1],DF)) return 1;
623 if( !DDF::FindLabel(DF, arg[2], label) ) {
624 di << "No label for entry" << "\n";
628 Handle(TDataStd_RealArray) A;
629 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
630 di << "There is no TDataStd_RealArray under label" << "\n";
634 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
635 //cout << A->Value(i) << endl;
646 //=======================================================================
647 //function : ChangeRealArray (DF, entry, indx, val )
648 //=======================================================================
649 static Standard_Integer DDataStd_ChangeRealArray (Draw_Interpretor& di,
656 if (!DDF::GetDF(arg[1],DF)) return 1;
658 if( !DDF::FindLabel(DF, arg[2], label) ) {
659 di << "No label for entry" << "\n";
663 Handle(TDataStd_RealArray) A;
664 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
665 di << "There is no TDataStd_RealArray at label" << "\n";
668 Standard_Integer indx = Draw::Atoi(arg[3]);
669 Standard_Real val = Draw::Atof(arg[4]);
670 Standard_Integer low = A->Lower(), up = A->Upper();
671 if(low <= indx && indx <= up)
672 A->SetValue(indx, val);
674 Handle(TColStd_HArray1OfReal) Arr = A->Array();
675 Handle(TColStd_HArray1OfReal) arr;
679 arr = new TColStd_HArray1OfReal(low, up);
680 for(i=low; i<= Arr->Upper(); i++)
681 arr->SetValue(i, Arr->Value(i));
682 for(i=Arr->Upper()+1; i<= up; i++) {
684 arr->SetValue(i, val);
688 } else if(indx < up) {//clip array : indx to be negative
690 arr = new TColStd_HArray1OfReal(low, up);
691 for(i=low; i< up; i++)
692 arr->SetValue(i, Arr->Value(i));
693 arr->SetValue(up, val);
699 di << "DDataStd_ChangeRealArray: Error" << "\n";
703 //=======================================================================
704 //function : SetVariable (DF, entry, isConstant[0/1], units)
705 //=======================================================================
706 static Standard_Integer DDataStd_SetVariable (Draw_Interpretor& di,
713 if (!DDF::GetDF(arg[1],DF)) return 1;
715 DDF::AddLabel(DF, arg[2], label);
717 Handle(TDataStd_Variable) aV = TDataStd_Variable::Set(label);
719 const char* aUnits = arg[4];
720 aV->Unit(Standard_CString(aUnits));
722 aV->Constant(Standard_Boolean(Draw::Atoi(arg[3])));
726 di << "Wrong arguments" << "\n";
730 //=======================================================================
731 //function : GetVariable (DF, entry, [isConstant], [units])
732 //=======================================================================
733 static Standard_Integer DDataStd_GetVariable (Draw_Interpretor& di,
740 if (!DDF::GetDF(arg[1],DF)) return 1;
742 DDF::AddLabel(DF, arg[2], label);
744 Handle(TDataStd_Variable) aV;
745 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
747 di << "TDataStd_Variable: no such attribute" << "\n";
750 Draw::Set(arg[3],TCollection_AsciiString(Standard_Integer(aV->IsConstant())).ToCString());
751 Draw::Set(arg[4],aV->Unit().ToCString());
755 di << "Wrong arguments" << "\n";
759 #include <TDataStd_Relation.hxx>
760 #include <TDataStd_Variable.hxx>
761 //=======================================================================
762 //function : SetRelation (DF, entry, expression, var1[, var2, ...])
763 //=======================================================================
764 static Standard_Integer DDataStd_SetRelation (Draw_Interpretor& di,
765 Standard_Integer nb, const char** arg)
770 if (!DDF::GetDF(arg[1],DF)) return 1;
772 DDF::AddLabel(DF, arg[2], label);
774 Standard_CString expr (arg[3]);
775 Handle(TDataStd_Relation) aR = TDataStd_Relation::Set(label);
776 aR->SetRelation(expr);
777 Handle(TDataStd_Variable) aV;
779 for (Standard_Integer i = 4; i < nb; i++)
781 if (!DDF::FindLabel(DF, arg[i], label))
783 di << "No label for entry" << arg[i] << "\n";
786 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
788 di << "No TDataStd_Variable Attribute on label" << "\n";
791 aR->GetVariables().Append(aV);
795 di << "Usage: SetRelation (DF, entry, expression, var1[, var2, ...])" << "\n";
799 //=======================================================================
800 //function : DumpRelation (DF, entry)
801 //=======================================================================
802 static Standard_Integer DDataStd_DumpRelation (Draw_Interpretor& di,
803 Standard_Integer nb, const char** arg)
808 if (!DDF::GetDF(arg[1],DF)) return 1;
811 if (!DDF::FindLabel(DF, arg[2], label))
813 di << "No label for entry " << arg[2] << "\n";
816 Handle(TDataStd_Relation) aR;
817 if (!label.FindAttribute(TDataStd_Relation::GetID(), aR))
819 di << "No TDataStd_Relation Attribute on label " << arg[2] << "\n";
823 di << "Relation: expression = \"" << aR->GetRelation()
824 << "\" variables list = (";
826 Handle(TDF_Attribute) aV;
827 TCollection_AsciiString anEntry;
829 TDF_ListIteratorOfAttributeList it;
830 for (it.Initialize(aR->GetVariables()); it.More(); it.Next())
836 TDF_Tool::Entry(label, anEntry);
837 di << anEntry.ToCString() << " ";
843 di << "Usage: DumpRelation (DF, entry)" << "\n";
847 #include <TFunction_Function.hxx>
848 //=======================================================================
849 //function : SetFunction (DF, entry, guid, failure)
850 //=======================================================================
851 static Standard_Integer DDataStd_SetFunction (Draw_Interpretor& di,
852 Standard_Integer nb, const char** arg)
857 if (!DDF::GetDF(arg[1],DF)) return 1;
859 DDF::AddLabel(DF, arg[2], label);
861 Standard_GUID guid (arg[3]);
862 Handle(TFunction_Function) aF = TFunction_Function::Set(label, guid);
864 int fail = Draw::Atoi(arg[4]);
865 aF->SetFailure(fail);
870 di << "Wrong arguments" << "\n";
874 //=======================================================================
875 //function : GetFunction (DF, entry, guid(out), failure(out))
876 //=======================================================================
877 static Standard_Integer DDataStd_GetFunction (Draw_Interpretor& di,
878 Standard_Integer nb, const char** arg)
883 if (!DDF::GetDF(arg[1],DF)) return 1;
885 if (!DDF::FindLabel(DF, arg[2], label))
887 di << "No label for entry" << "\n";
891 Handle(TFunction_Function) aF;
892 if (!label.FindAttribute(TFunction_Function::GetID(), aF))
894 di << "No TFunction_Function Attribute on label" << "\n";
898 char *aStrGUID = new char[37];
899 aF->GetDriverGUID().ToCString(aStrGUID);
900 Draw::Set(arg[3],aStrGUID);
902 Draw::Set(arg[4],TCollection_AsciiString(aF->GetFailure()).ToCString());
907 di << "Wrong arguments" << "\n";
911 //=======================================================================
912 //function : SetExtStringArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
913 //=======================================================================
914 static Standard_Integer DDataStd_SetExtStringArray (Draw_Interpretor& di,
921 if (!DDF::GetDF(arg[1],DF)) return 1;
923 DDF::AddLabel(DF, arg[2], label);
924 Standard_Integer isDelta = Draw::Atoi(arg[3]);
926 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
927 di << "Array of ExtString with bounds from = " << From << " to = " << To << "\n";
928 Handle(TDataStd_ExtStringArray) A = TDataStd_ExtStringArray::Set(label, From, To, isDelta);
931 for(Standard_Integer i = From; i<=To; i++) {
932 A->SetValue(i, arg[j] );
939 //=======================================================================
940 //function : GetExtStringArray (DF, entry )
941 //=======================================================================
942 static Standard_Integer DDataStd_GetExtStringArray (Draw_Interpretor& di,
949 if (!DDF::GetDF(arg[1],DF)) return 1;
951 if( !DDF::FindLabel(DF, arg[2], label) ) {
952 di << "No label for entry" << "\n";
956 Handle(TDataStd_ExtStringArray) A;
957 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
958 di << "There is no TDataStd_ExtStringArray under label" << "\n";
962 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
963 TCollection_AsciiString anAsciiString(A->Value(i),'?');
964 di << anAsciiString.ToCString();
972 //=======================================================================
973 //function : ChangeExtStrArray (DF, entry, indx, val )
974 //=======================================================================
975 static Standard_Integer DDataStd_ChangeExtStrArray (Draw_Interpretor& di,
982 if (!DDF::GetDF(arg[1],DF)) return 1;
984 if( !DDF::FindLabel(DF, arg[2], label) ) {
985 di << "No label for entry" << "\n";
989 Handle(TDataStd_ExtStringArray) A;
990 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
991 di << "There is no TDataStd_ExtStringArray at label" << "\n";
994 Standard_Integer indx = Draw::Atoi(arg[3]);
995 TCollection_ExtendedString val(arg[4]);
996 Standard_Integer low = A->Lower(), up = A->Upper();
997 if(low <= indx && indx <= up)
998 A->SetValue(indx, val);//TColStd_HArray1OfExtendedString
1000 Handle(TColStd_HArray1OfExtendedString) Arr = A->Array();
1001 Handle(TColStd_HArray1OfExtendedString) arr;
1005 arr = new TColStd_HArray1OfExtendedString(low, up);
1006 for(i=low; i<= Arr->Upper(); i++)
1007 arr->SetValue(i, Arr->Value(i));
1008 for(i=Arr->Upper()+1; i<= up; i++) {
1010 arr->SetValue(i, val);
1012 arr->SetValue(i, 0);
1014 } else if(indx < up) {//clip array : indx to be negative
1016 arr = new TColStd_HArray1OfExtendedString(low, up);
1017 for(i=low; i< up; i++)
1018 arr->SetValue(i, Arr->Value(i));
1019 arr->SetValue(up, val);
1021 A->ChangeArray(arr);
1025 di << "DDataStd_ChangeExtStringArray: Error" << "\n";
1030 //=======================================================================
1031 //function : DDataStd_KeepUTF
1032 //purpose : SetUTFName (DF, fatherEntry, fileName)
1033 //=======================================================================
1034 static Standard_Integer DDataStd_KeepUTF (Draw_Interpretor& di,
1035 Standard_Integer nb,
1039 Handle(TDF_Data) DF;
1040 if (!DDF::GetDF(arg[1],DF)) return 1;
1042 DDF::AddLabel(DF, arg[2], L);
1043 Standard_CString aFileName(arg[3]);
1046 ifstream anIS (aFileName, ios::in | ios::binary);
1048 ifstream anIS (aFileName);
1051 // Can not open file
1052 cout << "Error: can't open file " << aFileName <<endl;;
1057 anIS.getline(buf, 1023,'\n');
1058 // 0xEFBBBF - prefix of UTF8
1059 p = &buf[3]; //skip prefix
1060 TCollection_ExtendedString aES1(p, Standard_True);
1061 TDataStd_Name::Set(L.NewChild(), aES1);
1064 while (anIS.good() && !anIS.eof()) {
1065 anIS.getline(buf, 1023,'\n');
1066 TCollection_ExtendedString aES2(buf, Standard_True);
1067 const TDF_Label& aLab = L.NewChild();
1068 TDataStd_Name::Set(aLab, aES2);
1072 di << "SetUTFName : String is not kept in DF" << "\n";
1076 //=======================================================================
1077 //function : DDataStd_GetUTFtoFile
1078 //purpose : GetUTF (DF, fatherEntry, fileName)
1079 // : all strings from sub-labels of the <fatherEntry> concatenated
1080 // : in one, converted to UTF8 and kept in the file
1081 //=======================================================================
1082 static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di,
1083 Standard_Integer nb,
1087 Handle(TDF_Data) DF;
1088 if (!DDF::GetDF(arg[1],DF)) return 1;
1090 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
1092 TCollection_ExtendedString aES;
1093 Standard_Boolean aF = Standard_False;
1094 TDF_ChildIterator anIt(L);
1095 for(;anIt.More();anIt.Next()) {
1096 const TDF_Label& aLab = anIt.Value();
1097 if(!aLab.IsNull()) {
1098 Handle(TDataStd_Name) anAtt;
1099 if(aLab.FindAttribute(TDataStd_Name::GetID(), anAtt)) {
1100 if(anAtt->Get().Length()) {
1111 cout << "Data is not found in the Document" <<endl;
1115 Standard_CString aFileName(arg[3]);
1118 ofstream anOS (aFileName, ios::in | ios::binary | ios::ate);
1120 ofstream anOS (aFileName, ios::ate);
1123 // A problem with the stream
1125 cout << "Error: problem with the file stream, rdstate = " <<anOS.rdstate() <<endl;
1128 unsigned char prefix[4] = {0xEF,0xBB,0xBF, 0x00};
1129 anOS.write( (char*)&prefix[0], 3);
1130 Standard_Integer n = aES.LengthOfCString();
1131 Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(ROUNDMEM(n+1));
1132 n = aES.ToUTF8CString(aCstr);
1133 anOS.write( (char*)&aCstr[0], n);
1137 di << "GetUTF : Data is not extracted to the specified file " <<"\n";
1141 //=======================================================================
1142 //function : SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )
1143 //=======================================================================
1144 static Standard_Integer DDataStd_SetByteArray (Draw_Interpretor& di,
1145 Standard_Integer nb,
1150 Handle(TDF_Data) DF;
1151 if (!DDF::GetDF(arg[1],DF)) return 1;
1153 DDF::AddLabel(DF, arg[2], label);
1154 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1155 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
1156 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
1157 Handle(TDataStd_ByteArray) A = TDataStd_ByteArray::Set(label, From, To, isDelta);
1160 for(Standard_Integer i = From; i<=To; ++i) {
1161 Standard_Integer ival = Draw::Atoi(arg[j]);
1162 if(ival < 0 && 255 < ival) {
1163 cout << "Bad value = " << ival<< endl;
1166 A->SetValue(i, (Standard_Byte)ival);
1171 di << "DDataStd_SetByteArray: Error" << "\n";
1175 //=======================================================================
1176 //function : SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )
1177 //=======================================================================
1178 static Standard_Integer DDataStd_SetBooleanArray (Draw_Interpretor& di,
1179 Standard_Integer nb,
1184 Handle(TDF_Data) DF;
1185 if (!DDF::GetDF(arg[1],DF))
1189 DDF::AddLabel(DF, arg[2], label);
1190 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
1191 di << "Array of Standard_Boolean with bounds from = " << From << " to = " << To << "\n";
1192 Handle(TDataStd_BooleanArray) A = TDataStd_BooleanArray::Set(label, From, To);
1195 for(Standard_Integer i = From; i<=To; i++)
1197 Standard_Integer ival = Draw::Atoi(arg[j]);
1200 cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl;
1203 A->SetValue(i, (Standard_Boolean)ival);
1208 di << "DDataStd_SetBooleanArray: Error" << "\n";
1212 //=======================================================================
1213 //function : SetBooleanList (DF, entry, elmt1, elmt2, ... )
1214 //=======================================================================
1215 static Standard_Integer DDataStd_SetBooleanList (Draw_Interpretor& di,
1216 Standard_Integer nb,
1221 Handle(TDF_Data) DF;
1222 if (!DDF::GetDF(arg[1],DF))
1226 DDF::AddLabel(DF, arg[2], label);
1227 Handle(TDataStd_BooleanList) A = TDataStd_BooleanList::Set(label);
1228 for(Standard_Integer i = 3; i <= nb - 1; i++)
1230 Standard_Integer ival = Draw::Atoi(arg[i]);
1233 cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl;
1236 A->Append((Standard_Boolean)ival);
1240 di << "DDataStd_SetBooleanList: Error" << "\n";
1244 //=======================================================================
1245 //function : SetIntegerList (DF, entry, elmt1, elmt2, ... )
1246 //=======================================================================
1247 static Standard_Integer DDataStd_SetIntegerList (Draw_Interpretor& di,
1248 Standard_Integer nb,
1253 Handle(TDF_Data) DF;
1254 if (!DDF::GetDF(arg[1],DF))
1258 DDF::AddLabel(DF, arg[2], label);
1259 Handle(TDataStd_IntegerList) A = TDataStd_IntegerList::Set(label);
1260 for(Standard_Integer i = 3; i <= nb - 1; i++)
1262 Standard_Integer ival = Draw::Atoi(arg[i]);
1267 di << "DDataStd_SetIntegerList: Error" << "\n";
1271 //=======================================================================
1272 //function : SetRealList (DF, entry, elmt1, elmt2, ... )
1273 //=======================================================================
1274 static Standard_Integer DDataStd_SetRealList (Draw_Interpretor& di,
1275 Standard_Integer nb,
1280 Handle(TDF_Data) DF;
1281 if (!DDF::GetDF(arg[1],DF))
1285 DDF::AddLabel(DF, arg[2], label);
1286 Handle(TDataStd_RealList) A = TDataStd_RealList::Set(label);
1287 for(Standard_Integer i = 3; i <= nb - 1; i++)
1289 Standard_Real fval = Draw::Atof(arg[i]);
1294 di << "DDataStd_SetRealList: Error" << "\n";
1298 //=======================================================================
1299 //function : GetByteArray (DF, entry )
1300 //=======================================================================
1301 static Standard_Integer DDataStd_GetByteArray (Draw_Interpretor& di,
1307 Handle(TDF_Data) DF;
1308 if (!DDF::GetDF(arg[1],DF)) return 1;
1310 if( !DDF::FindLabel(DF, arg[2], label) ) {
1311 di << "No label for entry" << "\n";
1315 Handle(TDataStd_ByteArray) A;
1316 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
1317 di << "There is no TDataStd_ByteArray at label" << "\n";
1321 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
1322 //cout << A->Value(i) << endl;
1331 //=======================================================================
1332 //function : GetBooleanArray (DF, entry )
1333 //=======================================================================
1334 static Standard_Integer DDataStd_GetBooleanArray (Draw_Interpretor& di,
1338 Handle(TDF_Data) DF;
1339 if (!DDF::GetDF(arg[1],DF))
1343 if ( !DDF::FindLabel(DF, arg[2], label) )
1345 di << "No label for entry" << "\n";
1349 Handle(TDataStd_BooleanArray) A;
1350 if ( !label.FindAttribute(TDataStd_BooleanArray::GetID(), A) )
1352 di << "There is no TDataStd_BooleanArray at label" << "\n";
1356 for (Standard_Integer i = A->Lower(); i<=A->Upper(); i++)
1358 di << (Standard_Integer) A->Value(i);
1366 //=======================================================================
1367 //function : ChangeByteArray (DF, entry, indx, val )
1368 //=======================================================================
1369 static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
1370 Standard_Integer nb,
1375 Handle(TDF_Data) DF;
1376 if (!DDF::GetDF(arg[1],DF)) return 1;
1378 if( !DDF::FindLabel(DF, arg[2], label) ) {
1379 di << "No label for entry" << "\n";
1383 Handle(TDataStd_ByteArray) A;
1384 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
1385 di << "There is no TDataStd_ByteArray at label" << "\n";
1388 Standard_Integer indx = Draw::Atoi(arg[3]);
1389 Standard_Integer ival = Draw::Atoi(arg[4]);
1390 if (ival > 255 || ival < 0) {
1391 di << "DDataStd_ChangeByteArray: Bad value = " <<ival << "\n";
1394 Standard_Integer low = A->Lower(), up = A->Upper();
1395 if(low <= indx && indx <= up)
1396 A->SetValue(indx, (Standard_Byte)ival);
1398 Handle(TColStd_HArray1OfByte) Arr = A->InternalArray();
1399 Handle(TColStd_HArray1OfByte) arr;
1403 arr = new TColStd_HArray1OfByte(low, up);
1404 for(i=low; i<= Arr->Upper(); i++)
1405 arr->SetValue(i, Arr->Value(i));
1406 for(i=Arr->Upper()+1; i<= up; i++) {
1408 arr->SetValue(i, (Standard_Byte)ival);
1410 arr->SetValue(i, 0);
1412 } else if(indx < up) {//clip array : indx to be negative
1414 arr = new TColStd_HArray1OfByte(low, up);
1415 for(i=low; i< up; i++)
1416 arr->SetValue(i, Arr->Value(i));
1417 arr->SetValue(up, (Standard_Byte)ival);
1419 A->ChangeArray(arr);
1423 di << "DDataStd_ChangeByteArray: Error" << "\n";
1427 //=======================================================================
1428 //function : GetBooleanList (DF, entry )
1429 //=======================================================================
1430 static Standard_Integer DDataStd_GetBooleanList (Draw_Interpretor& di,
1434 Handle(TDF_Data) DF;
1435 if (!DDF::GetDF(arg[1],DF))
1439 if ( !DDF::FindLabel(DF, arg[2], label) )
1441 di << "No label for entry" << "\n";
1445 Handle(TDataStd_BooleanList) A;
1446 if ( !label.FindAttribute(TDataStd_BooleanList::GetID(), A) )
1448 di << "There is no TDataStd_BooleanList at label" << "\n";
1452 const TDataStd_ListOfByte& bList = A->List();
1453 TDataStd_ListIteratorOfListOfByte itr(bList);
1454 for (; itr.More(); itr.Next())
1456 di << (Standard_Integer) itr.Value() << " ";
1462 //=======================================================================
1463 //function : GetIntegerList (DF, entry )
1464 //=======================================================================
1465 static Standard_Integer DDataStd_GetIntegerList (Draw_Interpretor& di,
1469 Handle(TDF_Data) DF;
1470 if (!DDF::GetDF(arg[1],DF))
1474 if ( !DDF::FindLabel(DF, arg[2], label) )
1476 di << "No label for entry" << "\n";
1480 Handle(TDataStd_IntegerList) A;
1481 if ( !label.FindAttribute(TDataStd_IntegerList::GetID(), A) )
1483 di << "There is no TDataStd_IntegerList at label" << "\n";
1487 const TColStd_ListOfInteger& iList = A->List();
1488 TColStd_ListIteratorOfListOfInteger itr(iList);
1489 for (; itr.More(); itr.Next())
1491 di << itr.Value() << " ";
1497 //=======================================================================
1498 //function : GetRealList (DF, entry )
1499 //=======================================================================
1500 static Standard_Integer DDataStd_GetRealList (Draw_Interpretor& di,
1504 Handle(TDF_Data) DF;
1505 if (!DDF::GetDF(arg[1],DF))
1509 if ( !DDF::FindLabel(DF, arg[2], label) )
1511 di << "No label for entry" << "\n";
1515 Handle(TDataStd_RealList) A;
1516 if ( !label.FindAttribute(TDataStd_RealList::GetID(), A) )
1518 di << "There is no TDataStd_RealList at label" << "\n";
1522 const TColStd_ListOfReal& iList = A->List();
1523 TColStd_ListIteratorOfListOfReal itr(iList);
1524 for (; itr.More(); itr.Next())
1526 di << itr.Value() << " ";
1532 //=======================================================================
1533 //function : SetIntPackedMap (DF, entry, isDelta, key1, key2, ...
1534 //=======================================================================
1536 static Standard_Integer DDataStd_SetIntPackedMap (Draw_Interpretor& di,
1537 Standard_Integer nb,
1542 Handle(TDF_Data) DF;
1543 if (!DDF::GetDF(arg[1],DF)) return 1;
1545 DDF::AddLabel(DF, arg[2], aLabel);
1546 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1547 Standard_Integer aNum = nb - 4;
1548 Handle(TDataStd_IntPackedMap) anAtt;
1549 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
1550 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
1551 if(anAtt.IsNull()) {
1552 di << "IntPackedMap attribute is not found or not set" << "\n";
1555 Standard_Integer j = 4;
1556 TColStd_PackedMapOfInteger aMap;
1557 for(Standard_Integer i = 1; i<=aNum; i++) {
1558 aMap.Add (Draw::Atoi(arg[j]));
1561 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
1562 anAtt->ChangeMap(aHMap);
1563 cout << "Map extent = " << anAtt->Extent()<<endl;
1566 di << "DDataStd_SetIntPackedMap : Error" << "\n";
1570 //=======================================================================
1571 //function : GetIntPackedMap (DF, entry )
1572 //=======================================================================
1574 static Standard_Integer DDataStd_GetIntPackedMap (Draw_Interpretor& di,
1575 Standard_Integer nb,
1580 Handle(TDF_Data) DF;
1581 if (!DDF::GetDF(arg[1],DF)) return 1;
1583 DDF::AddLabel(DF, arg[2], aLabel);
1584 Handle(TDataStd_IntPackedMap) anAtt;
1585 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) {
1586 di << "IntPackedMap attribute is not found or not set" << "\n";
1589 const TColStd_PackedMapOfInteger& aMap = anAtt->GetMap();
1590 TColStd_MapIteratorOfPackedMapOfInteger itr(aMap);
1591 for (Standard_Integer j = 1; itr.More(); itr.Next(),j++){
1592 Standard_Integer aKey(itr.Key());
1597 di << "DDataStd_GetIntPackedMap : Error" << "\n";
1602 //=======================================================================
1603 //function : ChangeIntPackedMap_Add (DF, entry, Key1, Key2,... )
1604 //=======================================================================
1605 static Standard_Integer DDataStd_ChangeIntPackedMap_Add (Draw_Interpretor& di,
1606 Standard_Integer nb,
1611 Handle(TDF_Data) DF;
1612 if (!DDF::GetDF(arg[1],DF)) return 1;
1614 if( !DDF::FindLabel(DF, arg[2], label) ) {
1615 di << "No label for entry" << "\n";
1619 Handle(TDataStd_IntPackedMap) A;
1620 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1621 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1625 Standard_Integer i, aNum = nb - 3;
1626 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1627 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1628 if(!aHMap.IsNull()) {
1629 ahMap->ChangeMap().Assign(aHMap->Map());
1630 for(i=1; i<=aNum;i++) {
1631 Standard_Integer val = Draw::Atoi(arg[i+2]);
1632 if(!ahMap->Map().Contains(val))
1633 ahMap->ChangeMap().Add(val);
1636 A->ChangeMap(ahMap);
1640 di << "DDataStd_ChangeIntPackedMap_Add: Error" << "\n";
1645 //=======================================================================
1646 //function : ChangeIntPackedMap_Rem (DF, entry, Key1, Key2,... )
1647 //=======================================================================
1648 static Standard_Integer DDataStd_ChangeIntPackedMap_Rem (Draw_Interpretor& di,
1649 Standard_Integer nb,
1654 Handle(TDF_Data) DF;
1655 if (!DDF::GetDF(arg[1],DF)) return 1;
1657 if( !DDF::FindLabel(DF, arg[2], label) ) {
1658 di << "No label for entry" << "\n";
1662 Handle(TDataStd_IntPackedMap) A;
1663 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1664 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1668 Standard_Integer i, aNum = nb - 3;
1669 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1670 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1671 if(!aHMap.IsNull()) {
1672 ahMap->ChangeMap().Assign(aHMap->Map());
1673 for(i=1; i<=aNum;i++) {
1674 Standard_Integer val = Draw::Atoi(arg[i+2]);
1675 if(ahMap->Map().Contains(val))
1676 ahMap->ChangeMap().Remove(val);
1679 A->ChangeMap(ahMap);
1683 di << "DDataStd_ChangeIntPackedMap_Rem: Error" << "\n";
1687 //=======================================================================
1688 //function : ChangeIntPackedMap_AddRem (DF, entry, Key1, Key2,... )
1689 // : if Keyi exist in map - remove it, if no - add
1690 //=======================================================================
1691 static Standard_Integer DDataStd_ChangeIntPackedMap_AddRem (Draw_Interpretor& di,
1692 Standard_Integer nb,
1697 Handle(TDF_Data) DF;
1698 if (!DDF::GetDF(arg[1],DF)) return 1;
1700 if( !DDF::FindLabel(DF, arg[2], label) ) {
1701 di << "No label for entry" << "\n";
1705 Handle(TDataStd_IntPackedMap) A;
1706 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1707 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1711 Standard_Integer i, aNum = nb - 3;
1712 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1713 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1714 if(!aHMap.IsNull()) {
1715 ahMap->ChangeMap().Assign(aHMap->Map());
1716 for(i=1; i<=aNum;i++) {
1717 Standard_Integer val = Draw::Atoi(arg[i+2]);
1718 if(!ahMap->Map().Contains(val))
1719 ahMap->ChangeMap().Add(val);
1721 ahMap->ChangeMap().Remove(val);
1724 A->ChangeMap(ahMap);
1728 di << "DDataStd_ChangeIntPackedMap_AddRem: Error" << "\n";
1732 //=======================================================================
1733 //function : SetIntPHugeMap (DF, entry, isDelta Num)
1734 //=======================================================================
1736 static Standard_Integer DDataStd_SetIntPHugeMap (Draw_Interpretor& di,
1737 Standard_Integer nb,
1742 Handle(TDF_Data) DF;
1743 if (!DDF::GetDF(arg[1],DF)) return 1;
1745 DDF::AddLabel(DF, arg[2], aLabel);
1746 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1747 Standard_Integer aNum = Draw::Atoi(arg[4]);
1748 Handle(TDataStd_IntPackedMap) anAtt;
1749 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
1750 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
1751 if(anAtt.IsNull()) {
1752 di << "IntPackedMap attribute is not found or not set" << "\n";
1755 TColStd_PackedMapOfInteger aMap;
1756 for(Standard_Integer i = 1; i<=aNum; i++) {
1759 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
1760 anAtt->ChangeMap(aHMap);
1761 cout << "Map extent = " << anAtt->Extent()<<endl;
1764 di << "DDataStd_SetIntPHugeMap : Error" << "\n";
1768 //=======================================================================
1769 //function : SetNDataIntegers (DF, entry , Num
1770 //=======================================================================
1772 static Standard_Integer DDataStd_SetNDataIntegers2 (Draw_Interpretor& di,
1773 Standard_Integer nb,
1778 Handle(TDF_Data) DF;
1779 if (!DDF::GetDF(arg[1],DF)) return 1;
1781 DDF::AddLabel(DF, arg[2], aLabel);
1782 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
1783 Handle(TDataStd_NamedData) anAtt;
1784 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1785 anAtt = TDataStd_NamedData::Set(aLabel);
1786 if(anAtt.IsNull()) {
1787 di << "NamedData attribute is not found or not set" << "\n";
1791 TCollection_ExtendedString aKey("Key_");
1792 for(Standard_Integer i = 1; i<=aNumP; i++) {
1793 TCollection_ExtendedString key = aKey + i;
1794 Standard_Integer aVal = j+i;
1795 anAtt->SetInteger(key, aVal);
1800 di << "DDataStd_SetNDataIntegers2 : Error" << "\n";
1804 //=======================================================================
1805 //function : SetNDataIntArrays2 (DF, entry , key, NumOfArElem )
1806 //=======================================================================
1808 static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di,
1809 Standard_Integer nb,
1814 Handle(TDF_Data) DF;
1815 if (!DDF::GetDF(arg[1],DF)) return 1;
1817 DDF::AddLabel(DF, arg[2], aLabel);
1820 TCollection_ExtendedString aKey(arg[3]);
1821 Standard_Integer aNum = Draw::Atoi(arg[4]);
1822 if (aNum <= 0) return 1;
1823 Handle(TDataStd_NamedData) anAtt;
1824 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1825 anAtt = TDataStd_NamedData::Set(aLabel);
1826 if(anAtt.IsNull()) {
1827 cout<< "NamedData attribute is not found or not set" << endl;
1831 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
1832 for(Standard_Integer i = 1; i<=aNum; i++) {
1833 Standard_Integer aVal = j++;
1834 anArr->SetValue(i, aVal);
1837 anAtt->SetArrayOfIntegers(aKey, anArr);
1840 di << "DDataStd_SetNDataIntArrays2 : Error" << "\n";
1845 //=======================================================================
1846 //function : SetAsciiString(DF, entry , String)
1847 //=======================================================================
1849 static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
1850 Standard_Integer nb,
1855 Handle(TDF_Data) DF;
1856 if (!DDF::GetDF(arg[1],DF)) return 1;
1858 DDF::AddLabel(DF, arg[2], aLabel);
1859 TCollection_AsciiString aString(arg[3]);
1860 Handle(TDataStd_AsciiString) anAtt;
1861 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1862 anAtt = TDataStd_AsciiString::Set(aLabel, aString);
1863 if(anAtt.IsNull()) {
1864 di << "AsciiString attribute is not found or not set" << "\n";
1867 // anAtt->Set(aString);
1868 cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << endl;
1871 di << "DDataStd_SetAsciiString : Error" << "\n";
1875 //=======================================================================
1876 //function : GetAsciiString(DF, entry )
1877 //=======================================================================
1879 static Standard_Integer DDataStd_GetAsciiString (Draw_Interpretor& di,
1880 Standard_Integer nb,
1885 Handle(TDF_Data) DF;
1886 if (!DDF::GetDF(arg[1],DF)) return 1;
1888 DDF::AddLabel(DF, arg[2], aLabel);
1889 Handle(TDataStd_AsciiString) anAtt;
1890 if(!aLabel.FindAttribute(TDataStd_AsciiString::GetID(), anAtt)) {
1891 cout << "AsciiString attribute is not found or not set" << endl;
1894 cout << "String = " <<anAtt->Get().ToCString() << endl;
1897 di << "DDataStd_GetAsciiString : Error" << "\n";
1901 //=======================================================================
1902 //function : SetNDataIntegers (DF, entry , Num, key1, val1, ...
1903 //=======================================================================
1905 static Standard_Integer DDataStd_SetNDataIntegers (Draw_Interpretor& di,
1906 Standard_Integer nb,
1911 Handle(TDF_Data) DF;
1912 if (!DDF::GetDF(arg[1],DF)) return 1;
1914 DDF::AddLabel(DF, arg[2], aLabel);
1916 // TCollection_ExtendedString aString("123456789 0_abcde");
1917 // Standard_Integer aPos = aString.Search(" ");
1918 // cout << "From Start = " <<aPos<<endl;
1919 // aPos = aString.SearchFromEnd(" ");
1920 // cout << "From Start = " <<aPos<<endl;
1921 // TCollection_ExtendedString aValue = aString.Split(aPos);
1922 // cout << "Value = |"<<aValue<<endl;
1923 // cout << "aKey = " << aString << "|"<<endl;
1925 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
1926 Handle(TDataStd_NamedData) anAtt;
1927 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1928 anAtt = TDataStd_NamedData::Set(aLabel);
1929 if(anAtt.IsNull()) {
1930 di << "NamedData attribute is not found or not set" << "\n";
1934 for(Standard_Integer i = 1; i<=aNumP; i++) {
1935 TCollection_ExtendedString aKey(arg[j]);
1936 Standard_Integer aVal = Draw::Atoi(arg[j+1]);
1937 anAtt->SetInteger(aKey, aVal);
1942 di << "DDataStd_SetNDataIntegers : Error" << "\n";
1947 //=======================================================================
1948 //function : GetNDIntegers(DF, entry )
1949 //=======================================================================
1950 static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di,
1951 Standard_Integer nb,
1956 Handle(TDF_Data) DF;
1957 if (!DDF::GetDF(arg[1],DF)) return 1;
1959 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
1962 Handle(TDataStd_NamedData) anAtt;
1963 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
1964 cout << "NamedData attribute is not found or not set" << endl;
1967 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
1968 const TColStd_DataMapOfStringInteger& aMap = anAtt->GetIntegersContainer();
1969 TColStd_DataMapIteratorOfDataMapOfStringInteger itr(aMap);
1970 for (; itr.More(); itr.Next()){
1971 TCollection_ExtendedString aKey(itr.Key());
1972 TCollection_AsciiString aStr(aKey,'?');
1973 Standard_Integer aValue = itr.Value();
1974 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;;
1979 di << "DDataStd_GetNDIntegers : Error" << "\n";
1983 //=======================================================================
1984 //function : GetNDInteger(DF, entry, key [drawname])
1985 //=======================================================================
1986 static Standard_Integer DDataStd_GetNDInteger (Draw_Interpretor& di,
1987 Standard_Integer nb,
1992 Handle(TDF_Data) DF;
1993 if (!DDF::GetDF(arg[1],DF)) return 1;
1995 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
1998 Handle(TDataStd_NamedData) anAtt;
1999 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2000 cout << "NamedData attribute is not found or not set" << endl;
2004 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2005 if(!anAtt->HasInteger(arg[3])) {
2006 cout << "There is no data specified by Key = "<< arg[3] << endl;
2009 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetInteger(arg[3])<<endl;
2011 Draw::Set(arg[4], anAtt->GetInteger(arg[3]));
2015 di << "DDataStd_SetNDataIntegers : Error" << "\n";
2019 //========================== REALS ======================================
2020 //=======================================================================
2021 //function : SetNDataReals (DF, entry , Num, key1, val1, ...
2022 //=======================================================================
2024 static Standard_Integer DDataStd_SetNDataReals (Draw_Interpretor& di,
2025 Standard_Integer nb,
2030 Handle(TDF_Data) DF;
2031 if (!DDF::GetDF(arg[1],DF)) return 1;
2033 DDF::AddLabel(DF, arg[2], aLabel);
2035 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2036 Handle(TDataStd_NamedData) anAtt;
2037 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2038 anAtt = TDataStd_NamedData::Set(aLabel);
2039 if(anAtt.IsNull()) {
2040 cout << "NamedData attribute is not found or not set" << endl;;
2044 for(Standard_Integer i = 1; i<=aNumP; i++) {
2045 TCollection_ExtendedString aKey(arg[j]);
2046 Standard_Real aVal = Draw::Atof(arg[j+1]);
2047 anAtt->SetReal(aKey, aVal);
2052 di << "DDataStd_SetNDataReals : Error" << "\n";
2056 //=======================================================================
2057 //function : GetNDReals(DF, entry )
2058 //=======================================================================
2059 static Standard_Integer DDataStd_GetNDReals (Draw_Interpretor& di,
2060 Standard_Integer nb,
2065 Handle(TDF_Data) DF;
2066 if (!DDF::GetDF(arg[1],DF)) return 1;
2068 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2071 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2072 Handle(TDataStd_NamedData) anAtt;
2073 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2074 cout << "NamedData attribute is not found or not set" << endl;
2077 const TDataStd_DataMapOfStringReal& aMap = anAtt->GetRealsContainer();
2078 TDataStd_DataMapIteratorOfDataMapOfStringReal itr(aMap);
2079 for (; itr.More(); itr.Next()){
2080 TCollection_ExtendedString aKey(itr.Key());
2081 TCollection_AsciiString aStr(aKey,'?');
2082 Standard_Real aValue = itr.Value();
2083 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;
2087 di << "DDataStd_GetNDReals : Error" << "\n";
2091 //=======================================================================
2092 //function : GetNDReal(DF, entry, key [drawname])
2093 //=======================================================================
2094 static Standard_Integer DDataStd_GetNDReal (Draw_Interpretor& di,
2095 Standard_Integer nb,
2100 Handle(TDF_Data) DF;
2101 if (!DDF::GetDF(arg[1],DF)) return 1;
2103 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2106 Handle(TDataStd_NamedData) anAtt;
2107 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2108 cout << "NamedData attribute is not found or not set" << endl;
2112 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2113 if(!anAtt->HasReal(arg[3])) {
2114 cout << "There is no data specified by Key = "<< arg[3] << endl;
2117 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetReal(arg[3])<<endl;
2119 Draw::Set(arg[4], anAtt->GetReal(arg[3]));
2123 di << "DDataStd_GetNDReal : Error" << "\n";
2127 //======================= Strings =======================================
2128 //=======================================================================
2129 //function : SetNDataStrings (DF, entry , Num, key1, val1, ...
2130 //=======================================================================
2132 static Standard_Integer DDataStd_SetNDataStrings (Draw_Interpretor& di,
2133 Standard_Integer nb,
2138 Handle(TDF_Data) DF;
2139 if (!DDF::GetDF(arg[1],DF)) return 1;
2141 DDF::AddLabel(DF, arg[2], aLabel);
2143 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2144 Handle(TDataStd_NamedData) anAtt;
2145 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2146 anAtt = TDataStd_NamedData::Set(aLabel);
2147 if(anAtt.IsNull()) {
2148 di << "NamedData attribute is not found or not set" << "\n";
2152 for(Standard_Integer i = 1; i<=aNumP; i++) {
2153 TCollection_ExtendedString aKey(arg[j]);
2154 TCollection_ExtendedString aVal(arg[j+1]);
2155 anAtt->SetString(aKey, aVal);
2160 di << "DDataStd_SetNDataStrings : Error" << "\n";
2164 //=======================================================================
2165 //function : GetNDStrings(DF, entry )
2166 //=======================================================================
2167 static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di,
2168 Standard_Integer nb,
2173 Handle(TDF_Data) DF;
2174 if (!DDF::GetDF(arg[1],DF)) return 1;
2176 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2179 Handle(TDataStd_NamedData) anAtt;
2180 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2181 cout << "NamedData attribute is not found or not set" << endl;
2184 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2185 const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer();
2186 TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap);
2187 for (; itr.More(); itr.Next()){
2188 TCollection_ExtendedString aKey(itr.Key());
2189 TCollection_AsciiString aStr(aKey,'?');
2190 TCollection_ExtendedString aVal(itr.Value());
2191 TCollection_AsciiString aStrValue(aVal,'?');
2192 cout << "Key = " << aStr.ToCString() << " Value = " <<aStrValue.ToCString()<< endl;
2196 di << "DDataStd_GetNDStrings : Error" << "\n";
2200 //=======================================================================
2201 //function : GetNDString(DF, entry, key [drawname])
2202 //=======================================================================
2203 static Standard_Integer DDataStd_GetNDString (Draw_Interpretor& di,
2204 Standard_Integer nb,
2209 Handle(TDF_Data) DF;
2210 if (!DDF::GetDF(arg[1],DF)) return 1;
2212 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2215 Handle(TDataStd_NamedData) anAtt;
2216 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2217 di << "NamedData attribute is not found or not set" << "\n";
2221 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2222 if(!anAtt->HasString(arg[3])) {
2223 cout << "There is no data specified by Key = "<< arg[3] << endl;
2226 TCollection_AsciiString aValue (anAtt->GetString(arg[3]), '?');
2227 cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << endl;
2229 Draw::Set(arg[4], aValue.ToCString());
2233 di << "DDataStd_GetNDString : Error" << "\n";
2237 //=========================== Bytes =====================================
2238 //=======================================================================
2239 //function : SetNDataBytes (DF, entry , Num, key1, val1, ...
2240 //=======================================================================
2242 static Standard_Integer DDataStd_SetNDataBytes (Draw_Interpretor& di,
2243 Standard_Integer nb,
2248 Handle(TDF_Data) DF;
2249 if (!DDF::GetDF(arg[1],DF)) return 1;
2251 DDF::AddLabel(DF, arg[2], aLabel);
2253 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2254 Handle(TDataStd_NamedData) anAtt;
2255 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2256 anAtt = TDataStd_NamedData::Set(aLabel);
2257 if(anAtt.IsNull()) {
2258 cout << "NamedData attribute is not found or not set" << endl;
2262 for(Standard_Integer i = 1; i<=aNumP; i++) {
2263 TCollection_ExtendedString aKey(arg[j]);
2264 Standard_Byte aVal = (Standard_Byte)Draw::Atoi(arg[j+1]);
2265 anAtt->SetByte(aKey, aVal);
2270 di << "DDataStd_SetNDataBytes : Error" << "\n";
2274 //=======================================================================
2275 //function : GetNDBytes(DF, entry )
2276 //=======================================================================
2277 static Standard_Integer DDataStd_GetNDBytes (Draw_Interpretor& di,
2278 Standard_Integer nb,
2283 Handle(TDF_Data) DF;
2284 if (!DDF::GetDF(arg[1],DF)) return 1;
2286 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2289 Handle(TDataStd_NamedData) anAtt;
2290 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2291 cout << "NamedData attribute is not found or not set" << endl;
2294 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2295 const TDataStd_DataMapOfStringByte& aMap = anAtt->GetBytesContainer();
2296 TDataStd_DataMapIteratorOfDataMapOfStringByte itr(aMap);
2297 for (; itr.More(); itr.Next()){
2298 TCollection_ExtendedString aKey(itr.Key());
2299 TCollection_AsciiString aStr(aKey,'?');
2300 Standard_Byte aValue = itr.Value();
2301 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;
2305 di << "DDataStd_GetNDBytes : Error" << "\n";
2309 //=======================================================================
2310 //function : GetNDByte(DF, entry, key [drawname])
2311 //=======================================================================
2312 static Standard_Integer DDataStd_GetNDByte (Draw_Interpretor& di,
2313 Standard_Integer nb,
2318 Handle(TDF_Data) DF;
2319 if (!DDF::GetDF(arg[1],DF)) return 1;
2321 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2324 Handle(TDataStd_NamedData) anAtt;
2325 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2326 cout << "NamedData attribute is not found or not set" << endl;
2330 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2331 if(!anAtt->HasByte(arg[3])) {
2332 cout << "There is no data specified by Key = "<< arg[3] << endl;
2335 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetByte(arg[3])<< endl;
2337 Draw::Set(arg[4], anAtt->GetByte(arg[3]));
2341 di << "DDataStd_GetNDByte : Error" << "\n";
2344 //======================== IntArrays ====================================
2345 //=======================================================================
2346 //function : SetNDataIntArrays (DF, entry , key, NumOfArElem, val1, val2,... )
2347 //=======================================================================
2349 static Standard_Integer DDataStd_SetNDataIntAr (Draw_Interpretor& di,
2350 Standard_Integer nb,
2355 Handle(TDF_Data) DF;
2356 if (!DDF::GetDF(arg[1],DF)) return 1;
2358 DDF::AddLabel(DF, arg[2], aLabel);
2361 TCollection_ExtendedString aKey(arg[3]);
2362 Standard_Integer aNum = Draw::Atoi(arg[4]);
2363 if (aNum <= 0) return 1;
2364 Handle(TDataStd_NamedData) anAtt;
2365 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2366 anAtt = TDataStd_NamedData::Set(aLabel);
2367 if(anAtt.IsNull()) {
2368 cout<< "NamedData attribute is not found or not set" << endl;
2372 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
2373 for(Standard_Integer i = 1; i<=aNum; i++) {
2374 Standard_Integer aVal = Draw::Atoi(arg[j]);
2375 anArr->SetValue(i, aVal);
2378 anAtt->SetArrayOfIntegers(aKey, anArr);
2381 di << "DDataStd_SetNDataIntArrays : Error" << "\n";
2386 //=======================================================================
2387 //function : GetNDIntArrays(DF, entry )
2388 //=======================================================================
2389 static Standard_Integer DDataStd_GetNDIntArrays (Draw_Interpretor& di,
2390 Standard_Integer nb,
2395 Handle(TDF_Data) DF;
2396 if (!DDF::GetDF(arg[1],DF)) return 1;
2398 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2401 Handle(TDataStd_NamedData) anAtt;
2402 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2403 cout << "NamedData attribute is not found or not set" << endl;
2406 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2407 const TDataStd_DataMapOfStringHArray1OfInteger& aMap = anAtt->GetArraysOfIntegersContainer();
2408 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger itr(aMap);
2409 for (; itr.More(); itr.Next()){
2410 TCollection_ExtendedString aKey(itr.Key());
2411 TCollection_AsciiString aStr(aKey,'?');
2412 cout << "Key = " << aStr.ToCString()<< endl;
2413 Handle(TColStd_HArray1OfInteger) anArrValue = itr.Value();
2414 if(!anArrValue.IsNull()) {
2415 Standard_Integer lower = anArrValue->Lower();
2416 Standard_Integer upper = anArrValue->Upper();
2417 for(Standard_Integer i = lower; i<=upper;i++) {
2418 Standard_Integer aValue = anArrValue->Value(i);
2419 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2422 cout << "\tthe specified array is Null "<<endl;
2426 di << "DDataStd_GetNDIntArrays : Error" << "\n";
2430 //=======================================================================
2431 //function : GetNDIntArray(DF, entry, key )
2432 //=======================================================================
2433 static Standard_Integer DDataStd_GetNDIntArray (Draw_Interpretor& di,
2434 Standard_Integer nb,
2439 Handle(TDF_Data) DF;
2440 if (!DDF::GetDF(arg[1],DF)) return 1;
2442 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2445 Handle(TDataStd_NamedData) anAtt;
2446 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2447 cout << "NamedData attribute is not found or not set" << endl;
2451 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2452 if(!anAtt->HasArrayOfIntegers(arg[3])) {
2453 cout << "There is no data specified by Key = "<< arg[3] << endl;
2456 cout << "Key = " << arg[3] <<endl;
2458 Handle(TColStd_HArray1OfInteger) anArrValue = anAtt->GetArrayOfIntegers(arg[3]);
2459 if(!anArrValue.IsNull()) {
2460 Standard_Integer lower = anArrValue->Lower();
2461 Standard_Integer upper = anArrValue->Upper();
2462 for(Standard_Integer i = lower; i<=upper;i++) {
2463 Standard_Integer aValue = anArrValue->Value(i);
2464 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2467 cout << "\tthe specified array is Null or not found"<<endl;
2471 di << "DDataStd_SetNDataIntArray : Error" << "\n";
2474 //============================= RealArrays ==============================
2475 //=======================================================================
2476 //function : SetNDataRealArrays (DF entry key NumOfArElem val1 val2... )
2477 //=======================================================================
2479 static Standard_Integer DDataStd_SetNDataRealAr (Draw_Interpretor& di,
2480 Standard_Integer nb,
2485 Handle(TDF_Data) DF;
2486 if (!DDF::GetDF(arg[1],DF)) return 1;
2488 DDF::AddLabel(DF, arg[2], aLabel);
2491 TCollection_ExtendedString aKey(arg[3]);
2492 Standard_Integer aNum = Draw::Atoi(arg[4]);
2493 if (aNum <= 0) return 1;
2494 Handle(TDataStd_NamedData) anAtt;
2495 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2496 anAtt = TDataStd_NamedData::Set(aLabel);
2497 if(anAtt.IsNull()) {
2498 cout << "NamedData attribute is not found or not set" << endl;
2502 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1, aNum);
2503 for(Standard_Integer i = 1; i<=aNum; i++) {
2504 Standard_Real aVal = Draw::Atof(arg[j]);
2505 anArr->SetValue(i, aVal);
2508 anAtt->SetArrayOfReals(aKey, anArr);
2511 di << "DDataStd_SetNDataRealArrays : Error" << "\n";
2516 //=======================================================================
2517 //function : GetNDRealArrays(DF, entry )
2518 //=======================================================================
2519 static Standard_Integer DDataStd_GetNDRealArrays (Draw_Interpretor& di,
2520 Standard_Integer nb,
2525 Handle(TDF_Data) DF;
2526 if (!DDF::GetDF(arg[1],DF)) return 1;
2528 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2531 Handle(TDataStd_NamedData) anAtt;
2532 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2533 cout << "NamedData attribute is not found or not set" << endl;
2536 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2537 const TDataStd_DataMapOfStringHArray1OfReal& aMap = anAtt->GetArraysOfRealsContainer();
2538 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal itr(aMap);
2539 for (; itr.More(); itr.Next()){
2540 TCollection_ExtendedString aKey(itr.Key());
2541 TCollection_AsciiString aStr(aKey,'?');
2542 cout << "Key = " << aStr.ToCString()<<endl;
2543 Handle(TColStd_HArray1OfReal) anArrValue = itr.Value();
2544 if(!anArrValue.IsNull()) {
2545 Standard_Integer lower = anArrValue->Lower();
2546 Standard_Integer upper = anArrValue->Upper();
2547 for(Standard_Integer i = lower; i<=upper;i++) {
2548 Standard_Real aValue = anArrValue->Value(i);
2549 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2552 cout << "\tthe specified array is Null "<<endl;
2556 di << "DDataStd_GetNDRealArrays : Error" << "\n";
2560 //=======================================================================
2561 //function : GetNDRealArray(DF, entry, key )
2562 //=======================================================================
2563 static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
2564 Standard_Integer nb,
2569 Handle(TDF_Data) DF;
2570 if (!DDF::GetDF(arg[1],DF)) return 1;
2572 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2575 Handle(TDataStd_NamedData) anAtt;
2576 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2577 di << "NamedData attribute is not found or not set" << "\n";
2581 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2582 if(!anAtt->HasArrayOfReals(arg[3])) {
2583 cout << "There is no data specified by Key = "<< arg[3] << endl;
2586 cout << "Key = " << arg[3] <<endl;
2588 Handle(TColStd_HArray1OfReal) anArrValue = anAtt->GetArrayOfReals(arg[3]);
2589 if(!anArrValue.IsNull()) {
2590 Standard_Integer lower = anArrValue->Lower();
2591 Standard_Integer upper = anArrValue->Upper();
2592 for(Standard_Integer i = lower; i<=upper;i++) {
2593 Standard_Real aValue = anArrValue->Value(i);
2594 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2597 cout << "\tthe specified array is Null or not found"<<endl;
2601 di << "DDataStd_SetNDataRealArray : Error" << "\n";
2605 //=======================================================================
2606 //function : BasicCommands
2608 //=======================================================================
2610 void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
2613 static Standard_Boolean done = Standard_False;
2615 done = Standard_True;
2617 const char* g = "DData : Standard Attribute Commands";
2622 theCommands.Add ("SetInteger",
2623 "SetInteger (DF, entry, value)",
2624 __FILE__, DDataStd_SetInteger, g);
2626 theCommands.Add ("SetIntArray",
2627 "SetIntArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2628 __FILE__, DDataStd_SetIntArray, g);
2630 theCommands.Add ("SetReal",
2631 "SetReal (DF, entry, value)",
2632 __FILE__, DDataStd_SetReal, g);
2634 theCommands.Add ("SetRealArray",
2635 "SetRealArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2636 __FILE__, DDataStd_SetRealArray, g);
2638 theCommands.Add ("SetByteArray",
2639 "SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2640 __FILE__, DDataStd_SetByteArray, g);
2642 theCommands.Add ("SetExtStringArray",
2643 "SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2644 __FILE__, DDataStd_SetExtStringArray, g);
2646 theCommands.Add ("SetIntPackedMap",
2647 "SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
2648 __FILE__, DDataStd_SetIntPackedMap, g);
2650 theCommands.Add ("SetReference",
2651 "SetReference (DF, entry, reference)",
2652 __FILE__, DDataStd_SetReference, g);
2654 theCommands.Add ("SetComment",
2655 "SetComment (DF, entry, comment)",
2656 __FILE__, DDataStd_SetComment, g);
2658 theCommands.Add ("SetUAttribute",
2659 "SetUAttribute (DF, entry, LocalID)",
2660 __FILE__, DDataStd_SetUAttribute, g);
2662 theCommands.Add ("SetVariable",
2663 "SetVariable (DF, entry, isConstant[0/1], units)",
2664 __FILE__, DDataStd_SetVariable, g);
2666 theCommands.Add ("SetAsciiString",
2667 "SetAsciiString (DF, entry, String )",
2668 __FILE__, DDataStd_SetAsciiString, g);
2670 theCommands.Add ("SetBooleanArray",
2671 "SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2672 __FILE__, DDataStd_SetBooleanArray, g);
2674 theCommands.Add ("SetBooleanList",
2675 "SetBooleanList (DF, entry, elmt1, elmt2, ... )",
2676 __FILE__, DDataStd_SetBooleanList, g);
2678 theCommands.Add ("SetIntegerList",
2679 "SetIntegerList (DF, entry, elmt1, elmt2, ... )",
2680 __FILE__, DDataStd_SetIntegerList, g);
2682 theCommands.Add ("SetRealList",
2683 "SetRealList (DF, entry, elmt1, elmt2, ... )",
2684 __FILE__, DDataStd_SetRealList, g);
2689 theCommands.Add ("GetAsciiString",
2690 "GetAsciiString (DF, entry )",
2691 __FILE__, DDataStd_GetAsciiString, g);
2693 theCommands.Add ("GetInteger",
2694 "GetInteger (DF, entry, [drawname])",
2695 __FILE__, DDataStd_GetInteger, g);
2697 theCommands.Add ("GetIntArray",
2698 "GetIntArray (DF, entry )",
2699 __FILE__, DDataStd_GetIntArray, g);
2701 theCommands.Add ("GetRealArray",
2702 "GetRealArray (DF, entry )",
2703 __FILE__, DDataStd_GetRealArray, g);
2705 theCommands.Add ("GetByteArray",
2706 "GetByteArray (DF, entry )",
2707 __FILE__, DDataStd_GetByteArray, g);
2709 theCommands.Add ("GetExtStringArray",
2710 "GetExtStringArray (DF, entry )",
2711 __FILE__, DDataStd_GetExtStringArray, g);
2713 theCommands.Add ("GetIntPackedMap",
2714 "GetIntPackedMap (DF, entry )",
2715 __FILE__, DDataStd_GetIntPackedMap, g);
2717 theCommands.Add ("GetReal",
2718 "GetReal (DF, entry, [drawname])",
2719 __FILE__, DDataStd_GetReal, g);
2721 theCommands.Add ("GetReference",
2722 "GetReference (DF, entry)",
2723 __FILE__, DDataStd_GetReference, g);
2726 theCommands.Add ("GetComment",
2727 "GetComment (DF, entry)",
2728 __FILE__, DDataStd_GetComment, g);
2730 theCommands.Add("Self",
2731 "Self(document, entry)",
2732 __FILE__, DDataStd_Self, g);
2734 theCommands.Add ("GetUAttribute",
2735 "GetUAttribute (DF, entry)",
2736 __FILE__, DDataStd_GetUAttribute, g);
2738 theCommands.Add ("GetVariable",
2739 "GetVariable (DF, entry, [isConstant], [units])",
2740 __FILE__, DDataStd_GetVariable, g);
2742 theCommands.Add ("SetRelation",
2743 "SetRelation (DF, entry, expression, var1[, var2, ...])",
2744 __FILE__, DDataStd_SetRelation, g);
2746 theCommands.Add ("DumpRelation",
2747 "DumpRelation (DF, entry)",
2748 __FILE__, DDataStd_DumpRelation, g);
2750 theCommands.Add ("GetBooleanArray",
2751 "GetBooleanArray (DF, entry )",
2752 __FILE__, DDataStd_GetBooleanArray, g);
2754 theCommands.Add ("GetBooleanList",
2755 "GetBooleanList (DF, entry )",
2756 __FILE__, DDataStd_GetBooleanList, g);
2758 theCommands.Add ("GetIntegerList",
2759 "GetIntegerList (DF, entry )",
2760 __FILE__, DDataStd_GetIntegerList, g);
2762 theCommands.Add ("GetRealList",
2763 "GetRealList (DF, entry )",
2764 __FILE__, DDataStd_GetRealList, g);
2768 // ========================= UTF =====================================
2769 const char* ggg = "UTF Commands";
2771 theCommands.Add ("SetUTFName",
2772 "SetUTFName (DF, entry, fileName)",
2773 __FILE__, DDataStd_KeepUTF, ggg);
2775 theCommands.Add ("GetUTF",
2776 "GetUTF (DF, entry, fileName)",
2777 __FILE__, DDataStd_GetUTFtoFile, ggg);
2779 //======================= NData Commands ========================
2781 const char* gN = "NData Commands";
2782 theCommands.Add ("SetNDataIntegers",
2783 "SetNDataIntegers (DF, entry, NumPairs, key1, val1, ... )",
2784 __FILE__, DDataStd_SetNDataIntegers, gN);
2786 theCommands.Add ("SetNDataReals",
2787 "SetNDataReals (DF, entry, NumPairs, key1, val1, ... )",
2788 __FILE__, DDataStd_SetNDataReals, gN);
2790 theCommands.Add ("SetNDataStrings",
2791 "SetNDataStrings (DF, entry, NumPairs, key1, val1, ... )",
2792 __FILE__, DDataStd_SetNDataStrings, gN);
2794 theCommands.Add ("SetNDataBytes",
2795 "SetNDataBytes (DF, entry, NumPairs, key1, val1, ... )",
2796 __FILE__, DDataStd_SetNDataBytes, gN);
2798 theCommands.Add ("SetNDataIntArrays",
2799 "SetNDataIntArrays (DF entry entry key NumOfArrElems val1 val2... )",
2800 __FILE__, DDataStd_SetNDataIntAr, gN);
2802 theCommands.Add ("SetNDataRealArrays",
2803 "SetNDataRealArrays (DF entry key NumOfArrElems val1 val2... )",
2804 __FILE__, DDataStd_SetNDataRealAr, gN);
2808 theCommands.Add ("GetNDIntegers",
2809 "GetNDIntegers (DF, entry )",
2810 __FILE__, DDataStd_GetNDIntegers, g);
2812 theCommands.Add ("GetNDInteger",
2813 "GetNDInteger (DF entry key [drawname])",
2814 __FILE__, DDataStd_GetNDInteger, g);
2816 theCommands.Add ("GetNDReals",
2817 "GetNDReals (DF entry )",
2818 __FILE__, DDataStd_GetNDReals, g);
2820 theCommands.Add ("GetNDReal",
2821 "GetNDReal (DF entry key [drawname])",
2822 __FILE__, DDataStd_GetNDReal, g);
2824 theCommands.Add ("GetNDStrings",
2825 "GetNDStrings (DF entry )",
2826 __FILE__, DDataStd_GetNDStrings, g);
2828 theCommands.Add ("GetNDString",
2829 "GetNDString (DF entry key [drawname])",
2830 __FILE__, DDataStd_GetNDString, g);
2832 theCommands.Add ("GetNDBytes",
2833 "GetNDBytes (DF entry )",
2834 __FILE__, DDataStd_GetNDBytes, g);
2836 theCommands.Add ("GetNDByte",
2837 "GetNDByte (DF entry key [drawname])",
2838 __FILE__, DDataStd_GetNDByte, g);
2840 theCommands.Add ("GetNDIntArrays",
2841 "GetNDIntArrays (DF, entry )",
2842 __FILE__, DDataStd_GetNDIntArrays, g);
2844 theCommands.Add ("GetNDIntArray",
2845 "GetNDIntArray (DF entry key )",
2846 __FILE__, DDataStd_GetNDIntArray, g);
2848 theCommands.Add ("GetNDRealArrays",
2849 "GetNDRealArrays (DF entry )",
2850 __FILE__, DDataStd_GetNDRealArrays, g);
2852 theCommands.Add ("GetNDRealArray",
2853 "GetNDRealArray (DF entry key )",
2854 __FILE__, DDataStd_GetNDRealArray, g);
2856 //====================== Change =======================
2857 theCommands.Add ("ChangeByteArray",
2858 "ChangeByteArray (DF, entry, indx, value )",
2859 __FILE__, DDataStd_ChangeByteArray, g);
2861 theCommands.Add ("ChangeIntArray",
2862 "ChangeIntArray (DF, entry, indx, value )",
2863 __FILE__, DDataStd_ChangeIntArray, g);
2865 theCommands.Add ("ChangeRealArray",
2866 "ChangeRealArray (DF, entry, indx, value )",
2867 __FILE__, DDataStd_ChangeRealArray, g);
2869 theCommands.Add ("ChangeExtStrArray",
2870 "ChangeExtStrArray (DF, entry, indx, value )",
2871 __FILE__, DDataStd_ChangeExtStrArray, g);
2873 theCommands.Add ("ChangeIntPackedMap_Add",
2874 "ChangeIntPackedMAp_Add (DF, entry, key[,key [...]] )",
2875 __FILE__, DDataStd_ChangeIntPackedMap_Add, g);
2877 theCommands.Add ("ChangeIntPackedMap_Rem",
2878 "ChangeIntPackedMAp_Rem (DF, entry, key[,key [...]] )",
2879 __FILE__, DDataStd_ChangeIntPackedMap_Rem, g);
2881 theCommands.Add ("ChangeIntPackedMap_AddRem",
2882 "ChangeIntPackedMAp_AddRem (DF, entry, key[,key [...]] )",
2883 __FILE__, DDataStd_ChangeIntPackedMap_AddRem, g);
2885 //=========================================================
2886 // TFunction commands
2887 const char* gg = "DFunction Commands";
2889 theCommands.Add ("SetFunction",
2890 "SetFunction (DF, entry, guid, failure)",
2891 __FILE__, DDataStd_SetFunction, gg);
2893 theCommands.Add ("GetFunction",
2894 "GetFunction (DF, entry, guid(out), failure(out))",
2895 __FILE__, DDataStd_GetFunction, gg);
2897 //=========================================================
2900 //======================================================================
2901 //======= for internal use
2903 theCommands.Add ("SetNDataIntegers2",
2904 "SetNDataIntegers2 (DF, entry, NumPair )",
2905 __FILE__, DDataStd_SetNDataIntegers2, gN);
2907 theCommands.Add ("SetNDataIntArrays2",
2908 "SetNDataIntArrays2 (DF entry entry key NumOfArrElems)",
2909 __FILE__, DDataStd_SetNDataIntAr2, gN);
2911 theCommands.Add ("SetIntArrayT",
2912 "SetIntArrayT (DF, entry, isDelta, From, To )",
2913 __FILE__, DDataStd_SetIntArrayTest, g);
2915 theCommands.Add ("SetIntPHugeMap",
2916 "SetIntPHugeMap (DF, entry, isDelta Num)",
2917 __FILE__, DDataStd_SetIntPHugeMap, g);