ASL  0.1.7
Advanced Simulation Library
aslVTKCasters.h
Go to the documentation of this file.
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 #ifndef ASLVTKCASTERS_H
25 #define ASLVTKCASTERS_H
26 
27 #include <memory>
28 #include <string>
29 #include <vector>
30 #include <vtkSmartPointer.h>
31 #include <acl/aclHardware.h>
32 #include <aslGenerators.h>
33 #include <math/aslVectors.h>
34 
40 class vtkDataArray;
41 class vtkImageData;
42 class vtkIdTypeArray;
43 
44 namespace acl
45 {
46  class ElementBase;
47  typedef std::shared_ptr<ElementBase> Element;
48 }
49 
50 namespace asl
51 {
52  class Block;
53  class AbstractData;
54 
55 
58 
60  template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d,
61  unsigned int np,
62  unsigned int save = 0,
63  const std::string &name = "");
64 
66  template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1,
67  T *d2,
68  unsigned int np,
69  const std::string &name = "");
70 
72  template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1,
73  T *d2,
74  T *d3,
75  unsigned int np,
76  const std::string &name = "");
77 
79  template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray2in3(T *d1, T *d2,
80  unsigned int np,
81  const std::string &name);
82 
83 
85  vtkSmartPointer<vtkIdTypeArray> castVTKIdTypeArray(unsigned int *d0,
86  unsigned int *d1,
87  unsigned int *d2,
88  unsigned int *d3,
89  unsigned int np,
90  const std::string &name = "");
91 
92  vtkSmartPointer<vtkDataArray> castVTKDataArray(acl::Element source,
93  const std::string &name = "");
94 
95  void updateVTKDataArray(acl::Element source,
96  vtkSmartPointer<vtkDataArray> vtkData);
97 
98  void updateVTKDataArray(acl::Element source,
99  const std::string &name,
100  vtkSmartPointer<vtkImageData> vtkData);
101 
102  vtkSmartPointer<vtkImageData> castVTKData(const Block & b);
103 
104  vtkSmartPointer<vtkImageData> castVTKData(double *d,
105  const Block & b,
106  unsigned int save = 0,
107  const std::string &name = "");
108 
109  vtkSmartPointer<vtkImageData> castVTKData(double *d1,
110  double *d2,
111  const Block & b,
112  const std::string &name = "");
113 
114  vtkSmartPointer<vtkImageData> castVTKData(double *d1,
115  double *d2,
116  double *d3,
117  const Block & b,
118  const std::string &name = "");
119 
120  void putToVTKData(double *d, vtkSmartPointer<vtkImageData> target);
121  void putToVTKData(double *d1, double *d2, vtkSmartPointer<vtkImageData> target);
122  void putToVTKData(double *d1, double *d2, double *d3, vtkSmartPointer<vtkImageData> target);
123 
124 
125  vtkSmartPointer<vtkImageData> castVTKData(const AbstractData & d,
126  const std::vector<std::string> &names = std::vector<std::string>(0));
127 
128  SPDataWithGhostNodesACLData makeData(vtkSmartPointer<vtkImageData> image,
129  unsigned int arrayNum = 0,
130  acl::CommandQueue queue = acl::hardware.defaultQueue);
131 
132  std::shared_ptr<Block> makeBlock(vtkSmartPointer<vtkImageData> image);
133 
134  template<typename T> inline vtkSmartPointer<vtkDataArray> castVTKDataArray(std::shared_ptr<T> d,
135  unsigned int np,
136  const std::string &name = "")
137  {
138  return castVTKDataArray(d.get(), np, 1, name);
139  }
140 
141  vtkSmartPointer<vtkImageData> inline castVTKData(std::shared_ptr<double> d,
142  const Block & b,
143  const std::string &name = "")
144  {
145  return castVTKData(d.get(), b, 1, name);
146  }
147 
148 
149  template<typename T> inline vtkSmartPointer<vtkDataArray> castVTKDataArray(std::vector<T> & d,
150  unsigned int np,
151  const std::string &name = "")
152  {
153  return castVTKDataArray(&d.front(), np, 1, name);
154  }
155 
156 
157  vtkSmartPointer<vtkImageData> inline castVTKData(std::vector<double> & d,
158  const Block & b,
159  const std::string &name = "")
160  {
161  return castVTKData(&d.front(), b, 1, name);
162  }
163 
164 
165  template <typename T> AVec<T> castVTKVector(AVec<T> a, T fill = 0);
166 
167 
168 /* template <typename T> void combineArrays(T* d1,
169  T* d2,
170  T* d3,
171  unsigned int size,
172  T* dTarget,
173  unsigned int nComponents = 3);*/
175 
176 } //namespace acl
177 
178 //--------------------------------Implementation------------------------
179 
180 
181 #endif // ASLVTKCASTERS_H
void putToVTKData(double *d, vtkSmartPointer< vtkImageData > target)
Advanced Simulation Library.
Definition: aslDataInc.h:30
Advanced Computational Language.
Definition: acl.h:40
std::shared_ptr< DataWithGhostNodesACLData > SPDataWithGhostNodesACLData
Definition: aslGenerators.h:47
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition: acl.h:51
std::shared_ptr< Block > makeBlock(vtkSmartPointer< vtkImageData > image)
void updateVTKDataArray(acl::Element source, vtkSmartPointer< vtkDataArray > vtkData)
SPDataWithGhostNodesACLData makeData(vtkSmartPointer< vtkImageData > image, unsigned int arrayNum=0, acl::CommandQueue queue=acl::hardware.defaultQueue)
vtkSmartPointer< vtkIdTypeArray > castVTKIdTypeArray(unsigned int *d0, unsigned int *d1, unsigned int *d2, unsigned int *d3, unsigned int np, const std::string &name="")
creates VTKDataArray with 3 component d1, d2 and d3 and length np and name
vtkSmartPointer< vtkDataArray > castVTKDataArray(T *d, unsigned int np, unsigned int save=0, const std::string &name="")
creates VTKDataArray with 1 component d and length np and name
vtkSmartPointer< vtkImageData > castVTKData(const Block &b)
vtkSmartPointer< vtkDataArray > castVTKDataArray2in3(T *d1, T *d2, unsigned int np, const std::string &name)
creates VTKDataArray with 3 component d2, d1 and 0 and length np and name
definition of class АVec<T>
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
AVec< T > castVTKVector(AVec< T > a, T fill=0)
Hardware hardware