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