TTK
Loading...
Searching...
No Matches
CinemaImaging.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#include <Debug.h>
22
23#include <limits>
24#include <vector>
25
26namespace ttk {
27 class CinemaImaging : virtual public Debug {
28 public:
29 static const unsigned int INVALID_ID{
30 std::numeric_limits<unsigned int>::max()};
31 template <typename DT, typename IT>
32 int interpolateArray(DT *outputArray,
33
34 const unsigned int *primitiveIds,
35 const float *barycentricCoordinates,
36 const IT *connectivityList,
37
38 const DT *inputArray,
39 const size_t &nTuples,
40 const size_t &nComponents = 1,
41 const DT &missingValue
42 = std::numeric_limits<DT>::has_quiet_NaN
43 ? std::numeric_limits<DT>::quiet_NaN()
44 : std::numeric_limits<DT>::max()) const;
45
46 template <typename DT>
47 int lookupArray(DT *outputArray,
48
49 const unsigned int *primitiveIds,
50
51 const DT *inputArray,
52 const size_t &nTuples,
53 const size_t &nComponents = 1,
54 const DT &missingValue
55 = std::numeric_limits<DT>::has_quiet_NaN
56 ? std::numeric_limits<DT>::quiet_NaN()
57 : std::numeric_limits<DT>::max()) const;
58 };
59} // namespace ttk
60
61template <typename DT, typename IT>
63
64 const unsigned int *primitiveIds,
65 const float *barycentricCoordinates,
66 const IT *connectivityList,
67
68 const DT *inputArray,
69 const size_t &nTuples,
70 const size_t &nComponents,
71 const DT &missingValue) const {
72
73 if(nComponents != 1)
74 return 0;
75
76#ifdef TTK_ENABLE_OPENMP
77#pragma omp parallel for num_threads(this->threadNumber_)
78#endif
79 for(size_t i = 0; i < nTuples; i++) {
80 const unsigned int &cellId = primitiveIds[i];
81 if(cellId == CinemaImaging::INVALID_ID) {
82 outputArray[i] = missingValue;
83 continue;
84 }
85
86 const size_t cellIndex = cellId * 3;
87 const IT &v0 = connectivityList[cellIndex + 0];
88 const IT &v1 = connectivityList[cellIndex + 1];
89 const IT &v2 = connectivityList[cellIndex + 2];
90
91 const size_t bcIndex = i * 2;
92 const float &u = barycentricCoordinates[bcIndex + 0];
93 const float &v = barycentricCoordinates[bcIndex + 1];
94 const float w = 1 - u - v;
95
96 outputArray[i]
97 = w * inputArray[v0] + u * inputArray[v1] + v * inputArray[v2];
98 }
99
100 return 1;
101}
102
103template <typename DT>
105
106 const unsigned int *primitiveIds,
107
108 const DT *inputArray,
109 const size_t &nTuples,
110 const size_t &nComponents,
111 const DT &missingValue) const {
112
113#ifdef TTK_ENABLE_OPENMP
114#pragma omp parallel for num_threads(this->threadNumber_)
115#endif
116 for(size_t i = 0; i < nTuples; i++) {
117 size_t outputOffset = i * nComponents;
118 const unsigned int &cellId = primitiveIds[i];
119
120 if(cellId == CinemaImaging::INVALID_ID) {
121 for(size_t j = 0; j < nComponents; j++)
122 outputArray[outputOffset++] = missingValue;
123 continue;
124 } else {
125 size_t inputOffset = cellId * nComponents;
126 for(size_t j = 0; j < nComponents; j++)
127 outputArray[outputOffset++] = inputArray[inputOffset++];
128 }
129 }
130
131 return 1;
132}
TTK modules that generates images of a dataset.
static const unsigned int INVALID_ID
int interpolateArray(DT *outputArray, const unsigned int *primitiveIds, const float *barycentricCoordinates, const IT *connectivityList, const DT *inputArray, const size_t &nTuples, const size_t &nComponents=1, const DT &missingValue=std::numeric_limits< DT >::has_quiet_NaN ? std::numeric_limits< DT >::quiet_NaN() :std::numeric_limits< DT >::max()) const
int lookupArray(DT *outputArray, const unsigned int *primitiveIds, const DT *inputArray, const size_t &nTuples, const size_t &nComponents=1, const DT &missingValue=std::numeric_limits< DT >::has_quiet_NaN ? std::numeric_limits< DT >::quiet_NaN() :std::numeric_limits< DT >::max()) const
Minimalist debugging class.
Definition Debug.h:88
The Topology ToolKit.