Debian Codegraph @

src/utilities/aslVTKCasters.h

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 #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
35 /**
36 \defgroup VTKInterfacing VTK Interfacing
37 \ingroup Interfacing
38 */
39
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
56 /// @{
57 /// \ingroup VTKInterfacing
58
59 /// creates VTKDataArray with 1 component \p d and length \p np and \p name
60 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d,
61 unsigned int np,
62 unsigned int save = 0,
63 const std::string &name = "");
64
65 /// creates VTKDataArray with 2 component \p d1 and \p d2 and length \p np and \p name
66 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray(T *d1,
67 T *d2,
68 unsigned int np,
69 const std::string &name = "");
70
71 /// creates VTKDataArray with 3 component \p d1, \p d2 and \p d3 and length \p np and \p name
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
78 /// creates VTKDataArray with 3 component \p d2, \p d1 and 0 and length \p np and \p name
79 template<typename T> vtkSmartPointer<vtkDataArray> castVTKDataArray2in3(T *d1, T *d2,
80 unsigned int np,
81 const std::string &name);
82
83
84 /// creates VTKDataArray with 3 component \p d1, \p d2 and \p d3 and length \p np and \p name
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);*/
174 /// @}
175
176 } //namespace acl
177
178 //--------------------------------Implementation------------------------
179
180
181 #endif // ASLVTKCASTERS_H