973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | // Interface_Translates.hxx |
15 | |
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 |
20 | |
21 | // from HSequence to HArray1 : creates the HArray1 if HSequence not empty |
22 | // from HArray1 to HSequence : the HSequence must have been already created |
23 | |
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> |
30 | |
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> |
36 | |
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> |
41 | |
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) |
46 | |
47 | |
48 | #define SeqToArrayFrom(seq,arr,typarr,lowind) \ |
b311480e |
49 | if (!seq.IsNull()) {\ |
7fd59977 |
50 | Standard_Integer numseq, lenseq = seq->Length();\ |
51 | if (lenseq > 0) {\ |
52 | arr = new typarr (lowind,lenseq+1-lowind);\ |
53 | for (numseq = 1; numseq <= lenseq; numseq ++)\ |
54 | arr->SetValue (numseq+1-lowind, seq->Value(numseq));\ |
55 | }\ |
56 | } |
57 | |
58 | #define SeqToArray(seq,arr,typarr) \ |
59 | if (!seq.IsNull()) {\ |
60 | Standard_Integer numseq, lenseq = seq->Length();\ |
61 | if (lenseq > 0) {\ |
62 | arr = new typarr (1,lenseq);\ |
63 | for (numseq = 1; numseq <= lenseq; numseq ++)\ |
64 | arr->SetValue (numseq, seq->Value(numseq));\ |
65 | }\ |
66 | } |
67 | |
68 | #define SeqToArrayCast(seq,arr,typarr,typent) \ |
69 | if (!seq.IsNull()) {\ |
70 | Standard_Integer numseq, lenseq = seq->Length();\ |
71 | if (lenseq > 0) {\ |
72 | arr = new typarr (1,lenseq);\ |
73 | for (numseq = 1; numseq <= lenseq; numseq ++)\ |
74 | arr->SetValue (numseq, Handle(typent)::DownCast(seq->Value(numseq)));\ |
75 | }\ |
76 | } |
77 | |
78 | #define ArrayToSeq (arr,seq)\ |
79 | {\ |
80 | Standard_Integer nument, numlow = arr->Lower() , numup = arr->Upper();\ |
81 | for (nument = numlow; nument <= numup; nument ++)\ |
82 | seq->Append(arr->Value(nument));\ |
83 | } |