Test for 0022778: Bug in BRepMesh
[occt.git] / src / XSControl / XSControl_Utils.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <XSControl_Utils.ixx>
19#include <Message_Messenger.hxx>
20#include <Message.hxx>
21#include <Interface_Macros.hxx>
22#include <Interface_MSG.hxx>
23
24#include <TColStd_HSequenceOfAsciiString.hxx>
25#include <TColStd_HSequenceOfExtendedString.hxx>
26#include <TColStd_HArray1OfTransient.hxx>
27#include <Interface_HArray1OfHAsciiString.hxx>
28
29#include <TransferBRep.hxx>
30#include <TransferBRep_ShapeBinder.hxx>
31#include <TransferBRep_ShapeMapper.hxx>
32#include <TopoDS_HShape.hxx>
33#include <TopoDS.hxx>
34#include <TopoDS_Wire.hxx>
35#include <TopoDS_Shell.hxx>
36#include <TopoDS_Compound.hxx>
37#include <TopoDS_Iterator.hxx>
38#include <TopExp_Explorer.hxx>
39#include <Transfer_SimpleBinderOfTransient.hxx>
40
41#include <BRep_Builder.hxx>
42#include <BRepTools.hxx>
43
44
45static TCollection_AsciiString bufasc;
46static TCollection_ExtendedString bufext;
47static const Standard_ExtString voidext = { 0 };
48
49
50 XSControl_Utils::XSControl_Utils () { }
51
52// #########################################################
53// ####### Fonctions de TRACE #######
54
55 void XSControl_Utils::TraceLine (const Standard_CString line) const
56{
57 Handle(Message_Messenger) sout = Message::DefaultMessenger();
58 sout<<line<<endl;
59}
60
61 void XSControl_Utils::TraceLines (const Handle(Standard_Transient)& lines) const
62{
63 Handle(Message_Messenger) sout = Message::DefaultMessenger();
64 Standard_Integer i,nb;
65 DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,lines);
66 if (!linha.IsNull()) {
67 nb = linha->Length();
68 for (i = 1; i <= nb; i ++)
69 if (!linha->Value(i).IsNull()) sout<<linha->Value(i)->ToCString()<<endl;
70 return;
71 }
72 DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,lines);
73 if (!lina.IsNull()) {
74 nb = lina->Length();
75 for (i = 1; i <= nb; i ++)
76 sout<<lina->Value(i).ToCString()<<endl;
77 return;
78 }
79 DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,lines);
80 if (!linhe.IsNull()) {
81 nb = linhe->Length();
82 for (i = 1; i <= nb; i ++)
83 if (!linhe->Value(i).IsNull())
84 sout << linhe->Value(i) << endl;
85 return;
86 }
87 DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,lines);
88 if (!linee.IsNull()) {
89 nb = linee->Length();
90 for (i = 1; i <= nb; i ++)
91 sout << linee->Value(i) << endl;
92 return;
93 }
94 DeclareAndCast(TCollection_HAsciiString,lin1a,lines);
95 if (!lin1a.IsNull()) sout<<lin1a;
96 DeclareAndCast(TCollection_HExtendedString,lin1e,lines);
97 if (!lin1e.IsNull()) sout<<lin1e;
98}
99
100
101// #########################################################
102// ####### TRANSIENT : Quelques acces de base #######
103
104 Standard_Boolean XSControl_Utils::IsKind
105 (const Handle(Standard_Transient)& item, const Handle(Standard_Type)& what) const
106{
107 if (item.IsNull()) return Standard_False;
108 if (what.IsNull()) return Standard_False;
109 return item->IsKind(what);
110}
111
112 Standard_CString XSControl_Utils::TypeName
113 (const Handle(Standard_Transient)& item, const Standard_Boolean nopk) const
114{
115 if (item.IsNull()) return "";
116 DeclareAndCast(Standard_Type,atype,item);
117 if (atype.IsNull()) atype = item->DynamicType();
118 Standard_CString tn = atype->Name();
119 if (!nopk) return tn;
120 for (int i = 0; tn[i] != '\0'; i ++) {
121 if (tn[i] == '_') return &tn[i+1];
122 }
123 return tn;
124}
125
126
127// ####### TRANSIENT : Fonctions de liste #######
128
129 Handle(Standard_Transient) XSControl_Utils::TraValue
130 (const Handle(Standard_Transient)& seqval, const Standard_Integer num) const
131{
132 Handle(Standard_Transient) val;
133 if (num < 1) return val;
134 if (seqval.IsNull()) return val;
135 DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
136 if (!seqs.IsNull())
137 { if (num <= seqs->Length()) val = seqs->Value(num); return val; }
138 DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
139 if (!seqt.IsNull())
140 { if (num <= seqt->Length()) val = seqt->Value(num); return val; }
141// Standard_TypeMismatch::Raise("XSControl_Utils::SeqTraValue");
142 return val;
143}
144
145 Handle(TColStd_HSequenceOfTransient) XSControl_Utils::NewSeqTra () const
146 { return new TColStd_HSequenceOfTransient(); }
147
148 void XSControl_Utils::AppendTra
149 (const Handle(TColStd_HSequenceOfTransient)& seqval,
150 const Handle(Standard_Transient)& traval) const
151 { seqval->Append (traval); }
152
153
154// ####### DATES #######
155
156 Standard_CString XSControl_Utils::DateString
157 (const Standard_Integer yy, const Standard_Integer mm,
158 const Standard_Integer dd, const Standard_Integer hh,
159 const Standard_Integer mn, const Standard_Integer ss) const
160{
161 char ladate[50];
162 Interface_MSG::TDate (ladate, yy,mm,dd,hh,mn,ss);
163 bufasc.Clear(); bufasc.AssignCat(ladate);
164 return bufasc.ToCString();
165}
166
167 void XSControl_Utils::DateValues
168 (const Standard_CString text,
169 Standard_Integer& yy, Standard_Integer& mm, Standard_Integer& dd,
170 Standard_Integer& hh, Standard_Integer& mn, Standard_Integer& ss) const
171 { Interface_MSG::NDate (text, yy,mm,dd,hh,mn,ss); }
172
173
174// ##########################################################
175// ####### STRING : Ascii de base #######
176
177 Standard_CString XSControl_Utils::ToCString
178 (const Handle(TCollection_HAsciiString)& strval) const
179 {
180//JR/Hp
181 Standard_CString astr = (Standard_CString ) (strval.IsNull() ? "" : strval->ToCString());
182 return astr ;
183// return (strval.IsNull() ? "" : strval->ToCString());
184 }
185
186 Standard_CString XSControl_Utils::ToCString
187 (const TCollection_AsciiString& strval) const
188 { return strval.ToCString(); }
189
190 Handle(TCollection_HAsciiString) XSControl_Utils::ToHString
191 (const Standard_CString strcon) const
192 { return new TCollection_HAsciiString(strcon); }
193
194 TCollection_AsciiString XSControl_Utils::ToAString
195 (const Standard_CString strcon) const
196 { return TCollection_AsciiString(strcon); }
197
198// ####### STRING : Extended de base #######
199
200 Standard_ExtString XSControl_Utils::ToEString
201 (const Handle(TCollection_HExtendedString)& strval) const
202 { return (strval.IsNull() ? voidext : strval->ToExtString()); }
203
204 Standard_ExtString XSControl_Utils::ToEString
205 (const TCollection_ExtendedString& strval) const
206 { return strval.ToExtString(); }
207
208 Handle(TCollection_HExtendedString) XSControl_Utils::ToHString
209 (const Standard_ExtString strcon) const
210 { return new TCollection_HExtendedString(strcon); }
211
212 TCollection_ExtendedString XSControl_Utils::ToXString
213 (const Standard_ExtString strcon) const
214 { return TCollection_ExtendedString(strcon); }
215
216// ####### STRING : Ascii <-> Extended #######
217
218 Standard_ExtString XSControl_Utils::AsciiToExtended (const Standard_CString str) const
219{
220 bufext.Clear(); bufext = TCollection_ExtendedString (str);
221 return bufext.ToExtString();
222}
223
224 Standard_Boolean XSControl_Utils::IsAscii (const Standard_ExtString str) const
225{
226 bufext.Clear(); bufext.AssignCat (str);
227 return bufext.IsAscii();
228}
229
230 Standard_CString XSControl_Utils::ExtendedToAscii (const Standard_ExtString str) const
231{
232 bufext.Clear(); bufext.AssignCat (str); bufasc.Clear();
233 Standard_Integer i, nb = bufext.Length();
234 for (i = 1; i <= nb; i ++) {
235 int unext = bufext.Value(i);
236 unext = unext & 127;
237 char uncar = char(unext);
238 bufasc.AssignCat (uncar);
239 }
240 return bufasc.ToCString();
241}
242
243// ####### STRING : LISTES #######
244
245 Standard_CString XSControl_Utils::CStrValue
246 (const Handle(Standard_Transient)& list, const Standard_Integer num) const
247{
248 DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,list);
249 if (!linha.IsNull()) {
250//JR/Hp
251 Standard_CString astr = (Standard_CString )
252 (num > linha->Length() ? "" : linha->Value(num)->ToCString());
253 return astr ;
254// return (num > linha->Length() ? "" : linha->Value(num)->ToCString());
255 }
256
257 DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,list);
258 if (!lina.IsNull()) {
259//JR/Hp
260 Standard_CString astr = (Standard_CString )
261 (num > lina->Length() ? "" : lina->Value(num).ToCString());
262 return astr ;
263// return (num > lina->Length() ? "" : lina->Value(num).ToCString());
264 }
265
266 DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,list);
267 if (!linhe.IsNull()) {
268//JR/Hp
269 Standard_CString astr = (Standard_CString )
270 (num > linhe->Length() ? "" : ExtendedToAscii(linhe->Value(num)->ToExtString()));
271 return astr ;
272// return (num > linhe->Length() ? "" : ExtendedToAscii(linhe->Value(num)->ToExtString()));
273 }
274
275 DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,list);
276 if (!linee.IsNull()) {
277//JR/Hp
278 Standard_CString astr = (Standard_CString )
279 (num > linee->Length() ? "" : ExtendedToAscii(linee->Value(num).ToExtString()));
280 return astr ;
281// return (num > linee->Length() ? "" : ExtendedToAscii(linee->Value(num).T
282 }
283
284 DeclareAndCast(TCollection_HAsciiString,lin1a,list);
285 if (!lin1a.IsNull()) return lin1a->ToCString();
286 DeclareAndCast(TCollection_HExtendedString,lin1e,list);
287 if (!lin1e.IsNull()) return ExtendedToAscii(lin1e->ToExtString());
288 return "";
289}
290
291
292 Standard_ExtString XSControl_Utils::EStrValue
293 (const Handle(Standard_Transient)& list, const Standard_Integer num) const
294{
295 DeclareAndCast(TColStd_HSequenceOfHAsciiString,linha,list);
296 if (!linha.IsNull()) return
297 (num > linha->Length() ? voidext : AsciiToExtended(linha->Value(num)->ToCString()));
298
299 DeclareAndCast(TColStd_HSequenceOfAsciiString,lina,list);
300 if (!lina.IsNull())
301 (num > lina->Length() ? voidext : AsciiToExtended(lina->Value(num).ToCString()));
302
303 DeclareAndCast(TColStd_HSequenceOfHExtendedString,linhe,list);
304 if (!linhe.IsNull()) return
305 (num > linhe->Length() ? voidext : linhe->Value(num)->ToExtString());
306
307 DeclareAndCast(TColStd_HSequenceOfExtendedString,linee,list);
308 if (!linee.IsNull()) return
309 (num > linee->Length() ? voidext : linee->Value(num).ToExtString());
310
311 DeclareAndCast(TCollection_HAsciiString,lin1a,list);
312 if (!lin1a.IsNull()) return AsciiToExtended(lin1a->ToCString());
313 DeclareAndCast(TCollection_HExtendedString,lin1e,list);
314 if (!lin1e.IsNull()) return lin1e->ToExtString();
315 return voidext;
316}
317
318 Handle(TColStd_HSequenceOfHAsciiString) XSControl_Utils::NewSeqCStr () const
319 { return new TColStd_HSequenceOfHAsciiString(); }
320
321 void XSControl_Utils::AppendCStr
322 (const Handle(TColStd_HSequenceOfHAsciiString)& seqval,
323 const Standard_CString strval) const
324 { seqval->Append (new TCollection_HAsciiString(strval)); }
325
326 Handle(TColStd_HSequenceOfHExtendedString) XSControl_Utils::NewSeqEStr () const
327 { return new TColStd_HSequenceOfHExtendedString(); }
328
329 void XSControl_Utils::AppendEStr
330 (const Handle(TColStd_HSequenceOfHExtendedString)& seqval,
331 const Standard_ExtString strval) const
332 { seqval->Append (new TCollection_HExtendedString(strval)); }
333
334
335// ##########################################################
336// ####### SHAPES : Acces de base #######
337
338 Standard_Boolean XSControl_Utils::WriteShape
339 (const TopoDS_Shape& shape,
340 const Standard_CString filename) const
341 { return BRepTools::Write (shape,filename); }
342
343 TopoDS_Shape XSControl_Utils::NewShape () const
344 { TopoDS_Shape shape; return shape; }
345
346 Standard_Boolean XSControl_Utils::ReadShape
347 (TopoDS_Shape& shape,
348 const Standard_CString filename) const
349{
350 BRep_Builder B;
351 return BRepTools::Read (shape,filename,B);
352}
353
354 Standard_Boolean XSControl_Utils::IsNullShape (const TopoDS_Shape& shape) const
355 { return shape.IsNull(); }
356
357
358 TopoDS_Shape XSControl_Utils::CompoundFromSeq
359 (const Handle(TopTools_HSequenceOfShape)& seqval) const
360{
361 BRep_Builder B;
362 TopoDS_Compound C;
363 B.MakeCompound(C);
364 Standard_Integer i,n = seqval->Length();
365 for (i = 1; i <= n ; i ++) B.Add(C,seqval->Value(i));
366 return C;
367}
368
369 TopAbs_ShapeEnum XSControl_Utils::ShapeType
370 (const TopoDS_Shape& shape, const Standard_Boolean compound) const
371{
372 if (shape.IsNull()) return TopAbs_SHAPE;
373 TopAbs_ShapeEnum res = shape.ShapeType();
374 if (!compound || res != TopAbs_COMPOUND) return res;
375 res = TopAbs_SHAPE;
376 for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) {
377 TopoDS_Shape sh = iter.Value();
378 if (sh.IsNull()) continue;
379 TopAbs_ShapeEnum typ = sh.ShapeType();
380 if (typ == TopAbs_COMPOUND) typ = ShapeType (sh,compound);
381 if (res == TopAbs_SHAPE) res = typ;
382// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
383 else if (res == TopAbs_EDGE && typ == TopAbs_WIRE) res = typ;
384 else if (res == TopAbs_WIRE && typ == TopAbs_EDGE) continue;
385 else if (res == TopAbs_FACE && typ == TopAbs_SHELL) res = typ;
386 else if (res == TopAbs_SHELL && typ == TopAbs_FACE) continue;
387 else if (res != typ) return TopAbs_COMPOUND;
388 }
389 return res;
390}
391
392 TopoDS_Shape XSControl_Utils::SortedCompound
393 (const TopoDS_Shape& shape, const TopAbs_ShapeEnum type,
394 const Standard_Boolean explore, const Standard_Boolean compound) const
395{
396 if (shape.IsNull()) return shape;
397 TopAbs_ShapeEnum typ = shape.ShapeType();
398 TopoDS_Shape sh, sh0;
399 Standard_Integer nb = 0;
400
401// Compound : on le prend, soit tel quel, soit son contenu
402 if (typ == TopAbs_COMPOUND || typ == TopAbs_COMPSOLID) {
403 TopoDS_Compound C;
404 BRep_Builder B;
405 B.MakeCompound (C);
406 for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
407 sh0 = SortedCompound (it.Value(),type,explore,compound);
408 if (sh0.IsNull()) continue;
409 sh = sh0;
410 typ = sh.ShapeType();
411 if (typ == TopAbs_COMPOUND && !compound) {
412 for (TopoDS_Iterator it2 (sh); it2.More(); it2.Next())
413 { nb ++; sh = it2.Value(); B.Add (C, sh); }
414 }
415 else { nb ++; B.Add (C,sh); }
416 }
417 if (nb == 0) C.Nullify();
418 else if (nb == 1) return sh;
419 return C;
420 }
421
422// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
423 if (typ == type) return shape;
424 if (typ == TopAbs_EDGE && type == TopAbs_WIRE) {
425 BRep_Builder B;
426 TopoDS_Wire W;
427 B.MakeWire (W);
428 B.Add (W,shape); // ne passe pas ! : TopoDS::Edge(shape)
429 return W;
430 }
431 if (typ == TopAbs_FACE && type == TopAbs_SHELL) {
432 BRep_Builder B;
433 TopoDS_Shell S;
434 B.MakeShell (S);
435 B.Add (S,shape); // ne passe pas ! : TopoDS::Face(shape));
436 return S;
437 }
438
439// Le reste : selon exploration
440 if (!explore) {
441 TopoDS_Shape nulsh;
442 return nulsh;
443 }
444
445// Ici, on doit explorer
446// SOLID + mode COMPOUND : reconduire les SHELLs
447 if (typ == TopAbs_SOLID && compound) {
448 TopoDS_Compound C;
449 BRep_Builder B;
450 B.MakeCompound (C);
451 for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
452 sh0 = SortedCompound (it.Value(),type,explore,compound);
453 if (sh0.IsNull()) continue;
454 sh = sh0;
455 nb ++; B.Add (C,sh);
456 }
457 if (nb == 0) C.Nullify();
458 else if (nb == 1) return sh;
459 return C;
460 }
461
462// Exploration classique
463 TopoDS_Compound CC;
464 BRep_Builder BB;
465 BB.MakeCompound(CC);
466 for (TopExp_Explorer expl (shape,type); expl.More(); expl.Next()) {
467 nb ++; sh = expl.Current();
468 BB.Add (CC,sh);
469 }
470 if (nb == 0) CC.Nullify();
471 else if (nb == 1) return sh;
472 return CC;
473}
474
475
476// ####### SHAPES : Liste #######
477
478 TopoDS_Shape XSControl_Utils::ShapeValue
479 (const Handle(TopTools_HSequenceOfShape)& seqval, const Standard_Integer num) const
480{
481 TopoDS_Shape shape;
482 if (seqval.IsNull()) return shape;
483 if (num > 0 && num <= seqval->Length()) shape = seqval->Value(num);
484 return shape;
485}
486
487 Handle(TopTools_HSequenceOfShape) XSControl_Utils::NewSeqShape () const
488 { return new TopTools_HSequenceOfShape(); }
489
490 void XSControl_Utils::AppendShape
491 (const Handle(TopTools_HSequenceOfShape)& seqval, const TopoDS_Shape& shape) const
492 { seqval->Append (shape); }
493
494// ####### SHAPES <-> Transient #######
495
496 Handle(Standard_Transient) XSControl_Utils::ShapeBinder
497 (const TopoDS_Shape& shape, const Standard_Boolean hs) const
498 { if (hs) return new TopoDS_HShape (shape);
499 else return new TransferBRep_ShapeBinder (shape); }
500
501 TopoDS_Shape XSControl_Utils::BinderShape
502 (const Handle(Standard_Transient)& tr) const
503{
504 TopoDS_Shape sh;
505 DeclareAndCast(Transfer_Binder,sb,tr);
506 if (!sb.IsNull()) return TransferBRep::ShapeResult(sb);
507 DeclareAndCast(TransferBRep_ShapeMapper,sm,tr);
508 if (!sm.IsNull()) return sm->Value();
509 DeclareAndCast(TopoDS_HShape,hs,tr);
510 if (!hs.IsNull()) return hs->Shape();
511 return sh;
512}
513
514
515// ##########################################################
516// ####### LISTES : Fonctions Generales #######
517
518 Standard_Integer XSControl_Utils::SeqLength
519 (const Handle(Standard_Transient)& seqval) const
520{
521 if (seqval.IsNull()) return 0;
522 DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
523 if (!seqs.IsNull()) return seqs->Length();
524 DeclareAndCast(TColStd_HSequenceOfAsciiString,seqa,seqval);
525 if (!seqa.IsNull()) return seqa->Length();
526 DeclareAndCast(TColStd_HSequenceOfHExtendedString,seqe,seqval);
527 if (!seqe.IsNull()) return seqe->Length();
528 DeclareAndCast(TColStd_HSequenceOfHExtendedString,seqx,seqval);
529 if (!seqx.IsNull()) return seqx->Length();
530
531 DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
532 if (!seqt.IsNull()) return seqt->Length();
533 DeclareAndCast(TopTools_HSequenceOfShape,seqh,seqval);
534 if (!seqh.IsNull()) return seqh->Length();
535 DeclareAndCast(TColStd_HSequenceOfInteger,seqi,seqval);
536 if (!seqi.IsNull()) return seqi->Length();
537// Standard_TypeMismatch::Raise("XSControl_Utils::SeqLength");
538 return 0;
539}
540
541 Handle(Standard_Transient) XSControl_Utils::SeqToArr
542 (const Handle(Standard_Transient)& seqval, const Standard_Integer first) const
543{
544 Standard_Integer i,lng;
545 Handle(Standard_Transient) val;
546 if (seqval.IsNull()) return val;
547 DeclareAndCast(TColStd_HSequenceOfHAsciiString,seqs,seqval);
548 if (!seqs.IsNull()) {
549 lng = seqs->Length();
550 Handle(Interface_HArray1OfHAsciiString) arrs =
551 new Interface_HArray1OfHAsciiString(first,lng-first+1);
552 for (i = 1; i <= lng; i ++) arrs->SetValue (i-first+1,seqs->Value(i));
553 return arrs;
554 }
555 DeclareAndCast(TColStd_HSequenceOfTransient,seqt,seqval);
556 if (!seqt.IsNull()) {
557 lng = seqt->Length();
558 Handle(TColStd_HArray1OfTransient) arrt =
559 new TColStd_HArray1OfTransient(first,lng-first+1);
560 for (i = 1; i <= lng; i ++) arrt->SetValue (i-first+1,seqt->Value(i));
561 return arrt;
562 }
563 Standard_TypeMismatch::Raise("XSControl_Utils::SeqToArr");
564 return val;
565}
566
567
568 Handle(Standard_Transient) XSControl_Utils::ArrToSeq
569 (const Handle(Standard_Transient)& arrval) const
570{
571 Standard_Integer i,first,last;
572 Handle(Standard_Transient) val;
573 if (arrval.IsNull()) return val;
574 DeclareAndCast(Interface_HArray1OfHAsciiString,arrs,arrval);
575 if (!arrs.IsNull()) {
576 first = arrs->Lower();
577 last = arrs->Upper();
578 Handle(TColStd_HSequenceOfHAsciiString) seqs =
579 new TColStd_HSequenceOfHAsciiString();
580 for (i = first; i <= last; i ++) seqs->Append (arrs->Value(i));
581 return seqs;
582 }
583 DeclareAndCast(TColStd_HArray1OfTransient,arrt,arrval);
584 if (!arrt.IsNull()) {
585 first = arrt->Lower();
586 last = arrt->Upper();
587 Handle(TColStd_HSequenceOfTransient) seqt =
588 new TColStd_HSequenceOfTransient();
589 for (i = first; i <= last; i ++) seqt->Append (arrt->Value(i));
590 return seqt;
591 }
592 Standard_TypeMismatch::Raise("XSControl_Utils::ArrToSeq");
593 return val;
594}
595
596
597 Standard_Integer XSControl_Utils::SeqIntValue
598 (const Handle(TColStd_HSequenceOfInteger)& seqval,
599 const Standard_Integer num) const
600{
601 if (seqval.IsNull()) return 0;
602 return seqval->Value(num);
603}