Debian Codegraph @

src/utilities/aslVTKCasters.cxx

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #include "aslVTKCasters.h"
25
26 #include <data/aslBlocks.h>
27 #include <data/aslDataWrapper.h>
28 #include <acl/acl.h>
29 #include <acl/DataTypes/aclArray.h>
30 #include <data/aslDataWithGhostNodes.h>
31
32 #include <vtkDoubleArray.h>
33 #include <vtkFloatArray.h>
34 #include <vtkIntArray.h>
35 #include <vtkUnsignedIntArray.h>
36 #include <vtkLongLongArray.h>
37 #include <vtkIdTypeArray.h>
38 #include <vtkPointData.h>
39
40 #include <vtkImageData.h>
41
42 #include "acl/aclTypesList.h"
43
44
45 namespace asl
46 {
47
48 template <typename T> void combineArrays(T* d1, unsigned int size, T* dTarget, unsigned int nComponents=1);
49 template <typename T> void combineArrays(T* d1, T* d2, unsigned int size, T* dTarget,unsigned int nComponents=2);
50 template <typename T> void combineArrays(T* d1, T* d2, T* d3, unsigned int size, T* dTarget,unsigned int nComponents=3);
51 template <typename TO, typename TI> TO* combineArraysX(TI* d0, TI* d1, TI* d2, TI* d3, unsigned int size);
52
53 template <typename T> void combineArrays(T* d1,
54 unsigned int size,
55 T* dTarget,
56 unsigned int nComponents)
57 {
58 if (nComponents < 1)
59 errorMessage("combineArrays() - attempt to provide nComponents that is less than 1");
60
61 for(unsigned int i(0); i < size; ++i)
62 {
63 dTarget[i * nComponents] = d1[i];
64 }
65 }
66
67 #define BOOST_TT_rep_expression(r, data, T) \
68 template void combineArrays(T* d1, unsigned int size, T* dTarget, unsigned int nComponents);
69 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
70 #undef BOOST_TT_rep_expression
71
72 template <typename T> void combineArrays(T* d1,
73 T* d2,
74 unsigned int size,
75 T* dTarget,
76 unsigned int nComponents)
77 {
78 if (nComponents < 2)
79 errorMessage("combineArrays() - attempt to provide nComponents that is less than 2");
80
81 for(unsigned int i(0); i < size; ++i)
82 {
83 dTarget[nComponents * i] = d1[i];
84 dTarget[nComponents * i + 1] = d2[i];
85 }
86 }
87
88 #define BOOST_TT_rep_expression(r, data, T) \
89 template void combineArrays(T* d1, T* d2, unsigned int size, T* dTarget, unsigned int nComponents);
90 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
91 #undef BOOST_TT_rep_expression
92
93 template <typename T> void combineArrays(T* d1,
94 T* d2,
95 T* d3,
96 unsigned int size,
97 T* dTarget,
98 unsigned int nComponents)
99 {
100 if (nComponents < 3)
101 errorMessage("combineArrays() - attempt to provide nComponents that is less than 3");
102
103 for (unsigned int i(0); i < size; ++i)
104 {
105 dTarget[nComponents * i] = d1[i];
106 dTarget[nComponents * i + 1] = d2[i];
107 dTarget[nComponents * i + 2] = d3[i];
108 }
109 }
110
111 #define BOOST_TT_rep_expression(r, data, T) \
112 template void combineArrays(T* d1, T* d2, T* d3, unsigned int size, T* dTarget, unsigned int nComponents);
113 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
114 #undef BOOST_TT_rep_expression
115
116 template <typename T> T* combineArrays(T* d1, T* d2, unsigned int size)
117 {
118 T* d(new T[size * 2]);
119 combineArrays(d1, d2, size, d);
120 return d;
121 }
122
123 #define BOOST_TT_rep_expression(r, data, T) \
124 template T* combineArrays(T* d1, T* d2, unsigned int size);
125 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
126 #undef BOOST_TT_rep_expression
127
128 template <typename T> T* combineArrays(T* d1, T* d2, T* d3, unsigned int size)
129 {
130 T* d(new T[size * 3]);
131 combineArrays(d1, d2, d3, size, d);
132 return d;
133 }
134
135 #define BOOST_TT_rep_expression(r, data, T) \
136 template T* combineArrays(T* d1, T* d2, T* d3, unsigned int size);
137 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
138 #undef BOOST_TT_rep_expression
139
140 template <typename TO, typename TI> TO* combineArraysX(TI* d0, TI* d1, TI* d2, TI* d3, unsigned int size)
141 {
142 TO* d(new TO[size*4]);
143 for(unsigned int i(0); i < size; ++i)
144 {
145 d[4 * i] = d0[i];
146 d[4 * i + 1] = d1[i];
147 d[4 * i + 2] = d2[i];
148 d[4 * i + 3] = d3[i];
149 }
150 return d;
151 }
152
153 template vtkIdType* combineArraysX<vtkIdType, unsigned int>(unsigned int* d0,
154 unsigned int* d1,
155 unsigned int* d2,
156 unsigned int* d3,
157 unsigned int size);
158
159 template <typename T> class VTKDataArrayClass{};
160 template <> class VTKDataArrayClass<cl_double>{public: typedef vtkDoubleArray T;};
161 template <> class VTKDataArrayClass<cl_float>{public: typedef vtkFloatArray T;};
162 template <> class VTKDataArrayClass<cl_int>{public: typedef vtkIntArray T;};
163 template <> class VTKDataArrayClass<cl_uint>{public: typedef vtkUnsignedIntArray T;};
164 template <> class VTKDataArrayClass<cl_long>{public: typedef vtkLongLongArray T;};
165
166 template <typename T> AVec<T> castVTKVector(AVec<T> a, T fill)
167 {
168 AVec<T> b(3);
169 if (nD(a) == 1)
170 {
171 b[0] = a[0]; b[1] = fill; b[2] = fill;
172 }
173 if (nD(a) == 2)
174 {
175 b[0] = a[1]; b[1] = a[0]; b[2] = fill;
176 }
177 if (nD(a) == 3)
178 {
179 b[0] = a[2]; b[1] = a[1]; b[2] = a[0];
180 }
181 return b;
182 }
183
184 #define BOOST_TT_rep_expression(r, data, T) \
185 template AVec<T> castVTKVector(AVec<T> a, T fill);
186 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
187 #undef BOOST_TT_rep_expression
188
189 /// Combines 2 arrays into 3 (while 3rd one is made of '0')
190 /// and puts them in dTarget
191 template <typename T> void combine2ArraysInto3(T* d1,
192 T* d2,
193 unsigned int size,
194 T* dTarget)
195 {
196 for (unsigned int i(0); i < size; ++i)
197 {
198 dTarget[3 * i] = d2[i];
199 dTarget[3 * i + 1] = d1[i];
200 dTarget[3 * i + 2] = 0;
201 }
202 }
203
204 template <typename T> T* combine2ArraysInto3(T* d1, T* d2, unsigned int size)
205 {
206 T* d(new T[size * 3]);
207 combine2ArraysInto3(d1, d2, size, d);
208 return d;
209 }
210
211
212 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d,
213 unsigned int np,
214 unsigned int save,
215 const string &name)
216 {
217 typedef typename VTKDataArrayClass<T>::T DT;
218 vtkSmartPointer<DT> vtkArray(vtkSmartPointer<DT>::New());
219 vtkArray->SetName(name.c_str());
220 vtkArray->SetNumberOfComponents(1);
221 typedef decltype(DT::GetDataTypeValueMin()) vtkT;
222 if(sizeof(vtkT)!=sizeof(T))
223 errorMessage("castVTKDataArray: type conversion is illegal");
224 vtkArray->SetArray((vtkT*) d, np, save);
225 return vtkArray;
226 }
227
228
229 #define BOOST_TT_rep_expression(r, data, T) \
230 template vtkSmartPointer<vtkDataArray> castVTKDataArray<T>(T *d, unsigned int np, unsigned int save, const string &name);
231 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
232 #undef BOOST_TT_rep_expression
233
234 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1, T *d2, unsigned int np, const string &name)
235 {
236 typedef typename VTKDataArrayClass<T>::T DT;
237 vtkSmartPointer<DT> vtkArray(vtkSmartPointer<DT>::New());
238 vtkArray->SetName(name.c_str());
239 vtkArray->SetNumberOfComponents(2);
240 typedef decltype(DT::GetDataTypeValueMin()) vtkT;
241 if(sizeof(vtkT)!=sizeof(T))
242 errorMessage("castVTKDataArray: type convetion is illegal");
243 vtkArray->SetArray((vtkT*)combineArrays(d1, d2, np), 2 * np, 0);
244 return vtkArray;
245 }
246
247 #define BOOST_TT_rep_expression(r, data, T) \
248 template vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1, T *d2, unsigned int np, const string &name);
249 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
250 #undef BOOST_TT_rep_expression
251
252 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1, T *d2, T *d3, unsigned int np, const string &name)
253 {
254 typedef typename VTKDataArrayClass<T>::T DT;
255 vtkSmartPointer<DT> vtkArray(vtkSmartPointer<DT>::New());
256 vtkArray->SetName(name.c_str());
257 vtkArray->SetNumberOfComponents(3);
258 typedef decltype(DT::GetDataTypeValueMin()) vtkT;
259 if(sizeof(vtkT)!=sizeof(T))
260 errorMessage("castVTKDataArray: type convetion is illegal");
261 vtkArray->SetArray((vtkT*)combineArrays(d1, d2, d3, np), 3 * np, 0);
262 return vtkArray;
263 }
264
265 #define BOOST_TT_rep_expression(r, data, T) \
266 template vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1, T *d2, T *d3, unsigned int np, const string &name);
267 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
268 #undef BOOST_TT_rep_expression
269
270 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray2in3(T *d1, T *d2, unsigned int np, const string &name)
271 {
272 typedef typename VTKDataArrayClass<T>::T DT;
273 vtkSmartPointer<DT> vtkArray(vtkSmartPointer<DT>::New());
274 vtkArray->SetName(name.c_str());
275 vtkArray->SetNumberOfComponents(3);
276 typedef decltype(DT::GetDataTypeValueMin()) vtkT;
277 if(sizeof(vtkT)!=sizeof(T))
278 errorMessage("castVTKDataArray: type convetion is illegal");
279 vtkArray->SetArray((vtkT*)combine2ArraysInto3(d1, d2, np), 3 * np, 0);
280 return vtkArray;
281 }
282
283 #define BOOST_TT_rep_expression(r, data, T) \
284 template vtkSmartPointer<vtkDataArray> castVTKDataArray2in3(T *d1, T *d2, unsigned int np, const string &name);
285 BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types)
286 #undef BOOST_TT_rep_expression
287
288
289 vtkSmartPointer<vtkIdTypeArray> castVTKIdTypeArray(unsigned int *d0, unsigned int *d1, unsigned int *d2, unsigned int *d3, unsigned int np, const std::string &name)
290 {
291 vtkSmartPointer<vtkIdTypeArray> vtkArray(vtkSmartPointer<vtkIdTypeArray>::New());
292 vtkArray->SetName(name.c_str());
293 vtkArray->SetNumberOfComponents(1);
294 vtkArray->SetArray(combineArraysX<vtkIdType, unsigned int>(d0, d1, d2, d3, np), 4 * np, 0);
295 return vtkArray;
296 }
297
298
299 vtkSmartPointer<vtkDataArray> castVTKDataArray(acl::Element source, const string & name)
300 {
301 if (!isMemBlock(source))
302 errorMessage ("castVTKDoubleArray(): provided element is not a MemBlock type");
303
304 if (source->getTypeID() == acl::TYPE_DOUBLE)
305 {
306 double* d = new double[source->getSize()];
307 copy(source, d);
308 return castVTKDataArray(d, source->getSize(), 0, name);
309 }
310 if (source->getTypeID() == acl::TYPE_FLOAT)
311 {
312 float* d = new float[source->getSize()];
313 copy(source, d);
314 return castVTKDataArray(d, source->getSize(), 0, name);
315 }
316 if (source->getTypeID() == acl::TYPE_INT)
317 {
318 int* d = new int[source->getSize()];
319 copy(source, d);
320 return castVTKDataArray(d, source->getSize(), 0, name);
321 }
322 return NULL;
323 }
324
325
326 void updateVTKDataArray(acl::Element source,
327 vtkSmartPointer<vtkDataArray> vtkData)
328 {
329 if (!isMemBlock(source))
330 errorMessage ("updateVTKDataArray(): provided element is not a MemBlock type");
331
332 if (source->getTypeID() == acl::TYPE_DOUBLE)
333 {
334 double* d((double*)vtkData->GetVoidPointer(0));
335 copy(source, d);
336 }
337 if (source->getTypeID() == acl::TYPE_FLOAT)
338 {
339 float* d((float*)vtkData->GetVoidPointer(0));
340 copy(source, d);
341 }
342 if (source->getTypeID() == acl::TYPE_INT)
343 {
344 int* d =((int*)vtkData->GetVoidPointer(0));
345 copy(source, d);
346 }
347 vtkData->Modified();
348 }
349
350
351 void updateVTKDataArray(acl::Element source,
352 const std::string &name,
353 vtkSmartPointer<vtkImageData> vtkData)
354 {
355 auto da(vtkData->GetPointData()->GetScalars(name.c_str()));
356 updateVTKDataArray(source, da);
357 }
358
359
360 vtkSmartPointer<vtkImageData> castVTKData(const Block & b)
361 {
362 vtkSmartPointer<vtkImageData> image(vtkSmartPointer<vtkImageData>::New());
363 image->SetSpacing(b.dx,b.dx,b.dx);
364
365 image->SetOrigin(&castVTKVector(b.position)[0]);
366 image->SetDimensions(&castVTKVector(b.getSize(),1)[0]);
367 return image;
368 }
369
370
371 vtkSmartPointer<vtkImageData> castVTKData(double *d, const Block & b, unsigned int save, const std::string &name)
372 {
373 vtkSmartPointer<vtkImageData> image(castVTKData(b));
374 image->GetPointData()->SetScalars(castVTKDataArray(d,
375 productOfElements(b.getSize()),
376 save,
377 name));
378 return image;
379 }
380
381
382 vtkSmartPointer<vtkImageData> castVTKData(double *d1, double *d2, const Block & b, const std::string &name)
383 {
384 vtkSmartPointer<vtkImageData> image(castVTKData(b));
385 image->GetPointData()->SetVectors(castVTKDataArray(d1, d2,
386 productOfElements(b.getSize()),
387 name));
388 return image;
389 }
390
391
392 vtkSmartPointer<vtkImageData> castVTKData(double *d1, double *d2, double *d3, const Block & b, const std::string &name)
393 {
394 vtkSmartPointer<vtkImageData> image(castVTKData(b));
395 image->GetPointData()->SetVectors(castVTKDataArray(d1, d2, d3,
396 productOfElements(b.getSize()),
397 name));
398 return image;
399 }
400
401
402 vtkSmartPointer<vtkImageData> castVTKData(const AbstractData & d, const vector<string> & names)
403 {
404 const Block &b(d.getBlock());
405 vtkSmartPointer<vtkImageData> image(vtkSmartPointer<vtkImageData>::New());
406 image->SetSpacing(b.dx, b.dx, b.dx);
407
408 image->SetOrigin(&castVTKVector(b.position)[0]);
409 image->SetDimensions(&castVTKVector(b.getSize(), 1)[0]);
410 bool bnames(names.size() > 0);
411 image->GetPointData()->SetScalars(castVTKDataArray(d.getDContainer()[0], bnames ? names[0] : ""));
412 for (unsigned int i(1); i < d.getDContainer().size(); ++i)
413 image->GetPointData()->AddArray(castVTKDataArray(d.getDContainer()[i], bnames ? names[i] : ""));
414 return image;
415 }
416
417
418 void putToVTKData(double *d, vtkSmartPointer<vtkImageData> target)
419 {
420 double *dTarget(((vtkDoubleArray *) target->GetPointData()->GetArray(0))->GetPointer(0));
421 unsigned int size(target->GetPointData()->GetArray(0)->GetNumberOfTuples());
422 unsigned int nComponents(target->GetPointData()->GetArray(0)->GetNumberOfComponents());
423 combineArrays(d, size, dTarget, nComponents);
424 }
425
426
427 void putToVTKData(double *d1, double *d2, vtkSmartPointer<vtkImageData> target)
428 {
429 double *dTarget(((vtkDoubleArray *) target->GetPointData()->GetArray(0))->GetPointer(0));
430 unsigned int size(target->GetPointData()->GetArray(0)->GetNumberOfTuples());
431 unsigned int nComponents(target->GetPointData()->GetArray(0)->GetNumberOfComponents());
432 combineArrays(d1, d2, size, dTarget, nComponents);
433 }
434
435
436 void putToVTKData(double *d1, double *d2, double *d3, vtkSmartPointer<vtkImageData> target)
437 {
438 double *dTarget(((vtkDoubleArray *) target->GetPointData()->GetArray(0))->GetPointer(0));
439 unsigned int size(target->GetPointData()->GetArray(0)->GetNumberOfTuples());
440 unsigned int nComponents(target->GetPointData()->GetArray(0)->GetNumberOfComponents());
441 combineArrays(d1, d2, d3, size, dTarget, nComponents);
442 }
443
444
445 template <typename T> void decomposeArrays(T* d, T* d1, T* d2, unsigned int size)
446 {
447 for (unsigned int i(0); i < size; ++i)
448 {
449 d1[i] = d[2 * i];
450 d2[i] = d[2 * i + 1];
451 }
452 }
453
454 template void decomposeArrays<double>(double* d, double* d1, double* d2, unsigned int size);
455 template void decomposeArrays<float>(float* d, float* d1, float* d2, unsigned int size);
456 template void decomposeArrays<int>(int* d, int* d1, int* d2, unsigned int size);
457 template void decomposeArrays<unsigned int>(unsigned int* d, unsigned int* d1, unsigned int* d2, unsigned int size);
458
459 template <typename T> void decomposeArrays(T* d, T* d1, T* d2, T* d3, unsigned int size)
460 {
461 for (unsigned int i(0); i < size; ++i)
462 {
463 d1[i] = d[3 * i];
464 d2[i] = d[3 * i + 1];
465 d3[i] = d[3 * i + 2];
466 }
467 }
468
469 template void decomposeArrays<double>(double* d, double* d1, double* d2, double* d3, unsigned int size);
470 template void decomposeArrays<float>(float* d, float* d1, float* d2, float* d3, unsigned int size);
471 template void decomposeArrays<int>(int* d, int* d1, int* d2, int* d3, unsigned int size);
472 template void decomposeArrays<unsigned int>(unsigned int* d, unsigned int* d1, unsigned int* d2, unsigned int* d3, unsigned int size);
473
474
475 // Creates destination arrays (they need to be deleted outside after being used!),
476 // transfers data from \p source to \p destination.
477 template <typename T> void decomposeVTKDataArray(vtkDataArray * source,
478 vector<T *> & destination)
479 {
480 typedef typename VTKDataArrayClass<T>::T DataType;
481
482 unsigned int numOfComponents(source->GetNumberOfComponents());
483 unsigned int numOfTuples(source->GetNumberOfTuples());
484
485 for (unsigned int i = 0; i < numOfComponents; ++i)
486 {
487 destination.push_back(new T[numOfTuples]);
488 }
489
490 DataType * array((DataType *) source);
491 for (unsigned int i = 0; i < numOfTuples; ++i)
492 {
493 for (unsigned int j = 0; j < numOfComponents; ++j)
494 {
495 destination[j][i] = array->GetValue(numOfComponents * i + j);
496 }
497 }
498 }
499
500 template void decomposeVTKDataArray<double>(vtkDataArray * source,
501 vector<double *> & destination);
502 template void decomposeVTKDataArray<float>(vtkDataArray * source,
503 vector<float *> & destination);
504 template void decomposeVTKDataArray<int>(vtkDataArray * source,
505 vector<int *> & destination);
506 template void decomposeVTKDataArray<unsigned int>(vtkDataArray * source,
507 vector<unsigned int *> & destination);
508
509 std::shared_ptr<Block> makeBlock(vtkSmartPointer<vtkImageData> image)
510 {
511 int dims[3];
512 image->GetDimensions(dims);
513
514 double spacing[3];
515 image->GetSpacing(spacing);
516
517 double origin[3];
518 int extent[6];
519 image->GetOrigin(origin);
520 image->GetExtent(extent);
521 origin[0]+=extent[0]*spacing[0];
522 origin[1]+=extent[2]*spacing[1];
523 origin[2]+=extent[4]*spacing[2];
524
525 shared_ptr<Block> block(new Block(makeAVec<int>(dims[2], dims[1], dims[0]),
526 spacing[0],
527 makeAVec<double>(origin[2], origin[1], origin[0])));
528
529 return block;
530 }
531
532
533 // Converts vtk data type into asl data type;
534 // exits if non-supported data type is provided.
535 acl::TypeID aslType(int vtkType)
536 {
537 acl::TypeID t(acl::TYPE_INT);
538 switch (vtkType)
539 {
540 case VTK_INT :
541 t = acl::TYPE_INT;
542 break;
543 case VTK_UNSIGNED_INT :
544 t = acl::TYPE_UINT;
545 break;
546 case VTK_FLOAT :
547 t = acl::TYPE_FLOAT;
548 break;
549 case VTK_DOUBLE :
550 t = acl::TYPE_DOUBLE;
551 break;
552 case VTK_LONG :
553 t = acl::TYPE_LONG;
554 break;
555 default :
556 errorMessage("aslType - vtk data type not recognized: " + numToStr(vtkType));
557 break;
558 }
559 return t;
560 }
561
562 SPDataWithGhostNodesACLData makeData(vtkSmartPointer<vtkImageData> image,
563 unsigned int arrayNum,
564 acl::CommandQueue queue)
565 {
566
567 if ((int)arrayNum >= image->GetPointData()->GetNumberOfArrays())
568 errorMessage("makeData() - arrayNum out of range");
569
570 shared_ptr<Block> block = makeBlock(image);
571 acl::TypeID type = aslType(image->GetPointData()->GetArray(arrayNum)->GetDataType());
572 unsigned int numOfComponents(image->GetPointData()->GetArray(arrayNum)->GetNumberOfComponents());
573 SPDataWithGhostNodesACLData data = generateDataContainerACL_SP(offset(*block,-1),
574 type,
575 numOfComponents,
576 1,
577 queue);
578
579 switch (type)
580 {
581 case acl::TYPE_INT :
582 {
583 vector<cl_int *> decomposedData;
584 decomposeVTKDataArray<cl_int>(image->GetPointData()->GetArray(arrayNum),
585 decomposedData);
586 for (unsigned int i = 0; i < decomposedData.size(); ++i)
587 {
588 copy(decomposedData[i], data->getDContainer()[i]);
589 delete[] decomposedData[i];
590 }
591 break;
592 }
593 case acl::TYPE_UINT :
594 {
595 vector<cl_uint *> decomposedData;
596 decomposeVTKDataArray<cl_uint>(image->GetPointData()->GetArray(arrayNum),
597 decomposedData);
598 for (unsigned int i = 0; i < decomposedData.size(); ++i)
599 {
600 copy(decomposedData[i], data->getDContainer()[i]);
601 delete[] decomposedData[i];
602 }
603 break;
604 }
605 case acl::TYPE_FLOAT :
606 {
607 vector<cl_float *> decomposedData;
608 decomposeVTKDataArray<cl_float>(image->GetPointData()->GetArray(arrayNum),
609 decomposedData);
610 for (unsigned int i = 0; i < decomposedData.size(); ++i)
611 {
612 copy(decomposedData[i], data->getDContainer()[i]);
613 delete[] decomposedData[i];
614 }
615 break;
616 }
617 case acl::TYPE_DOUBLE :
618 {
619 vector<cl_double *> decomposedData;
620 decomposeVTKDataArray<cl_double>(image->GetPointData()->GetArray(arrayNum),
621 decomposedData);
622 for (unsigned int i = 0; i < decomposedData.size(); ++i)
623 {
624 copy(decomposedData[i], data->getDContainer()[i]);
625 delete[] decomposedData[i];
626 }
627 break;
628 }
629 case acl::TYPE_LONG :
630 {
631 vector<cl_long *> decomposedData;
632 decomposeVTKDataArray<cl_long>(image->GetPointData()->GetArray(arrayNum),
633 decomposedData);
634 for (unsigned int i = 0; i < decomposedData.size(); ++i)
635 {
636 copy(decomposedData[i], data->getDContainer()[i]);
637 delete[] decomposedData[i];
638 }
639 break;
640 }
641 }
642
643 return data;
644 }
645
646
647 } // asl