1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 // Interface_Translates.hxx
16 // This set of macros provides some simple translation formula, i.e.
17 // from a HSequence to an HArray and reverse
18 // Include files for the types of HSequence and HArray1 remain to be called
19 // Other kinds of translations remain to be completely written
21 // from HSequence to HArray1 : creates the HArray1 if HSequence not empty
22 // from HArray1 to HSequence : the HSequence must have been already created
24 // SeqToArray(seq,arr,TColStd_HArray1OfReal) will :
25 // consider <seq> input HSequence (here, must be TColStd_HSequenceOfReal)
26 // consider <arr> output HArray1, declared but to be created
27 // do nothing if <seq> is null or empty; else
28 // create <arr> as TColStd_HArrayOfReal(1,seq->Length())
29 // then fill each value of <arr> with the homologous from <seq>
31 // SeqToArrayFrom(seq,arr,TColStd_HArray1OfReal,lowind) will :
32 // consider <lowind> as an Integer (variable or constant) which defines
33 // the desired lower index if different from one
34 // do the same thing as SeqToArray if <lowind> equates 1
35 // else fixes lower index of <arr> as <lowind>
37 // SeqToArrayCast(seq,arr,Interface_HArray1OfHAsciiString,TCollection_HAsciiString) will :
38 // do as SeqToArray, but array values are Handles to be casted
39 // (if <seq> does not work with the same type, e.g. Standard_Transient)
40 // fill array value by the result of DownCast of the type <typent>
42 // ArrayToSeq(arr,seq) will fill <seq> a sequence with the items of <arr> a
43 // HArray1. <seq> and <arr> are already created (<seq> can be empty or not)
44 // Items from <arr> are considered as compatible with items from <seq>
45 // (no DownCast required for Handles)
48 #define SeqToArrayFrom(seq,arr,typarr,lowind) \
50 Standard_Integer numseq, lenseq = seq->Length();\
52 arr = new typarr (lowind,lenseq+1-lowind);\
53 for (numseq = 1; numseq <= lenseq; numseq ++)\
54 arr->SetValue (numseq+1-lowind, seq->Value(numseq));\
58 #define SeqToArray(seq,arr,typarr) \
60 Standard_Integer numseq, lenseq = seq->Length();\
62 arr = new typarr (1,lenseq);\
63 for (numseq = 1; numseq <= lenseq; numseq ++)\
64 arr->SetValue (numseq, seq->Value(numseq));\
68 #define SeqToArrayCast(seq,arr,typarr,typent) \
70 Standard_Integer numseq, lenseq = seq->Length();\
72 arr = new typarr (1,lenseq);\
73 for (numseq = 1; numseq <= lenseq; numseq ++)\
74 arr->SetValue (numseq, Handle(typent)::DownCast(seq->Value(numseq)));\
78 #define ArrayToSeq (arr,seq)\
80 Standard_Integer nument, numlow = arr->Lower() , numup = arr->Upper();\
81 for (nument = numlow; nument <= numup; nument ++)\
82 seq->Append(arr->Value(nument));\