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 //=======================================================================
103 //function : DDataStd_SetInteger
104 //purpose : SetInteger (DF, entry, value)
105 //=======================================================================
107 static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di,
113 if (!DDF::GetDF(arg[1],DF)) return 1;
115 DDF::AddLabel(DF, arg[2], L);
116 TDataStd_Integer::Set(L,Draw::Atoi(arg[3]));
119 di << "DDataStd_SetInteger : Error" << "\n";
123 //=======================================================================
124 //function : DDataStd_SetReal
125 //purpose : SetReal (DF, entry, value)
126 //=======================================================================
128 static Standard_Integer DDataStd_SetReal (Draw_Interpretor& di,
134 if (!DDF::GetDF(arg[1],DF)) return 1;
136 DDF::AddLabel(DF, arg[2], L);
137 TDataStd_Real::Set(L,Draw::Atof(arg[3]));
140 di << "DDataStd_SetReal : Error" << "\n";
146 //=======================================================================
147 //function : DDataStd_SetReference
148 //purpose : SetReference (DF, entry, reference)
149 //=======================================================================
151 static Standard_Integer DDataStd_SetReference (Draw_Interpretor& di,
157 if (!DDF::GetDF(arg[1],DF)) return 1;
159 DDF::AddLabel(DF, arg[2], L);
161 if (!DDF::FindLabel(DF,arg[3],LREF)) return 1;
162 TDF_Reference::Set(L,LREF);
165 di << "DDataStd_SetReference : Error" << "\n";
170 //=======================================================================
171 //function : DDataStd_SetComment
172 //purpose : SetComment (DF, entry, Comment)
173 //=======================================================================
175 static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di,
181 if (!DDF::GetDF(arg[1],DF)) return 1;
183 DDF::AddLabel(DF, arg[2], L);
184 TDataStd_Comment::Set(L,arg[3]);
187 di << "DDataStd_SetComment : Error" << "\n";
193 //=======================================================================
194 //function : DDataStd_GetInteger
195 //purpose : GetReal (DF, entry, [drawname])
196 //=======================================================================
198 static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
202 if (nb == 3 || nb == 4) {
204 if (!DDF::GetDF(arg[1],DF)) return 1;
205 Handle(TDataStd_Integer) A;
206 if (!DDF::Find(DF,arg[2],TDataStd_Integer::GetID(),A)) return 1;
207 if (nb == 4) Draw::Set(arg[3],A->Get());
208 else Draw::Set(arg[2],A->Get());
212 di << "DDataStd_GetInteger : Error" << "\n";
216 //=======================================================================
217 //function : DDataStd_GetReal
218 //purpose : GetReal (DF, entry, [drawname])
219 //=======================================================================
221 static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di,
225 if (nb == 3 || nb == 4) {
227 if (!DDF::GetDF(arg[1],DF)) return 1;
228 Handle(TDataStd_Real) A;
229 if (!DDF::Find(DF,arg[2],TDataStd_Real::GetID(),A)) return 1;
230 if (nb == 4) Draw::Set(arg[3],A->Get());
231 else Draw::Set(arg[2],A->Get());
235 di << "DDataStd_GetReal : Error" << "\n";
240 //=======================================================================
241 //function : DDataStd_GetReference
242 //purpose : GetShape (DF, entry)
243 //=======================================================================
245 static Standard_Integer DDataStd_GetReference (Draw_Interpretor& di,
251 if (!DDF::GetDF(arg[1],DF)) return 1;
252 Handle(TDF_Reference) REF;
253 if (!DDF::Find(DF,arg[2],TDF_Reference::GetID(),REF)) return 1;
254 TCollection_AsciiString entry; TDF_Tool::Entry(REF->Get(),entry);
255 di << entry.ToCString();
258 di << "DDataStd_GetReference : Error" << "\n";
262 //=======================================================================
263 //function : DDataStd_GetComment
264 //purpose : GetShape (DF, entry)
265 //=======================================================================
267 static Standard_Integer DDataStd_GetComment (Draw_Interpretor& di,
273 if (!DDF::GetDF(arg[1],DF)) return 1;
274 Handle(TDataStd_Comment) A;
275 if (!DDF::Find(DF,arg[2],TDataStd_Comment::GetID(),A)) return 1;
276 TCollection_AsciiString s(A->Get(),'?');
280 di << "DDataStd_GetComment : Error" << "\n";
286 //=======================================================================
288 //purpose : Self (document,label)
289 //=======================================================================
291 static Standard_Integer DDataStd_Self (Draw_Interpretor& di,
295 TCollection_AsciiString s;
298 if (!DDF::GetDF(arg[1],DF)) return 1;
300 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
301 // TDataStd::MakeSelfContained(L,removed);
302 // if (removed.IsEmpty()) cout << "noone attriburte removed" << endl;
303 // for (TDF_ListIteratorOfAttributeList it(removed);it.More();it.Next()) {
304 // TDF_Tool::Entry(it.Value()->Label(),s); cout << s << " ";
309 di << "Self : Error" << "\n";
315 //=======================================================================
316 //function : SetUObject (DF, entry, ObjectID)
317 //=======================================================================
318 // static Standard_Integer DDataStd_SetUObject (Draw_Interpretor&,
319 // Standard_Integer nb,
323 // Handle(TDF_Data) DF;
324 // if (!DDF::GetDF(arg[1],DF)) return 1;
326 // DDF::AddLabel(DF, arg[2], label);
328 // Standard_GUID guid(arg[3]); //"00000000-0000-0000-1111-000000000000");
329 // TDataStd_UObject::Set(label, guid);
333 // cout << "Wrong arguments" << endl;
337 //=======================================================================
338 //function : SetUAttribute (DF, entry, LocalID)
339 //=======================================================================
340 static Standard_Integer DDataStd_SetUAttribute (Draw_Interpretor& di,
346 if (!DDF::GetDF(arg[1],DF)) return 1;
348 DDF::AddLabel(DF, arg[2], label);
350 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
351 TDataStd_UAttribute::Set(label, guid);
355 di << "Wrong arguments" << "\n";
359 //=======================================================================
360 //function : GetUAttribute (DF, entry, LoaclID)
361 //=======================================================================
362 static Standard_Integer DDataStd_GetUAttribute (Draw_Interpretor& di,
368 if (!DDF::GetDF(arg[1],DF)) return 1;
370 if( !DDF::FindLabel(DF, arg[2], label) ) {
371 di << "No label for entry" << "\n";
374 Standard_GUID guid(arg[3]); //"00000000-0000-0000-2222-000000000000");
376 Handle(TDataStd_UAttribute) UA;
377 if( !label.FindAttribute(guid, UA) ) {
378 di << "No UAttribute Attribute on label" << "\n";
381 // UA->ID().ShallowDump(cout);
383 char *aStrGUID = new char[37];
384 UA->ID().ToCString(aStrGUID);
390 di << "Wrong arguments" << "\n";
395 //=======================================================================
396 //function : CheckUObject (DF, entry, ObjectID)
397 //=======================================================================
398 // static Standard_Integer DDataStd_CheckUObject (Draw_Interpretor&,
399 // Standard_Integer nb,
403 // Handle(TDF_Data) DF;
404 // if (!DDF::GetDF(arg[1],DF)) return 1;
406 // if( !DDF::FindLabel(DF, arg[2], label) ) {
407 // cout << "No label for entry" << endl;
410 // Handle(TDataStd_Object) O;
411 // Handle(TDataStd_UObject) UO;
412 // Standard_GUID guidUO(arg[3]);
414 // if( !label.FindAttribute( TDataStd_Object::GetID(), O) ) {
415 // cout << "No Object Attribute on label" << endl;
418 // cout << "UObject is found with ObjectID = ";
419 // O->Find(label, guidUO, UO);
420 // UO->ObjectID().ShallowDump(cout);
426 // cout << "Wrong arguments" << endl;
431 //=======================================================================
432 //function : SetIntArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
433 //=======================================================================
434 static Standard_Integer DDataStd_SetIntArray (Draw_Interpretor& di,
441 if (!DDF::GetDF(arg[1],DF)) return 1;
443 DDF::AddLabel(DF, arg[2], label);
444 Standard_Integer isDelta = Draw::Atoi(arg[3]);
445 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
446 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
447 Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
450 for(Standard_Integer i = From; i<=To; i++) {
451 A->SetValue(i, Draw::Atoi(arg[j]) );
458 //=======================================================================
459 //function : GetIntArray (DF, entry )
460 //=======================================================================
461 static Standard_Integer DDataStd_GetIntArray (Draw_Interpretor& di,
468 if (!DDF::GetDF(arg[1],DF)) return 1;
470 if( !DDF::FindLabel(DF, arg[2], label) ) {
471 di << "No label for entry" << "\n";
475 Handle(TDataStd_IntegerArray) A;
476 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
477 di << "There is no TDataStd_IntegerArray under label" << "\n";
481 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
482 //cout << A->Value(i) << endl;
491 //=======================================================================
492 //function : ChangeIntArray (DF, entry, indx, val )
493 //=======================================================================
494 static Standard_Integer DDataStd_ChangeIntArray (Draw_Interpretor& di,
501 if (!DDF::GetDF(arg[1],DF)) return 1;
503 if( !DDF::FindLabel(DF, arg[2], label) ) {
504 di << "No label for entry" << "\n";
508 Handle(TDataStd_IntegerArray) A;
509 if ( !label.FindAttribute(TDataStd_IntegerArray::GetID(), A) ) {
510 di << "There is no TDataStd_IntegerArray at label" << "\n";
513 Standard_Integer indx = Draw::Atoi(arg[3]);
514 Standard_Integer val = Draw::Atoi(arg[4]);
515 Standard_Integer low = A->Lower(), up = A->Upper();
516 if(low <= indx && indx <= up)
517 A->SetValue(indx, val);
519 Handle(TColStd_HArray1OfInteger) Arr = A->Array();
520 Handle(TColStd_HArray1OfInteger) arr;
524 arr = new TColStd_HArray1OfInteger(low, up);
525 for(i=low; i<= Arr->Upper(); i++)
526 arr->SetValue(i, Arr->Value(i));
527 for(i=Arr->Upper()+1; i<= up; i++) {
529 arr->SetValue(i, val);
533 } else if(indx < up) {//clip array : indx to be negative
535 arr = new TColStd_HArray1OfInteger(low, up);
536 for(i=low; i< up; i++)
537 arr->SetValue(i, Arr->Value(i));
538 arr->SetValue(up, val);
544 di << "DDataStd_ChangeIntArray: Error" << "\n";
548 //=======================================================================
549 //function : SetIntArrayT (DF, entry , isDelta, From, To) - for testing
551 //=======================================================================
552 static Standard_Integer DDataStd_SetIntArrayTest (Draw_Interpretor& di,
559 if (!DDF::GetDF(arg[1],DF)) return 1;
561 DDF::AddLabel(DF, arg[2], label);
562 Standard_Integer isDelta = Draw::Atoi(arg[3]);
563 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
564 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
565 Handle(TDataStd_IntegerArray) A = TDataStd_IntegerArray::Set(label, From, To, isDelta);
568 Standard_Integer k = 100;
569 for(Standard_Integer i = From; i<=To; i++) {
577 //=======================================================================
578 //function : SetRealArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
579 //=======================================================================
580 static Standard_Integer DDataStd_SetRealArray (Draw_Interpretor& di,
587 if (!DDF::GetDF(arg[1],DF)) return 1;
589 DDF::AddLabel(DF, arg[2], label);
590 Standard_Integer isDelta = Draw::Atoi(arg[3]);
592 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
593 di << " Array of Standard_Real with bounds from = " << From << " to = " << To << "\n";
594 Handle(TDataStd_RealArray) A = TDataStd_RealArray::Set(label, From, To, isDelta);
597 for(Standard_Integer i = From; i<=To; i++) {
598 A->SetValue(i, Draw::Atof(arg[j]) );
605 //=======================================================================
606 //function : GetRealArray (DF, entry )
607 //=======================================================================
608 static Standard_Integer DDataStd_GetRealArray (Draw_Interpretor& di,
614 if (!DDF::GetDF(arg[1],DF)) return 1;
616 if( !DDF::FindLabel(DF, arg[2], label) ) {
617 di << "No label for entry" << "\n";
621 Handle(TDataStd_RealArray) A;
622 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
623 di << "There is no TDataStd_RealArray under label" << "\n";
627 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
628 //cout << A->Value(i) << endl;
639 //=======================================================================
640 //function : ChangeRealArray (DF, entry, indx, val )
641 //=======================================================================
642 static Standard_Integer DDataStd_ChangeRealArray (Draw_Interpretor& di,
649 if (!DDF::GetDF(arg[1],DF)) return 1;
651 if( !DDF::FindLabel(DF, arg[2], label) ) {
652 di << "No label for entry" << "\n";
656 Handle(TDataStd_RealArray) A;
657 if ( !label.FindAttribute(TDataStd_RealArray::GetID(), A) ) {
658 di << "There is no TDataStd_RealArray at label" << "\n";
661 Standard_Integer indx = Draw::Atoi(arg[3]);
662 Standard_Real val = Draw::Atof(arg[4]);
663 Standard_Integer low = A->Lower(), up = A->Upper();
664 if(low <= indx && indx <= up)
665 A->SetValue(indx, val);
667 Handle(TColStd_HArray1OfReal) Arr = A->Array();
668 Handle(TColStd_HArray1OfReal) arr;
672 arr = new TColStd_HArray1OfReal(low, up);
673 for(i=low; i<= Arr->Upper(); i++)
674 arr->SetValue(i, Arr->Value(i));
675 for(i=Arr->Upper()+1; i<= up; i++) {
677 arr->SetValue(i, val);
681 } else if(indx < up) {//clip array : indx to be negative
683 arr = new TColStd_HArray1OfReal(low, up);
684 for(i=low; i< up; i++)
685 arr->SetValue(i, Arr->Value(i));
686 arr->SetValue(up, val);
692 di << "DDataStd_ChangeRealArray: Error" << "\n";
696 //=======================================================================
697 //function : SetVariable (DF, entry, isConstant[0/1], units)
698 //=======================================================================
699 static Standard_Integer DDataStd_SetVariable (Draw_Interpretor& di,
706 if (!DDF::GetDF(arg[1],DF)) return 1;
708 DDF::AddLabel(DF, arg[2], label);
710 Handle(TDataStd_Variable) aV = TDataStd_Variable::Set(label);
712 const char* aUnits = arg[4];
713 aV->Unit(Standard_CString(aUnits));
715 aV->Constant(Standard_Boolean(Draw::Atoi(arg[3])));
719 di << "Wrong arguments" << "\n";
723 //=======================================================================
724 //function : GetVariable (DF, entry, [isConstant], [units])
725 //=======================================================================
726 static Standard_Integer DDataStd_GetVariable (Draw_Interpretor& di,
733 if (!DDF::GetDF(arg[1],DF)) return 1;
735 DDF::AddLabel(DF, arg[2], label);
737 Handle(TDataStd_Variable) aV;
738 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
740 di << "TDataStd_Variable: no such attribute" << "\n";
743 Draw::Set(arg[3],TCollection_AsciiString(Standard_Integer(aV->IsConstant())).ToCString());
744 Draw::Set(arg[4],aV->Unit().ToCString());
748 di << "Wrong arguments" << "\n";
752 #include <TDataStd_Relation.hxx>
753 #include <TDataStd_Variable.hxx>
754 //=======================================================================
755 //function : SetRelation (DF, entry, expression, var1[, var2, ...])
756 //=======================================================================
757 static Standard_Integer DDataStd_SetRelation (Draw_Interpretor& di,
758 Standard_Integer nb, const char** arg)
763 if (!DDF::GetDF(arg[1],DF)) return 1;
765 DDF::AddLabel(DF, arg[2], label);
767 Standard_CString expr (arg[3]);
768 Handle(TDataStd_Relation) aR = TDataStd_Relation::Set(label);
769 aR->SetRelation(expr);
770 Handle(TDataStd_Variable) aV;
772 for (Standard_Integer i = 4; i < nb; i++)
774 if (!DDF::FindLabel(DF, arg[i], label))
776 di << "No label for entry" << arg[i] << "\n";
779 if (!label.FindAttribute(TDataStd_Variable::GetID(), aV))
781 di << "No TDataStd_Variable Attribute on label" << "\n";
784 aR->GetVariables().Append(aV);
788 di << "Usage: SetRelation (DF, entry, expression, var1[, var2, ...])" << "\n";
792 //=======================================================================
793 //function : DumpRelation (DF, entry)
794 //=======================================================================
795 static Standard_Integer DDataStd_DumpRelation (Draw_Interpretor& di,
796 Standard_Integer nb, const char** arg)
801 if (!DDF::GetDF(arg[1],DF)) return 1;
804 if (!DDF::FindLabel(DF, arg[2], label))
806 di << "No label for entry " << arg[2] << "\n";
809 Handle(TDataStd_Relation) aR;
810 if (!label.FindAttribute(TDataStd_Relation::GetID(), aR))
812 di << "No TDataStd_Relation Attribute on label " << arg[2] << "\n";
816 di << "Relation: expression = \"" << aR->GetRelation()
817 << "\" variables list = (";
819 Handle(TDF_Attribute) aV;
820 TCollection_AsciiString anEntry;
822 TDF_ListIteratorOfAttributeList it;
823 for (it.Initialize(aR->GetVariables()); it.More(); it.Next())
829 TDF_Tool::Entry(label, anEntry);
830 di << anEntry.ToCString() << " ";
836 di << "Usage: DumpRelation (DF, entry)" << "\n";
840 #include <TFunction_Function.hxx>
841 //=======================================================================
842 //function : SetFunction (DF, entry, guid, failure)
843 //=======================================================================
844 static Standard_Integer DDataStd_SetFunction (Draw_Interpretor& di,
845 Standard_Integer nb, const char** arg)
850 if (!DDF::GetDF(arg[1],DF)) return 1;
852 DDF::AddLabel(DF, arg[2], label);
854 Standard_GUID guid (arg[3]);
855 Handle(TFunction_Function) aF = TFunction_Function::Set(label, guid);
857 int fail = Draw::Atoi(arg[4]);
858 aF->SetFailure(fail);
863 di << "Wrong arguments" << "\n";
867 //=======================================================================
868 //function : GetFunction (DF, entry, guid(out), failure(out))
869 //=======================================================================
870 static Standard_Integer DDataStd_GetFunction (Draw_Interpretor& di,
871 Standard_Integer nb, const char** arg)
876 if (!DDF::GetDF(arg[1],DF)) return 1;
878 if (!DDF::FindLabel(DF, arg[2], label))
880 di << "No label for entry" << "\n";
884 Handle(TFunction_Function) aF;
885 if (!label.FindAttribute(TFunction_Function::GetID(), aF))
887 di << "No TFunction_Function Attribute on label" << "\n";
891 char *aStrGUID = new char[37];
892 aF->GetDriverGUID().ToCString(aStrGUID);
893 Draw::Set(arg[3],aStrGUID);
895 Draw::Set(arg[4],TCollection_AsciiString(aF->GetFailure()).ToCString());
900 di << "Wrong arguments" << "\n";
904 //=======================================================================
905 //function : SetExtStringArray (DF, entry , isDelta, From, To, elmt1, elmt2, ...
906 //=======================================================================
907 static Standard_Integer DDataStd_SetExtStringArray (Draw_Interpretor& di,
914 if (!DDF::GetDF(arg[1],DF)) return 1;
916 DDF::AddLabel(DF, arg[2], label);
917 Standard_Integer isDelta = Draw::Atoi(arg[3]);
919 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
920 di << "Array of ExtString with bounds from = " << From << " to = " << To << "\n";
921 Handle(TDataStd_ExtStringArray) A = TDataStd_ExtStringArray::Set(label, From, To, isDelta);
924 for(Standard_Integer i = From; i<=To; i++) {
925 A->SetValue(i, arg[j] );
932 //=======================================================================
933 //function : GetExtStringArray (DF, entry )
934 //=======================================================================
935 static Standard_Integer DDataStd_GetExtStringArray (Draw_Interpretor& di,
942 if (!DDF::GetDF(arg[1],DF)) return 1;
944 if( !DDF::FindLabel(DF, arg[2], label) ) {
945 di << "No label for entry" << "\n";
949 Handle(TDataStd_ExtStringArray) A;
950 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
951 di << "There is no TDataStd_ExtStringArray under label" << "\n";
955 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
956 TCollection_AsciiString anAsciiString(A->Value(i),'?');
957 di << anAsciiString.ToCString();
965 //=======================================================================
966 //function : ChangeExtStrArray (DF, entry, indx, val )
967 //=======================================================================
968 static Standard_Integer DDataStd_ChangeExtStrArray (Draw_Interpretor& di,
975 if (!DDF::GetDF(arg[1],DF)) return 1;
977 if( !DDF::FindLabel(DF, arg[2], label) ) {
978 di << "No label for entry" << "\n";
982 Handle(TDataStd_ExtStringArray) A;
983 if ( !label.FindAttribute(TDataStd_ExtStringArray::GetID(), A) ) {
984 di << "There is no TDataStd_ExtStringArray at label" << "\n";
987 Standard_Integer indx = Draw::Atoi(arg[3]);
988 TCollection_ExtendedString val(arg[4]);
989 Standard_Integer low = A->Lower(), up = A->Upper();
990 if(low <= indx && indx <= up)
991 A->SetValue(indx, val);//TColStd_HArray1OfExtendedString
993 Handle(TColStd_HArray1OfExtendedString) Arr = A->Array();
994 Handle(TColStd_HArray1OfExtendedString) arr;
998 arr = new TColStd_HArray1OfExtendedString(low, up);
999 for(i=low; i<= Arr->Upper(); i++)
1000 arr->SetValue(i, Arr->Value(i));
1001 for(i=Arr->Upper()+1; i<= up; i++) {
1003 arr->SetValue(i, val);
1005 arr->SetValue(i, 0);
1007 } else if(indx < up) {//clip array : indx to be negative
1009 arr = new TColStd_HArray1OfExtendedString(low, up);
1010 for(i=low; i< up; i++)
1011 arr->SetValue(i, Arr->Value(i));
1012 arr->SetValue(up, val);
1014 A->ChangeArray(arr);
1018 di << "DDataStd_ChangeExtStringArray: Error" << "\n";
1023 //=======================================================================
1024 //function : DDataStd_KeepUTF
1025 //purpose : SetUTFName (DF, fatherEntry, fileName)
1026 //=======================================================================
1027 static Standard_Integer DDataStd_KeepUTF (Draw_Interpretor& di,
1028 Standard_Integer nb,
1032 Handle(TDF_Data) DF;
1033 if (!DDF::GetDF(arg[1],DF)) return 1;
1035 DDF::AddLabel(DF, arg[2], L);
1036 Standard_CString aFileName(arg[3]);
1039 ifstream anIS (aFileName, ios::in | ios::binary);
1041 ifstream anIS (aFileName);
1044 // Can not open file
1045 cout << "Error: can't open file " << aFileName <<endl;;
1050 anIS.getline(buf, 1023,'\n');
1051 // 0xEFBBBF - prefix of UTF8
1052 p = &buf[3]; //skip prefix
1053 TCollection_ExtendedString aES1(p, Standard_True);
1054 TDataStd_Name::Set(L.NewChild(), aES1);
1057 while (anIS.good() && !anIS.eof()) {
1058 anIS.getline(buf, 1023,'\n');
1059 TCollection_ExtendedString aES2(buf, Standard_True);
1060 const TDF_Label& aLab = L.NewChild();
1061 TDataStd_Name::Set(aLab, aES2);
1065 di << "SetUTFName : String is not kept in DF" << "\n";
1069 //=======================================================================
1070 //function : DDataStd_GetUTFtoFile
1071 //purpose : GetUTF (DF, fatherEntry, fileName)
1072 // : all strings from sub-labels of the <fatherEntry> concatenated
1073 // : in one, converted to UTF8 and kept in the file
1074 //=======================================================================
1075 static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di,
1076 Standard_Integer nb,
1080 Handle(TDF_Data) DF;
1081 if (!DDF::GetDF(arg[1],DF)) return 1;
1083 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
1085 TCollection_ExtendedString aES;
1086 Standard_Boolean aF = Standard_False;
1087 TDF_ChildIterator anIt(L);
1088 for(;anIt.More();anIt.Next()) {
1089 const TDF_Label& aLab = anIt.Value();
1090 if(!aLab.IsNull()) {
1091 Handle(TDataStd_Name) anAtt;
1092 if(aLab.FindAttribute(TDataStd_Name::GetID(), anAtt)) {
1093 if(anAtt->Get().Length()) {
1104 cout << "Data is not found in the Document" <<endl;
1108 Standard_CString aFileName(arg[3]);
1111 ofstream anOS (aFileName, ios::in | ios::binary | ios::ate);
1113 ofstream anOS (aFileName, ios::ate);
1116 // A problem with the stream
1118 cout << "Error: problem with the file stream, rdstate = " <<anOS.rdstate() <<endl;
1121 unsigned char prefix[4] = {0xEF,0xBB,0xBF, 0x00};
1122 anOS.write( (char*)&prefix[0], 3);
1123 Standard_Integer n = aES.LengthOfCString();
1124 Standard_PCharacter aCstr = (Standard_PCharacter) Standard::Allocate(n+1);
1125 n = aES.ToUTF8CString(aCstr);
1126 anOS.write( (char*)&aCstr[0], n);
1130 di << "GetUTF : Data is not extracted to the specified file " <<"\n";
1134 //=======================================================================
1135 //function : SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )
1136 //=======================================================================
1137 static Standard_Integer DDataStd_SetByteArray (Draw_Interpretor& di,
1138 Standard_Integer nb,
1143 Handle(TDF_Data) DF;
1144 if (!DDF::GetDF(arg[1],DF)) return 1;
1146 DDF::AddLabel(DF, arg[2], label);
1147 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1148 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
1149 di << "Array of Standard_Integer with bounds from = " << From << " to = " << To << "\n";
1150 Handle(TDataStd_ByteArray) A = TDataStd_ByteArray::Set(label, From, To, isDelta);
1153 for(Standard_Integer i = From; i<=To; ++i) {
1154 Standard_Integer ival = Draw::Atoi(arg[j]);
1155 if(ival < 0 && 255 < ival) {
1156 cout << "Bad value = " << ival<< endl;
1159 A->SetValue(i, (Standard_Byte)ival);
1164 di << "DDataStd_SetByteArray: Error" << "\n";
1168 //=======================================================================
1169 //function : SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )
1170 //=======================================================================
1171 static Standard_Integer DDataStd_SetBooleanArray (Draw_Interpretor& di,
1172 Standard_Integer nb,
1177 Handle(TDF_Data) DF;
1178 if (!DDF::GetDF(arg[1],DF))
1182 DDF::AddLabel(DF, arg[2], label);
1183 Standard_Integer From = Draw::Atoi(arg[4]), To = Draw::Atoi( arg[5] ), j;
1184 di << "Array of Standard_Boolean with bounds from = " << From << " to = " << To << "\n";
1185 Handle(TDataStd_BooleanArray) A = TDataStd_BooleanArray::Set(label, From, To);
1188 for(Standard_Integer i = From; i<=To; i++)
1190 Standard_Integer ival = Draw::Atoi(arg[j]);
1193 cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl;
1196 A->SetValue(i, (Standard_Boolean)ival);
1201 di << "DDataStd_SetBooleanArray: Error" << "\n";
1205 //=======================================================================
1206 //function : SetBooleanList (DF, entry, elmt1, elmt2, ... )
1207 //=======================================================================
1208 static Standard_Integer DDataStd_SetBooleanList (Draw_Interpretor& di,
1209 Standard_Integer nb,
1214 Handle(TDF_Data) DF;
1215 if (!DDF::GetDF(arg[1],DF))
1219 DDF::AddLabel(DF, arg[2], label);
1220 Handle(TDataStd_BooleanList) A = TDataStd_BooleanList::Set(label);
1221 for(Standard_Integer i = 3; i <= nb - 1; i++)
1223 Standard_Integer ival = Draw::Atoi(arg[i]);
1226 cout << "Bad value = " << ival<< ". 0 or 1 is expected." << endl;
1229 A->Append((Standard_Boolean)ival);
1233 di << "DDataStd_SetBooleanList: Error" << "\n";
1237 //=======================================================================
1238 //function : SetIntegerList (DF, entry, elmt1, elmt2, ... )
1239 //=======================================================================
1240 static Standard_Integer DDataStd_SetIntegerList (Draw_Interpretor& di,
1241 Standard_Integer nb,
1246 Handle(TDF_Data) DF;
1247 if (!DDF::GetDF(arg[1],DF))
1251 DDF::AddLabel(DF, arg[2], label);
1252 Handle(TDataStd_IntegerList) A = TDataStd_IntegerList::Set(label);
1253 for(Standard_Integer i = 3; i <= nb - 1; i++)
1255 Standard_Integer ival = Draw::Atoi(arg[i]);
1260 di << "DDataStd_SetIntegerList: Error" << "\n";
1264 //=======================================================================
1265 //function : SetRealList (DF, entry, elmt1, elmt2, ... )
1266 //=======================================================================
1267 static Standard_Integer DDataStd_SetRealList (Draw_Interpretor& di,
1268 Standard_Integer nb,
1273 Handle(TDF_Data) DF;
1274 if (!DDF::GetDF(arg[1],DF))
1278 DDF::AddLabel(DF, arg[2], label);
1279 Handle(TDataStd_RealList) A = TDataStd_RealList::Set(label);
1280 for(Standard_Integer i = 3; i <= nb - 1; i++)
1282 Standard_Real fval = Draw::Atof(arg[i]);
1287 di << "DDataStd_SetRealList: Error" << "\n";
1291 //=======================================================================
1292 //function : GetByteArray (DF, entry )
1293 //=======================================================================
1294 static Standard_Integer DDataStd_GetByteArray (Draw_Interpretor& di,
1300 Handle(TDF_Data) DF;
1301 if (!DDF::GetDF(arg[1],DF)) return 1;
1303 if( !DDF::FindLabel(DF, arg[2], label) ) {
1304 di << "No label for entry" << "\n";
1308 Handle(TDataStd_ByteArray) A;
1309 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
1310 di << "There is no TDataStd_ByteArray at label" << "\n";
1314 for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
1315 //cout << A->Value(i) << endl;
1324 //=======================================================================
1325 //function : GetBooleanArray (DF, entry )
1326 //=======================================================================
1327 static Standard_Integer DDataStd_GetBooleanArray (Draw_Interpretor& di,
1331 Handle(TDF_Data) DF;
1332 if (!DDF::GetDF(arg[1],DF))
1336 if ( !DDF::FindLabel(DF, arg[2], label) )
1338 di << "No label for entry" << "\n";
1342 Handle(TDataStd_BooleanArray) A;
1343 if ( !label.FindAttribute(TDataStd_BooleanArray::GetID(), A) )
1345 di << "There is no TDataStd_BooleanArray at label" << "\n";
1349 for (Standard_Integer i = A->Lower(); i<=A->Upper(); i++)
1351 di << (Standard_Integer) A->Value(i);
1359 //=======================================================================
1360 //function : ChangeByteArray (DF, entry, indx, val )
1361 //=======================================================================
1362 static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
1363 Standard_Integer nb,
1368 Handle(TDF_Data) DF;
1369 if (!DDF::GetDF(arg[1],DF)) return 1;
1371 if( !DDF::FindLabel(DF, arg[2], label) ) {
1372 di << "No label for entry" << "\n";
1376 Handle(TDataStd_ByteArray) A;
1377 if ( !label.FindAttribute(TDataStd_ByteArray::GetID(), A) ) {
1378 di << "There is no TDataStd_ByteArray at label" << "\n";
1381 Standard_Integer indx = Draw::Atoi(arg[3]);
1382 Standard_Integer ival = Draw::Atoi(arg[4]);
1383 if (ival > 255 || ival < 0) {
1384 di << "DDataStd_ChangeByteArray: Bad value = " <<ival << "\n";
1387 Standard_Integer low = A->Lower(), up = A->Upper();
1388 if(low <= indx && indx <= up)
1389 A->SetValue(indx, (Standard_Byte)ival);
1391 Handle(TColStd_HArray1OfByte) Arr = A->InternalArray();
1392 Handle(TColStd_HArray1OfByte) arr;
1396 arr = new TColStd_HArray1OfByte(low, up);
1397 for(i=low; i<= Arr->Upper(); i++)
1398 arr->SetValue(i, Arr->Value(i));
1399 for(i=Arr->Upper()+1; i<= up; i++) {
1401 arr->SetValue(i, (Standard_Byte)ival);
1403 arr->SetValue(i, 0);
1405 } else if(indx < up) {//clip array : indx to be negative
1407 arr = new TColStd_HArray1OfByte(low, up);
1408 for(i=low; i< up; i++)
1409 arr->SetValue(i, Arr->Value(i));
1410 arr->SetValue(up, (Standard_Byte)ival);
1412 A->ChangeArray(arr);
1416 di << "DDataStd_ChangeByteArray: Error" << "\n";
1420 //=======================================================================
1421 //function : GetBooleanList (DF, entry )
1422 //=======================================================================
1423 static Standard_Integer DDataStd_GetBooleanList (Draw_Interpretor& di,
1427 Handle(TDF_Data) DF;
1428 if (!DDF::GetDF(arg[1],DF))
1432 if ( !DDF::FindLabel(DF, arg[2], label) )
1434 di << "No label for entry" << "\n";
1438 Handle(TDataStd_BooleanList) A;
1439 if ( !label.FindAttribute(TDataStd_BooleanList::GetID(), A) )
1441 di << "There is no TDataStd_BooleanList at label" << "\n";
1445 const TDataStd_ListOfByte& bList = A->List();
1446 TDataStd_ListIteratorOfListOfByte itr(bList);
1447 for (; itr.More(); itr.Next())
1449 di << (Standard_Integer) itr.Value() << " ";
1455 //=======================================================================
1456 //function : GetIntegerList (DF, entry )
1457 //=======================================================================
1458 static Standard_Integer DDataStd_GetIntegerList (Draw_Interpretor& di,
1462 Handle(TDF_Data) DF;
1463 if (!DDF::GetDF(arg[1],DF))
1467 if ( !DDF::FindLabel(DF, arg[2], label) )
1469 di << "No label for entry" << "\n";
1473 Handle(TDataStd_IntegerList) A;
1474 if ( !label.FindAttribute(TDataStd_IntegerList::GetID(), A) )
1476 di << "There is no TDataStd_IntegerList at label" << "\n";
1480 const TColStd_ListOfInteger& iList = A->List();
1481 TColStd_ListIteratorOfListOfInteger itr(iList);
1482 for (; itr.More(); itr.Next())
1484 di << itr.Value() << " ";
1490 //=======================================================================
1491 //function : GetRealList (DF, entry )
1492 //=======================================================================
1493 static Standard_Integer DDataStd_GetRealList (Draw_Interpretor& di,
1497 Handle(TDF_Data) DF;
1498 if (!DDF::GetDF(arg[1],DF))
1502 if ( !DDF::FindLabel(DF, arg[2], label) )
1504 di << "No label for entry" << "\n";
1508 Handle(TDataStd_RealList) A;
1509 if ( !label.FindAttribute(TDataStd_RealList::GetID(), A) )
1511 di << "There is no TDataStd_RealList at label" << "\n";
1515 const TColStd_ListOfReal& iList = A->List();
1516 TColStd_ListIteratorOfListOfReal itr(iList);
1517 for (; itr.More(); itr.Next())
1519 di << itr.Value() << " ";
1525 //=======================================================================
1526 //function : SetIntPackedMap (DF, entry, isDelta, key1, key2, ...
1527 //=======================================================================
1529 static Standard_Integer DDataStd_SetIntPackedMap (Draw_Interpretor& di,
1530 Standard_Integer nb,
1535 Handle(TDF_Data) DF;
1536 if (!DDF::GetDF(arg[1],DF)) return 1;
1538 DDF::AddLabel(DF, arg[2], aLabel);
1539 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1540 Standard_Integer aNum = nb - 4;
1541 Handle(TDataStd_IntPackedMap) anAtt;
1542 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
1543 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
1544 if(anAtt.IsNull()) {
1545 di << "IntPackedMap attribute is not found or not set" << "\n";
1548 Standard_Integer j = 4;
1549 TColStd_PackedMapOfInteger aMap;
1550 for(Standard_Integer i = 1; i<=aNum; i++) {
1551 aMap.Add (Draw::Atoi(arg[j]));
1554 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
1555 anAtt->ChangeMap(aHMap);
1556 cout << "Map extent = " << anAtt->Extent()<<endl;
1559 di << "DDataStd_SetIntPackedMap : Error" << "\n";
1563 //=======================================================================
1564 //function : GetIntPackedMap (DF, entry )
1565 //=======================================================================
1567 static Standard_Integer DDataStd_GetIntPackedMap (Draw_Interpretor& di,
1568 Standard_Integer nb,
1573 Handle(TDF_Data) DF;
1574 if (!DDF::GetDF(arg[1],DF)) return 1;
1576 DDF::AddLabel(DF, arg[2], aLabel);
1577 Handle(TDataStd_IntPackedMap) anAtt;
1578 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt)) {
1579 di << "IntPackedMap attribute is not found or not set" << "\n";
1582 const TColStd_PackedMapOfInteger& aMap = anAtt->GetMap();
1583 TColStd_MapIteratorOfPackedMapOfInteger itr(aMap);
1584 for (Standard_Integer j = 1; itr.More(); itr.Next(),j++){
1585 Standard_Integer aKey(itr.Key());
1590 di << "DDataStd_GetIntPackedMap : Error" << "\n";
1595 //=======================================================================
1596 //function : ChangeIntPackedMap_Add (DF, entry, Key1, Key2,... )
1597 //=======================================================================
1598 static Standard_Integer DDataStd_ChangeIntPackedMap_Add (Draw_Interpretor& di,
1599 Standard_Integer nb,
1604 Handle(TDF_Data) DF;
1605 if (!DDF::GetDF(arg[1],DF)) return 1;
1607 if( !DDF::FindLabel(DF, arg[2], label) ) {
1608 di << "No label for entry" << "\n";
1612 Handle(TDataStd_IntPackedMap) A;
1613 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1614 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1618 Standard_Integer i, aNum = nb - 3;
1619 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1620 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1621 if(!aHMap.IsNull()) {
1622 ahMap->ChangeMap().Assign(aHMap->Map());
1623 for(i=1; i<=aNum;i++) {
1624 Standard_Integer val = Draw::Atoi(arg[i+2]);
1625 if(!ahMap->Map().Contains(val))
1626 ahMap->ChangeMap().Add(val);
1629 A->ChangeMap(ahMap);
1633 di << "DDataStd_ChangeIntPackedMap_Add: Error" << "\n";
1638 //=======================================================================
1639 //function : ChangeIntPackedMap_Rem (DF, entry, Key1, Key2,... )
1640 //=======================================================================
1641 static Standard_Integer DDataStd_ChangeIntPackedMap_Rem (Draw_Interpretor& di,
1642 Standard_Integer nb,
1647 Handle(TDF_Data) DF;
1648 if (!DDF::GetDF(arg[1],DF)) return 1;
1650 if( !DDF::FindLabel(DF, arg[2], label) ) {
1651 di << "No label for entry" << "\n";
1655 Handle(TDataStd_IntPackedMap) A;
1656 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1657 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1661 Standard_Integer i, aNum = nb - 3;
1662 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1663 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1664 if(!aHMap.IsNull()) {
1665 ahMap->ChangeMap().Assign(aHMap->Map());
1666 for(i=1; i<=aNum;i++) {
1667 Standard_Integer val = Draw::Atoi(arg[i+2]);
1668 if(ahMap->Map().Contains(val))
1669 ahMap->ChangeMap().Remove(val);
1672 A->ChangeMap(ahMap);
1676 di << "DDataStd_ChangeIntPackedMap_Rem: Error" << "\n";
1680 //=======================================================================
1681 //function : ChangeIntPackedMap_AddRem (DF, entry, Key1, Key2,... )
1682 // : if Keyi exist in map - remove it, if no - add
1683 //=======================================================================
1684 static Standard_Integer DDataStd_ChangeIntPackedMap_AddRem (Draw_Interpretor& di,
1685 Standard_Integer nb,
1690 Handle(TDF_Data) DF;
1691 if (!DDF::GetDF(arg[1],DF)) return 1;
1693 if( !DDF::FindLabel(DF, arg[2], label) ) {
1694 di << "No label for entry" << "\n";
1698 Handle(TDataStd_IntPackedMap) A;
1699 if ( !label.FindAttribute(TDataStd_IntPackedMap::GetID(), A) ) {
1700 di << "There is no TDataStd_IntPackedMap at label" << "\n";
1704 Standard_Integer i, aNum = nb - 3;
1705 Handle(TColStd_HPackedMapOfInteger) aHMap = A->GetHMap();
1706 Handle(TColStd_HPackedMapOfInteger) ahMap = new TColStd_HPackedMapOfInteger();
1707 if(!aHMap.IsNull()) {
1708 ahMap->ChangeMap().Assign(aHMap->Map());
1709 for(i=1; i<=aNum;i++) {
1710 Standard_Integer val = Draw::Atoi(arg[i+2]);
1711 if(!ahMap->Map().Contains(val))
1712 ahMap->ChangeMap().Add(val);
1714 ahMap->ChangeMap().Remove(val);
1717 A->ChangeMap(ahMap);
1721 di << "DDataStd_ChangeIntPackedMap_AddRem: Error" << "\n";
1725 //=======================================================================
1726 //function : SetIntPHugeMap (DF, entry, isDelta Num)
1727 //=======================================================================
1729 static Standard_Integer DDataStd_SetIntPHugeMap (Draw_Interpretor& di,
1730 Standard_Integer nb,
1735 Handle(TDF_Data) DF;
1736 if (!DDF::GetDF(arg[1],DF)) return 1;
1738 DDF::AddLabel(DF, arg[2], aLabel);
1739 Standard_Integer isDelta = Draw::Atoi(arg[3]);
1740 Standard_Integer aNum = Draw::Atoi(arg[4]);
1741 Handle(TDataStd_IntPackedMap) anAtt;
1742 if(!aLabel.FindAttribute(TDataStd_IntPackedMap::GetID(), anAtt))
1743 anAtt = TDataStd_IntPackedMap::Set(aLabel, isDelta);
1744 if(anAtt.IsNull()) {
1745 di << "IntPackedMap attribute is not found or not set" << "\n";
1748 TColStd_PackedMapOfInteger aMap;
1749 for(Standard_Integer i = 1; i<=aNum; i++) {
1752 const Handle(TColStd_HPackedMapOfInteger)& aHMap = new TColStd_HPackedMapOfInteger(aMap);
1753 anAtt->ChangeMap(aHMap);
1754 cout << "Map extent = " << anAtt->Extent()<<endl;
1757 di << "DDataStd_SetIntPHugeMap : Error" << "\n";
1761 //=======================================================================
1762 //function : SetNDataIntegers (DF, entry , Num
1763 //=======================================================================
1765 static Standard_Integer DDataStd_SetNDataIntegers2 (Draw_Interpretor& di,
1766 Standard_Integer nb,
1771 Handle(TDF_Data) DF;
1772 if (!DDF::GetDF(arg[1],DF)) return 1;
1774 DDF::AddLabel(DF, arg[2], aLabel);
1775 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
1776 Handle(TDataStd_NamedData) anAtt;
1777 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1778 anAtt = TDataStd_NamedData::Set(aLabel);
1779 if(anAtt.IsNull()) {
1780 di << "NamedData attribute is not found or not set" << "\n";
1784 TCollection_ExtendedString aKey("Key_");
1785 for(Standard_Integer i = 1; i<=aNumP; i++) {
1786 TCollection_ExtendedString key = aKey + i;
1787 Standard_Integer aVal = j+i;
1788 anAtt->SetInteger(key, aVal);
1793 di << "DDataStd_SetNDataIntegers2 : Error" << "\n";
1797 //=======================================================================
1798 //function : SetNDataIntArrays2 (DF, entry , key, NumOfArElem )
1799 //=======================================================================
1801 static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di,
1802 Standard_Integer nb,
1807 Handle(TDF_Data) DF;
1808 if (!DDF::GetDF(arg[1],DF)) return 1;
1810 DDF::AddLabel(DF, arg[2], aLabel);
1813 TCollection_ExtendedString aKey(arg[3]);
1814 Standard_Integer aNum = Draw::Atoi(arg[4]);
1815 if (aNum <= 0) return 1;
1816 Handle(TDataStd_NamedData) anAtt;
1817 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1818 anAtt = TDataStd_NamedData::Set(aLabel);
1819 if(anAtt.IsNull()) {
1820 cout<< "NamedData attribute is not found or not set" << endl;
1824 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
1825 for(Standard_Integer i = 1; i<=aNum; i++) {
1826 Standard_Integer aVal = j++;
1827 anArr->SetValue(i, aVal);
1830 anAtt->SetArrayOfIntegers(aKey, anArr);
1833 di << "DDataStd_SetNDataIntArrays2 : Error" << "\n";
1838 //=======================================================================
1839 //function : SetAsciiString(DF, entry , String)
1840 //=======================================================================
1842 static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
1843 Standard_Integer nb,
1848 Handle(TDF_Data) DF;
1849 if (!DDF::GetDF(arg[1],DF)) return 1;
1851 DDF::AddLabel(DF, arg[2], aLabel);
1852 TCollection_AsciiString aString(arg[3]);
1853 Handle(TDataStd_AsciiString) anAtt;
1854 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1855 anAtt = TDataStd_AsciiString::Set(aLabel, aString);
1856 if(anAtt.IsNull()) {
1857 di << "AsciiString attribute is not found or not set" << "\n";
1860 // anAtt->Set(aString);
1861 cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << endl;
1864 di << "DDataStd_SetAsciiString : Error" << "\n";
1868 //=======================================================================
1869 //function : GetAsciiString(DF, entry )
1870 //=======================================================================
1872 static Standard_Integer DDataStd_GetAsciiString (Draw_Interpretor& di,
1873 Standard_Integer nb,
1878 Handle(TDF_Data) DF;
1879 if (!DDF::GetDF(arg[1],DF)) return 1;
1881 DDF::AddLabel(DF, arg[2], aLabel);
1882 Handle(TDataStd_AsciiString) anAtt;
1883 if(!aLabel.FindAttribute(TDataStd_AsciiString::GetID(), anAtt)) {
1884 cout << "AsciiString attribute is not found or not set" << endl;
1887 cout << "String = " <<anAtt->Get().ToCString() << endl;
1890 di << "DDataStd_GetAsciiString : Error" << "\n";
1894 //=======================================================================
1895 //function : SetNDataIntegers (DF, entry , Num, key1, val1, ...
1896 //=======================================================================
1898 static Standard_Integer DDataStd_SetNDataIntegers (Draw_Interpretor& di,
1899 Standard_Integer nb,
1904 Handle(TDF_Data) DF;
1905 if (!DDF::GetDF(arg[1],DF)) return 1;
1907 DDF::AddLabel(DF, arg[2], aLabel);
1909 // TCollection_ExtendedString aString("123456789 0_abcde");
1910 // Standard_Integer aPos = aString.Search(" ");
1911 // cout << "From Start = " <<aPos<<endl;
1912 // aPos = aString.SearchFromEnd(" ");
1913 // cout << "From Start = " <<aPos<<endl;
1914 // TCollection_ExtendedString aValue = aString.Split(aPos);
1915 // cout << "Value = |"<<aValue<<endl;
1916 // cout << "aKey = " << aString << "|"<<endl;
1918 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
1919 Handle(TDataStd_NamedData) anAtt;
1920 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
1921 anAtt = TDataStd_NamedData::Set(aLabel);
1922 if(anAtt.IsNull()) {
1923 di << "NamedData attribute is not found or not set" << "\n";
1927 for(Standard_Integer i = 1; i<=aNumP; i++) {
1928 TCollection_ExtendedString aKey(arg[j]);
1929 Standard_Integer aVal = Draw::Atoi(arg[j+1]);
1930 anAtt->SetInteger(aKey, aVal);
1935 di << "DDataStd_SetNDataIntegers : Error" << "\n";
1940 //=======================================================================
1941 //function : GetNDIntegers(DF, entry )
1942 //=======================================================================
1943 static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di,
1944 Standard_Integer nb,
1949 Handle(TDF_Data) DF;
1950 if (!DDF::GetDF(arg[1],DF)) return 1;
1952 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
1955 Handle(TDataStd_NamedData) anAtt;
1956 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
1957 cout << "NamedData attribute is not found or not set" << endl;
1960 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
1961 const TColStd_DataMapOfStringInteger& aMap = anAtt->GetIntegersContainer();
1962 TColStd_DataMapIteratorOfDataMapOfStringInteger itr(aMap);
1963 for (; itr.More(); itr.Next()){
1964 TCollection_ExtendedString aKey(itr.Key());
1965 TCollection_AsciiString aStr(aKey,'?');
1966 Standard_Integer aValue = itr.Value();
1967 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;;
1972 di << "DDataStd_GetNDIntegers : Error" << "\n";
1976 //=======================================================================
1977 //function : GetNDInteger(DF, entry, key [drawname])
1978 //=======================================================================
1979 static Standard_Integer DDataStd_GetNDInteger (Draw_Interpretor& di,
1980 Standard_Integer nb,
1985 Handle(TDF_Data) DF;
1986 if (!DDF::GetDF(arg[1],DF)) return 1;
1988 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
1991 Handle(TDataStd_NamedData) anAtt;
1992 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
1993 cout << "NamedData attribute is not found or not set" << endl;
1997 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
1998 if(!anAtt->HasInteger(arg[3])) {
1999 cout << "There is no data specified by Key = "<< arg[3] << endl;
2002 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetInteger(arg[3])<<endl;
2004 Draw::Set(arg[4], anAtt->GetInteger(arg[3]));
2008 di << "DDataStd_SetNDataIntegers : Error" << "\n";
2012 //========================== REALS ======================================
2013 //=======================================================================
2014 //function : SetNDataReals (DF, entry , Num, key1, val1, ...
2015 //=======================================================================
2017 static Standard_Integer DDataStd_SetNDataReals (Draw_Interpretor& di,
2018 Standard_Integer nb,
2023 Handle(TDF_Data) DF;
2024 if (!DDF::GetDF(arg[1],DF)) return 1;
2026 DDF::AddLabel(DF, arg[2], aLabel);
2028 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2029 Handle(TDataStd_NamedData) anAtt;
2030 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2031 anAtt = TDataStd_NamedData::Set(aLabel);
2032 if(anAtt.IsNull()) {
2033 cout << "NamedData attribute is not found or not set" << endl;;
2037 for(Standard_Integer i = 1; i<=aNumP; i++) {
2038 TCollection_ExtendedString aKey(arg[j]);
2039 Standard_Real aVal = Draw::Atof(arg[j+1]);
2040 anAtt->SetReal(aKey, aVal);
2045 di << "DDataStd_SetNDataReals : Error" << "\n";
2049 //=======================================================================
2050 //function : GetNDReals(DF, entry )
2051 //=======================================================================
2052 static Standard_Integer DDataStd_GetNDReals (Draw_Interpretor& di,
2053 Standard_Integer nb,
2058 Handle(TDF_Data) DF;
2059 if (!DDF::GetDF(arg[1],DF)) return 1;
2061 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2064 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2065 Handle(TDataStd_NamedData) anAtt;
2066 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2067 cout << "NamedData attribute is not found or not set" << endl;
2070 const TDataStd_DataMapOfStringReal& aMap = anAtt->GetRealsContainer();
2071 TDataStd_DataMapIteratorOfDataMapOfStringReal itr(aMap);
2072 for (; itr.More(); itr.Next()){
2073 TCollection_ExtendedString aKey(itr.Key());
2074 TCollection_AsciiString aStr(aKey,'?');
2075 Standard_Real aValue = itr.Value();
2076 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;
2080 di << "DDataStd_GetNDReals : Error" << "\n";
2084 //=======================================================================
2085 //function : GetNDReal(DF, entry, key [drawname])
2086 //=======================================================================
2087 static Standard_Integer DDataStd_GetNDReal (Draw_Interpretor& di,
2088 Standard_Integer nb,
2093 Handle(TDF_Data) DF;
2094 if (!DDF::GetDF(arg[1],DF)) return 1;
2096 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2099 Handle(TDataStd_NamedData) anAtt;
2100 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2101 cout << "NamedData attribute is not found or not set" << endl;
2105 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2106 if(!anAtt->HasReal(arg[3])) {
2107 cout << "There is no data specified by Key = "<< arg[3] << endl;
2110 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetReal(arg[3])<<endl;
2112 Draw::Set(arg[4], anAtt->GetReal(arg[3]));
2116 di << "DDataStd_GetNDReal : Error" << "\n";
2120 //======================= Strings =======================================
2121 //=======================================================================
2122 //function : SetNDataStrings (DF, entry , Num, key1, val1, ...
2123 //=======================================================================
2125 static Standard_Integer DDataStd_SetNDataStrings (Draw_Interpretor& di,
2126 Standard_Integer nb,
2131 Handle(TDF_Data) DF;
2132 if (!DDF::GetDF(arg[1],DF)) return 1;
2134 DDF::AddLabel(DF, arg[2], aLabel);
2136 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2137 Handle(TDataStd_NamedData) anAtt;
2138 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2139 anAtt = TDataStd_NamedData::Set(aLabel);
2140 if(anAtt.IsNull()) {
2141 di << "NamedData attribute is not found or not set" << "\n";
2145 for(Standard_Integer i = 1; i<=aNumP; i++) {
2146 TCollection_ExtendedString aKey(arg[j]);
2147 TCollection_ExtendedString aVal(arg[j+1]);
2148 anAtt->SetString(aKey, aVal);
2153 di << "DDataStd_SetNDataStrings : Error" << "\n";
2157 //=======================================================================
2158 //function : GetNDStrings(DF, entry )
2159 //=======================================================================
2160 static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di,
2161 Standard_Integer nb,
2166 Handle(TDF_Data) DF;
2167 if (!DDF::GetDF(arg[1],DF)) return 1;
2169 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2172 Handle(TDataStd_NamedData) anAtt;
2173 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2174 cout << "NamedData attribute is not found or not set" << endl;
2177 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2178 const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer();
2179 TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap);
2180 for (; itr.More(); itr.Next()){
2181 TCollection_ExtendedString aKey(itr.Key());
2182 TCollection_AsciiString aStr(aKey,'?');
2183 TCollection_ExtendedString aVal(itr.Value());
2184 TCollection_AsciiString aStrValue(aVal,'?');
2185 cout << "Key = " << aStr.ToCString() << " Value = " <<aStrValue.ToCString()<< endl;
2189 di << "DDataStd_GetNDStrings : Error" << "\n";
2193 //=======================================================================
2194 //function : GetNDString(DF, entry, key [drawname])
2195 //=======================================================================
2196 static Standard_Integer DDataStd_GetNDString (Draw_Interpretor& di,
2197 Standard_Integer nb,
2202 Handle(TDF_Data) DF;
2203 if (!DDF::GetDF(arg[1],DF)) return 1;
2205 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2208 Handle(TDataStd_NamedData) anAtt;
2209 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2210 di << "NamedData attribute is not found or not set" << "\n";
2214 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2215 if(!anAtt->HasString(arg[3])) {
2216 cout << "There is no data specified by Key = "<< arg[3] << endl;
2219 TCollection_AsciiString aValue (anAtt->GetString(arg[3]), '?');
2220 cout << "Key = " << arg[3] << " Value = " << aValue.ToCString() << endl;
2222 Draw::Set(arg[4], aValue.ToCString());
2226 di << "DDataStd_GetNDString : Error" << "\n";
2230 //=========================== Bytes =====================================
2231 //=======================================================================
2232 //function : SetNDataBytes (DF, entry , Num, key1, val1, ...
2233 //=======================================================================
2235 static Standard_Integer DDataStd_SetNDataBytes (Draw_Interpretor& di,
2236 Standard_Integer nb,
2241 Handle(TDF_Data) DF;
2242 if (!DDF::GetDF(arg[1],DF)) return 1;
2244 DDF::AddLabel(DF, arg[2], aLabel);
2246 Standard_Integer aNumP = Draw::Atoi(arg[3]), j;
2247 Handle(TDataStd_NamedData) anAtt;
2248 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2249 anAtt = TDataStd_NamedData::Set(aLabel);
2250 if(anAtt.IsNull()) {
2251 cout << "NamedData attribute is not found or not set" << endl;
2255 for(Standard_Integer i = 1; i<=aNumP; i++) {
2256 TCollection_ExtendedString aKey(arg[j]);
2257 Standard_Byte aVal = (Standard_Byte)Draw::Atoi(arg[j+1]);
2258 anAtt->SetByte(aKey, aVal);
2263 di << "DDataStd_SetNDataBytes : Error" << "\n";
2267 //=======================================================================
2268 //function : GetNDBytes(DF, entry )
2269 //=======================================================================
2270 static Standard_Integer DDataStd_GetNDBytes (Draw_Interpretor& di,
2271 Standard_Integer nb,
2276 Handle(TDF_Data) DF;
2277 if (!DDF::GetDF(arg[1],DF)) return 1;
2279 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2282 Handle(TDataStd_NamedData) anAtt;
2283 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2284 cout << "NamedData attribute is not found or not set" << endl;
2287 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2288 const TDataStd_DataMapOfStringByte& aMap = anAtt->GetBytesContainer();
2289 TDataStd_DataMapIteratorOfDataMapOfStringByte itr(aMap);
2290 for (; itr.More(); itr.Next()){
2291 TCollection_ExtendedString aKey(itr.Key());
2292 TCollection_AsciiString aStr(aKey,'?');
2293 Standard_Byte aValue = itr.Value();
2294 cout << "Key = " << aStr.ToCString() << " Value = " <<aValue<<endl;
2298 di << "DDataStd_GetNDBytes : Error" << "\n";
2302 //=======================================================================
2303 //function : GetNDByte(DF, entry, key [drawname])
2304 //=======================================================================
2305 static Standard_Integer DDataStd_GetNDByte (Draw_Interpretor& di,
2306 Standard_Integer nb,
2311 Handle(TDF_Data) DF;
2312 if (!DDF::GetDF(arg[1],DF)) return 1;
2314 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2317 Handle(TDataStd_NamedData) anAtt;
2318 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2319 cout << "NamedData attribute is not found or not set" << endl;
2323 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2324 if(!anAtt->HasByte(arg[3])) {
2325 cout << "There is no data specified by Key = "<< arg[3] << endl;
2328 cout << "Key = " << arg[3] << " Value = " <<anAtt->GetByte(arg[3])<< endl;
2330 Draw::Set(arg[4], anAtt->GetByte(arg[3]));
2334 di << "DDataStd_GetNDByte : Error" << "\n";
2337 //======================== IntArrays ====================================
2338 //=======================================================================
2339 //function : SetNDataIntArrays (DF, entry , key, NumOfArElem, val1, val2,... )
2340 //=======================================================================
2342 static Standard_Integer DDataStd_SetNDataIntAr (Draw_Interpretor& di,
2343 Standard_Integer nb,
2348 Handle(TDF_Data) DF;
2349 if (!DDF::GetDF(arg[1],DF)) return 1;
2351 DDF::AddLabel(DF, arg[2], aLabel);
2354 TCollection_ExtendedString aKey(arg[3]);
2355 Standard_Integer aNum = Draw::Atoi(arg[4]);
2356 if (aNum <= 0) return 1;
2357 Handle(TDataStd_NamedData) anAtt;
2358 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2359 anAtt = TDataStd_NamedData::Set(aLabel);
2360 if(anAtt.IsNull()) {
2361 cout<< "NamedData attribute is not found or not set" << endl;
2365 Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1, aNum);
2366 for(Standard_Integer i = 1; i<=aNum; i++) {
2367 Standard_Integer aVal = Draw::Atoi(arg[j]);
2368 anArr->SetValue(i, aVal);
2371 anAtt->SetArrayOfIntegers(aKey, anArr);
2374 di << "DDataStd_SetNDataIntArrays : Error" << "\n";
2379 //=======================================================================
2380 //function : GetNDIntArrays(DF, entry )
2381 //=======================================================================
2382 static Standard_Integer DDataStd_GetNDIntArrays (Draw_Interpretor& di,
2383 Standard_Integer nb,
2388 Handle(TDF_Data) DF;
2389 if (!DDF::GetDF(arg[1],DF)) return 1;
2391 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2394 Handle(TDataStd_NamedData) anAtt;
2395 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2396 cout << "NamedData attribute is not found or not set" << endl;
2399 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2400 const TDataStd_DataMapOfStringHArray1OfInteger& aMap = anAtt->GetArraysOfIntegersContainer();
2401 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger itr(aMap);
2402 for (; itr.More(); itr.Next()){
2403 TCollection_ExtendedString aKey(itr.Key());
2404 TCollection_AsciiString aStr(aKey,'?');
2405 cout << "Key = " << aStr.ToCString()<< endl;
2406 Handle(TColStd_HArray1OfInteger) anArrValue = itr.Value();
2407 if(!anArrValue.IsNull()) {
2408 Standard_Integer lower = anArrValue->Lower();
2409 Standard_Integer upper = anArrValue->Upper();
2410 for(Standard_Integer i = lower; i<=upper;i++) {
2411 Standard_Integer aValue = anArrValue->Value(i);
2412 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2415 cout << "\tthe specified array is Null "<<endl;
2419 di << "DDataStd_GetNDIntArrays : Error" << "\n";
2423 //=======================================================================
2424 //function : GetNDIntArray(DF, entry, key )
2425 //=======================================================================
2426 static Standard_Integer DDataStd_GetNDIntArray (Draw_Interpretor& di,
2427 Standard_Integer nb,
2432 Handle(TDF_Data) DF;
2433 if (!DDF::GetDF(arg[1],DF)) return 1;
2435 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2438 Handle(TDataStd_NamedData) anAtt;
2439 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2440 cout << "NamedData attribute is not found or not set" << endl;
2444 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2445 if(!anAtt->HasArrayOfIntegers(arg[3])) {
2446 cout << "There is no data specified by Key = "<< arg[3] << endl;
2449 cout << "Key = " << arg[3] <<endl;
2451 Handle(TColStd_HArray1OfInteger) anArrValue = anAtt->GetArrayOfIntegers(arg[3]);
2452 if(!anArrValue.IsNull()) {
2453 Standard_Integer lower = anArrValue->Lower();
2454 Standard_Integer upper = anArrValue->Upper();
2455 for(Standard_Integer i = lower; i<=upper;i++) {
2456 Standard_Integer aValue = anArrValue->Value(i);
2457 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2460 cout << "\tthe specified array is Null or not found"<<endl;
2464 di << "DDataStd_SetNDataIntArray : Error" << "\n";
2467 //============================= RealArrays ==============================
2468 //=======================================================================
2469 //function : SetNDataRealArrays (DF entry key NumOfArElem val1 val2... )
2470 //=======================================================================
2472 static Standard_Integer DDataStd_SetNDataRealAr (Draw_Interpretor& di,
2473 Standard_Integer nb,
2478 Handle(TDF_Data) DF;
2479 if (!DDF::GetDF(arg[1],DF)) return 1;
2481 DDF::AddLabel(DF, arg[2], aLabel);
2484 TCollection_ExtendedString aKey(arg[3]);
2485 Standard_Integer aNum = Draw::Atoi(arg[4]);
2486 if (aNum <= 0) return 1;
2487 Handle(TDataStd_NamedData) anAtt;
2488 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt))
2489 anAtt = TDataStd_NamedData::Set(aLabel);
2490 if(anAtt.IsNull()) {
2491 cout << "NamedData attribute is not found or not set" << endl;
2495 Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1, aNum);
2496 for(Standard_Integer i = 1; i<=aNum; i++) {
2497 Standard_Real aVal = Draw::Atof(arg[j]);
2498 anArr->SetValue(i, aVal);
2501 anAtt->SetArrayOfReals(aKey, anArr);
2504 di << "DDataStd_SetNDataRealArrays : Error" << "\n";
2509 //=======================================================================
2510 //function : GetNDRealArrays(DF, entry )
2511 //=======================================================================
2512 static Standard_Integer DDataStd_GetNDRealArrays (Draw_Interpretor& di,
2513 Standard_Integer nb,
2518 Handle(TDF_Data) DF;
2519 if (!DDF::GetDF(arg[1],DF)) return 1;
2521 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2524 Handle(TDataStd_NamedData) anAtt;
2525 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2526 cout << "NamedData attribute is not found or not set" << endl;
2529 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2530 const TDataStd_DataMapOfStringHArray1OfReal& aMap = anAtt->GetArraysOfRealsContainer();
2531 TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal itr(aMap);
2532 for (; itr.More(); itr.Next()){
2533 TCollection_ExtendedString aKey(itr.Key());
2534 TCollection_AsciiString aStr(aKey,'?');
2535 cout << "Key = " << aStr.ToCString()<<endl;
2536 Handle(TColStd_HArray1OfReal) anArrValue = itr.Value();
2537 if(!anArrValue.IsNull()) {
2538 Standard_Integer lower = anArrValue->Lower();
2539 Standard_Integer upper = anArrValue->Upper();
2540 for(Standard_Integer i = lower; i<=upper;i++) {
2541 Standard_Real aValue = anArrValue->Value(i);
2542 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2545 cout << "\tthe specified array is Null "<<endl;
2549 di << "DDataStd_GetNDRealArrays : Error" << "\n";
2553 //=======================================================================
2554 //function : GetNDRealArray(DF, entry, key )
2555 //=======================================================================
2556 static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
2557 Standard_Integer nb,
2562 Handle(TDF_Data) DF;
2563 if (!DDF::GetDF(arg[1],DF)) return 1;
2565 if(!DDF::FindLabel(DF, arg[2], aLabel)) return 1;
2568 Handle(TDataStd_NamedData) anAtt;
2569 if(!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAtt)) {
2570 di << "NamedData attribute is not found or not set" << "\n";
2574 cout <<"NamedData attribute at Label = " << arg[2] <<endl;
2575 if(!anAtt->HasArrayOfReals(arg[3])) {
2576 cout << "There is no data specified by Key = "<< arg[3] << endl;
2579 cout << "Key = " << arg[3] <<endl;
2581 Handle(TColStd_HArray1OfReal) anArrValue = anAtt->GetArrayOfReals(arg[3]);
2582 if(!anArrValue.IsNull()) {
2583 Standard_Integer lower = anArrValue->Lower();
2584 Standard_Integer upper = anArrValue->Upper();
2585 for(Standard_Integer i = lower; i<=upper;i++) {
2586 Standard_Real aValue = anArrValue->Value(i);
2587 cout << "\tValue("<<i<<")"<<" = " <<aValue<<endl;
2590 cout << "\tthe specified array is Null or not found"<<endl;
2594 di << "DDataStd_SetNDataRealArray : Error" << "\n";
2598 //=======================================================================
2599 //function : BasicCommands
2601 //=======================================================================
2603 void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
2606 static Standard_Boolean done = Standard_False;
2608 done = Standard_True;
2610 const char* g = "DData : Standard Attribute Commands";
2615 theCommands.Add ("SetInteger",
2616 "SetInteger (DF, entry, value)",
2617 __FILE__, DDataStd_SetInteger, g);
2619 theCommands.Add ("SetIntArray",
2620 "SetIntArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2621 __FILE__, DDataStd_SetIntArray, g);
2623 theCommands.Add ("SetReal",
2624 "SetReal (DF, entry, value)",
2625 __FILE__, DDataStd_SetReal, g);
2627 theCommands.Add ("SetRealArray",
2628 "SetRealArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2629 __FILE__, DDataStd_SetRealArray, g);
2631 theCommands.Add ("SetByteArray",
2632 "SetByteArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2633 __FILE__, DDataStd_SetByteArray, g);
2635 theCommands.Add ("SetExtStringArray",
2636 "SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2637 __FILE__, DDataStd_SetExtStringArray, g);
2639 theCommands.Add ("SetIntPackedMap",
2640 "SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
2641 __FILE__, DDataStd_SetIntPackedMap, g);
2643 theCommands.Add ("SetReference",
2644 "SetReference (DF, entry, reference)",
2645 __FILE__, DDataStd_SetReference, g);
2647 theCommands.Add ("SetComment",
2648 "SetComment (DF, entry, comment)",
2649 __FILE__, DDataStd_SetComment, g);
2651 theCommands.Add ("SetUAttribute",
2652 "SetUAttribute (DF, entry, LocalID)",
2653 __FILE__, DDataStd_SetUAttribute, g);
2655 theCommands.Add ("SetVariable",
2656 "SetVariable (DF, entry, isConstant[0/1], units)",
2657 __FILE__, DDataStd_SetVariable, g);
2659 theCommands.Add ("SetAsciiString",
2660 "SetAsciiString (DF, entry, String )",
2661 __FILE__, DDataStd_SetAsciiString, g);
2663 theCommands.Add ("SetBooleanArray",
2664 "SetBooleanArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
2665 __FILE__, DDataStd_SetBooleanArray, g);
2667 theCommands.Add ("SetBooleanList",
2668 "SetBooleanList (DF, entry, elmt1, elmt2, ... )",
2669 __FILE__, DDataStd_SetBooleanList, g);
2671 theCommands.Add ("SetIntegerList",
2672 "SetIntegerList (DF, entry, elmt1, elmt2, ... )",
2673 __FILE__, DDataStd_SetIntegerList, g);
2675 theCommands.Add ("SetRealList",
2676 "SetRealList (DF, entry, elmt1, elmt2, ... )",
2677 __FILE__, DDataStd_SetRealList, g);
2682 theCommands.Add ("GetAsciiString",
2683 "GetAsciiString (DF, entry )",
2684 __FILE__, DDataStd_GetAsciiString, g);
2686 theCommands.Add ("GetInteger",
2687 "GetInteger (DF, entry, [drawname])",
2688 __FILE__, DDataStd_GetInteger, g);
2690 theCommands.Add ("GetIntArray",
2691 "GetIntArray (DF, entry )",
2692 __FILE__, DDataStd_GetIntArray, g);
2694 theCommands.Add ("GetRealArray",
2695 "GetRealArray (DF, entry )",
2696 __FILE__, DDataStd_GetRealArray, g);
2698 theCommands.Add ("GetByteArray",
2699 "GetByteArray (DF, entry )",
2700 __FILE__, DDataStd_GetByteArray, g);
2702 theCommands.Add ("GetExtStringArray",
2703 "GetExtStringArray (DF, entry )",
2704 __FILE__, DDataStd_GetExtStringArray, g);
2706 theCommands.Add ("GetIntPackedMap",
2707 "GetIntPackedMap (DF, entry )",
2708 __FILE__, DDataStd_GetIntPackedMap, g);
2710 theCommands.Add ("GetReal",
2711 "GetReal (DF, entry, [drawname])",
2712 __FILE__, DDataStd_GetReal, g);
2714 theCommands.Add ("GetReference",
2715 "GetReference (DF, entry)",
2716 __FILE__, DDataStd_GetReference, g);
2719 theCommands.Add ("GetComment",
2720 "GetComment (DF, entry)",
2721 __FILE__, DDataStd_GetComment, g);
2723 theCommands.Add("Self",
2724 "Self(document, entry)",
2725 __FILE__, DDataStd_Self, g);
2727 theCommands.Add ("GetUAttribute",
2728 "GetUAttribute (DF, entry)",
2729 __FILE__, DDataStd_GetUAttribute, g);
2731 theCommands.Add ("GetVariable",
2732 "GetVariable (DF, entry, [isConstant], [units])",
2733 __FILE__, DDataStd_GetVariable, g);
2735 theCommands.Add ("SetRelation",
2736 "SetRelation (DF, entry, expression, var1[, var2, ...])",
2737 __FILE__, DDataStd_SetRelation, g);
2739 theCommands.Add ("DumpRelation",
2740 "DumpRelation (DF, entry)",
2741 __FILE__, DDataStd_DumpRelation, g);
2743 theCommands.Add ("GetBooleanArray",
2744 "GetBooleanArray (DF, entry )",
2745 __FILE__, DDataStd_GetBooleanArray, g);
2747 theCommands.Add ("GetBooleanList",
2748 "GetBooleanList (DF, entry )",
2749 __FILE__, DDataStd_GetBooleanList, g);
2751 theCommands.Add ("GetIntegerList",
2752 "GetIntegerList (DF, entry )",
2753 __FILE__, DDataStd_GetIntegerList, g);
2755 theCommands.Add ("GetRealList",
2756 "GetRealList (DF, entry )",
2757 __FILE__, DDataStd_GetRealList, g);
2761 // ========================= UTF =====================================
2762 const char* ggg = "UTF Commands";
2764 theCommands.Add ("SetUTFName",
2765 "SetUTFName (DF, entry, fileName)",
2766 __FILE__, DDataStd_KeepUTF, ggg);
2768 theCommands.Add ("GetUTF",
2769 "GetUTF (DF, entry, fileName)",
2770 __FILE__, DDataStd_GetUTFtoFile, ggg);
2772 //======================= NData Commands ========================
2774 const char* gN = "NData Commands";
2775 theCommands.Add ("SetNDataIntegers",
2776 "SetNDataIntegers (DF, entry, NumPairs, key1, val1, ... )",
2777 __FILE__, DDataStd_SetNDataIntegers, gN);
2779 theCommands.Add ("SetNDataReals",
2780 "SetNDataReals (DF, entry, NumPairs, key1, val1, ... )",
2781 __FILE__, DDataStd_SetNDataReals, gN);
2783 theCommands.Add ("SetNDataStrings",
2784 "SetNDataStrings (DF, entry, NumPairs, key1, val1, ... )",
2785 __FILE__, DDataStd_SetNDataStrings, gN);
2787 theCommands.Add ("SetNDataBytes",
2788 "SetNDataBytes (DF, entry, NumPairs, key1, val1, ... )",
2789 __FILE__, DDataStd_SetNDataBytes, gN);
2791 theCommands.Add ("SetNDataIntArrays",
2792 "SetNDataIntArrays (DF entry entry key NumOfArrElems val1 val2... )",
2793 __FILE__, DDataStd_SetNDataIntAr, gN);
2795 theCommands.Add ("SetNDataRealArrays",
2796 "SetNDataRealArrays (DF entry key NumOfArrElems val1 val2... )",
2797 __FILE__, DDataStd_SetNDataRealAr, gN);
2801 theCommands.Add ("GetNDIntegers",
2802 "GetNDIntegers (DF, entry )",
2803 __FILE__, DDataStd_GetNDIntegers, g);
2805 theCommands.Add ("GetNDInteger",
2806 "GetNDInteger (DF entry key [drawname])",
2807 __FILE__, DDataStd_GetNDInteger, g);
2809 theCommands.Add ("GetNDReals",
2810 "GetNDReals (DF entry )",
2811 __FILE__, DDataStd_GetNDReals, g);
2813 theCommands.Add ("GetNDReal",
2814 "GetNDReal (DF entry key [drawname])",
2815 __FILE__, DDataStd_GetNDReal, g);
2817 theCommands.Add ("GetNDStrings",
2818 "GetNDStrings (DF entry )",
2819 __FILE__, DDataStd_GetNDStrings, g);
2821 theCommands.Add ("GetNDString",
2822 "GetNDString (DF entry key [drawname])",
2823 __FILE__, DDataStd_GetNDString, g);
2825 theCommands.Add ("GetNDBytes",
2826 "GetNDBytes (DF entry )",
2827 __FILE__, DDataStd_GetNDBytes, g);
2829 theCommands.Add ("GetNDByte",
2830 "GetNDByte (DF entry key [drawname])",
2831 __FILE__, DDataStd_GetNDByte, g);
2833 theCommands.Add ("GetNDIntArrays",
2834 "GetNDIntArrays (DF, entry )",
2835 __FILE__, DDataStd_GetNDIntArrays, g);
2837 theCommands.Add ("GetNDIntArray",
2838 "GetNDIntArray (DF entry key )",
2839 __FILE__, DDataStd_GetNDIntArray, g);
2841 theCommands.Add ("GetNDRealArrays",
2842 "GetNDRealArrays (DF entry )",
2843 __FILE__, DDataStd_GetNDRealArrays, g);
2845 theCommands.Add ("GetNDRealArray",
2846 "GetNDRealArray (DF entry key )",
2847 __FILE__, DDataStd_GetNDRealArray, g);
2849 //====================== Change =======================
2850 theCommands.Add ("ChangeByteArray",
2851 "ChangeByteArray (DF, entry, indx, value )",
2852 __FILE__, DDataStd_ChangeByteArray, g);
2854 theCommands.Add ("ChangeIntArray",
2855 "ChangeIntArray (DF, entry, indx, value )",
2856 __FILE__, DDataStd_ChangeIntArray, g);
2858 theCommands.Add ("ChangeRealArray",
2859 "ChangeRealArray (DF, entry, indx, value )",
2860 __FILE__, DDataStd_ChangeRealArray, g);
2862 theCommands.Add ("ChangeExtStrArray",
2863 "ChangeExtStrArray (DF, entry, indx, value )",
2864 __FILE__, DDataStd_ChangeExtStrArray, g);
2866 theCommands.Add ("ChangeIntPackedMap_Add",
2867 "ChangeIntPackedMAp_Add (DF, entry, key[,key [...]] )",
2868 __FILE__, DDataStd_ChangeIntPackedMap_Add, g);
2870 theCommands.Add ("ChangeIntPackedMap_Rem",
2871 "ChangeIntPackedMAp_Rem (DF, entry, key[,key [...]] )",
2872 __FILE__, DDataStd_ChangeIntPackedMap_Rem, g);
2874 theCommands.Add ("ChangeIntPackedMap_AddRem",
2875 "ChangeIntPackedMAp_AddRem (DF, entry, key[,key [...]] )",
2876 __FILE__, DDataStd_ChangeIntPackedMap_AddRem, g);
2878 //=========================================================
2879 // TFunction commands
2880 const char* gg = "DFunction Commands";
2882 theCommands.Add ("SetFunction",
2883 "SetFunction (DF, entry, guid, failure)",
2884 __FILE__, DDataStd_SetFunction, gg);
2886 theCommands.Add ("GetFunction",
2887 "GetFunction (DF, entry, guid(out), failure(out))",
2888 __FILE__, DDataStd_GetFunction, gg);
2890 //=========================================================
2893 //======================================================================
2894 //======= for internal use
2896 theCommands.Add ("SetNDataIntegers2",
2897 "SetNDataIntegers2 (DF, entry, NumPair )",
2898 __FILE__, DDataStd_SetNDataIntegers2, gN);
2900 theCommands.Add ("SetNDataIntArrays2",
2901 "SetNDataIntArrays2 (DF entry entry key NumOfArrElems)",
2902 __FILE__, DDataStd_SetNDataIntAr2, gN);
2904 theCommands.Add ("SetIntArrayT",
2905 "SetIntArrayT (DF, entry, isDelta, From, To )",
2906 __FILE__, DDataStd_SetIntArrayTest, g);
2908 theCommands.Add ("SetIntPHugeMap",
2909 "SetIntPHugeMap (DF, entry, isDelta Num)",
2910 __FILE__, DDataStd_SetIntPHugeMap, g);