GCC Code Coverage Report


Directory: ./
File: openvdb_ax/openvdb_ax/test/integration/TestHarness.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 163 182 89.6%
Functions: 124 135 91.9%
Branches: 144 276 52.2%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include "TestHarness.h"
5 #include "../util.h"
6
7 #include <openvdb_ax/compiler/PointExecutable.h>
8 #include <openvdb_ax/compiler/VolumeExecutable.h>
9
10 #include <openvdb/points/PointConversion.h>
11 #include <openvdb/tools/ValueTransformer.h>
12
13 namespace unittest_util
14 {
15
16 1449 std::string loadText(const std::string& codeFileName)
17 {
18 2898 std::ostringstream sstream;
19
1/2
✓ Branch 1 taken 1449 times.
✗ Branch 2 not taken.
2898 std::ifstream fs(codeFileName);
20
21
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1449 times.
1449 if (fs.fail()) {
22 throw std::runtime_error(std::string("Failed to open ") + std::string(codeFileName));
23 }
24
25
1/2
✓ Branch 1 taken 1449 times.
✗ Branch 2 not taken.
1449 sstream << fs.rdbuf();
26 1449 return sstream.str();
27 }
28
29 728 bool wrapExecution(openvdb::points::PointDataGrid& grid,
30 const std::string& codeFileName,
31 const std::string * const group,
32 openvdb::ax::Logger& logger,
33 const openvdb::ax::CustomData::Ptr& data,
34 const openvdb::ax::CompilerOptions& opts,
35 const bool createMissing)
36 {
37 using namespace openvdb::ax;
38
39 1456 Compiler compiler(opts);
40
1/2
✓ Branch 1 taken 728 times.
✗ Branch 2 not taken.
728 const std::string code = loadText(codeFileName);
41
1/2
✓ Branch 1 taken 728 times.
✗ Branch 2 not taken.
728 ast::Tree::ConstPtr syntaxTree = ast::parse(code.c_str(), logger);
42
2/2
✓ Branch 0 taken 727 times.
✓ Branch 1 taken 1 times.
728 if (!syntaxTree) return false;
43
3/6
✓ Branch 1 taken 727 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 720 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1454 PointExecutable::Ptr executable = compiler.compile<PointExecutable>(*syntaxTree, logger, data);
44
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 7 times.
727 if (!executable) return false;
45
1/2
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
720 executable->setCreateMissing(createMissing);
46
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
720 if (group) executable->setGroupExecution(*group);
47
1/2
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
720 executable->execute(grid);
48 return true;
49 }
50
51 713 bool wrapExecution(openvdb::GridPtrVec& grids,
52 const std::string& codeFileName,
53 openvdb::ax::Logger& logger,
54 const openvdb::ax::CustomData::Ptr& data,
55 const openvdb::ax::CompilerOptions& opts,
56 const bool createMissing)
57 {
58 using namespace openvdb::ax;
59
60 1426 Compiler compiler(opts);
61
1/2
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
713 const std::string code = loadText(codeFileName);
62
63
1/2
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
713 ast::Tree::ConstPtr syntaxTree = ast::parse(code.c_str(), logger);
64
1/2
✓ Branch 0 taken 713 times.
✗ Branch 1 not taken.
713 if (!syntaxTree) return false;
65
2/6
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 713 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1426 VolumeExecutable::Ptr executable = compiler.compile<VolumeExecutable>(*syntaxTree, logger, data);
66
1/2
✓ Branch 0 taken 713 times.
✗ Branch 1 not taken.
713 if (!executable) return false;
67
1/2
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
713 executable->setCreateMissing(createMissing);
68
2/6
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 713 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
713 executable->setValueIterator(VolumeExecutable::IterType::ON);
69
1/2
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
713 executable->execute(grids);
70 return true;
71 }
72
73 1 void AXTestHarness::addInputGroups(const std::vector<std::string> &names,
74 const std::vector<bool> &defaults)
75 {
76
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (size_t i = 0; i < names.size(); i++) {
77
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for (auto& grid : mInputPointGrids) {
78 4 openvdb::points::appendGroup(grid->tree(), names[i]);
79 4 openvdb::points::setGroup(grid->tree(), names[i], defaults[i]);
80 }
81 }
82 1 }
83
84 2 void AXTestHarness::addExpectedGroups(const std::vector<std::string> &names,
85 const std::vector<bool> &defaults)
86 {
87
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 for (size_t i = 0; i < names.size(); i++) {
88
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 for (auto& grid : mOutputPointGrids) {
89 6 openvdb::points::appendGroup(grid->tree(), names[i]);
90 6 openvdb::points::setGroup(grid->tree(), names[i], defaults[i]);
91 }
92 }
93 2 }
94
95 369 bool AXTestHarness::executeCode(const std::string& codeFile,
96 const std::string* const group,
97 const bool createMissing)
98 {
99
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 1 times.
369 if (mUsePoints) {
100
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 360 times.
1088 for (auto& grid : mInputPointGrids) {
101 this->clear();
102
2/2
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 720 times.
728 if (!wrapExecution(*grid, codeFile, group, mLogger, mCustomData, mOpts, createMissing)) {
103 8 return false;
104 }
105 }
106 }
107
108
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 4 times.
361 if (mUseDenseVolumes) {
109 this->clear();
110
1/2
✓ Branch 1 taken 357 times.
✗ Branch 2 not taken.
357 if (!wrapExecution(mInputDenseVolumeGrids, codeFile, mLogger, mCustomData, mOpts, createMissing)) {
111 return false;
112 }
113 }
114
2/2
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 5 times.
361 if (mUseSparseVolumes) {
115 this->clear();
116
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 356 times.
356 if (!wrapExecution(mInputSparseVolumeGrids, codeFile, mLogger, mCustomData, mOpts, createMissing)) {
117 return false;
118 }
119 }
120 return true;
121 }
122
123 template <typename T>
124 1476 void AXTestHarness::addInputPtAttributes(const std::vector<std::string>& names,
125 const std::vector<T>& values)
126 {
127
2/2
✓ Branch 0 taken 1699 times.
✓ Branch 1 taken 738 times.
4874 for (size_t i = 0; i < names.size(); i++) {
128
2/2
✓ Branch 0 taken 3398 times.
✓ Branch 1 taken 1699 times.
10194 for (auto& grid : mInputPointGrids) {
129 6796 openvdb::points::appendAttribute<T>(grid->tree(), names[i], values[i]);
130 }
131 }
132 1476 }
133
134 template <typename T>
135 1494 void AXTestHarness::addInputVolumes(const std::vector<std::string>& names,
136 const std::vector<T>& values)
137 {
138 using GridType = typename openvdb::BoolGrid::ValueConverter<T>::Type;
139
140
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 747 times.
4946 for (size_t i = 0; i < names.size(); i++) {
141 1328 typename GridType::Ptr grid = GridType::create();
142
2/6
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 295 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4042 grid->denseFill(mVolumeBounds, values[i], true/*active*/);
143
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 grid->setName(names[i]);
144
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 mInputDenseVolumeGrids.emplace_back(grid);
145 }
146
147
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 747 times.
4946 for (size_t i = 0; i < names.size(); i++) {
148 1328 typename GridType::Ptr grid = GridType::create();
149
2/2
✓ Branch 0 taken 3452 times.
✓ Branch 1 taken 1726 times.
10356 for (const auto& config : mSparseVolumeConfig) {
150
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 3452 times.
17260 for (const auto& coord : config.second) {
151
1/4
✓ Branch 1 taken 5178 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
12126 grid->tree().addTile(config.first, coord, values[i], true);
152 }
153 }
154
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 grid->setName(names[i]);
155
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 mInputSparseVolumeGrids.emplace_back(grid);
156 }
157 1494 }
158
159 template <typename T>
160 1496 void AXTestHarness::addExpectedPtAttributes(const std::vector<std::string>& names,
161 const std::vector<T>& values)
162 {
163
2/2
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 748 times.
4954 for (size_t i = 0; i < names.size(); i++) {
164
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 1729 times.
10374 for (auto& grid : mOutputPointGrids) {
165 6916 openvdb::points::appendAttribute<T>(grid->tree(), names[i], values[i]);
166 }
167 }
168 1496 }
169
170 template <typename T>
171 1494 void AXTestHarness::addExpectedVolumes(const std::vector<std::string>& names,
172 const std::vector<T>& values)
173 {
174 using GridType = typename openvdb::BoolGrid::ValueConverter<T>::Type;
175
176
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 747 times.
4946 for (size_t i = 0; i < names.size(); i++) {
177 1328 typename GridType::Ptr grid = GridType::create();
178
2/4
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 295 times.
✗ Branch 5 not taken.
4042 grid->denseFill(mVolumeBounds, values[i], true/*active*/);
179
2/6
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1726 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3452 grid->setName(names[i] + "_expected");
180
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 mOutputDenseVolumeGrids.emplace_back(grid);
181 }
182
183
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 747 times.
4946 for (size_t i = 0; i < names.size(); i++) {
184 1328 typename GridType::Ptr grid = GridType::create();
185
2/2
✓ Branch 0 taken 3452 times.
✓ Branch 1 taken 1726 times.
10356 for (const auto& config : mSparseVolumeConfig) {
186
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 3452 times.
17260 for (const auto& coord : config.second) {
187
1/4
✓ Branch 1 taken 5178 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
12126 grid->tree().addTile(config.first, coord, values[i], true);
188 }
189 }
190
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 grid->setName(names[i]);
191
1/2
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
3452 mOutputSparseVolumeGrids.emplace_back(grid);
192 }
193 1494 }
194
195 362 bool AXTestHarness::checkAgainstExpected(std::ostream& sstream)
196 {
197 362 unittest_util::ComparisonSettings settings;
198 bool success = true;
199
200
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 1 times.
362 if (mUsePoints) {
201 722 std::stringstream resultStream;
202
1/2
✓ Branch 1 taken 361 times.
✗ Branch 2 not taken.
722 unittest_util::ComparisonResult result(resultStream);
203
204 const size_t count = mInputPointGrids.size();
205
2/2
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 361 times.
1083 for (size_t i = 0; i < count; ++i) {
206 const auto& input = mInputPointGrids[i];
207 const auto& expected = mOutputPointGrids[i];
208 const bool pass =
209
1/2
✓ Branch 1 taken 722 times.
✗ Branch 2 not taken.
722 unittest_util::compareGrids(result, *expected, *input, settings, nullptr);
210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
722 if (!pass) sstream << resultStream.str() << std::endl;
211 success &= pass;
212 }
213 }
214
215
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 4 times.
362 if (mUseDenseVolumes) {
216
2/2
✓ Branch 0 taken 2510 times.
✓ Branch 1 taken 358 times.
2868 for (size_t i = 0; i < mInputDenseVolumeGrids.size(); i++) {
217 5020 std::stringstream resultStream;
218
1/2
✓ Branch 1 taken 2510 times.
✗ Branch 2 not taken.
5020 unittest_util::ComparisonResult result(resultStream);
219 const bool volumeSuccess =
220
1/2
✓ Branch 1 taken 2510 times.
✗ Branch 2 not taken.
2510 unittest_util::compareUntypedGrids(result, *mOutputDenseVolumeGrids[i],
221 *mInputDenseVolumeGrids[i], settings, nullptr);
222 success &= volumeSuccess;
223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2510 times.
2510 if (!volumeSuccess) sstream << resultStream.str() << std::endl;
224 }
225 }
226
227
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 5 times.
362 if (mUseSparseVolumes) {
228
2/2
✓ Branch 0 taken 2509 times.
✓ Branch 1 taken 357 times.
2866 for (size_t i = 0; i < mInputSparseVolumeGrids.size(); i++) {
229 5018 std::stringstream resultStream;
230
1/2
✓ Branch 1 taken 2509 times.
✗ Branch 2 not taken.
5018 unittest_util::ComparisonResult result(resultStream);
231 const bool volumeSuccess =
232
1/2
✓ Branch 1 taken 2509 times.
✗ Branch 2 not taken.
2509 unittest_util::compareUntypedGrids(result, *mOutputSparseVolumeGrids[i],
233 *mInputSparseVolumeGrids[i], settings, nullptr);
234 success &= volumeSuccess;
235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2509 times.
2509 if (!volumeSuccess) sstream << resultStream.str() << std::endl;
236 }
237 }
238
239 362 return success;
240 }
241
242 3 void AXTestHarness::testVolumes(const bool enable)
243 {
244 3 mUseSparseVolumes = enable;
245 3 mUseDenseVolumes = enable;
246 3 }
247
248 1 void AXTestHarness::testSparseVolumes(const bool enable)
249 {
250 1 mUseSparseVolumes = enable;
251 1 }
252
253 1 void AXTestHarness::testDenseVolumes(const bool enable)
254 {
255 1 mUseDenseVolumes = enable;
256 1 }
257
258 1 void AXTestHarness::testPoints(const bool enable)
259 {
260 1 mUsePoints = enable;
261 1 }
262
263 void AXTestHarness::reset(const openvdb::Index64 ppv, const openvdb::CoordBBox& bounds)
264 {
265 using openvdb::points::PointDataGrid;
266 using openvdb::points::NullCodec;
267
268 mInputPointGrids.clear();
269 mOutputPointGrids.clear();
270 mInputSparseVolumeGrids.clear();
271 mInputDenseVolumeGrids.clear();
272 mOutputSparseVolumeGrids.clear();
273 mOutputDenseVolumeGrids.clear();
274
275 openvdb::math::Transform::Ptr transform =
276 openvdb::math::Transform::createLinearTransform(1.0);
277 openvdb::MaskGrid::Ptr mask = openvdb::MaskGrid::create();
278 mask->setTransform(transform);
279 mask->sparseFill(bounds, true, true);
280 openvdb::points::PointDataGrid::Ptr points =
281 openvdb::points::denseUniformPointScatter(*mask, static_cast<float>(ppv));
282 mask.reset();
283
284 mInputPointGrids.emplace_back(points);
285 mOutputPointGrids.emplace_back(points->deepCopy());
286 mOutputPointGrids.back()->setName("custom_expected");
287
288 mVolumeBounds = bounds;
289
290 this->clear();
291 }
292
293 278 void AXTestHarness::reset()
294 {
295 using openvdb::points::PointDataGrid;
296 using openvdb::points::NullCodec;
297
298 278 mInputPointGrids.clear();
299 278 mOutputPointGrids.clear();
300 278 mInputSparseVolumeGrids.clear();
301 278 mInputDenseVolumeGrids.clear();
302 278 mOutputSparseVolumeGrids.clear();
303 278 mOutputDenseVolumeGrids.clear();
304
305 std::vector<openvdb::Vec3d> coordinates =
306 {openvdb::Vec3d(0.0, 0.0, 0.0),
307 openvdb::Vec3d(0.0, 0.0, 0.05),
308 openvdb::Vec3d(0.0, 1.0, 0.0),
309 278 openvdb::Vec3d(1.0, 1.0, 0.0)};
310
311 openvdb::math::Transform::Ptr transform1 =
312
1/2
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
278 openvdb::math::Transform::createLinearTransform(1.0);
313
314 openvdb::points::PointDataGrid::Ptr onePointGrid =
315 openvdb::points::createPointDataGrid<NullCodec, PointDataGrid>
316
3/8
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 278 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
556 (std::vector<openvdb::Vec3d>{coordinates[0]}, *transform1);
317
318
2/4
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
278 onePointGrid->setName("1_point");
319
1/2
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
278 mInputPointGrids.emplace_back(onePointGrid);
320
3/8
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 278 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
556 mOutputPointGrids.emplace_back(onePointGrid->deepCopy());
321
2/4
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
278 mOutputPointGrids.back()->setName("1_point_expected");
322
323 openvdb::math::Transform::Ptr transform2 =
324
1/2
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
278 openvdb::math::Transform::createLinearTransform(0.1);
325
326 openvdb::points::PointDataGrid::Ptr fourPointGrid =
327 openvdb::points::createPointDataGrid<NullCodec, PointDataGrid>
328
1/2
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
278 (coordinates, *transform2);
329
330
2/4
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
278 fourPointGrid->setName("4_points");
331
1/2
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
278 mInputPointGrids.emplace_back(fourPointGrid);
332
3/8
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 278 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
556 mOutputPointGrids.emplace_back(fourPointGrid->deepCopy());
333
2/4
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 278 times.
✗ Branch 5 not taken.
556 mOutputPointGrids.back()->setName("4_points_expected");
334
335 278 mVolumeBounds = openvdb::CoordBBox({0,0,0}, {0,0,0});
336
337 this->clear();
338 278 }
339
340 template <typename ValueT>
341 using ConverterT = typename openvdb::BoolGrid::ValueConverter<ValueT>::Type;
342
343 116 void AXTestHarness::resetInputsToZero()
344 {
345
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 116 times.
348 for (auto& grid : mInputPointGrids) {
346
1/2
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
232 openvdb::tree::LeafManager<openvdb::points::PointDataTree> manager(grid->tree());
347
2/4
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 464 times.
✗ Branch 7 not taken.
696 manager.foreach([](openvdb::points::PointDataTree::LeafNodeType& leaf, size_t) {
348 const size_t attrs = leaf.attributeSet().size();
349
2/4
✓ Branch 1 taken 464 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
928 const size_t pidx = leaf.attributeSet().descriptor().find("P");
350
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 464 times.
4064 for (size_t idx = 0; idx < attrs; ++idx) {
351
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 3136 times.
3600 if (idx == pidx) continue;
352 3136 leaf.attributeArray(idx).collapse();
353 }
354 464 });
355 }
356
357 /// @todo: share with volume executable when the move to header files is made
358 /// for customization of grid types.
359 using SupportedTypeList = openvdb::TypeList<
360 ConverterT<double>,
361 ConverterT<float>,
362 ConverterT<int64_t>,
363 ConverterT<int32_t>,
364 ConverterT<int16_t>,
365 ConverterT<bool>,
366 ConverterT<openvdb::math::Vec2<double>>,
367 ConverterT<openvdb::math::Vec2<float>>,
368 ConverterT<openvdb::math::Vec2<int32_t>>,
369 ConverterT<openvdb::math::Vec3<double>>,
370 ConverterT<openvdb::math::Vec3<float>>,
371 ConverterT<openvdb::math::Vec3<int32_t>>,
372 ConverterT<openvdb::math::Vec4<double>>,
373 ConverterT<openvdb::math::Vec4<float>>,
374 ConverterT<openvdb::math::Vec4<int32_t>>,
375 ConverterT<openvdb::math::Mat3<double>>,
376 ConverterT<openvdb::math::Mat3<float>>,
377 ConverterT<openvdb::math::Mat4<double>>,
378 ConverterT<openvdb::math::Mat4<float>>,
379 ConverterT<std::string>>;
380
381
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 116 times.
900 for (auto& grid : mInputSparseVolumeGrids) {
382 2352 const bool success = grid->apply<SupportedTypeList>([](auto& typed) {
383 using GridType = typename std::decay<decltype(typed)>::type;
384 7939502 openvdb::tools::foreach(typed.beginValueAll(), [](auto it) {
385 50134320 it.setValue(openvdb::zeroVal<typename GridType::ValueType>());
386 });
387 1568 });
388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if (!success) {
389 throw std::runtime_error("Unable to reset input grid of an unsupported type");
390 }
391 }
392
393
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 116 times.
900 for (auto& grid : mInputDenseVolumeGrids) {
394 2352 const bool success = grid->apply<SupportedTypeList>([](auto& typed) {
395 using GridType = typename std::decay<decltype(typed)>::type;
396 4262204 openvdb::tools::foreach(typed.beginValueAll(), [](auto it) {
397 26909280 it.setValue(openvdb::zeroVal<typename GridType::ValueType>());
398 });
399 1568 });
400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if (!success) {
401 throw std::runtime_error("Unable to reset input grid of an unsupported type");
402 }
403 }
404 116 }
405
406
407 #define REGISTER_HARNESS_METHODS(T) \
408 template void AXTestHarness::addInputPtAttributes<T>(const std::vector<std::string>&, const std::vector<T>&); \
409 template void AXTestHarness::addInputVolumes<T>(const std::vector<std::string>&, const std::vector<T>&); \
410 template void AXTestHarness::addExpectedPtAttributes<T>(const std::vector<std::string>&, const std::vector<T>&); \
411 template void AXTestHarness::addExpectedVolumes<T>(const std::vector<std::string>&, const std::vector<T>&);
412
413 REGISTER_HARNESS_METHODS(double)
414 REGISTER_HARNESS_METHODS(float)
415 REGISTER_HARNESS_METHODS(int64_t)
416 REGISTER_HARNESS_METHODS(int32_t)
417 REGISTER_HARNESS_METHODS(int16_t)
418 REGISTER_HARNESS_METHODS(bool)
419 REGISTER_HARNESS_METHODS(openvdb::math::Vec2<double>)
420 REGISTER_HARNESS_METHODS(openvdb::math::Vec2<float>)
421 REGISTER_HARNESS_METHODS(openvdb::math::Vec2<int32_t>)
422 REGISTER_HARNESS_METHODS(openvdb::math::Vec3<double>)
423 REGISTER_HARNESS_METHODS(openvdb::math::Vec3<float>)
424 REGISTER_HARNESS_METHODS(openvdb::math::Vec3<int32_t>)
425 REGISTER_HARNESS_METHODS(openvdb::math::Vec4<double>)
426 REGISTER_HARNESS_METHODS(openvdb::math::Vec4<float>)
427 REGISTER_HARNESS_METHODS(openvdb::math::Vec4<int32_t>)
428 REGISTER_HARNESS_METHODS(openvdb::math::Mat3<double>)
429 REGISTER_HARNESS_METHODS(openvdb::math::Mat3<float>)
430 REGISTER_HARNESS_METHODS(openvdb::math::Mat4<double>)
431 REGISTER_HARNESS_METHODS(openvdb::math::Mat4<float>)
432 REGISTER_HARNESS_METHODS(std::string)
433
434 }
435
436
437