1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Interface_Translates.hxx
// This set of macros provides some simple translation formula, i.e.
// from a HSequence to an HArray and reverse
// Include files for the types of HSequence and HArray1 remain to be called
// Other kinds of translations remain to be completely written
// from HSequence to HArray1 : creates the HArray1 if HSequence not empty
// from HArray1 to HSequence : the HSequence must have been already created
// SeqToArray(seq,arr,TColStd_HArray1OfReal) will :
// consider <seq> input HSequence (here, must be TColStd_HSequenceOfReal)
// consider <arr> output HArray1, declared but to be created
// do nothing if <seq> is null or empty; else
// create <arr> as TColStd_HArrayOfReal(1,seq->Length())
// then fill each value of <arr> with the homologous from <seq>
// SeqToArrayFrom(seq,arr,TColStd_HArray1OfReal,lowind) will :
// consider <lowind> as an Integer (variable or constant) which defines
// the desired lower index if different from one
// do the same thing as SeqToArray if <lowind> equates 1
// else fixes lower index of <arr> as <lowind>
// SeqToArrayCast(seq,arr,Interface_HArray1OfHAsciiString,TCollection_HAsciiString) will :
// do as SeqToArray, but array values are Handles to be casted
// (if <seq> does not work with the same type, e.g. Standard_Transient)
// fill array value by the result of DownCast of the type <typent>
// ArrayToSeq(arr,seq) will fill <seq> a sequence with the items of <arr> a
// HArray1. <seq> and <arr> are already created (<seq> can be empty or not)
// Items from <arr> are considered as compatible with items from <seq>
// (no DownCast required for Handles)
#define SeqToArrayFrom(seq,arr,typarr,lowind) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (lowind,lenseq+1-lowind);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq+1-lowind, seq->Value(numseq));\
}\
}
#define SeqToArray(seq,arr,typarr) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (1,lenseq);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq, seq->Value(numseq));\
}\
}
#define SeqToArrayCast(seq,arr,typarr,typent) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (1,lenseq);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq, Handle(typent)::DownCast(seq->Value(numseq)));\
}\
}
#define ArrayToSeq (arr,seq)\
{\
Standard_Integer nument, numlow = arr->Lower() , numup = arr->Upper();\
for (nument = numlow; nument <= numup; nument ++)\
seq->Append(arr->Value(nument));\
}
|