b311480e |
1 | // Created on: 2007-06-27 |
2 | // Created by: Sergey ZARITCHNY |
3 | // Copyright (c) 2007-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | #include <PDataStd_NamedData.ixx> |
22 | #define ROW_NUMBER 6 |
23 | //======================================================================= |
24 | //function : PDataStd_NamedData |
25 | //purpose : |
26 | //======================================================================= |
27 | PDataStd_NamedData::PDataStd_NamedData() { } |
28 | |
29 | //======================================================================= |
30 | //function : Init |
31 | //purpose : |
32 | //======================================================================= |
33 | void PDataStd_NamedData::Init(const Handle(TColStd_HArray2OfInteger)& theDim) |
34 | { |
35 | if(theDim.IsNull()) return; |
36 | if(theDim->RowLength() > 0 && (theDim->UpperRow() - theDim->LowerRow() + 1) == ROW_NUMBER ) { |
37 | myDimensions = new PColStd_HArray2OfInteger(theDim->LowerRow(),theDim->UpperRow(),theDim->LowerCol(),theDim->UpperCol(), 0); |
38 | Standard_Integer i, j = theDim->LowerCol(); |
39 | |
40 | for(i = theDim->LowerRow();i<=theDim->UpperRow(); i++) { |
41 | myDimensions->SetValue(i,j, theDim->Value(i,j)); |
42 | myDimensions->SetValue(i,j+1, theDim->Value(i,j+1)); |
43 | } |
44 | |
45 | i = theDim->LowerRow(); |
46 | //1.Integers |
47 | Standard_Integer aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
48 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
49 | myIntKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
50 | myIntValues = new PColStd_HArray1OfInteger(theDim->Value(i,j), theDim->Value(i,j+1)); |
51 | } |
52 | //2.Reals |
53 | i++; |
54 | aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
55 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
56 | myRealKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
57 | myRealValues = new PColStd_HArray1OfReal(theDim->Value(i,j), theDim->Value(i,j+1)); |
58 | } |
59 | //3.Strings |
60 | i++; |
61 | aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
62 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
63 | myStrKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
64 | myStrValues = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
65 | } |
66 | |
67 | //4.Bytes |
68 | i++; |
69 | aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
70 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
71 | myByteKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
72 | myByteValues = new PDataStd_HArray1OfByte(theDim->Value(i,j), theDim->Value(i,j+1)); |
73 | } |
74 | |
75 | //5.ArraysOfIntegers |
76 | i++; |
77 | aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
78 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
79 | myArrIntKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
80 | myArrIntValues = new PDataStd_HArray1OfHArray1OfInteger(theDim->Value(i,j), theDim->Value(i,j+1)); |
81 | } |
82 | |
83 | //6. |
84 | i++; |
85 | aSize = theDim->Value(i,j+1) - theDim->Value(i,j); |
86 | if(aSize>=0 && (theDim->Value(i,j) | theDim->Value(i,j+1))) { |
87 | myArrRealKeys = new PColStd_HArray1OfExtendedString (theDim->Value(i,j), theDim->Value(i,j+1)); |
88 | myArrRealValues = new PDataStd_HArray1OfHArray1OfReal(theDim->Value(i,j), theDim->Value(i,j+1)); |
89 | } |
90 | |
91 | } |
92 | } |
93 | |
94 | //======================================================================= |
95 | //function : LowerI |
96 | //purpose : |
97 | //======================================================================= |
98 | Standard_Integer PDataStd_NamedData::LowerI() const |
99 | { |
100 | return myDimensions->Value(myDimensions->LowerRow(),myDimensions->LowerCol()); |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : UpperI |
105 | //purpose : |
106 | //======================================================================= |
107 | Standard_Integer PDataStd_NamedData::UpperI() const |
108 | { |
109 | return myDimensions->Value(myDimensions->LowerRow(),myDimensions->UpperCol()); |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : LowerR |
114 | //purpose : |
115 | //======================================================================= |
116 | Standard_Integer PDataStd_NamedData::LowerR() const |
117 | { |
118 | return myDimensions->Value(myDimensions->LowerRow()+1,myDimensions->LowerCol()); |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : UpperR |
123 | //purpose : |
124 | //======================================================================= |
125 | Standard_Integer PDataStd_NamedData::UpperR() const |
126 | { |
127 | return myDimensions->Value(myDimensions->LowerRow()+1,myDimensions->UpperCol()); |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : LowerS |
132 | //purpose : |
133 | //======================================================================= |
134 | Standard_Integer PDataStd_NamedData::LowerS() const |
135 | { |
136 | return myDimensions->Value(myDimensions->LowerRow()+2,myDimensions->LowerCol()); |
137 | } |
138 | |
139 | //======================================================================= |
140 | //function : UpperS |
141 | //purpose : |
142 | //======================================================================= |
143 | Standard_Integer PDataStd_NamedData::UpperS() const |
144 | { |
145 | return myDimensions->Value(myDimensions->LowerRow()+2,myDimensions->UpperCol()); |
146 | } |
147 | |
148 | //======================================================================= |
149 | //function : LowerB |
150 | //purpose : |
151 | //======================================================================= |
152 | Standard_Integer PDataStd_NamedData::LowerB() const |
153 | { |
154 | return myDimensions->Value(myDimensions->LowerRow()+3,myDimensions->LowerCol()); |
155 | } |
156 | |
157 | //======================================================================= |
158 | //function : UpperB |
159 | //purpose : |
160 | //======================================================================= |
161 | Standard_Integer PDataStd_NamedData::UpperB() const |
162 | { |
163 | return myDimensions->Value(myDimensions->LowerRow()+3,myDimensions->UpperCol()); |
164 | } |
165 | |
166 | //======================================================================= |
167 | //function : LowerAI |
168 | //purpose : |
169 | //======================================================================= |
170 | Standard_Integer PDataStd_NamedData::LowerAI() const |
171 | { |
172 | return myDimensions->Value(myDimensions->LowerRow()+4,myDimensions->LowerCol()); |
173 | } |
174 | |
175 | //======================================================================= |
176 | //function : UpperAI |
177 | //purpose : |
178 | //======================================================================= |
179 | Standard_Integer PDataStd_NamedData::UpperAI() const |
180 | { |
181 | return myDimensions->Value(myDimensions->LowerRow()+4,myDimensions->UpperCol()); |
182 | } |
183 | |
184 | //======================================================================= |
185 | //function : LowerAR |
186 | //purpose : |
187 | //======================================================================= |
188 | Standard_Integer PDataStd_NamedData::LowerAR() const |
189 | { |
190 | return myDimensions->Value(myDimensions->LowerRow()+5,myDimensions->LowerCol()); |
191 | } |
192 | |
193 | //======================================================================= |
194 | //function : UpperAR |
195 | //purpose : |
196 | //======================================================================= |
197 | Standard_Integer PDataStd_NamedData::UpperAR() const |
198 | { |
199 | return myDimensions->Value(myDimensions->LowerRow()+5,myDimensions->UpperCol()); |
200 | } |
201 | |
202 | |
203 | //======================================================================= |
204 | //function : SetIntDataItem |
205 | //purpose : |
206 | //======================================================================= |
207 | void PDataStd_NamedData::SetIntDataItem(const Standard_Integer index, |
208 | const Handle(PCollection_HExtendedString)& key, |
209 | const Standard_Integer value) |
210 | { |
211 | if(myIntKeys.IsNull() || myIntValues.IsNull()) return; |
212 | myIntKeys->SetValue(index, key); |
213 | myIntValues->SetValue(index, value); |
214 | } |
215 | |
216 | //======================================================================= |
217 | //function : IntDataItemValue |
218 | //purpose : |
219 | //======================================================================= |
220 | Standard_Integer PDataStd_NamedData::IntDataItemValue(const Standard_Integer index, |
221 | Handle(PCollection_HExtendedString)& key) const |
222 | { |
223 | if(myIntKeys.IsNull() || myIntValues.IsNull()) return 0; |
224 | key = myIntKeys->Value(index); |
225 | return myIntValues->Value(index); |
226 | } |
227 | |
228 | //======================================================================= |
229 | //function : SetRealDataItem |
230 | //purpose : |
231 | //======================================================================= |
232 | void PDataStd_NamedData::SetRealDataItem(const Standard_Integer index, |
233 | const Handle(PCollection_HExtendedString)& key, |
234 | const Standard_Real value) |
235 | { |
236 | if(myRealKeys.IsNull() || myRealValues.IsNull()) return; |
237 | myRealKeys->SetValue(index, key); |
238 | myRealValues->SetValue(index, value); |
239 | } |
240 | |
241 | //======================================================================= |
242 | //function : RealDataItemValue |
243 | //purpose : |
244 | //======================================================================= |
245 | Standard_Real PDataStd_NamedData::RealDataItemValue(const Standard_Integer index, |
246 | Handle(PCollection_HExtendedString)& key) const |
247 | { |
248 | if(myRealKeys.IsNull() || myRealValues.IsNull()) return 0.; |
249 | key = myRealKeys->Value(index); |
250 | return myRealValues->Value(index); |
251 | } |
252 | |
253 | //======================================================================= |
254 | //function : SetStrDataItem |
255 | //purpose : |
256 | //======================================================================= |
257 | void PDataStd_NamedData::SetStrDataItem(const Standard_Integer index, |
258 | const Handle(PCollection_HExtendedString)& key, |
259 | const Handle(PCollection_HExtendedString)& value) |
260 | { |
261 | if(myStrKeys.IsNull() || myStrValues.IsNull()) return; |
262 | myStrKeys->SetValue(index, key); |
263 | myStrValues->SetValue(index, value); |
264 | } |
265 | |
266 | //======================================================================= |
267 | //function : StrDataItemValue |
268 | //purpose : |
269 | //======================================================================= |
270 | Handle(PCollection_HExtendedString) PDataStd_NamedData::StrDataItemValue |
271 | (const Standard_Integer index, |
272 | Handle(PCollection_HExtendedString)& key) const |
273 | { |
274 | Handle(PCollection_HExtendedString) aVal; |
275 | if(myStrKeys.IsNull() || myStrValues.IsNull()) return aVal; |
276 | key = myStrKeys->Value(index); |
277 | return myStrValues->Value(index); |
278 | } |
279 | |
280 | //======================================================================= |
281 | //function : SetByteDataItem |
282 | //purpose : |
283 | //======================================================================= |
284 | void PDataStd_NamedData::SetByteDataItem(const Standard_Integer index, |
285 | const Handle(PCollection_HExtendedString)& key, |
286 | const Standard_Byte value) |
287 | { |
288 | if(myByteKeys.IsNull() || myByteValues.IsNull()) return; |
289 | myByteKeys->SetValue(index, key); |
290 | myByteValues->SetValue(index, value); |
291 | } |
292 | |
293 | //======================================================================= |
294 | //function : ByteDataItemValue |
295 | //purpose : |
296 | //======================================================================= |
297 | Standard_Byte PDataStd_NamedData::ByteDataItemValue(const Standard_Integer index, |
298 | Handle(PCollection_HExtendedString)& key) const |
299 | { |
300 | if(myByteKeys.IsNull() || myByteValues.IsNull()) return 0x00; |
301 | key = myByteKeys->Value(index); |
302 | return myByteValues->Value(index); |
303 | } |
304 | |
305 | //======================================================================= |
306 | //function : SetArrIntDataItem |
307 | //purpose : |
308 | //======================================================================= |
309 | void PDataStd_NamedData::SetArrIntDataItem(const Standard_Integer index, |
310 | const Handle(PCollection_HExtendedString)& key, |
311 | const Handle(PColStd_HArray1OfInteger)& value) |
312 | { |
313 | if(myArrIntKeys.IsNull() || myArrIntValues.IsNull()) return; |
314 | myArrIntKeys->SetValue(index, key); |
315 | myArrIntValues->SetValue(index, value); |
316 | } |
317 | |
318 | //======================================================================= |
319 | //function : ArrIntDataItemValue |
320 | //purpose : |
321 | //======================================================================= |
322 | Handle(PColStd_HArray1OfInteger) PDataStd_NamedData::ArrIntDataItemValue |
323 | (const Standard_Integer index, |
324 | Handle(PCollection_HExtendedString)& key) const |
325 | { |
326 | Handle(PColStd_HArray1OfInteger) aVal; |
327 | if(myArrIntKeys.IsNull() || myArrIntValues.IsNull()) return aVal; |
328 | key = myArrIntKeys->Value(index); |
329 | return myArrIntValues->Value(index); |
330 | } |
331 | |
332 | //======================================================================= |
333 | //function : SetArrRealDataItem |
334 | //purpose : |
335 | //======================================================================= |
336 | void PDataStd_NamedData::SetArrRealDataItem(const Standard_Integer index, |
337 | const Handle(PCollection_HExtendedString)& key, |
338 | const Handle(PColStd_HArray1OfReal)& value) |
339 | { |
340 | if(myArrRealKeys.IsNull() || myArrRealValues.IsNull()) return; |
341 | myArrRealKeys->SetValue(index, key); |
342 | myArrRealValues->SetValue(index, value); |
343 | } |
344 | |
345 | //======================================================================= |
346 | //function : ArrRealDataItemValue |
347 | //purpose : |
348 | //======================================================================= |
349 | Handle(PColStd_HArray1OfReal) PDataStd_NamedData::ArrRealDataItemValue |
350 | (const Standard_Integer index, |
351 | Handle(PCollection_HExtendedString)& key) const |
352 | { |
353 | Handle(PColStd_HArray1OfReal) aVal; |
354 | if(myArrRealKeys.IsNull() || myArrRealValues.IsNull()) return aVal; |
355 | key = myArrRealKeys->Value(index); |
356 | return myArrRealValues->Value(index); |
357 | } |
358 | |
359 | //======================================================================= |
360 | //function : HasIntegers |
361 | //purpose : |
362 | //======================================================================= |
363 | Standard_Boolean PDataStd_NamedData::HasIntegers() const |
364 | { |
365 | return !myIntKeys.IsNull(); |
366 | } |
367 | //======================================================================= |
368 | //function : HasReals |
369 | //purpose : |
370 | //======================================================================= |
371 | Standard_Boolean PDataStd_NamedData::HasReals() const |
372 | { |
373 | return !myRealKeys.IsNull(); |
374 | } |
375 | |
376 | //======================================================================= |
377 | //function : HasStrings |
378 | //purpose : |
379 | //======================================================================= |
380 | Standard_Boolean PDataStd_NamedData::HasStrings() const |
381 | { |
382 | return !myStrKeys.IsNull(); |
383 | } |
384 | |
385 | //======================================================================= |
386 | //function : HasBytes |
387 | //purpose : |
388 | //======================================================================= |
389 | Standard_Boolean PDataStd_NamedData::HasBytes() const |
390 | { |
391 | return !myByteKeys.IsNull(); |
392 | } |
393 | |
394 | //======================================================================= |
395 | //function : HasArraysOfIntegers |
396 | //purpose : |
397 | //======================================================================= |
398 | Standard_Boolean PDataStd_NamedData::HasArraysOfIntegers() const |
399 | { |
400 | return !myArrIntKeys.IsNull(); |
401 | } |
402 | |
403 | //======================================================================= |
404 | //function : HasArraysOfReals |
405 | //purpose : |
406 | //======================================================================= |
407 | Standard_Boolean PDataStd_NamedData::HasArraysOfReals() const |
408 | { |
409 | return !myArrRealKeys.IsNull(); |
410 | } |