Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | #include <openvdb/openvdb.h> | ||
5 | #include <openvdb/tools/LevelSetSphere.h> // for createLevelSetSphere | ||
6 | #include <openvdb/tools/LevelSetUtil.h> // for sdfToFogVolume | ||
7 | #include <openvdb/tools/VolumeToSpheres.h> // for fillWithSpheres | ||
8 | |||
9 | #include <gtest/gtest.h> | ||
10 | |||
11 | #include <cmath> | ||
12 | #include <iostream> | ||
13 | #include <limits> | ||
14 | #include <vector> | ||
15 | |||
16 | |||
17 | 4 | class TestVolumeToSpheres: public ::testing::Test | |
18 | { | ||
19 | }; | ||
20 | |||
21 | |||
22 | //////////////////////////////////////// | ||
23 | |||
24 | |||
25 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestVolumeToSpheres, testFromLevelSet) |
26 | { | ||
27 | const float | ||
28 | radius = 20.0f, | ||
29 | voxelSize = 1.0f, | ||
30 | halfWidth = 3.0f; | ||
31 | const openvdb::Vec3f center(15.0f, 13.0f, 16.0f); | ||
32 | |||
33 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | openvdb::FloatGrid::ConstPtr grid = openvdb::tools::createLevelSetSphere<openvdb::FloatGrid>( |
34 | radius, center, voxelSize, halfWidth); | ||
35 | |||
36 | const bool overlapping = false; | ||
37 | const int instanceCount = 10000; | ||
38 | const float | ||
39 | isovalue = 0.0f, | ||
40 | minRadius = 5.0f, | ||
41 | maxRadius = std::numeric_limits<float>::max(); | ||
42 | const openvdb::Vec2i sphereCount(1, 100); | ||
43 | |||
44 | { | ||
45 | std::vector<openvdb::Vec4s> spheres; | ||
46 | |||
47 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::fillWithSpheres(*grid, spheres, sphereCount, overlapping, |
48 | minRadius, maxRadius, isovalue, instanceCount); | ||
49 | |||
50 |
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(1, int(spheres.size())); |
51 | |||
52 | //for (size_t i=0; i< spheres.size(); ++i) { | ||
53 | // std::cout << "\nSphere #" << i << ": " << spheres[i] << std::endl; | ||
54 | //} | ||
55 | |||
56 | const auto tolerance = 2.0 * voxelSize; | ||
57 |
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(center[0], spheres[0][0], tolerance); |
58 |
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(center[1], spheres[0][1], tolerance); |
59 |
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(center[2], spheres[0][2], tolerance); |
60 |
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(radius, spheres[0][3], tolerance); |
61 | } | ||
62 | { | ||
63 | // Verify that an isovalue outside the narrow band still produces a valid sphere. | ||
64 | std::vector<openvdb::Vec4s> spheres; | ||
65 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::fillWithSpheres(*grid, spheres, sphereCount, |
66 | overlapping, minRadius, maxRadius, 1.5f * halfWidth, instanceCount); | ||
67 |
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(1, int(spheres.size())); |
68 | } | ||
69 | { | ||
70 | // Verify that an isovalue inside the narrow band produces no spheres. | ||
71 | std::vector<openvdb::Vec4s> spheres; | ||
72 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::fillWithSpheres(*grid, spheres, sphereCount, |
73 | overlapping, minRadius, maxRadius, -1.5f * halfWidth, instanceCount); | ||
74 |
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(0, int(spheres.size())); |
75 | } | ||
76 | 1 | } | |
77 | |||
78 | |||
79 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestVolumeToSpheres, testFromFog) |
80 | { | ||
81 | const float | ||
82 | radius = 20.0f, | ||
83 | voxelSize = 1.0f, | ||
84 | halfWidth = 3.0f; | ||
85 | const openvdb::Vec3f center(15.0f, 13.0f, 16.0f); | ||
86 | |||
87 | auto grid = openvdb::tools::createLevelSetSphere<openvdb::FloatGrid>( | ||
88 | 1 | radius, center, voxelSize, halfWidth); | |
89 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::sdfToFogVolume(*grid); |
90 | |||
91 | const bool overlapping = false; | ||
92 | const int instanceCount = 10000; | ||
93 | const float | ||
94 | isovalue = 0.01f, | ||
95 | minRadius = 5.0f, | ||
96 | maxRadius = std::numeric_limits<float>::max(); | ||
97 | const openvdb::Vec2i sphereCount(1, 100); | ||
98 | |||
99 | { | ||
100 | std::vector<openvdb::Vec4s> spheres; | ||
101 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::fillWithSpheres(*grid, spheres, sphereCount, overlapping, |
102 | minRadius, maxRadius, isovalue, instanceCount); | ||
103 | |||
104 | //for (size_t i=0; i< spheres.size(); ++i) { | ||
105 | // std::cout << "\nSphere #" << i << ": " << spheres[i] << std::endl; | ||
106 | //} | ||
107 | |||
108 |
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(1, int(spheres.size())); |
109 | |||
110 | const auto tolerance = 2.0 * voxelSize; | ||
111 |
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(center[0], spheres[0][0], tolerance); |
112 |
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(center[1], spheres[0][1], tolerance); |
113 |
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(center[2], spheres[0][2], tolerance); |
114 |
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(radius, spheres[0][3], tolerance); |
115 | } | ||
116 | { | ||
117 | // Verify that an isovalue outside the narrow band still produces valid spheres. | ||
118 | std::vector<openvdb::Vec4s> spheres; | ||
119 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::fillWithSpheres(*grid, spheres, sphereCount, overlapping, |
120 | minRadius, maxRadius, 10.0f, instanceCount); | ||
121 |
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(!spheres.empty()); |
122 | } | ||
123 | 1 | } | |
124 | |||
125 | |||
126 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestVolumeToSpheres, testMinimumSphereCount) |
127 | { | ||
128 | using namespace openvdb; | ||
129 | { | ||
130 | auto grid = tools::createLevelSetSphere<FloatGrid>(/*radius=*/5.0f, | ||
131 | 1 | /*center=*/Vec3f(15.0f, 13.0f, 16.0f), /*voxelSize=*/1.0f, /*halfWidth=*/3.0f); | |
132 | |||
133 | // Verify that the requested minimum number of spheres is generated, for various minima. | ||
134 | const int maxSphereCount = 100; | ||
135 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int minSphereCount = 1; minSphereCount < 20; minSphereCount += 5) { |
136 | std::vector<Vec4s> spheres; | ||
137 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | tools::fillWithSpheres(*grid, spheres, Vec2i(minSphereCount, maxSphereCount), |
138 | /*overlapping=*/true, /*minRadius=*/2.0f); | ||
139 | |||
140 | // Given the relatively large minimum radius, the actual sphere count | ||
141 | // should be no larger than the requested mimimum count. | ||
142 |
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(minSphereCount, int(spheres.size())); |
143 | //EXPECT_TRUE(int(spheres.size()) >= minSphereCount); | ||
144 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
4 | EXPECT_TRUE(int(spheres.size()) <= maxSphereCount); |
145 | } | ||
146 | } | ||
147 | { | ||
148 | // One step in the sphere packing algorithm is to erode the active voxel mask | ||
149 | // of the input grid. Previously, for very small grids this sometimes resulted in | ||
150 | // an empty mask and therefore no spheres. Verify that that no longer happens | ||
151 | // (as long as the minimum sphere count is nonzero). | ||
152 | |||
153 | 2 | FloatGrid grid; | |
154 | 1 | CoordBBox bbox(Coord(1), Coord(2)); | |
155 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | grid.fill(bbox, 1.0f); |
156 | |||
157 | const float minRadius = 1.0f; | ||
158 | const Vec2i sphereCount(5, 100); | ||
159 | |||
160 | std::vector<Vec4s> spheres; | ||
161 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::fillWithSpheres(grid, spheres, sphereCount, /*overlapping=*/true, minRadius); |
162 | |||
163 |
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(int(spheres.size()) >= sphereCount[0]); |
164 | } | ||
165 | 1 | } | |
166 | |||
167 | |||
168 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestVolumeToSpheres, testClosestSurfacePoint) |
169 | { | ||
170 | using namespace openvdb; | ||
171 | |||
172 | const float voxelSize = 1.0f; | ||
173 | const Vec3f center{0.0f}; // ensure multiple internal nodes | ||
174 | |||
175 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (const float radius: { 8.0f, 50.0f }) { |
176 | // Construct a spherical level set. | ||
177 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | const auto sphere = tools::createLevelSetSphere<FloatGrid>(radius, center, voxelSize); |
178 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE(sphere); |
179 | |||
180 | // Construct the corners of a cube that exactly encloses the sphere. | ||
181 | const std::vector<Vec3R> corners{ | ||
182 | 2 | { -radius, -radius, -radius }, | |
183 | { -radius, -radius, radius }, | ||
184 | { -radius, radius, -radius }, | ||
185 | { -radius, radius, radius }, | ||
186 | { radius, -radius, -radius }, | ||
187 | { radius, -radius, radius }, | ||
188 | { radius, radius, -radius }, | ||
189 | { radius, radius, radius }, | ||
190 |
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 | }; |
191 | // Compute the distance from a corner of the cube to the surface of the sphere. | ||
192 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | const auto distToSurface = Vec3d{radius}.length() - radius; |
193 | |||
194 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | auto csp = tools::ClosestSurfacePoint<FloatGrid>::create(*sphere); |
195 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE(csp); |
196 | |||
197 | // Move each corner point to the closest surface point. | ||
198 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | auto points = corners; |
199 | std::vector<float> distances; | ||
200 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | bool ok = csp->searchAndReplace(points, distances); |
201 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE(ok); |
202 |
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(8, int(points.size())); |
203 |
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(8, int(distances.size())); |
204 | |||
205 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (auto d: distances) { |
206 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 16 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.
|
16 | EXPECT_TRUE((std::abs(d - distToSurface) / distToSurface) < 0.01); // rel err < 1% |
207 | } | ||
208 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (int i = 0; i < 8; ++i) { |
209 |
2/4✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
|
16 | const auto intersection = corners[i] + distToSurface * (center - corners[i]).unit(); |
210 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 16 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.
|
16 | EXPECT_TRUE(points[i].eq(intersection, /*tolerance=*/0.1)); |
211 | } | ||
212 | |||
213 | // Place a point inside the sphere. | ||
214 | points.clear(); | ||
215 | distances.clear(); | ||
216 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | points.emplace_back(1, 0, 0); |
217 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | ok = csp->searchAndReplace(points, distances); |
218 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE(ok); |
219 |
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(1, int(points.size())); |
220 |
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(1, int(distances.size())); |
221 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE((std::abs(radius - 1 - distances[0]) / (radius - 1)) < 0.01); |
222 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
|
2 | EXPECT_TRUE(points[0].eq(Vec3R{radius, 0, 0}, /*tolerance=*/0.5)); |
223 | ///< @todo off by half a voxel in y and z | ||
224 | } | ||
225 | 1 | } | |
226 |