Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | #include <openvdb/Types.h> | ||
5 | #include <openvdb/openvdb.h> | ||
6 | #include <openvdb/tools/ChangeBackground.h> | ||
7 | #include <openvdb/tools/Composite.h> // for csunion() | ||
8 | #include <openvdb/tools/Diagnostics.h> | ||
9 | #include <openvdb/tools/GridOperators.h> | ||
10 | #include <openvdb/tools/LevelSetUtil.h> | ||
11 | #include <openvdb/tools/LevelSetSphere.h> | ||
12 | #include <openvdb/tools/LevelSetAdvect.h> | ||
13 | #include <openvdb/tools/LevelSetMeasure.h> | ||
14 | #include <openvdb/tools/LevelSetMorph.h> | ||
15 | #include <openvdb/tools/LevelSetRebuild.h> | ||
16 | #include <openvdb/tools/LevelSetPlatonic.h> | ||
17 | #include <openvdb/tools/Mask.h> | ||
18 | #include <openvdb/tools/Morphology.h> | ||
19 | #include <openvdb/tools/PointAdvect.h> | ||
20 | #include <openvdb/tools/PointScatter.h> | ||
21 | #include <openvdb/tools/Prune.h> | ||
22 | #include <openvdb/tools/ValueTransformer.h> | ||
23 | #include <openvdb/tools/VectorTransformer.h> | ||
24 | #include <openvdb/tools/VolumeAdvect.h> | ||
25 | #include <openvdb/util/Util.h> | ||
26 | #include <openvdb/util/CpuTimer.h> | ||
27 | #include <openvdb/math/Stats.h> | ||
28 | #include "util.h" // for unittest_util::makeSphere() | ||
29 | #include <gtest/gtest.h> | ||
30 | #include <algorithm> // for std::sort | ||
31 | #include <atomic> | ||
32 | #include <random> | ||
33 | #include <sstream> | ||
34 | |||
35 | |||
36 | // Uncomment to test on models from our web-site | ||
37 | //#define TestTools_DATA_PATH "/home/kmu/src/openvdb/data/" | ||
38 | //#define TestTools_DATA_PATH "/usr/pic1/Data/OpenVDB/LevelSetModels/" | ||
39 | |||
40 | #define ASSERT_DOUBLES_EXACTLY_EQUAL(expected, actual) \ | ||
41 | EXPECT_NEAR((expected), (actual), /*tolerance=*/0.0); | ||
42 | |||
43 | 20 | class TestTools: public ::testing::Test | |
44 | { | ||
45 | public: | ||
46 | 20 | void SetUp() override { openvdb::initialize(); } | |
47 | 20 | void TearDown() override { openvdb::uninitialize(); } | |
48 | }; | ||
49 | |||
50 | |||
51 | #if 0 | ||
52 | namespace { | ||
53 | |||
54 | // Simple helper class to write out numbered vdbs | ||
55 | template<typename GridT> | ||
56 | class FrameWriter | ||
57 | { | ||
58 | public: | ||
59 | FrameWriter(int version, typename GridT::Ptr grid): | ||
60 | mFrame(0), mVersion(version), mGrid(grid) | ||
61 | {} | ||
62 | |||
63 | void operator()(const std::string& name, float time, size_t n) | ||
64 | { | ||
65 | std::ostringstream ostr; | ||
66 | ostr << name << "_" << mVersion << "_" << mFrame << ".vdb"; | ||
67 | openvdb::io::File file(ostr.str()); | ||
68 | openvdb::GridPtrVec grids; | ||
69 | grids.push_back(mGrid); | ||
70 | file.write(grids); | ||
71 | std::cerr << "\nWrote \"" << ostr.str() << "\" with time = " | ||
72 | << time << " after CFL-iterations = " << n << std::endl; | ||
73 | ++mFrame; | ||
74 | } | ||
75 | |||
76 | private: | ||
77 | int mFrame, mVersion; | ||
78 | typename GridT::Ptr mGrid; | ||
79 | }; | ||
80 | |||
81 | } // unnamed namespace | ||
82 | #endif | ||
83 | |||
84 | |||
85 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testInteriorMask) |
86 | { | ||
87 | using namespace openvdb; | ||
88 | |||
89 | const CoordBBox | ||
90 | 1 | extBand{Coord{-1}, Coord{100}}, | |
91 | 1 | isoBand{Coord{0}, Coord{99}}, | |
92 | 1 | intBand{Coord{1}, Coord{98}}, | |
93 | 1 | inside{Coord{2}, Coord{97}}; | |
94 | |||
95 | // Construct a "level set" with a three-voxel narrow band | ||
96 | // (the distances aren't correct, but they have the right sign). | ||
97 | 2 | FloatGrid lsgrid{/*background=*/2.f}; | |
98 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lsgrid.fill(extBand, 1.f); |
99 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lsgrid.fill(isoBand, 0.f); |
100 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lsgrid.fill(intBand, -1.f); |
101 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lsgrid.fill(inside, -2.f, /*active=*/false); |
102 | |||
103 | // For a non-level-set grid, tools::interiorMask() should return | ||
104 | // a mask of the active voxels. | ||
105 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | auto mask = tools::interiorMask(lsgrid); |
106 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
2 | EXPECT_EQ(extBand.volume() - inside.volume(), mask->activeVoxelCount()); |
107 | |||
108 | // For a level set, tools::interiorMask() should return a mask | ||
109 | // of the interior of the isosurface. | ||
110 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lsgrid.setGridClass(GRID_LEVEL_SET); |
111 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | mask = tools::interiorMask(lsgrid); |
112 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(intBand.volume(), mask->activeVoxelCount()); |
113 | 1 | } | |
114 | |||
115 | |||
116 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testLevelSetSphere) |
117 | { | ||
118 | const float radius = 4.3f; | ||
119 | const openvdb::Vec3f center(15.8f, 13.2f, 16.7f); | ||
120 | const float voxelSize = 1.5f, width = 3.25f; | ||
121 | const int dim = 32; | ||
122 | |||
123 | openvdb::FloatGrid::Ptr grid1 = | ||
124 | 1 | openvdb::tools::createLevelSetSphere<openvdb::FloatGrid>(radius, center, voxelSize, width); | |
125 | |||
126 | /// Also test ultra slow makeSphere in unittest/util.h | ||
127 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::FloatGrid::Ptr grid2 = openvdb::createLevelSet<openvdb::FloatGrid>(voxelSize, width); |
128 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<openvdb::FloatGrid>( |
129 | 1 | openvdb::Coord(dim), center, radius, *grid2, unittest_util::SPHERE_SPARSE_NARROW_BAND); | |
130 | |||
131 | 1 | const float outside = grid1->background(), inside = -outside; | |
132 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
|
33 | for (int i=0; i<dim; ++i) { |
133 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 32 times.
|
1056 | for (int j=0; j<dim; ++j) { |
134 |
2/2✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 1024 times.
|
33792 | for (int k=0; k<dim; ++k) { |
135 |
1/2✓ Branch 1 taken 32768 times.
✗ Branch 2 not taken.
|
32768 | const openvdb::Vec3f p(voxelSize*float(i), voxelSize*float(j), voxelSize*float(k)); |
136 |
1/2✓ Branch 1 taken 32768 times.
✗ Branch 2 not taken.
|
32768 | const float dist = (p-center).length() - radius; |
137 |
1/2✓ Branch 1 taken 32768 times.
✗ Branch 2 not taken.
|
32768 | const float val1 = grid1->tree().getValue(openvdb::Coord(i,j,k)); |
138 | ✗ | const float val2 = grid2->tree().getValue(openvdb::Coord(i,j,k)); | |
139 |
2/2✓ Branch 0 taken 31812 times.
✓ Branch 1 taken 956 times.
|
32768 | if (dist > outside) { |
140 |
2/16✓ Branch 1 taken 31812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31812 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
31812 | EXPECT_NEAR( outside, val1, 0.0001); |
141 |
2/16✓ Branch 1 taken 31812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31812 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
31812 | EXPECT_NEAR( outside, val2, 0.0001); |
142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 956 times.
|
956 | } else if (dist < inside) { |
143 | ✗ | EXPECT_NEAR( inside, val1, 0.0001); | |
144 | ✗ | EXPECT_NEAR( inside, val2, 0.0001); | |
145 | } else { | ||
146 |
2/16✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 956 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
956 | EXPECT_NEAR( dist, val1, 0.0001); |
147 |
2/16✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 956 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
956 | EXPECT_NEAR( dist, val2, 0.0001); |
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(grid1->activeVoxelCount(), grid2->activeVoxelCount()); |
154 | 1 | }// testLevelSetSphere | |
155 | |||
156 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testLevelSetPlatonic) |
157 | { | ||
158 | using namespace openvdb; | ||
159 | |||
160 | const float scale = 0.5f; | ||
161 | const Vec3f center(1.0f, 2.0f, 3.0f); | ||
162 | const float voxelSize = 0.025f, width = 2.0f, background = width*voxelSize; | ||
163 | const Coord ijk(int(center[0]/voxelSize), | ||
164 | int(center[1]/voxelSize), | ||
165 | int(center[2]/voxelSize));// inside | ||
166 | |||
167 | // The tests below are not particularly good (a visual inspection | ||
168 | // in Houdini is much better) but at least it exercises the code | ||
169 | // and performs an elementary suite of tests. | ||
170 | |||
171 | {// test tetrahedron | ||
172 | FloatGrid::Ptr ls = tools::createLevelSetTetrahedron<FloatGrid>(scale, center, | ||
173 | 1 | voxelSize, width); | |
174 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(ls->activeVoxelCount() > 0); |
175 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(ls->tree().isValueOff(ijk)); |
176 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(-ls->background(), ls->tree().getValue(ijk), 1e-6); |
177 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(background, ls->background(), 1e-6); |
178 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(ls->background(),ls->tree().getValue(Coord(0)), 1e-6); |
179 | } | ||
180 | {// test cube | ||
181 | FloatGrid::Ptr ls = tools::createLevelSetCube<FloatGrid>(scale, center, | ||
182 | 1 | voxelSize, width); | |
183 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(ls->activeVoxelCount() > 0); |
184 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(ls->tree().isValueOff(ijk)); |
185 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(-ls->background(),ls->tree().getValue(ijk), 1e-6); |
186 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(background, ls->background(), 1e-6); |
187 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(ls->background(),ls->tree().getValue(Coord(0)), 1e-6); |
188 | } | ||
189 | {// test octahedron | ||
190 | FloatGrid::Ptr ls = tools::createLevelSetOctahedron<FloatGrid>(scale, center, | ||
191 | 1 | voxelSize, width); | |
192 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(ls->activeVoxelCount() > 0); |
193 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(ls->tree().isValueOff(ijk)); |
194 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(-ls->background(),ls->tree().getValue(ijk), 1e-6); |
195 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(background, ls->background(), 1e-6); |
196 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(ls->background(),ls->tree().getValue(Coord(0)), 1e-6); |
197 | } | ||
198 | {// test icosahedron | ||
199 | FloatGrid::Ptr ls = tools::createLevelSetIcosahedron<FloatGrid>(scale, center, | ||
200 | 1 | voxelSize, width); | |
201 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(ls->activeVoxelCount() > 0); |
202 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(ls->tree().isValueOff(ijk)); |
203 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(-ls->background(),ls->tree().getValue(ijk), 1e-6); |
204 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(background, ls->background(), 1e-6); |
205 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(ls->background(),ls->tree().getValue(Coord(0)), 1e-6); |
206 | } | ||
207 | {// test dodecahedron | ||
208 | FloatGrid::Ptr ls = tools::createLevelSetDodecahedron<FloatGrid>(scale, center, | ||
209 | 1 | voxelSize, width); | |
210 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(ls->activeVoxelCount() > 0); |
211 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(ls->tree().isValueOff(ijk)); |
212 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(-ls->background(),ls->tree().getValue(ijk), 1e-6); |
213 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(background, ls->background(), 1e-6); |
214 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(ls->background(),ls->tree().getValue(Coord(0)), 1e-6); |
215 | } | ||
216 | |||
217 | 1 | }// testLevelSetPlatonic | |
218 | |||
219 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | TEST_F(TestTools, testLevelSetAdvect) |
220 | { | ||
221 | // Uncomment sections below to run this (time-consuming) test | ||
222 | using namespace openvdb; | ||
223 | |||
224 | const int dim = 128; | ||
225 | const Vec3f center(0.35f, 0.35f, 0.35f); | ||
226 | const float radius = 0.15f, voxelSize = 1.0f/(dim-1); | ||
227 | 1 | const float halfWidth = 3.0f, gamma = halfWidth*voxelSize; | |
228 | |||
229 | using GridT = FloatGrid; | ||
230 | //using VectT = Vec3fGrid; | ||
231 | |||
232 | {//test tracker::resize | ||
233 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | GridT::Ptr grid = tools::createLevelSetSphere<GridT>(radius, center, voxelSize, halfWidth); |
234 | using TrackerT = tools::LevelSetTracker<GridT>; | ||
235 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TrackerT tracker(*grid); |
236 | tracker.setSpatialScheme(math::FIRST_BIAS); | ||
237 | tracker.setTemporalScheme(math::TVD_RK1); | ||
238 | |||
239 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | ASSERT_DOUBLES_EXACTLY_EQUAL( gamma, grid->background()); |
240 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | ASSERT_DOUBLES_EXACTLY_EQUAL( halfWidth, tracker.getHalfWidth()); |
241 | |||
242 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(!tracker.resize()); |
243 | |||
244 | {// check range of on values in a sphere w/o mask | ||
245 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::CheckRange<GridT, true, true, GridT::ValueOnCIter> c(-gamma, gamma); |
246 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::Diagnose<GridT> d(*grid); |
247 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::string str = d.check(c); |
248 | //std::cerr << "Values out of range:\n" << str; | ||
249 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(str.empty()); |
250 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.valueCount())); |
251 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.failureCount())); |
252 | } | ||
253 | {// check norm of gradient of sphere w/o mask | ||
254 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::CheckNormGrad<GridT> c(*grid, 0.9f, 1.1f); |
255 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::Diagnose<GridT> d(*grid); |
256 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::string str = d.check(c, false, true, false, false); |
257 | //std::cerr << "NormGrad:\n" << str; | ||
258 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(str.empty()); |
259 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.valueCount())); |
260 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.failureCount())); |
261 | } | ||
262 | |||
263 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(tracker.resize(4)); |
264 | |||
265 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | ASSERT_DOUBLES_EXACTLY_EQUAL( 4*voxelSize, grid->background()); |
266 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | ASSERT_DOUBLES_EXACTLY_EQUAL( 4.0f, tracker.getHalfWidth()); |
267 | |||
268 | {// check range of on values in a sphere w/o mask | ||
269 | 1 | const float g = gamma + voxelSize; | |
270 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::CheckRange<GridT, true, true, GridT::ValueOnCIter> c(-g, g); |
271 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::Diagnose<GridT> d(*grid); |
272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::string str = d.check(c); |
273 | //std::cerr << "Values out of range:\n" << str; | ||
274 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(str.empty()); |
275 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.valueCount())); |
276 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.failureCount())); |
277 | } | ||
278 | {// check norm of gradient of sphere w/o mask | ||
279 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::CheckNormGrad<GridT> c(*grid, 0.4f, 1.1f); |
280 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::Diagnose<GridT> d(*grid); |
281 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::string str = d.check(c, false, true, false, false); |
282 | //std::cerr << "NormGrad:\n" << str; | ||
283 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(str.empty()); |
284 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.valueCount())); |
285 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, int(d.failureCount())); |
286 | } | ||
287 | } | ||
288 | /* | ||
289 | {//test tracker | ||
290 | GridT::Ptr grid = openvdb::tools::createLevelSetSphere<GridT>(radius, center, voxelSize); | ||
291 | using TrackerT = openvdb::tools::LevelSetTracker<GridT>; | ||
292 | TrackerT tracker(*grid); | ||
293 | tracker.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
294 | tracker.setTemporalScheme(openvdb::math::TVD_RK1); | ||
295 | |||
296 | FrameWriter<GridT> fw(dim, grid); fw("Tracker",0, 0); | ||
297 | //for (float t = 0, dt = 0.005f; !grid->empty() && t < 3.0f; t += dt) { | ||
298 | // fw("Enright", t + dt, advect.advect(t, t + dt)); | ||
299 | //} | ||
300 | for (float t = 0, dt = 0.5f; !grid->empty() && t < 1.0f; t += dt) { | ||
301 | tracker.track(); | ||
302 | fw("Tracker", 0, 0); | ||
303 | } | ||
304 | */ | ||
305 | |||
306 | /* | ||
307 | {//test EnrightField | ||
308 | GridT::Ptr grid = openvdb::tools::createLevelSetSphere<GridT>(radius, center, voxelSize); | ||
309 | using FieldT = openvdb::tools::EnrightField<float>; | ||
310 | FieldT field; | ||
311 | |||
312 | using AdvectT = openvdb::tools::LevelSetAdvection<GridT, FieldT>; | ||
313 | AdvectT advect(*grid, field); | ||
314 | advect.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
315 | advect.setTemporalScheme(openvdb::math::TVD_RK2); | ||
316 | advect.setTrackerSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
317 | advect.setTrackerTemporalScheme(openvdb::math::TVD_RK1); | ||
318 | |||
319 | FrameWriter<GridT> fw(dim, grid); fw("Enright",0, 0); | ||
320 | //for (float t = 0, dt = 0.005f; !grid->empty() && t < 3.0f; t += dt) { | ||
321 | // fw("Enright", t + dt, advect.advect(t, t + dt)); | ||
322 | //} | ||
323 | for (float t = 0, dt = 0.5f; !grid->empty() && t < 1.0f; t += dt) { | ||
324 | fw("Enright", t + dt, advect.advect(t, t + dt)); | ||
325 | } | ||
326 | } | ||
327 | */ | ||
328 | /* | ||
329 | {// test DiscreteGrid - Aligned | ||
330 | GridT::Ptr grid = openvdb::tools::createLevelSetSphere<GridT>(radius, center, voxelSize); | ||
331 | VectT vect(openvdb::Vec3f(1,0,0)); | ||
332 | using FieldT = openvdb::tools::DiscreteField<VectT>; | ||
333 | FieldT field(vect); | ||
334 | using AdvectT = openvdb::tools::LevelSetAdvection<GridT, FieldT>; | ||
335 | AdvectT advect(*grid, field); | ||
336 | advect.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
337 | advect.setTemporalScheme(openvdb::math::TVD_RK2); | ||
338 | |||
339 | FrameWriter<GridT> fw(dim, grid); fw("Aligned",0, 0); | ||
340 | //for (float t = 0, dt = 0.005f; !grid->empty() && t < 3.0f; t += dt) { | ||
341 | // fw("Aligned", t + dt, advect.advect(t, t + dt)); | ||
342 | //} | ||
343 | for (float t = 0, dt = 0.5f; !grid->empty() && t < 1.0f; t += dt) { | ||
344 | fw("Aligned", t + dt, advect.advect(t, t + dt)); | ||
345 | } | ||
346 | } | ||
347 | */ | ||
348 | /* | ||
349 | {// test DiscreteGrid - Transformed | ||
350 | GridT::Ptr grid = openvdb::tools::createLevelSetSphere<GridT>(radius, center, voxelSize); | ||
351 | VectT vect(openvdb::Vec3f(0,0,0)); | ||
352 | VectT::Accessor acc = vect.getAccessor(); | ||
353 | for (openvdb::Coord ijk(0); ijk[0]<dim; ++ijk[0]) | ||
354 | for (ijk[1]=0; ijk[1]<dim; ++ijk[1]) | ||
355 | for (ijk[2]=0; ijk[2]<dim; ++ijk[2]) | ||
356 | acc.setValue(ijk, openvdb::Vec3f(1,0,0)); | ||
357 | vect.transform().scale(2.0f); | ||
358 | using FieldT = openvdb::tools::DiscreteField<VectT>; | ||
359 | FieldT field(vect); | ||
360 | using AdvectT = openvdb::tools::LevelSetAdvection<GridT, FieldT>; | ||
361 | AdvectT advect(*grid, field); | ||
362 | advect.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
363 | advect.setTemporalScheme(openvdb::math::TVD_RK2); | ||
364 | |||
365 | FrameWriter<GridT> fw(dim, grid); fw("Xformed",0, 0); | ||
366 | //for (float t = 0, dt = 0.005f; !grid->empty() && t < 3.0f; t += dt) { | ||
367 | // fw("Xformed", t + dt, advect.advect(t, t + dt)); | ||
368 | //} | ||
369 | for (float t = 0, dt = 0.5f; !grid->empty() && t < 1.0f; t += dt) { | ||
370 | fw("Xformed", t + dt, advect.advect(t, t + dt)); | ||
371 | } | ||
372 | } | ||
373 | */ | ||
374 | 1 | }//testLevelSetAdvect | |
375 | |||
376 | |||
377 | //////////////////////////////////////// | ||
378 | |||
379 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testLevelSetMorph) |
380 | { | ||
381 | using GridT = openvdb::FloatGrid; | ||
382 | {//test morphing overlapping but aligned spheres | ||
383 | const int dim = 64; | ||
384 | const openvdb::Vec3f C1(0.35f, 0.35f, 0.35f), C2(0.4f, 0.4f, 0.4f); | ||
385 | const float radius = 0.15f, voxelSize = 1.0f/(dim-1); | ||
386 | |||
387 | 1 | GridT::Ptr source = openvdb::tools::createLevelSetSphere<GridT>(radius, C1, voxelSize); | |
388 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | GridT::Ptr target = openvdb::tools::createLevelSetSphere<GridT>(radius, C2, voxelSize); |
389 | |||
390 | using MorphT = openvdb::tools::LevelSetMorphing<GridT>; | ||
391 | MorphT morph(*source, *target); | ||
392 | morph.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
393 | morph.setTemporalScheme(openvdb::math::TVD_RK3); | ||
394 | morph.setTrackerSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
395 | morph.setTrackerTemporalScheme(openvdb::math::TVD_RK2); | ||
396 | |||
397 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const std::string name("SphereToSphere"); |
398 | //FrameWriter<GridT> fw(dim, source); | ||
399 | //fw(name, 0.0f, 0); | ||
400 | //util::CpuTimer timer; | ||
401 | const float tMax = 0.05f/voxelSize; | ||
402 | //std::cerr << "\nt-max = " << tMax << std::endl; | ||
403 | //timer.start("\nMorphing"); | ||
404 |
4/6✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 1 times.
|
33 | for (float t = 0, dt = 0.1f; !source->empty() && t < tMax; t += dt) { |
405 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | morph.advect(t, t + dt); |
406 | //fw(name, t + dt, morph.advect(t, t + dt)); | ||
407 | } | ||
408 | // timer.stop(); | ||
409 | |||
410 | const float invDx = 1.0f/voxelSize; | ||
411 | openvdb::math::Stats s; | ||
412 |
2/2✓ Branch 0 taken 7067 times.
✓ Branch 1 taken 1 times.
|
7068 | for (GridT::ValueOnCIter it = source->tree().cbeginValueOn(); it; ++it) { |
413 |
3/6✓ Branch 1 taken 7067 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7067 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 7067 times.
✗ Branch 9 not taken.
|
7067 | s.add( invDx*(*it - target->tree().getValue(it.getCoord())) ); |
414 | } | ||
415 |
2/2✓ Branch 0 taken 6955 times.
✓ Branch 1 taken 1 times.
|
6956 | for (GridT::ValueOnCIter it = target->tree().cbeginValueOn(); it; ++it) { |
416 |
3/6✓ Branch 1 taken 6955 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6955 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6955 times.
✗ Branch 9 not taken.
|
6955 | s.add( invDx*(*it - target->tree().getValue(it.getCoord())) ); |
417 | } | ||
418 | //s.print("Morph"); | ||
419 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(0.0, s.min(), 0.50); |
420 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(0.0, s.max(), 0.50); |
421 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(0.0, s.avg(), 0.02); |
422 | /* | ||
423 | openvdb::math::Histogram h(s, 30); | ||
424 | for (GridT::ValueOnCIter it = source->tree().cbeginValueOn(); it; ++it) { | ||
425 | h.add( invDx*(*it - target->tree().getValue(it.getCoord())) ); | ||
426 | } | ||
427 | for (GridT::ValueOnCIter it = target->tree().cbeginValueOn(); it; ++it) { | ||
428 | h.add( invDx*(*it - target->tree().getValue(it.getCoord())) ); | ||
429 | } | ||
430 | h.print("Morph"); | ||
431 | */ | ||
432 | } | ||
433 | /* | ||
434 | // Uncomment sections below to run this (very time-consuming) test | ||
435 | {//test morphing between the bunny and the buddha models loaded from files | ||
436 | util::CpuTimer timer; | ||
437 | openvdb::initialize();//required whenever I/O of OpenVDB files is performed! | ||
438 | openvdb::io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/bunny.vdb"); | ||
439 | sourceFile.open(); | ||
440 | GridT::Ptr source = openvdb::gridPtrCast<GridT>(sourceFile.getGrids()->at(0)); | ||
441 | |||
442 | openvdb::io::File targetFile("/usr/pic1/Data/OpenVDB/LevelSetModels/buddha.vdb"); | ||
443 | targetFile.open(); | ||
444 | GridT::Ptr target = openvdb::gridPtrCast<GridT>(targetFile.getGrids()->at(0)); | ||
445 | |||
446 | using MorphT = openvdb::tools::LevelSetMorphing<GridT>; | ||
447 | MorphT morph(*source, *target); | ||
448 | morph.setSpatialScheme(openvdb::math::FIRST_BIAS); | ||
449 | //morph.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
450 | morph.setTemporalScheme(openvdb::math::TVD_RK2); | ||
451 | morph.setTrackerSpatialScheme(openvdb::math::FIRST_BIAS); | ||
452 | //morph.setTrackerSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
453 | morph.setTrackerTemporalScheme(openvdb::math::TVD_RK2); | ||
454 | |||
455 | const std::string name("Bunny2Buddha"); | ||
456 | FrameWriter<GridT> fw(1, source); | ||
457 | fw(name, 0.0f, 0); | ||
458 | for (float t = 0, dt = 1.0f; !source->empty() && t < 300.0f; t += dt) { | ||
459 | timer.start("Morphing"); | ||
460 | const int cflCount = morph.advect(t, t + dt); | ||
461 | timer.stop(); | ||
462 | fw(name, t + dt, cflCount); | ||
463 | } | ||
464 | } | ||
465 | */ | ||
466 | /* | ||
467 | // Uncomment sections below to run this (very time-consuming) test | ||
468 | {//test morphing between the dragon and the teapot models loaded from files | ||
469 | util::CpuTimer timer; | ||
470 | openvdb::initialize();//required whenever I/O of OpenVDB files is performed! | ||
471 | openvdb::io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/dragon.vdb"); | ||
472 | sourceFile.open(); | ||
473 | GridT::Ptr source = openvdb::gridPtrCast<GridT>(sourceFile.getGrids()->at(0)); | ||
474 | |||
475 | openvdb::io::File targetFile("/usr/pic1/Data/OpenVDB/LevelSetModels/utahteapot.vdb"); | ||
476 | targetFile.open(); | ||
477 | GridT::Ptr target = openvdb::gridPtrCast<GridT>(targetFile.getGrids()->at(0)); | ||
478 | |||
479 | using MorphT = openvdb::tools::LevelSetMorphing<GridT>; | ||
480 | MorphT morph(*source, *target); | ||
481 | morph.setSpatialScheme(openvdb::math::FIRST_BIAS); | ||
482 | //morph.setSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
483 | morph.setTemporalScheme(openvdb::math::TVD_RK2); | ||
484 | //morph.setTrackerSpatialScheme(openvdb::math::HJWENO5_BIAS); | ||
485 | morph.setTrackerSpatialScheme(openvdb::math::FIRST_BIAS); | ||
486 | morph.setTrackerTemporalScheme(openvdb::math::TVD_RK2); | ||
487 | |||
488 | const std::string name("Dragon2Teapot"); | ||
489 | FrameWriter<GridT> fw(5, source); | ||
490 | fw(name, 0.0f, 0); | ||
491 | for (float t = 0, dt = 0.4f; !source->empty() && t < 110.0f; t += dt) { | ||
492 | timer.start("Morphing"); | ||
493 | const int cflCount = morph.advect(t, t + dt); | ||
494 | timer.stop(); | ||
495 | fw(name, t + dt, cflCount); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | */ | ||
500 | 1 | }//testLevelSetMorph | |
501 | |||
502 | //////////////////////////////////////// | ||
503 | |||
504 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testLevelSetMeasure) |
505 | { | ||
506 | const double percentage = 0.1/100.0;//i.e. 0.1% | ||
507 | using GridT = openvdb::FloatGrid; | ||
508 | const int dim = 256; | ||
509 | openvdb::Real area, volume, mean, gauss; | ||
510 | |||
511 | // First sphere | ||
512 | openvdb::Vec3f C(0.35f, 0.35f, 0.35f); | ||
513 | openvdb::Real r = 0.15, voxelSize = 1.0/(dim-1); | ||
514 | const openvdb::Real Pi = openvdb::math::pi<openvdb::Real>(); | ||
515 | 1 | GridT::Ptr sphere = openvdb::tools::createLevelSetSphere<GridT>(float(r), C, float(voxelSize)); | |
516 | |||
517 | using MeasureT = openvdb::tools::LevelSetMeasure<GridT>; | ||
518 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | MeasureT m(*sphere); |
519 | |||
520 | /// Test area and volume of sphere in world units | ||
521 | area = 4*Pi*r*r; | ||
522 | volume = 4.0/3.0*Pi*r*r*r; | ||
523 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
524 | //std::cerr << "\nVolume of sphere = " << volume << " " << v << std::endl; | ||
525 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
526 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(), percentage*area); |
527 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(), percentage*volume); |
528 | |||
529 | // Test area, volume and average mean curvature of sphere in world units | ||
530 | mean = 1.0/r; | ||
531 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
532 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
533 | //std::cerr << "radius in world units = " << r << std::endl; | ||
534 | //std::cerr << "Avg mean curvature of sphere = " << mean << " " << cm << std::endl; | ||
535 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
536 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(), percentage*area); |
537 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(), percentage*volume); |
538 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(), percentage*mean); |
539 | |||
540 | // Test area, volume, average mean curvature and average gaussian curvature of sphere in world units | ||
541 | gauss = 1.0/(r*r); | ||
542 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
543 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
544 | //std::cerr << "radius in world units = " << r << std::endl; | ||
545 | //std::cerr << "Avg mean curvature of sphere = " << mean << " " << cm << std::endl; | ||
546 | //std::cerr << "Avg gaussian curvature of sphere = " << gauss << " " << cg << std::endl; | ||
547 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
548 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(), percentage*area); |
549 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(), percentage*volume); |
550 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(), percentage*mean); |
551 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(gauss, m.avgGaussianCurvature(), percentage*gauss); |
552 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, m.genus()); |
553 | |||
554 | // Test measures of sphere in voxel units | ||
555 | r /= voxelSize; | ||
556 | area = 4*Pi*r*r; | ||
557 | volume = 4.0/3.0*Pi*r*r*r; | ||
558 | mean = 1.0/r; | ||
559 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
560 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
561 | //std::cerr << "Avg mean curvature of sphere = " << curv << " " << cm << std::endl; | ||
562 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
563 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(false), percentage*area); |
564 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(false), percentage*volume); |
565 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(false), percentage*mean); |
566 | |||
567 | gauss = 1.0/(r*r); | ||
568 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
569 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
570 | //std::cerr << "radius in voxel units = " << r << std::endl; | ||
571 | //std::cerr << "Avg mean curvature of sphere = " << mean << " " << cm << std::endl; | ||
572 | //std::cerr << "Avg gaussian curvature of sphere = " << gauss << " " << cg << std::endl; | ||
573 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
574 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(false), percentage*area); |
575 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(false), percentage*volume); |
576 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(false), percentage*mean); |
577 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(gauss, m.avgGaussianCurvature(false), percentage*gauss); |
578 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, m.genus()); |
579 | |||
580 | // Second sphere | ||
581 | 1 | C = openvdb::Vec3f(5.4f, 6.4f, 8.4f); | |
582 | r = 0.57; | ||
583 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | sphere = openvdb::tools::createLevelSetSphere<GridT>(float(r), C, float(voxelSize)); |
584 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | m.init(*sphere); |
585 | |||
586 | // Test all measures of sphere in world units | ||
587 | area = 4*Pi*r*r; | ||
588 | volume = 4.0/3.0*Pi*r*r*r; | ||
589 | mean = 1.0/r; | ||
590 | gauss = 1.0/(r*r); | ||
591 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
592 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
593 | //std::cerr << "radius in world units = " << r << std::endl; | ||
594 | //std::cerr << "Avg mean curvature of sphere = " << mean << " " << cm << std::endl; | ||
595 | //std::cerr << "Avg gaussian curvature of sphere = " << gauss << " " << cg << std::endl; | ||
596 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
597 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(), percentage*area); |
598 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(), percentage*volume); |
599 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(), percentage*mean); |
600 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(gauss, m.avgGaussianCurvature(), percentage*gauss); |
601 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, m.genus()); |
602 | //EXPECT_NEAR(area, openvdb::tools::levelSetArea(*sphere), percentage*area); | ||
603 | //EXPECT_NEAR(volume,openvdb::tools::levelSetVolume(*sphere),percentage*volume); | ||
604 | //EXPECT_EQ(0, openvdb::tools::levelSetGenus(*sphere)); | ||
605 | |||
606 | // Test all measures of sphere in voxel units | ||
607 | r /= voxelSize; | ||
608 | area = 4*Pi*r*r; | ||
609 | volume = 4.0/3.0*Pi*r*r*r; | ||
610 | mean = 1.0/r; | ||
611 | gauss = 1.0/(r*r); | ||
612 | //std::cerr << "\nArea of sphere = " << area << " " << a << std::endl; | ||
613 | //std::cerr << "Volume of sphere = " << volume << " " << v << std::endl; | ||
614 | //std::cerr << "radius in voxel units = " << r << std::endl; | ||
615 | //std::cerr << "Avg mean curvature of sphere = " << mean << " " << cm << std::endl; | ||
616 | //std::cerr << "Avg gaussian curvature of sphere = " << gauss << " " << cg << std::endl; | ||
617 | // Test accuracy of computed measures to within 0.1% of the exact measure. | ||
618 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, m.area(false), percentage*area); |
619 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume, m.volume(false), percentage*volume); |
620 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(mean, m.avgMeanCurvature(false), percentage*mean); |
621 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(gauss, m.avgGaussianCurvature(false), percentage*gauss); |
622 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(area, openvdb::tools::levelSetArea(*sphere,false), |
623 | percentage*area); | ||
624 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_NEAR(volume,openvdb::tools::levelSetVolume(*sphere,false), |
625 | percentage*volume); | ||
626 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(0, openvdb::tools::levelSetGenus(*sphere)); |
627 | |||
628 | // Read level set from file | ||
629 | /* | ||
630 | util::CpuTimer timer; | ||
631 | openvdb::initialize();//required whenever I/O of OpenVDB files is performed! | ||
632 | openvdb::io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/venusstatue.vdb"); | ||
633 | sourceFile.open(); | ||
634 | GridT::Ptr model = openvdb::gridPtrCast<GridT>(sourceFile.getGrids()->at(0)); | ||
635 | m.reinit(*model); | ||
636 | |||
637 | //m.setGrainSize(1); | ||
638 | timer.start("\nParallel measure of area and volume"); | ||
639 | m.measure(a, v, false); | ||
640 | timer.stop(); | ||
641 | std::cerr << "Model: area = " << a << ", volume = " << v << std::endl; | ||
642 | |||
643 | timer.start("\nParallel measure of area, volume and curvature"); | ||
644 | m.measure(a, v, c, false); | ||
645 | timer.stop(); | ||
646 | std::cerr << "Model: area = " << a << ", volume = " << v | ||
647 | << ", average curvature = " << c << std::endl; | ||
648 | |||
649 | m.setGrainSize(0); | ||
650 | timer.start("\nSerial measure of area and volume"); | ||
651 | m.measure(a, v, false); | ||
652 | timer.stop(); | ||
653 | std::cerr << "Model: area = " << a << ", volume = " << v << std::endl; | ||
654 | |||
655 | timer.start("\nSerial measure of area, volume and curvature"); | ||
656 | m.measure(a, v, c, false); | ||
657 | timer.stop(); | ||
658 | std::cerr << "Model: area = " << a << ", volume = " << v | ||
659 | << ", average curvature = " << c << std::endl; | ||
660 | */ | ||
661 | |||
662 | {// testing total genus of multiple disjoint level set spheres with different radius | ||
663 | const float dx = 0.5f, r = 50.0f; | ||
664 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | auto grid = openvdb::createLevelSet<openvdb::FloatGrid>(dx); |
665 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(openvdb::tools::levelSetGenus(*grid), openvdb::RuntimeError); |
666 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | for (int i=1; i<=3; ++i) { |
667 |
2/6✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3 | auto sphere = openvdb::tools::createLevelSetSphere<GridT>(r+float(i)*5.0f , openvdb::Vec3f(100.0f*float(i)), dx); |
668 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | openvdb::tools::csgUnion(*grid, *sphere); |
669 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | const int x = openvdb::tools::levelSetEulerCharacteristic(*grid);// since they are not overlapping re-normalization is not required |
670 | //std::cerr << "Euler characteristics of " << i << " sphere(s) = " << x << std::endl; | ||
671 |
2/18✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
3 | EXPECT_EQ(2*i, x); |
672 | } | ||
673 | } | ||
674 | {// testing total genus of multiple disjoint level set cubes of different size | ||
675 | const float dx = 0.5f, size = 50.0f; | ||
676 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | auto grid = openvdb::createLevelSet<openvdb::FloatGrid>(dx); |
677 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(openvdb::tools::levelSetGenus(*grid), openvdb::RuntimeError); |
678 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (int i=1; i<=2; ++i) { |
679 |
2/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2 | auto shape = openvdb::tools::createLevelSetCube<openvdb::FloatGrid>(size, openvdb::Vec3f(100.0f*float(i)), dx); |
680 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | openvdb::tools::csgUnion(*grid, *shape); |
681 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | const int x = openvdb::tools::levelSetEulerCharacteristic(*grid); |
682 | //std::cerr << "Euler characteristics of " << i << " cubes(s) = " << x << std::endl; | ||
683 |
2/18✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
2 | EXPECT_EQ(2*i, x); |
684 | } | ||
685 | } | ||
686 | {// testing Euler characteristic and total genus of multiple intersecting (connected) level set spheres | ||
687 | const float dx = 0.5f, r = 50.0f; | ||
688 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | auto grid = openvdb::createLevelSet<openvdb::FloatGrid>(dx); |
689 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(openvdb::tools::levelSetGenus(*grid), openvdb::RuntimeError); |
690 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int i=1; i<=4; ++i) { |
691 |
2/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
4 | auto sphere = openvdb::tools::createLevelSetSphere<GridT>( r , openvdb::Vec3f(30.0f*float(i), 0.0f, 0.0f), dx); |
692 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | openvdb::tools::csgUnion(*grid, *sphere); |
693 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | const int genus = openvdb::tools::levelSetGenus(*grid); |
694 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | const int x = openvdb::tools::levelSetEulerCharacteristic(*grid); |
695 | //std::cerr << "Genus of " << i << " sphere(s) = " << genus << std::endl; | ||
696 |
2/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
4 | EXPECT_EQ(0, genus); |
697 | //std::cerr << "Euler characteristics of " << i << " sphere(s) = " << genus << std::endl; | ||
698 |
2/18✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
4 | EXPECT_EQ(2, x); |
699 | } | ||
700 | } | ||
701 | |||
702 | 1 | }//testLevelSetMeasure | |
703 | |||
704 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testMagnitude) |
705 | { | ||
706 | using namespace openvdb; | ||
707 | { | ||
708 | 1 | FloatGrid::Ptr grid = FloatGrid::create(/*background=*/5.0); | |
709 | FloatTree& tree = grid->tree(); | ||
710 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
711 | |||
712 | const Coord dim(64,64,64); | ||
713 | const Vec3f center(35.0f, 30.0f, 40.0f); | ||
714 | const float radius=0.0f; | ||
715 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
716 | |||
717 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!tree.empty()); |
718 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_EQ(dim[0]*dim[1]*dim[2], int(tree.activeVoxelCount())); |
719 | |||
720 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | VectorGrid::Ptr gradGrid = tools::gradient(*grid); |
721 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(int(tree.activeVoxelCount()), int(gradGrid->activeVoxelCount())); |
722 | |||
723 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr mag = tools::magnitude(*gradGrid); |
724 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(int(tree.activeVoxelCount()), int(mag->activeVoxelCount())); |
725 | |||
726 | FloatGrid::ConstAccessor accessor = mag->getConstAccessor(); | ||
727 | |||
728 | Coord xyz(35,30,30); | ||
729 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | float v = accessor.getValue(xyz); |
730 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(1.0, v, 0.01); |
731 | |||
732 | xyz.reset(35,10,40); | ||
733 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | v = accessor.getValue(xyz); |
734 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(1.0, v, 0.01); |
735 | } | ||
736 | { | ||
737 | // Test on a grid with (only) tile values. | ||
738 | |||
739 | 2 | Vec3fGrid grid; | |
740 | Vec3fTree& tree = grid.tree(); | ||
741 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
742 | |||
743 | const Vec3f v(1.f, 2.f, 2.f); | ||
744 | const float expectedLength = v.length(); | ||
745 | |||
746 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.addTile(/*level=*/1, Coord(-100), v, /*active=*/true); |
747 | 1 | tree.addTile(/*level=*/1, Coord(100), v, /*active=*/true); | |
748 | |||
749 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!tree.empty()); |
750 | |||
751 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr length = tools::magnitude(grid); |
752 | |||
753 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(int(tree.activeVoxelCount()), int(length->activeVoxelCount())); |
754 | |||
755 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (auto it = length->cbeginValueOn(); it; ++it) { |
756 |
2/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_NEAR(expectedLength, *it, 1.0e-6); |
757 | } | ||
758 | } | ||
759 | 1 | } | |
760 | |||
761 | |||
762 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testMaskedMagnitude) |
763 | { | ||
764 | using namespace openvdb; | ||
765 | { | ||
766 | 1 | FloatGrid::Ptr grid = FloatGrid::create(/*background=*/5.0); | |
767 | FloatTree& tree = grid->tree(); | ||
768 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
769 | |||
770 | const Coord dim(64,64,64); | ||
771 | const Vec3f center(35.0f, 30.0f, 40.0f); | ||
772 | const float radius=0.0f; | ||
773 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
774 | |||
775 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!tree.empty()); |
776 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_EQ(dim[0]*dim[1]*dim[2], int(tree.activeVoxelCount())); |
777 | |||
778 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | VectorGrid::Ptr gradGrid = tools::gradient(*grid); |
779 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_EQ(int(tree.activeVoxelCount()), int(gradGrid->activeVoxelCount())); |
780 | |||
781 | // create a masking grid | ||
782 | 1 | const CoordBBox maskbbox(Coord(35, 30, 30), Coord(41, 41, 41)); | |
783 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | BoolGrid::Ptr maskGrid = BoolGrid::create(false); |
784 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2 | maskGrid->fill(maskbbox, true/*value*/, true/*activate*/); |
785 | |||
786 | // compute the magnitude in masked region | ||
787 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr mag = tools::magnitude(*gradGrid, *maskGrid); |
788 | |||
789 | FloatGrid::ConstAccessor accessor = mag->getConstAccessor(); | ||
790 | |||
791 | // test in the masked region | ||
792 | Coord xyz(35,30,30); | ||
793 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(maskbbox.isInside(xyz)); |
794 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | float v = accessor.getValue(xyz); |
795 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(1.0, v, 0.01); |
796 | |||
797 | // test outside the masked region | ||
798 | xyz.reset(35,10,40); | ||
799 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!maskbbox.isInside(xyz)); |
800 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | v = accessor.getValue(xyz); |
801 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(0.0, v, 0.01); |
802 | } | ||
803 | { | ||
804 | // Test on a grid with (only) tile values. | ||
805 | |||
806 | 2 | Vec3fGrid grid; | |
807 | Vec3fTree& tree = grid.tree(); | ||
808 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
809 | |||
810 | const Vec3f v(1.f, 2.f, 2.f); | ||
811 | const float expectedLength = v.length(); | ||
812 | |||
813 | 1 | tree.addTile(/*level=*/1, Coord(100), v, /*active=*/true); | |
814 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | const int expectedActiveVoxelCount = int(tree.activeVoxelCount()); |
815 | 1 | tree.addTile(/*level=*/1, Coord(-100), v, /*active=*/true); | |
816 | |||
817 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!tree.empty()); |
818 | |||
819 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | BoolGrid mask; |
820 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | mask.fill(CoordBBox(Coord(90), Coord(200)), true, true); |
821 | |||
822 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr length = tools::magnitude(grid, mask); |
823 | |||
824 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_EQ(expectedActiveVoxelCount, int(length->activeVoxelCount())); |
825 | |||
826 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | for (auto it = length->cbeginValueOn(); it; ++it) { |
827 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(expectedLength, *it, 1.0e-6); |
828 | } | ||
829 | } | ||
830 | 1 | } | |
831 | |||
832 | |||
833 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testNormalize) |
834 | { | ||
835 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(5.0); |
836 | openvdb::FloatTree& tree = grid->tree(); | ||
837 | |||
838 | const openvdb::Coord dim(64,64,64); | ||
839 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f); | ||
840 | const float radius=10.0f; | ||
841 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<openvdb::FloatGrid>( |
842 | dim,center,radius,*grid, unittest_util::SPHERE_DENSE); | ||
843 | |||
844 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_EQ(dim[0]*dim[1]*dim[2], int(tree.activeVoxelCount())); |
845 | openvdb::Coord xyz(10, 20, 30); | ||
846 | |||
847 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::VectorGrid::Ptr grad = openvdb::tools::gradient(*grid); |
848 | |||
849 | using Vec3Type = openvdb::VectorGrid::ValueType; | ||
850 | |||
851 | using ValueIter = openvdb::VectorGrid::ValueOnIter; | ||
852 | |||
853 | struct Local { | ||
854 | static inline Vec3Type op(const Vec3Type &x) { return x * 2.0f; } | ||
855 | 262144 | static inline void visit(const ValueIter& it) { it.setValue(op(*it)); } | |
856 | }; | ||
857 | |||
858 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | openvdb::tools::foreach(grad->beginValueOn(), Local::visit, true); |
859 | |||
860 | openvdb::VectorGrid::ConstAccessor accessor = grad->getConstAccessor(); | ||
861 | |||
862 | 1 | xyz = openvdb::Coord(35,10,40); | |
863 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Vec3Type v = accessor.getValue(xyz); |
864 | //std::cerr << "\nPassed testNormalize(" << xyz << ")=" << v.length() << std::endl; | ||
865 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(2.0,v.length(),0.001); |
866 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::VectorGrid::Ptr norm = openvdb::tools::normalize(*grad); |
867 | |||
868 | ✗ | accessor = norm->getConstAccessor(); | |
869 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | v = accessor.getValue(xyz); |
870 | //std::cerr << "\nPassed testNormalize(" << xyz << ")=" << v.length() << std::endl; | ||
871 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(1.0, v.length(), 0.0001); |
872 | 1 | } | |
873 | |||
874 | |||
875 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testMaskedNormalize) |
876 | { | ||
877 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(5.0); |
878 | openvdb::FloatTree& tree = grid->tree(); | ||
879 | |||
880 | const openvdb::Coord dim(64,64,64); | ||
881 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f); | ||
882 | const float radius=10.0f; | ||
883 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<openvdb::FloatGrid>( |
884 | dim,center,radius,*grid, unittest_util::SPHERE_DENSE); | ||
885 | |||
886 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_EQ(dim[0]*dim[1]*dim[2], int(tree.activeVoxelCount())); |
887 | openvdb::Coord xyz(10, 20, 30); | ||
888 | |||
889 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::VectorGrid::Ptr grad = openvdb::tools::gradient(*grid); |
890 | |||
891 | using Vec3Type = openvdb::VectorGrid::ValueType; | ||
892 | |||
893 | using ValueIter = openvdb::VectorGrid::ValueOnIter; | ||
894 | |||
895 | struct Local { | ||
896 | static inline Vec3Type op(const Vec3Type &x) { return x * 2.0f; } | ||
897 | 262144 | static inline void visit(const ValueIter& it) { it.setValue(op(*it)); } | |
898 | }; | ||
899 | |||
900 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | openvdb::tools::foreach(grad->beginValueOn(), Local::visit, true); |
901 | |||
902 | openvdb::VectorGrid::ConstAccessor accessor = grad->getConstAccessor(); | ||
903 | |||
904 | 1 | xyz = openvdb::Coord(35,10,40); | |
905 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Vec3Type v = accessor.getValue(xyz); |
906 | |||
907 | // create a masking grid | ||
908 | |||
909 | 1 | const openvdb::CoordBBox maskbbox(openvdb::Coord(35, 30, 30), openvdb::Coord(41, 41, 41)); | |
910 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | openvdb::BoolGrid::Ptr maskGrid = openvdb::BoolGrid::create(false); |
911 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2 | maskGrid->fill(maskbbox, true/*value*/, true/*activate*/); |
912 | |||
913 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(2.0,v.length(),0.001); |
914 | |||
915 | // compute the normalized valued in the masked region | ||
916 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::VectorGrid::Ptr norm = openvdb::tools::normalize(*grad, *maskGrid); |
917 | |||
918 |
1/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | accessor = norm->getConstAccessor(); |
919 | { // outside the masked region | ||
920 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!maskbbox.isInside(xyz)); |
921 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | v = accessor.getValue(xyz); |
922 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(0.0, v.length(), 0.0001); |
923 | } | ||
924 | { // inside the masked region | ||
925 | xyz.reset(35, 30, 30); | ||
926 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | v = accessor.getValue(xyz); |
927 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_NEAR(1.0, v.length(), 0.0001); |
928 | } | ||
929 | 1 | } | |
930 | |||
931 | //////////////////////////////////////// | ||
932 | |||
933 | |||
934 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testPointAdvect) |
935 | { | ||
936 | { | ||
937 | // Setup: Advect a number of points in a uniform velocity field (1,1,1). | ||
938 | // over a time dt=1 with each of the 4 different advection schemes. | ||
939 | // Points initialized at latice points. | ||
940 | // | ||
941 | // Uses: FloatTree (velocity), collocated sampling, advection | ||
942 | // | ||
943 | // Expected: All advection schemes will have the same result. Each point will | ||
944 | // be advanced to a new latice point. The i-th point will be at (i+1,i+1,i+1) | ||
945 | // | ||
946 | |||
947 | const size_t numPoints = 2000000; | ||
948 | |||
949 | // create a uniform velocity field in SINGLE PRECISION | ||
950 | const openvdb::Vec3f velocityBackground(1, 1, 1); | ||
951 | 1 | openvdb::Vec3fGrid::Ptr velocityGrid = openvdb::Vec3fGrid::create(velocityBackground); | |
952 | |||
953 | // using all the default template arguments | ||
954 | openvdb::tools::PointAdvect<> advectionTool(*velocityGrid); | ||
955 | |||
956 | // create points | ||
957 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | std::vector<openvdb::Vec3f> pointList(numPoints); /// larger than the tbb chunk size |
958 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2000000 times.
|
2000001 | for (size_t i = 0; i < numPoints; i++) { |
959 | 2000000 | pointList[i] = openvdb::Vec3f(float(i), float(i), float(i)); | |
960 | } | ||
961 | |||
962 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (unsigned int order = 1; order < 5; ++order) { |
963 | // check all four time integrations schemes | ||
964 | // construct an advection tool. By default the number of cpt iterations is zero | ||
965 | advectionTool.setIntegrationOrder(order); | ||
966 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | advectionTool.advect(pointList, /*dt=*/1.0, /*iterations=*/1); |
967 | |||
968 | // check locations | ||
969 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8000000 times.
|
8000004 | for (size_t i = 0; i < numPoints; i++) { |
970 |
1/2✓ Branch 1 taken 8000000 times.
✗ Branch 2 not taken.
|
8000000 | openvdb::Vec3f expected(float(i + 1), float(i + 1), float(i + 1)); |
971 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 8000000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
8000000 | EXPECT_EQ(expected, pointList[i]); |
972 | } | ||
973 | // reset values | ||
974 |
2/2✓ Branch 0 taken 8000000 times.
✓ Branch 1 taken 4 times.
|
8000004 | for (size_t i = 0; i < numPoints; i++) { |
975 | 8000000 | pointList[i] = openvdb::Vec3f(float(i), float(i), float(i)); | |
976 | } | ||
977 | } | ||
978 | |||
979 | } | ||
980 | |||
981 | { | ||
982 | // Setup: Advect a number of points in a uniform velocity field (1,1,1). | ||
983 | // over a time dt=1 with each of the 4 different advection schemes. | ||
984 | // And then project the point location onto the x-y plane | ||
985 | // Points initialized at latice points. | ||
986 | // | ||
987 | // Uses: DoubleTree (velocity), staggered sampling, constraint projection, advection | ||
988 | // | ||
989 | // Expected: All advection schemes will have the same result. Modes 1-4: Each point will | ||
990 | // be advanced to a new latice point and projected to x-y plane. | ||
991 | // The i-th point will be at (i+1,i+1,0). For mode 0 (no advection), i-th point | ||
992 | // will be found at (i, i, 0) | ||
993 | |||
994 | const size_t numPoints = 4; | ||
995 | |||
996 | // create a uniform velocity field in DOUBLE PRECISION | ||
997 | const openvdb::Vec3d velocityBackground(1, 1, 1); | ||
998 | 1 | openvdb::Vec3dGrid::Ptr velocityGrid = openvdb::Vec3dGrid::create(velocityBackground); | |
999 | |||
1000 | // create a simple (horizontal) constraint field valid for a | ||
1001 | // (-10,10)x(-10,10)x(-10,10) | ||
1002 | const openvdb::Vec3d cptBackground(0, 0, 0); | ||
1003 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::Vec3dGrid::Ptr cptGrid = openvdb::Vec3dGrid::create(cptBackground); |
1004 | openvdb::Vec3dTree& cptTree = cptGrid->tree(); | ||
1005 | |||
1006 | // create points | ||
1007 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | std::vector<openvdb::Vec3d> pointList(numPoints); |
1008 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (unsigned int i = 0; i < numPoints; i++) pointList[i] = openvdb::Vec3d(i, i, i); |
1009 | |||
1010 | // Initialize the constraint field in a [-10,10]x[-10,10]x[-10,10] box | ||
1011 | // this test will only work if the points remain in the box | ||
1012 | openvdb::Coord ijk(0, 0, 0); | ||
1013 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
|
22 | for (int i = -10; i < 11; i++) { |
1014 | ijk.setX(i); | ||
1015 |
2/2✓ Branch 0 taken 441 times.
✓ Branch 1 taken 21 times.
|
462 | for (int j = -10; j < 11; j++) { |
1016 | ijk.setY(j); | ||
1017 |
2/2✓ Branch 0 taken 9261 times.
✓ Branch 1 taken 441 times.
|
9702 | for (int k = -10; k < 11; k++) { |
1018 | ijk.setZ(k); | ||
1019 | // set the value as projection onto the x-y plane | ||
1020 |
1/4✓ Branch 1 taken 9261 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
18522 | cptTree.setValue(ijk, openvdb::Vec3d(i, j, 0)); |
1021 | } | ||
1022 | } | ||
1023 | } | ||
1024 | |||
1025 | // construct an advection tool. By default the number of cpt iterations is zero | ||
1026 | openvdb::tools::ConstrainedPointAdvect<openvdb::Vec3dGrid, | ||
1027 | std::vector<openvdb::Vec3d>, true> constrainedAdvectionTool(*velocityGrid, *cptGrid, 0); | ||
1028 | constrainedAdvectionTool.setThreaded(false); | ||
1029 | |||
1030 | // change the number of constraint interation from default 0 to 5 | ||
1031 | constrainedAdvectionTool.setConstraintIterations(5); | ||
1032 | |||
1033 | // test the pure-projection mode (order = 0) | ||
1034 | constrainedAdvectionTool.setIntegrationOrder(0); | ||
1035 | |||
1036 | // change the number of constraint interation (from 0 to 5) | ||
1037 | constrainedAdvectionTool.setConstraintIterations(5); | ||
1038 | |||
1039 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | constrainedAdvectionTool.advect(pointList, /*dt=*/1.0, /*iterations=*/1); |
1040 | |||
1041 | // check locations | ||
1042 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
|
5 | for (unsigned int i = 0; i < numPoints; i++) { |
1043 | 4 | openvdb::Vec3d expected(i, i, 0); // location (i, i, i) projected on to x-y plane | |
1044 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
|
16 | for (int n=0; n<3; ++n) { |
1045 |
3/18✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
12 | EXPECT_NEAR(expected[n], pointList[i][n], /*tolerance=*/1e-6); |
1046 | } | ||
1047 | } | ||
1048 | |||
1049 | // reset values | ||
1050 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
|
5 | for (unsigned int i = 0; i < numPoints; i++) pointList[i] = openvdb::Vec3d(i, i, i); |
1051 | |||
1052 | // test all four time integrations schemes | ||
1053 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (unsigned int order = 1; order < 5; ++order) { |
1054 | |||
1055 | constrainedAdvectionTool.setIntegrationOrder(order); | ||
1056 | |||
1057 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | constrainedAdvectionTool.advect(pointList, /*dt=*/1.0, /*iterations=*/1); |
1058 | |||
1059 | // check locations | ||
1060 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
|
20 | for (unsigned int i = 0; i < numPoints; i++) { |
1061 | 16 | openvdb::Vec3d expected(i+1, i+1, 0); // location (i,i,i) projected onto x-y plane | |
1062 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
|
64 | for (int n=0; n<3; ++n) { |
1063 |
3/18✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 48 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
48 | EXPECT_NEAR(expected[n], pointList[i][n], /*tolerance=*/1e-6); |
1064 | } | ||
1065 | } | ||
1066 | // reset values | ||
1067 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
|
20 | for (unsigned int i = 0; i < numPoints; i++) pointList[i] = openvdb::Vec3d(i, i, i); |
1068 | } | ||
1069 | } | ||
1070 | 1 | } | |
1071 | |||
1072 | |||
1073 | //////////////////////////////////////// | ||
1074 | |||
1075 | |||
1076 | namespace { | ||
1077 | |||
1078 | struct PointList | ||
1079 | { | ||
1080 | struct Point { double x,y,z; }; | ||
1081 | std::vector<Point> list; | ||
1082 | openvdb::Index64 size() const { return openvdb::Index64(list.size()); } | ||
1083 | 2806826 | void add(const openvdb::Vec3d &p) { Point q={p[0],p[1],p[2]}; list.push_back(q); } | |
1084 | }; | ||
1085 | } | ||
1086 | |||
1087 | |||
1088 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testPointScatter) |
1089 | { | ||
1090 | using GridType = openvdb::FloatGrid; | ||
1091 | const openvdb::Coord dim(64, 64, 64); | ||
1092 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f); | ||
1093 | const float radius = 20.0; | ||
1094 | using RandGen = std::mersenne_twister_engine<uint32_t, 32, 351, 175, 19, | ||
1095 | 0xccab8ee7, 11, 0xffffffff, 7, 0x31b6ab00, 15, 0xffe50000, 17, 1812433253>; // mt11213b | ||
1096 | RandGen mtRand; | ||
1097 | |||
1098 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GridType::Ptr grid = GridType::create(/*background=*/2.0); |
1099 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<GridType>( |
1100 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE_NARROW_BAND); | ||
1101 | |||
1102 | {// test fixed point count scattering | ||
1103 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const openvdb::Index64 pointCount = 1000; |
1104 | PointList points; | ||
1105 | openvdb::tools::UniformPointScatter<PointList, RandGen> scatter(points, pointCount, mtRand); | ||
1106 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | scatter.operator()<GridType>(*grid); |
1107 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ( pointCount, scatter.getPointCount() ); |
1108 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ( pointCount, points.size() ); |
1109 | } | ||
1110 | {// test uniform density scattering | ||
1111 | const float density = 1.0f;//per volume = per voxel since voxel size = 1 | ||
1112 | PointList points; | ||
1113 | openvdb::tools::UniformPointScatter<PointList, RandGen> scatter(points, density, mtRand); | ||
1114 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | scatter.operator()<GridType>(*grid); |
1115 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ( scatter.getVoxelCount(), scatter.getPointCount() ); |
1116 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ( scatter.getVoxelCount(), points.size() ); |
1117 | } | ||
1118 | {// test non-uniform density scattering | ||
1119 | const float density = 1.0f;//per volume = per voxel since voxel size = 1 | ||
1120 | PointList points; | ||
1121 | openvdb::tools::NonUniformPointScatter<PointList, RandGen> scatter(points, density, mtRand); | ||
1122 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | scatter.operator()<GridType>(*grid); |
1123 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( scatter.getVoxelCount() < scatter.getPointCount() ); |
1124 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ( scatter.getPointCount(), points.size() ); |
1125 | } | ||
1126 | {// test dense uniform scattering | ||
1127 | const size_t pointsPerVoxel = 8; | ||
1128 | PointList points; | ||
1129 | openvdb::tools::DenseUniformPointScatter<PointList, RandGen> | ||
1130 | scatter(points, pointsPerVoxel, mtRand); | ||
1131 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | scatter.operator()<GridType>(*grid); |
1132 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ( scatter.getVoxelCount()*pointsPerVoxel, scatter.getPointCount() ); |
1133 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ( scatter.getPointCount(), points.size() ); |
1134 | } | ||
1135 | 1 | } | |
1136 | |||
1137 | //////////////////////////////////////// | ||
1138 | |||
1139 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testVolumeAdvect) |
1140 | { | ||
1141 | using namespace openvdb; | ||
1142 | |||
1143 | 2 | Vec3fGrid velocity(Vec3f(1.0f, 0.0f, 0.0f)); | |
1144 | using GridT = FloatGrid; | ||
1145 | using AdvT = tools::VolumeAdvection<Vec3fGrid>; | ||
1146 | using SamplerT = tools::Sampler<1>; | ||
1147 | |||
1148 | {//test non-uniform grids (throws) | ||
1149 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | GridT::Ptr density0 = GridT::create(0.0f); |
1150 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | density0->transform().preScale(Vec3d(1.0, 2.0, 3.0));//i.e. non-uniform voxels |
1151 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AdvT a(velocity); |
1152 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW((a.advect<GridT, SamplerT>(*density0, 0.1f)), RuntimeError); |
1153 | } | ||
1154 | |||
1155 | {// test spatialOrder and temporalOrder | ||
1156 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AdvT a(velocity); |
1157 | |||
1158 | // Default should be SEMI | ||
1159 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.spatialOrder()); |
1160 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.temporalOrder()); |
1161 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1162 | |||
1163 | a.setIntegrator(tools::Scheme::SEMI); | ||
1164 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.spatialOrder()); |
1165 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.temporalOrder()); |
1166 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1167 | |||
1168 | a.setIntegrator(tools::Scheme::MID); | ||
1169 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.spatialOrder()); |
1170 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.temporalOrder()); |
1171 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1172 | |||
1173 | a.setIntegrator(tools::Scheme::RK3); | ||
1174 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.spatialOrder()); |
1175 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(3, a.temporalOrder()); |
1176 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1177 | |||
1178 | a.setIntegrator(tools::Scheme::RK4); | ||
1179 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(1, a.spatialOrder()); |
1180 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(4, a.temporalOrder()); |
1181 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1182 | |||
1183 | a.setIntegrator(tools::Scheme::MAC); | ||
1184 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.spatialOrder()); |
1185 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.temporalOrder()); |
1186 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( a.isLimiterOn()); |
1187 | |||
1188 | a.setIntegrator(tools::Scheme::BFECC); | ||
1189 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.spatialOrder()); |
1190 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.temporalOrder()); |
1191 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( a.isLimiterOn()); |
1192 | |||
1193 | a.setLimiter(tools::Scheme::NO_LIMITER); | ||
1194 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.spatialOrder()); |
1195 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(2, a.temporalOrder()); |
1196 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!a.isLimiterOn()); |
1197 | } | ||
1198 | |||
1199 | {//test RK4 advect without a mask | ||
1200 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | GridT::Ptr density0 = GridT::create(0.0f), density1; |
1201 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | density0->fill(CoordBBox(Coord(0),Coord(6)), 1.0f); |
1202 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord( 3,3,3)), 1.0f); |
1203 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(24,3,3)), 0.0f); |
1204 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( density0->tree().isValueOn(Coord( 3,3,3))); |
1205 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!density0->tree().isValueOn(Coord(24,3,3))); |
1206 | |||
1207 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AdvT a(velocity); |
1208 | a.setIntegrator(tools::Scheme::RK4); | ||
1209 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 1 times.
|
241 | for (int i=1; i<=240; ++i) { |
1210 |
1/2✓ Branch 1 taken 240 times.
✗ Branch 2 not taken.
|
480 | density1 = a.advect<GridT, SamplerT>(*density0, 0.1f); |
1211 | //std::ostringstream ostr; | ||
1212 | //ostr << "densityAdvect" << "_" << i << ".vdb"; | ||
1213 | //std::cerr << "Writing " << ostr.str() << std::endl; | ||
1214 | //openvdb::io::File file(ostr.str()); | ||
1215 | //openvdb::GridPtrVec grids; | ||
1216 | //grids.push_back(density1); | ||
1217 | //file.write(grids); | ||
1218 | density0 = density1; | ||
1219 | } | ||
1220 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(3,3,3)), 0.0f); |
1221 |
1/18✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
1 | EXPECT_TRUE(density0->tree().getValue(Coord(24,3,3)) > 0.0f); |
1222 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!density0->tree().isValueOn(Coord( 3,3,3))); |
1223 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( density0->tree().isValueOn(Coord(24,3,3))); |
1224 | } | ||
1225 | {//test MAC advect without a mask | ||
1226 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | GridT::Ptr density0 = GridT::create(0.0f), density1; |
1227 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | density0->fill(CoordBBox(Coord(0),Coord(6)), 1.0f); |
1228 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord( 3,3,3)), 1.0f); |
1229 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(24,3,3)), 0.0f); |
1230 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( density0->tree().isValueOn(Coord( 3,3,3))); |
1231 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!density0->tree().isValueOn(Coord(24,3,3))); |
1232 | |||
1233 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AdvT a(velocity); |
1234 | a.setIntegrator(tools::Scheme::BFECC); | ||
1235 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 1 times.
|
241 | for (int i=1; i<=240; ++i) { |
1236 |
1/2✓ Branch 1 taken 240 times.
✗ Branch 2 not taken.
|
480 | density1 = a.advect<GridT, SamplerT>(*density0, 0.1f); |
1237 | //std::ostringstream ostr; | ||
1238 | //ostr << "densityAdvect" << "_" << i << ".vdb"; | ||
1239 | //std::cerr << "Writing " << ostr.str() << std::endl; | ||
1240 | //openvdb::io::File file(ostr.str()); | ||
1241 | //openvdb::GridPtrVec grids; | ||
1242 | //grids.push_back(density1); | ||
1243 | //file.write(grids); | ||
1244 | density0 = density1; | ||
1245 | } | ||
1246 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(3,3,3)), 0.0f); |
1247 |
1/18✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
1 | EXPECT_TRUE(density0->tree().getValue(Coord(24,3,3)) > 0.0f); |
1248 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!density0->tree().isValueOn(Coord( 3,3,3))); |
1249 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( density0->tree().isValueOn(Coord(24,3,3))); |
1250 | } | ||
1251 | {//test advect with a mask | ||
1252 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | GridT::Ptr density0 = GridT::create(0.0f), density1; |
1253 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | density0->fill(CoordBBox(Coord(0),Coord(6)), 1.0f); |
1254 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord( 3,3,3)), 1.0f); |
1255 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(24,3,3)), 0.0f); |
1256 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE( density0->tree().isValueOn(Coord( 3,3,3))); |
1257 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!density0->tree().isValueOn(Coord(24,3,3))); |
1258 | |||
1259 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | BoolGrid::Ptr mask = BoolGrid::create(false); |
1260 |
1/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | mask->fill(CoordBBox(Coord(4,0,0),Coord(30,8,8)), true); |
1261 | |||
1262 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AdvT a(velocity); |
1263 | a.setGrainSize(0); | ||
1264 | a.setIntegrator(tools::Scheme::MAC); | ||
1265 | //a.setIntegrator(tools::Scheme::BFECC); | ||
1266 | //a.setIntegrator(tools::Scheme::RK4); | ||
1267 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 1 times.
|
241 | for (int i=1; i<=240; ++i) { |
1268 |
1/2✓ Branch 1 taken 240 times.
✗ Branch 2 not taken.
|
480 | density1 = a.advect<GridT, BoolGrid, SamplerT>(*density0, *mask, 0.1f); |
1269 | //std::ostringstream ostr; | ||
1270 | //ostr << "densityAdvectMask" << "_" << i << ".vdb"; | ||
1271 | //std::cerr << "Writing " << ostr.str() << std::endl; | ||
1272 | //openvdb::io::File file(ostr.str()); | ||
1273 | //openvdb::GridPtrVec grids; | ||
1274 | //grids.push_back(density1); | ||
1275 | //file.write(grids); | ||
1276 | density0 = density1; | ||
1277 | } | ||
1278 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(density0->tree().getValue(Coord(3,3,3)), 1.0f); |
1279 |
1/18✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
1 | EXPECT_TRUE(density0->tree().getValue(Coord(24,3,3)) > 0.0f); |
1280 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(density0->tree().isValueOn(Coord( 3,3,3))); |
1281 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(density0->tree().isValueOn(Coord(24,3,3))); |
1282 | } | ||
1283 | |||
1284 | /* | ||
1285 | {//benchmark on a sphere | ||
1286 | util::CpuTimer timer; | ||
1287 | GridT::Ptr density0 = GridT::create(0.0f), density1; | ||
1288 | density0->fill(CoordBBox(Coord(0), Coord(600)), 1.0f); | ||
1289 | timer.start("densify"); | ||
1290 | density0->tree().voxelizeActiveTiles(); | ||
1291 | timer.stop(); | ||
1292 | AdvT a(velocity); | ||
1293 | a.setGrainSize(1); | ||
1294 | //a.setLimiter(tools::Scheme::NO_LIMITER); | ||
1295 | //a.setIntegrator(tools::Scheme::MAC); | ||
1296 | //a.setIntegrator(tools::Scheme::BFECC); | ||
1297 | a.setIntegrator(tools::Scheme::RK4); | ||
1298 | |||
1299 | for (int i=1; i<=10; ++i) { | ||
1300 | timer.start("Volume Advection"); | ||
1301 | density1 = a.advect<GridT, SamplerT>(*density0, 0.1f); | ||
1302 | timer.stop(); | ||
1303 | std::ostringstream ostr; | ||
1304 | ostr << "densityAdvectMask" << "_" << i << ".vdb"; | ||
1305 | std::cerr << "Writing " << ostr.str() << std::endl; | ||
1306 | io::File file(ostr.str()); | ||
1307 | GridPtrVec grids; | ||
1308 | grids.push_back(density1); | ||
1309 | file.write(grids); | ||
1310 | density0.swap(density1); | ||
1311 | } | ||
1312 | } | ||
1313 | */ | ||
1314 | 1 | }// testVolumeAdvect | |
1315 | |||
1316 | //////////////////////////////////////// | ||
1317 | |||
1318 | |||
1319 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testFloatApply) |
1320 | { | ||
1321 | using ValueIter = openvdb::FloatTree::ValueOnIter; | ||
1322 | |||
1323 | struct Local { | ||
1324 | 128000 | static inline float op(float x) { return x * 2.f; } | |
1325 | 64000 | static inline void visit(const ValueIter& it) { it.setValue(op(*it)); } | |
1326 | }; | ||
1327 | |||
1328 | 1 | const float background = 1.0; | |
1329 | 2 | openvdb::FloatTree tree(background); | |
1330 | |||
1331 | const int MIN = -1000, MAX = 1000, STEP = 50; | ||
1332 | openvdb::Coord xyz; | ||
1333 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
|
41 | for (int z = MIN; z < MAX; z += STEP) { |
1334 | xyz.setZ(z); | ||
1335 |
2/2✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
|
1640 | for (int y = MIN; y < MAX; y += STEP) { |
1336 | xyz.setY(y); | ||
1337 |
2/2✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
|
65600 | for (int x = MIN; x < MAX; x += STEP) { |
1338 | xyz.setX(x); | ||
1339 |
1/2✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
|
128000 | tree.setValue(xyz, float(x + y + z)); |
1340 | } | ||
1341 | } | ||
1342 | } | ||
1343 | /// @todo set some tile values | ||
1344 | |||
1345 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::foreach(tree.begin<ValueIter>(), Local::visit, /*threaded=*/true); |
1346 | |||
1347 | float expected = Local::op(background); | ||
1348 | //EXPECT_NEAR(expected, tree.background(), /*tolerance=*/0.0); | ||
1349 | //expected = Local::op(-background); | ||
1350 | //EXPECT_NEAR(expected, -tree.background(), /*tolerance=*/0.0); | ||
1351 | |||
1352 |
2/2✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1 times.
|
64001 | for (openvdb::FloatTree::ValueOnCIter it = tree.cbeginValueOn(); it; ++it) { |
1353 | 64000 | xyz = it.getCoord(); | |
1354 |
1/2✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
|
64000 | expected = Local::op(float(xyz[0] + xyz[1] + xyz[2])); |
1355 |
2/16✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
64000 | EXPECT_NEAR(expected, it.getValue(), /*tolerance=*/0.0); |
1356 | } | ||
1357 | 1 | } | |
1358 | |||
1359 | |||
1360 | //////////////////////////////////////// | ||
1361 | |||
1362 | |||
1363 | namespace { | ||
1364 | |||
1365 | template<typename IterT> | ||
1366 | struct MatMul { | ||
1367 | openvdb::math::Mat3s mat; | ||
1368 | 1 | MatMul(const openvdb::math::Mat3s& _mat): mat(_mat) {} | |
1369 | 15625 | openvdb::Vec3s xform(const openvdb::Vec3s& v) const { return mat.transform(v); } | |
1370 | 31250 | void operator()(const IterT& it) const { it.setValue(xform(*it)); } | |
1371 | }; | ||
1372 | |||
1373 | } | ||
1374 | |||
1375 | |||
1376 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestTools, testVectorApply) |
1377 | { | ||
1378 | using ValueIter = openvdb::VectorTree::ValueOnIter; | ||
1379 | |||
1380 | const openvdb::Vec3s background(1, 1, 1); | ||
1381 | 2 | openvdb::VectorTree tree(background); | |
1382 | |||
1383 | const int MIN = -1000, MAX = 1000, STEP = 80; | ||
1384 | openvdb::Coord xyz; | ||
1385 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
|
26 | for (int z = MIN; z < MAX; z += STEP) { |
1386 | xyz.setZ(z); | ||
1387 |
2/2✓ Branch 0 taken 625 times.
✓ Branch 1 taken 25 times.
|
650 | for (int y = MIN; y < MAX; y += STEP) { |
1388 | xyz.setY(y); | ||
1389 |
2/2✓ Branch 0 taken 15625 times.
✓ Branch 1 taken 625 times.
|
16250 | for (int x = MIN; x < MAX; x += STEP) { |
1390 | xyz.setX(x); | ||
1391 |
1/2✓ Branch 1 taken 15625 times.
✗ Branch 2 not taken.
|
31250 | tree.setValue(xyz, openvdb::Vec3s(float(x), float(y), float(z))); |
1392 | } | ||
1393 | } | ||
1394 | } | ||
1395 | /// @todo set some tile values | ||
1396 | |||
1397 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | MatMul<ValueIter> op(openvdb::math::Mat3s(1, 2, 3, -1, -2, -3, 3, 2, 1)); |
1398 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::tools::foreach(tree.beginValueOn(), op, /*threaded=*/true); |
1399 | |||
1400 | openvdb::Vec3s expected; | ||
1401 |
2/2✓ Branch 0 taken 15625 times.
✓ Branch 1 taken 1 times.
|
15626 | for (openvdb::VectorTree::ValueOnCIter it = tree.cbeginValueOn(); it; ++it) { |
1402 | 15625 | xyz = it.getCoord(); | |
1403 |
1/2✓ Branch 2 taken 15625 times.
✗ Branch 3 not taken.
|
15625 | expected = op.xform(openvdb::Vec3s(float(xyz[0]), float(xyz[1]), float(xyz[2]))); |
1404 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 15625 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
15625 | EXPECT_EQ(expected, it.getValue()); |
1405 | } | ||
1406 | 1 | } | |
1407 | |||
1408 | |||
1409 | //////////////////////////////////////// | ||
1410 | |||
1411 | |||
1412 | namespace { | ||
1413 | |||
1414 | struct AccumSum { | ||
1415 | int64_t sum; int joins; | ||
1416 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AccumSum(): sum(0), joins(0) {} |
1417 |
2/2✓ Branch 0 taken 1369008 times.
✓ Branch 1 taken 19458 times.
|
1388466 | void operator()(const openvdb::Int32Tree::ValueOnCIter& it) |
1418 | { | ||
1419 | 1369008 | if (it.isVoxelValue()) sum += *it; | |
1420 |
1/2✓ Branch 0 taken 19458 times.
✗ Branch 1 not taken.
|
38916 | else sum += (*it) * it.getVoxelCount(); |
1421 | 1388466 | } | |
1422 | 3 | void join(AccumSum& other) { sum += other.sum; joins += 1 + other.joins; } | |
1423 | }; | ||
1424 | |||
1425 | |||
1426 | struct AccumLeafVoxelCount { | ||
1427 | using LeafRange = openvdb::tree::LeafManager<openvdb::Int32Tree>::LeafRange; | ||
1428 | openvdb::Index64 count; | ||
1429 | 1 | AccumLeafVoxelCount(): count(0) {} | |
1430 | 1801 | void operator()(const LeafRange::Iterator& it) { count += it->onVoxelCount(); } | |
1431 | 3 | void join(AccumLeafVoxelCount& other) { count += other.count; } | |
1432 | }; | ||
1433 | |||
1434 | } | ||
1435 | |||
1436 | |||
1437 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testAccumulate) |
1438 | { | ||
1439 | using namespace openvdb; | ||
1440 | |||
1441 | 1 | const int value = 2; | |
1442 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | Int32Tree tree(/*background=*/0); |
1443 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.fill(CoordBBox::createCube(Coord(0), 198), value, /*active=*/true); |
1444 | |||
1445 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const int64_t expected = tree.activeVoxelCount() * value; |
1446 | { | ||
1447 | AccumSum op; | ||
1448 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::accumulate(tree.cbeginValueOn(), op, /*threaded=*/false); |
1449 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(expected, op.sum); |
1450 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(0, op.joins); |
1451 | } | ||
1452 | { | ||
1453 | AccumSum op; | ||
1454 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | tools::accumulate(tree.cbeginValueOn(), op, /*threaded=*/true); |
1455 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(expected, op.sum); |
1456 | } | ||
1457 | { | ||
1458 | AccumLeafVoxelCount op; | ||
1459 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | tree::LeafManager<Int32Tree> mgr(tree); |
1460 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | tools::accumulate(mgr.leafRange().begin(), op, /*threaded=*/true); |
1461 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(tree.activeLeafVoxelCount(), op.count); |
1462 | } | ||
1463 | 1 | } | |
1464 | |||
1465 | |||
1466 | //////////////////////////////////////// | ||
1467 | |||
1468 | |||
1469 | namespace { | ||
1470 | |||
1471 | template<typename InIterT, typename OutTreeT> | ||
1472 | struct FloatToVec | ||
1473 | { | ||
1474 | using ValueT = typename InIterT::ValueT; | ||
1475 | using Accessor = typename openvdb::tree::ValueAccessor<OutTreeT>; | ||
1476 | |||
1477 | // Transform a scalar value into a vector value. | ||
1478 | 31256 | static openvdb::Vec3s toVec(const ValueT& v) { return openvdb::Vec3s(v, v*2, v*3); } | |
1479 | |||
1480 | FloatToVec() : numTiles{0} {} | ||
1481 | 4 | FloatToVec(const FloatToVec& other) : numTiles{other.numTiles.load(std::memory_order_acquire)} {} | |
1482 | |||
1483 |
2/2✓ Branch 0 taken 31250 times.
✓ Branch 1 taken 6 times.
|
31256 | void operator()(const InIterT& it, Accessor& acc) |
1484 | { | ||
1485 | if (it.isVoxelValue()) { // set a single voxel | ||
1486 | 31250 | acc.setValue(it.getCoord(), toVec(*it)); | |
1487 | } else { // fill an entire tile | ||
1488 | numTiles.fetch_add(1); | ||
1489 | 6 | openvdb::CoordBBox bbox; | |
1490 | 6 | it.getBoundingBox(bbox); | |
1491 | 12 | acc.tree().fill(bbox, toVec(*it)); | |
1492 | } | ||
1493 | 31256 | } | |
1494 | |||
1495 | std::atomic<int> numTiles; | ||
1496 | }; | ||
1497 | |||
1498 | } | ||
1499 | |||
1500 | |||
1501 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testTransformValues) |
1502 | { | ||
1503 | using openvdb::CoordBBox; | ||
1504 | using openvdb::Coord; | ||
1505 | using openvdb::Vec3s; | ||
1506 | |||
1507 | using Tree323f = openvdb::tree::Tree4<float, 3, 2, 3>::Type; | ||
1508 | using Tree323v = openvdb::tree::Tree4<Vec3s, 3, 2, 3>::Type; | ||
1509 | |||
1510 | 1 | const float background = 1.0; | |
1511 | 2 | Tree323f ftree(background); | |
1512 | |||
1513 | const int MIN = -1000, MAX = 1000, STEP = 80; | ||
1514 | Coord xyz; | ||
1515 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
|
26 | for (int z = MIN; z < MAX; z += STEP) { |
1516 | xyz.setZ(z); | ||
1517 |
2/2✓ Branch 0 taken 625 times.
✓ Branch 1 taken 25 times.
|
650 | for (int y = MIN; y < MAX; y += STEP) { |
1518 | xyz.setY(y); | ||
1519 |
2/2✓ Branch 0 taken 15625 times.
✓ Branch 1 taken 625 times.
|
16250 | for (int x = MIN; x < MAX; x += STEP) { |
1520 | xyz.setX(x); | ||
1521 |
1/2✓ Branch 1 taken 15625 times.
✗ Branch 2 not taken.
|
31250 | ftree.setValue(xyz, float(x + y + z)); |
1522 | } | ||
1523 | } | ||
1524 | } | ||
1525 | // Set some tile values. | ||
1526 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ftree.fill(CoordBBox(Coord(1024), Coord(1024 + 8 - 1)), 3 * 1024); // level-1 tile |
1527 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ftree.fill(CoordBBox(Coord(2048), Coord(2048 + 32 - 1)), 3 * 2048); // level-2 tile |
1528 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ftree.fill(CoordBBox(Coord(3072), Coord(3072 + 256 - 1)), 3 * 3072); // level-3 tile |
1529 | |||
1530 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (int shareOp = 0; shareOp <= 1; ++shareOp) { |
1531 | FloatToVec<Tree323f::ValueOnCIter, Tree323v> op; | ||
1532 | 4 | Tree323v vtree; | |
1533 |
4/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
|
2 | openvdb::tools::transformValues(ftree.cbeginValueOn(), vtree, op, |
1534 | /*threaded=*/true, shareOp); | ||
1535 | |||
1536 | // The tile count is accurate only if the functor is shared. Otherwise, | ||
1537 | // it is initialized to zero in the main thread and never changed. | ||
1538 |
4/18✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
3 | EXPECT_EQ(shareOp ? 3 : 0, int(op.numTiles)); |
1539 | |||
1540 | Vec3s expected; | ||
1541 |
2/2✓ Branch 0 taken 31256 times.
✓ Branch 1 taken 2 times.
|
31258 | for (Tree323v::ValueOnCIter it = vtree.cbeginValueOn(); it; ++it) { |
1542 | 31256 | xyz = it.getCoord(); | |
1543 |
1/2✓ Branch 1 taken 31256 times.
✗ Branch 2 not taken.
|
31256 | expected = op.toVec(float(xyz[0] + xyz[1] + xyz[2])); |
1544 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 31256 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
31256 | EXPECT_EQ(expected, it.getValue()); |
1545 | } | ||
1546 | // Check values inside the tiles. | ||
1547 |
2/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(op.toVec(3 * 1024), vtree.getValue(Coord(1024 + 4))); |
1548 |
2/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(op.toVec(3 * 2048), vtree.getValue(Coord(2048 + 16))); |
1549 |
2/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(op.toVec(3 * 3072), vtree.getValue(Coord(3072 + 128))); |
1550 | } | ||
1551 | 1 | } | |
1552 | |||
1553 | |||
1554 | //////////////////////////////////////// | ||
1555 | |||
1556 | |||
1557 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testUtil) |
1558 | { | ||
1559 | using openvdb::CoordBBox; | ||
1560 | using openvdb::Coord; | ||
1561 | using openvdb::Vec3s; | ||
1562 | |||
1563 | using CharTree = openvdb::tree::Tree4<bool, 3, 2, 3>::Type; | ||
1564 | |||
1565 | // Test boolean operators | ||
1566 | 2 | CharTree treeA(false), treeB(false); | |
1567 | |||
1568 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | treeA.fill(CoordBBox(Coord(-10), Coord(10)), true); |
1569 | treeA.voxelizeActiveTiles(); | ||
1570 | |||
1571 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | treeB.fill(CoordBBox(Coord(-10), Coord(10)), true); |
1572 | treeB.voxelizeActiveTiles(); | ||
1573 | |||
1574 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const size_t voxelCountA = treeA.activeVoxelCount(); |
1575 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const size_t voxelCountB = treeB.activeVoxelCount(); |
1576 | |||
1577 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(voxelCountA, voxelCountB); |
1578 | |||
1579 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | CharTree::Ptr tree = openvdb::util::leafTopologyDifference(treeA, treeB); |
1580 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(tree->activeVoxelCount() == 0); |
1581 | |||
1582 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | tree = openvdb::util::leafTopologyIntersection(treeA, treeB); |
1583 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(tree->activeVoxelCount() == voxelCountA); |
1584 | |||
1585 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2 | treeA.fill(CoordBBox(Coord(-10), Coord(22)), true); |
1586 | treeA.voxelizeActiveTiles(); | ||
1587 | |||
1588 | const size_t voxelCount = treeA.activeVoxelCount(); | ||
1589 | |||
1590 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | tree = openvdb::util::leafTopologyDifference(treeA, treeB); |
1591 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(tree->activeVoxelCount() == (voxelCount - voxelCountA)); |
1592 | |||
1593 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | tree = openvdb::util::leafTopologyIntersection(treeA, treeB); |
1594 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(tree->activeVoxelCount() == voxelCountA); |
1595 | 1 | } | |
1596 | |||
1597 | |||
1598 | //////////////////////////////////////// | ||
1599 | |||
1600 | |||
1601 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testVectorTransformer) |
1602 | { | ||
1603 | using namespace openvdb; | ||
1604 | |||
1605 | 1 | Mat4d xform = Mat4d::identity(); | |
1606 | 1 | xform.preTranslate(Vec3d(0.1, -2.5, 3)); | |
1607 | 1 | xform.preScale(Vec3d(0.5, 1.1, 2)); | |
1608 | 1 | xform.preRotate(math::X_AXIS, 30.0 * M_PI / 180.0); | |
1609 | 1 | xform.preRotate(math::Y_AXIS, 300.0 * M_PI / 180.0); | |
1610 | |||
1611 | 1 | Mat4d invXform = xform.inverse(); | |
1612 | 1 | invXform = invXform.transpose(); | |
1613 | |||
1614 | { | ||
1615 | // Set some vector values in a grid, then verify that tools::transformVectors() | ||
1616 | // transforms them as expected for each VecType. | ||
1617 | |||
1618 | const Vec3s refVec0(0, 0, 0), refVec1(1, 0, 0), refVec2(0, 1, 0), refVec3(0, 0, 1); | ||
1619 | |||
1620 | 2 | Vec3SGrid grid; | |
1621 | Vec3SGrid::Accessor acc = grid.getAccessor(); | ||
1622 | |||
1623 | #define resetGrid() \ | ||
1624 | { \ | ||
1625 | grid.clear(); \ | ||
1626 | acc.setValue(Coord(0), refVec0); \ | ||
1627 | acc.setValue(Coord(1), refVec1); \ | ||
1628 | acc.setValue(Coord(2), refVec2); \ | ||
1629 | acc.setValue(Coord(3), refVec3); \ | ||
1630 | } | ||
1631 | |||
1632 | // Verify that grid values are in world space by default. | ||
1633 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(grid.isInWorldSpace()); |
1634 | |||
1635 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1636 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_INVARIANT); |
1637 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1638 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(0)).eq(refVec0)); |
1639 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(refVec1)); |
1640 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(refVec2)); |
1641 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(refVec3)); |
1642 | |||
1643 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1644 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_COVARIANT); |
1645 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1646 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(0)).eq(invXform.transform3x3(refVec0))); |
1647 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(invXform.transform3x3(refVec1))); |
1648 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(invXform.transform3x3(refVec2))); |
1649 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(invXform.transform3x3(refVec3))); |
1650 | |||
1651 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1652 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_COVARIANT_NORMALIZE); |
1653 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1654 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
2 | EXPECT_EQ(refVec0, acc.getValue(Coord(0))); |
1655 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
2 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(invXform.transform3x3(refVec1).unit())); |
1656 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
2 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(invXform.transform3x3(refVec2).unit())); |
1657 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
2 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(invXform.transform3x3(refVec3).unit())); |
1658 | |||
1659 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1660 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_CONTRAVARIANT_RELATIVE); |
1661 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1662 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(0)).eq(xform.transform3x3(refVec0))); |
1663 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(xform.transform3x3(refVec1))); |
1664 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(xform.transform3x3(refVec2))); |
1665 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(xform.transform3x3(refVec3))); |
1666 | |||
1667 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1668 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_CONTRAVARIANT_ABSOLUTE); |
1669 | /// @todo This doesn't really test the behavior w.r.t. homogeneous coords. | ||
1670 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1671 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(0)).eq(xform.transformH(refVec0))); |
1672 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(xform.transformH(refVec1))); |
1673 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(xform.transformH(refVec2))); |
1674 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(xform.transformH(refVec3))); |
1675 | |||
1676 | // Verify that transformVectors() has no effect on local-space grids. | ||
1677 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | resetGrid(); |
1678 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setVectorType(VEC_CONTRAVARIANT_RELATIVE); |
1679 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | grid.setIsInWorldSpace(false); |
1680 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::transformVectors(grid, xform); |
1681 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(0)).eq(refVec0)); |
1682 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(1)).eq(refVec1)); |
1683 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(2)).eq(refVec2)); |
1684 |
2/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
1 | EXPECT_TRUE(acc.getValue(Coord(3)).eq(refVec3)); |
1685 | |||
1686 | #undef resetGrid | ||
1687 | } | ||
1688 | { | ||
1689 | // Verify that transformVectors() operates only on vector-valued grids. | ||
1690 | 2 | FloatGrid scalarGrid; | |
1691 |
3/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
2 | EXPECT_THROW(tools::transformVectors(scalarGrid, xform), TypeError); |
1692 | } | ||
1693 | 1 | } | |
1694 | |||
1695 | |||
1696 | //////////////////////////////////////// | ||
1697 | |||
1698 | |||
1699 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestTools, testPrune) |
1700 | { | ||
1701 | /// @todo Add more unit-tests! | ||
1702 | |||
1703 | using namespace openvdb; | ||
1704 | |||
1705 | {// try prunning a tree with const values | ||
1706 | 1 | const float value = 5.345f; | |
1707 | |||
1708 | 2 | FloatTree tree(value); | |
1709 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(0), tree.leafCount()); |
1710 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(1), tree.nonLeafCount()); // root node |
1711 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
1712 | |||
1713 | 1 | tree.fill(CoordBBox(Coord(-10), Coord(10)), value, /*active=*/false); | |
1714 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(!tree.empty()); |
1715 | |||
1716 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::prune(tree); |
1717 | |||
1718 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(0), tree.leafCount()); |
1719 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(1), tree.nonLeafCount()); // root node |
1720 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_TRUE(tree.empty()); |
1721 | } | ||
1722 | |||
1723 | {// Prune a tree with a single leaf node with random values in the range [0,1] | ||
1724 | using LeafNodeT = tree::LeafNode<float,3>; | ||
1725 | 1 | const float val = 1.0, tol = 1.1f; | |
1726 | |||
1727 | // Fill a leaf node with random values in the range [0,1] | ||
1728 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | LeafNodeT *leaf = new LeafNodeT(Coord(0), val, true); |
1729 | math::Random01 r(145); | ||
1730 | 1 | std::vector<float> data(LeafNodeT::NUM_VALUES); | |
1731 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (Index i=0; i<LeafNodeT::NUM_VALUES; ++i) { |
1732 | 512 | const float v = float(r()); | |
1733 |
1/2✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
|
512 | data[i] = v; |
1734 |
1/2✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
|
512 | leaf->setValueOnly(i, v); |
1735 | } | ||
1736 | |||
1737 | // Insert leaf node into an empty tree | ||
1738 | 2 | FloatTree tree(val); | |
1739 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.addLeaf(leaf); |
1740 | |||
1741 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(1), tree.leafCount()); |
1742 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal |
1743 | |||
1744 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::prune(tree);// tolerance is zero |
1745 | |||
1746 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(1), tree.leafCount()); |
1747 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal |
1748 | |||
1749 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::prune(tree, tol); |
1750 | |||
1751 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(0), tree.leafCount()); |
1752 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal |
1753 | |||
1754 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::sort(data.begin(), data.end()); |
1755 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const float median = data[(LeafNodeT::NUM_VALUES-1)>>1]; |
1756 | |||
1757 |
2/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1 | ASSERT_DOUBLES_EXACTLY_EQUAL(median, tree.getValue(Coord(0))); |
1758 | } | ||
1759 | |||
1760 | /* | ||
1761 | {// Benchmark serial prune | ||
1762 | util::CpuTimer timer; | ||
1763 | initialize();//required whenever I/O of OpenVDB files is performed! | ||
1764 | io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/crawler.vdb"); | ||
1765 | sourceFile.open(false);//disable delayed loading | ||
1766 | FloatGrid::Ptr grid = gridPtrCast<FloatGrid>(sourceFile.getGrids()->at(0)); | ||
1767 | const Index32 leafCount = grid->tree().leafCount(); | ||
1768 | |||
1769 | timer.start("\nSerial tolerance prune"); | ||
1770 | grid->tree().prune(); | ||
1771 | timer.stop(); | ||
1772 | EXPECT_EQ(leafCount, grid->tree().leafCount()); | ||
1773 | } | ||
1774 | {// Benchmark parallel prune | ||
1775 | util::CpuTimer timer; | ||
1776 | initialize();//required whenever I/O of OpenVDB files is performed! | ||
1777 | io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/crawler.vdb"); | ||
1778 | sourceFile.open(false);//disable delayed loading | ||
1779 | FloatGrid::Ptr grid = gridPtrCast<FloatGrid>(sourceFile.getGrids()->at(0)); | ||
1780 | const Index32 leafCount = grid->tree().leafCount(); | ||
1781 | |||
1782 | timer.start("\nParallel tolerance prune"); | ||
1783 | tools::prune(grid->tree()); | ||
1784 | timer.stop(); | ||
1785 | EXPECT_EQ(leafCount, grid->tree().leafCount()); | ||
1786 | } | ||
1787 | */ | ||
1788 | 1 | } | |
1789 |