TECA
The Toolkit for Extreme Climate Analysis
teca_vtk_util.h
Go to the documentation of this file.
1 #ifndef teca_vtk_util_h
2 #define teca_vtk_util_h
3 
4 /// @file
5 
6 #include "teca_config.h"
7 #include "teca_cartesian_mesh.h"
8 
9 #if defined(TECA_HAS_VTK) || defined(TECA_HAS_PARAVIEW)
10 #include "vtkFloatArray.h"
11 #include "vtkDoubleArray.h"
12 #include "vtkCharArray.h"
13 #include "vtkUnsignedCharArray.h"
14 #include "vtkShortArray.h"
15 #include "vtkUnsignedShortArray.h"
16 #include "vtkIntArray.h"
17 #include "vtkUnsignedIntArray.h"
18 #include "vtkLongArray.h"
19 #include "vtkUnsignedLongArray.h"
20 #include "vtkLongLongArray.h"
21 #include "vtkUnsignedLongLongArray.h"
22 #include "vtkPointData.h"
23 class vtkRectilinearGrid;
24 #else
25 using vtkFloatArray = void*;
26 using vtkDoubleArray = void*;
27 using vtkCharArray = void*;
28 using vtkUnsignedCharArray = void*;
29 using vtkShortArray = void*;
30 using vtkUnsignedShortArray = void*;
31 using vtkIntArray = void*;
32 using vtkUnsignedIntArray = void*;
33 using vtkLongArray = void*;
34 using vtkUnsignedLongArray = void*;
35 using vtkLongLongArray = void*;
36 using vtkUnsignedLongLongArray = void*;
37 class vtkRectilinearGrid;
38 #endif
39 
40 
41 /// Codes dealing with VTK
42 namespace teca_vtk_util
43 {
44 
45 /// @cond
46 
47 // traits class for naming and/or selecting
48 // the VTK type given a C++ type
49 template <typename T> struct vtk_tt {};
50 #define VTK_TT_SPEC(_ctype, _ctypestr, _vtype, _fmt) \
51 template <> \
52 struct vtk_tt <_ctype> \
53 { \
54  using type = _vtype; \
55  \
56  static constexpr const char *str() \
57  { return #_ctypestr; } \
58  \
59  static constexpr const char *fmt() \
60  { return _fmt; } \
61 };
62 VTK_TT_SPEC(float, float, vtkFloatArray, "%g")
63 VTK_TT_SPEC(double, double, vtkDoubleArray, "%g")
64 VTK_TT_SPEC(char, char, vtkCharArray, "%hhi")
65 VTK_TT_SPEC(unsigned char, unsigned_char, vtkUnsignedCharArray, "%hhu")
66 VTK_TT_SPEC(short, short, vtkShortArray, "%hi")
67 VTK_TT_SPEC(unsigned short, unsigned_short, vtkUnsignedShortArray, "%hu")
68 VTK_TT_SPEC(int, int, vtkIntArray, "%i")
69 VTK_TT_SPEC(unsigned int, unsigned_int, vtkUnsignedIntArray, "%u")
70 VTK_TT_SPEC(long, long, vtkLongArray, "%li")
71 VTK_TT_SPEC(unsigned long, unsigned_long, vtkUnsignedLongArray, "%lu")
72 VTK_TT_SPEC(long long, long_long, vtkLongLongArray, "%lli")
73 VTK_TT_SPEC(unsigned long long, unsigned_long_long, vtkUnsignedLongLongArray, "%llu")
74 
75 /// @endcond
76 
77 /// deep copy input mesh into the VTK object. @returns 0 if successful
78 int deep_copy(vtkRectilinearGrid *output,
79  const_p_teca_cartesian_mesh input);
80 
81 };
82 
83 #endif
teca_vtk_util::deep_copy
int deep_copy(vtkRectilinearGrid *output, const_p_teca_cartesian_mesh input)
deep copy input mesh into the VTK object.
teca_vtk_util
Codes dealing with VTK.
Definition: teca_vtk_util.h:42