TTK
Loading...
Searching...
No Matches
ttkUtils.h
Go to the documentation of this file.
1
7
8#pragma once
9
10// VTK Module
11#include <ttkAlgorithmModule.h>
12
13#include <string>
14#include <vector>
15#include <vtkType.h>
16
17class vtkFieldData;
18class vtkDataArray;
19class vtkDoubleArray;
20class vtkPoints;
21class vtkAbstractArray;
22class vtkCellArray;
23class vtkDataSet;
24
25template <typename T>
27
28class TTKALGORITHM_EXPORT ttkUtils {
29private:
30 ttkUtils() = default;
31
32public:
33 static int replaceVariable(const std::string &iString,
34 vtkFieldData *fieldData,
35 std::string &oString,
36 std::string &errorMsg);
37
38 static int replaceVariables(const std::string &iString,
39 vtkFieldData *fieldData,
40 std::string &oString,
41 std::string &errorMsg);
42
43 static int stringListToVector(const std::string &iString,
44 std::vector<std::string> &v);
45
46 static int stringListToDoubleVector(const std::string &iString,
47 std::vector<double> &v);
48
50 csvToVtkArray(const std::string &line);
51
53 csvToDoubleArray(const std::string &line);
54
55 // Emultate old VTK functions
56 static void *GetVoidPointer(vtkDataArray *array, vtkIdType start = 0);
57 static void *GetVoidPointer(vtkPoints *points, vtkIdType start = 0);
58 template <typename DT>
59 static DT *GetPointer(vtkDataArray *array, vtkIdType start = 0) {
60 return static_cast<DT *>(ttkUtils::GetVoidPointer(array, start));
61 }
62
63 static vtkSmartPointer<vtkAbstractArray> SliceArray(vtkAbstractArray *array,
64 vtkIdType idx);
65
66 static void *
67 WriteVoidPointer(vtkDataArray *array, vtkIdType start, vtkIdType numValues);
68 static void *
69 WritePointer(vtkDataArray *array, vtkIdType start, vtkIdType numValues);
70
71 static void
72 SetVoidArray(vtkDataArray *array, void *data, vtkIdType size, int save);
73
74 // Fill Cell array using a pointer with the old memory layout
75 // DEPRECATED
76 static void FillCellArrayFromSingle(vtkIdType const *cells,
77 vtkIdType ncells,
78 vtkCellArray *cellArray);
79
80 // Fill Cell array using a pointer with the new memory layout
81 static void FillCellArrayFromDual(vtkIdType const *cells_co,
82 vtkIdType const *cells_off,
83 vtkIdType ncells,
84 vtkCellArray *cellArray);
85
86 /*
87 * @brief Fills an UnstructuredGrid or a PolyData dataset with
88 * vertices
89 *
90 * @param[out] dataSet Dataset to fill (either UnstructuredGrid or
91 * PolyData)
92 * @param[in] points Input points
93 *
94 * @return 1 if success, 0 otherwise
95 */
96 static int CellVertexFromPoints(vtkDataSet *const dataSet,
97 vtkPoints *const points);
98};
TTK Util Functions.
Definition ttkUtils.h:28
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
Definition ttkUtils.cpp:226
static DT * GetPointer(vtkDataArray *array, vtkIdType start=0)
Definition ttkUtils.h:59