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/math/Stencils.h> | ||
7 | #include <openvdb/math/Operators.h> | ||
8 | #include <openvdb/tools/GridOperators.h> | ||
9 | #include "util.h" // for unittest_util::makeSphere() | ||
10 | #include <openvdb/tools/LevelSetSphere.h> | ||
11 | |||
12 | #include <gtest/gtest.h> | ||
13 | |||
14 | |||
15 | 8 | class TestMeanCurvature: public ::testing::Test | |
16 | { | ||
17 | 8 | void SetUp() override { openvdb::initialize(); } | |
18 | 8 | void TearDown() override { openvdb::uninitialize(); } | |
19 | }; | ||
20 | |||
21 | |||
22 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testISMeanCurvature) |
23 | { | ||
24 | using namespace openvdb; | ||
25 | |||
26 | typedef FloatGrid::ConstAccessor AccessorType; | ||
27 | |||
28 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
29 | FloatTree& tree = grid->tree(); | ||
30 | AccessorType inAccessor = grid->getConstAccessor(); | ||
31 | AccessorType::ValueType alpha, beta, meancurv, normGrad; | ||
32 | Coord xyz(35,30,30); | ||
33 | |||
34 | // First test an empty grid | ||
35 |
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()); |
36 | typedef math::ISMeanCurvature<math::CD_SECOND, math::CD_2ND> SecondOrder; | ||
37 |
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(!SecondOrder::result(inAccessor, xyz, alpha, beta)); |
38 | |||
39 | typedef math::ISMeanCurvature<math::CD_FOURTH, math::CD_4TH> FourthOrder; | ||
40 |
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(!FourthOrder::result(inAccessor, xyz, alpha, beta)); |
41 | |||
42 | typedef math::ISMeanCurvature<math::CD_SIXTH, math::CD_6TH> SixthOrder; | ||
43 |
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(!SixthOrder::result(inAccessor, xyz, alpha, beta)); |
44 | |||
45 | // Next test a level set sphere | ||
46 | const openvdb::Coord dim(64,64,64); | ||
47 | const openvdb::Vec3f center(35.0f ,30.0f, 40.0f); | ||
48 | const float radius=0.0f; | ||
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
50 | |||
51 |
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()); |
52 | |||
53 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | SecondOrder::result(inAccessor, xyz, alpha, beta); |
54 | |||
55 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
56 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
57 | |||
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(1.0/10.0, meancurv, 0.001); |
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(1.0/10.0, normGrad, 0.001); |
60 | |||
61 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FourthOrder::result(inAccessor, xyz, alpha, beta); |
62 | |||
63 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
64 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
65 | |||
66 |
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/10.0, meancurv, 0.001); |
67 |
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/10.0, normGrad, 0.001); |
68 | |||
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | SixthOrder::result(inAccessor, xyz, alpha, beta); |
70 | |||
71 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
72 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
73 | |||
74 |
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/10.0, meancurv, 0.001); |
75 |
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/10.0, normGrad, 0.001); |
76 | |||
77 | xyz.reset(35,10,40); | ||
78 | |||
79 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | SecondOrder::result(inAccessor, xyz, alpha, beta); |
80 | |||
81 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
82 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
83 | |||
84 |
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/20.0, meancurv, 0.001); |
85 |
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/20.0, normGrad, 0.001); |
86 | 1 | } | |
87 | |||
88 | |||
89 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testISMeanCurvatureStencil) |
90 | { | ||
91 | using namespace openvdb; | ||
92 | |||
93 | typedef FloatGrid::ConstAccessor AccessorType; | ||
94 | |||
95 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
96 | FloatTree& tree = grid->tree(); | ||
97 | math::SecondOrderDenseStencil<FloatGrid> dense_2nd(*grid); | ||
98 | math::FourthOrderDenseStencil<FloatGrid> dense_4th(*grid); | ||
99 | math::SixthOrderDenseStencil<FloatGrid> dense_6th(*grid); | ||
100 | AccessorType::ValueType alpha, beta; | ||
101 | Coord xyz(35,30,30); | ||
102 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
103 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
104 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
105 | |||
106 | // First test on an empty grid | ||
107 |
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()); |
108 | |||
109 | typedef math::ISMeanCurvature<math::CD_SECOND, math::CD_2ND> SecondOrder; | ||
110 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(!SecondOrder::result(dense_2nd, alpha, beta)); |
111 | |||
112 | typedef math::ISMeanCurvature<math::CD_FOURTH, math::CD_4TH> FourthOrder; | ||
113 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(!FourthOrder::result(dense_4th, alpha, beta)); |
114 | |||
115 | typedef math::ISMeanCurvature<math::CD_SIXTH, math::CD_6TH> SixthOrder; | ||
116 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(!SixthOrder::result(dense_6th, alpha, beta)); |
117 | |||
118 | // Next test on a level set sphere | ||
119 | const openvdb::Coord dim(64,64,64); | ||
120 | const openvdb::Vec3f center(35.0f ,30.0f, 40.0f); | ||
121 | const float radius=0.0f; | ||
122 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
123 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
124 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
125 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
126 | |||
127 |
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()); |
128 | |||
129 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(SecondOrder::result(dense_2nd, alpha, beta)); |
130 | |||
131 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AccessorType::ValueType meancurv = alpha/(2*math::Pow3(beta) ); |
132 | 1 | AccessorType::ValueType normGrad = alpha/(2*math::Pow2(beta) ); | |
133 | |||
134 |
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/10.0, meancurv, 0.001); |
135 |
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/10.0, normGrad, 0.001); |
136 | |||
137 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(FourthOrder::result(dense_4th, alpha, beta)); |
138 | |||
139 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
140 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
141 | |||
142 |
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/10.0, meancurv, 0.001); |
143 |
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/10.0, normGrad, 0.001); |
144 | |||
145 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(SixthOrder::result(dense_6th, alpha, beta)); |
146 | |||
147 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
148 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
149 | |||
150 |
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/10.0, meancurv, 0.001); |
151 |
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/10.0, normGrad, 0.001); |
152 | |||
153 | xyz.reset(35,10,40); | ||
154 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
155 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(SecondOrder::result(dense_2nd, alpha, beta)); |
156 | |||
157 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = alpha/(2*math::Pow3(beta) ); |
158 | 1 | normGrad = alpha/(2*math::Pow2(beta) ); | |
159 | |||
160 |
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/20.0, meancurv, 0.001); |
161 |
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/20.0, normGrad, 0.001); |
162 | 1 | } | |
163 | |||
164 | |||
165 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testWSMeanCurvature) |
166 | { | ||
167 | using namespace openvdb; | ||
168 | using math::AffineMap; | ||
169 | using math::TranslationMap; | ||
170 | using math::UniformScaleMap; | ||
171 | |||
172 | typedef FloatGrid::ConstAccessor AccessorType; | ||
173 | |||
174 | {// Empty grid test | ||
175 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
176 | FloatTree& tree = grid->tree(); | ||
177 | AccessorType inAccessor = grid->getConstAccessor(); | ||
178 | Coord xyz(35,30,30); | ||
179 |
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()); |
180 | |||
181 | AccessorType::ValueType meancurv; | ||
182 | AccessorType::ValueType normGrad; | ||
183 | |||
184 | 1 | AffineMap affine; | |
185 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
186 | affine, inAccessor, xyz); | ||
187 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( |
188 | affine, inAccessor, xyz); | ||
189 |
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, meancurv, 0.0); |
190 |
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, normGrad, 0.0); |
191 | |||
192 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
193 | affine, inAccessor, xyz); | ||
194 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( |
195 | affine, inAccessor, xyz); | ||
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(0.0, meancurv, 0.0); |
197 |
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, normGrad, 0.0); |
198 | |||
199 | UniformScaleMap uniform; | ||
200 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( |
201 | uniform, inAccessor, xyz); | ||
202 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( |
203 | uniform, inAccessor, xyz); | ||
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(0.0, meancurv, 0.0); |
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(0.0, normGrad, 0.0); |
206 | |||
207 | xyz.reset(35,10,40); | ||
208 | |||
209 | TranslationMap trans; | ||
210 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::result( |
211 | trans, inAccessor, xyz); | ||
212 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::normGrad( |
213 | trans, inAccessor, xyz); | ||
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(0.0, meancurv, 0.0); |
215 |
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, normGrad, 0.0); |
216 | } | ||
217 | |||
218 | { // unit size voxel test | ||
219 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
220 | FloatTree& tree = grid->tree(); | ||
221 | |||
222 | const openvdb::Coord dim(64,64,64); | ||
223 | const openvdb::Vec3f center(35.0f ,30.0f, 40.0f); | ||
224 | const float radius=0.0f; | ||
225 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
226 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
227 | |||
228 |
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()); |
229 | Coord xyz(35,30,30); | ||
230 | |||
231 | AccessorType inAccessor = grid->getConstAccessor(); | ||
232 | |||
233 | AccessorType::ValueType meancurv; | ||
234 | AccessorType::ValueType normGrad; | ||
235 | |||
236 | 1 | AffineMap affine; | |
237 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
238 | affine, inAccessor, xyz); | ||
239 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( |
240 | affine, inAccessor, xyz); | ||
241 | |||
242 |
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/10.0, meancurv, 0.001); |
243 |
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/10.0, normGrad, 0.001); |
244 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
245 | affine, inAccessor, xyz); | ||
246 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( |
247 | affine, inAccessor, xyz); | ||
248 | |||
249 | |||
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_NEAR(1.0/10.0, meancurv, 0.001); |
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_NEAR(1.0/10.0, normGrad, 0.001); |
252 | |||
253 | UniformScaleMap uniform; | ||
254 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( |
255 | uniform, inAccessor, xyz); | ||
256 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( |
257 | uniform, inAccessor, xyz); | ||
258 | |||
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_NEAR(1.0/10.0, meancurv, 0.001); |
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_NEAR(1.0/10.0, normGrad, 0.001); |
261 | |||
262 | xyz.reset(35,10,40); | ||
263 | |||
264 | TranslationMap trans; | ||
265 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::result( |
266 | trans, inAccessor, xyz); | ||
267 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::normGrad( |
268 | trans, inAccessor, xyz); | ||
269 | |||
270 | |||
271 |
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/20.0, meancurv, 0.001); |
272 |
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/20.0, normGrad, 0.001); |
273 | } | ||
274 | { // non-unit sized voxel | ||
275 | |||
276 | double voxel_size = 0.5; | ||
277 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = FloatGrid::create(/*backgroundValue=*/5.0); |
278 |
3/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 9 not taken.
✗ Branch 10 not taken.
|
2 | grid->setTransform(math::Transform::createLinearTransform(voxel_size)); |
279 |
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->empty()); |
280 | |||
281 | const openvdb::Coord dim(32,32,32); | ||
282 | const openvdb::Vec3f center(6.0f, 8.0f, 10.0f);//i.e. (12,16,20) in index space | ||
283 | const float radius=10.0f; | ||
284 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
285 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
286 | |||
287 | AccessorType inAccessor = grid->getConstAccessor(); | ||
288 | |||
289 | AccessorType::ValueType meancurv; | ||
290 | AccessorType::ValueType normGrad; | ||
291 | |||
292 | Coord xyz(20,16,20); | ||
293 |
1/4✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
1 | AffineMap affine(voxel_size*math::Mat3d::identity()); |
294 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
295 | affine, inAccessor, xyz); | ||
296 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( |
297 | affine, inAccessor, xyz); | ||
298 | |||
299 |
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/4.0, meancurv, 0.001); |
300 |
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/4.0, normGrad, 0.001); |
301 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
302 | affine, inAccessor, xyz); | ||
303 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( |
304 | affine, inAccessor, xyz); | ||
305 | |||
306 | |||
307 |
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/4.0, meancurv, 0.001); |
308 |
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/4.0, normGrad, 0.001); |
309 | |||
310 | UniformScaleMap uniform(voxel_size); | ||
311 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( |
312 | uniform, inAccessor, xyz); | ||
313 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( |
314 | uniform, inAccessor, xyz); | ||
315 | |||
316 |
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/4.0, meancurv, 0.001); |
317 |
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/4.0, normGrad, 0.001); |
318 | |||
319 | } | ||
320 | { // NON-UNIFORM SCALING AND ROTATION | ||
321 | |||
322 | Vec3d voxel_sizes(0.25, 0.45, 0.75); | ||
323 | FloatGrid::Ptr grid = FloatGrid::create(); | ||
324 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | math::MapBase::Ptr base_map( new math::ScaleMap(voxel_sizes)); |
325 | // apply rotation | ||
326 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | math::MapBase::Ptr rotated_map = base_map->preRotate(1.5, math::X_AXIS); |
327 |
4/10✓ 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.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
3 | grid->setTransform(math::Transform::Ptr(new math::Transform(rotated_map))); |
328 |
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->empty()); |
329 | |||
330 | const openvdb::Coord dim(32,32,32); | ||
331 | const openvdb::Vec3f center(6.0f, 8.0f, 10.0f);//i.e. (12,16,20) in index space | ||
332 | const float radius=10.0f; | ||
333 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
334 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
335 | |||
336 | AccessorType inAccessor = grid->getConstAccessor(); | ||
337 | |||
338 | AccessorType::ValueType meancurv; | ||
339 | AccessorType::ValueType normGrad; | ||
340 | |||
341 | Coord xyz(20,16,20); | ||
342 | Vec3d location = grid->indexToWorld(xyz); | ||
343 | double dist = (center - location).length(); | ||
344 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AffineMap::ConstPtr affine = grid->transform().map<AffineMap>(); |
345 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
346 | *affine, inAccessor, xyz); | ||
347 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( |
348 | *affine, inAccessor, xyz); | ||
349 | |||
350 |
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/dist, meancurv, 0.001); |
351 |
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/dist, normGrad, 0.001); |
352 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
353 | *affine, inAccessor, xyz); | ||
354 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( |
355 | *affine, inAccessor, xyz); | ||
356 | |||
357 | |||
358 |
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/dist, meancurv, 0.001); |
359 |
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/dist, normGrad, 0.001); |
360 | } | ||
361 | 1 | } | |
362 | |||
363 | |||
364 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testWSMeanCurvatureStencil) |
365 | { | ||
366 | using namespace openvdb; | ||
367 | using math::AffineMap; | ||
368 | using math::TranslationMap; | ||
369 | using math::UniformScaleMap; | ||
370 | |||
371 | typedef FloatGrid::ConstAccessor AccessorType; | ||
372 | |||
373 | {// empty grid test | ||
374 | 1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); | |
375 | FloatTree& tree = grid->tree(); | ||
376 |
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()); |
377 | Coord xyz(35,30,30); | ||
378 | |||
379 | math::SecondOrderDenseStencil<FloatGrid> dense_2nd(*grid); | ||
380 | math::FourthOrderDenseStencil<FloatGrid> dense_4th(*grid); | ||
381 | math::SixthOrderDenseStencil<FloatGrid> dense_6th(*grid); | ||
382 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
383 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
384 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
385 | |||
386 | AccessorType::ValueType meancurv; | ||
387 | AccessorType::ValueType normGrad; | ||
388 | |||
389 | 1 | AffineMap affine; | |
390 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
391 | affine, dense_2nd); | ||
392 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( | |
393 | affine, dense_2nd); | ||
394 |
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, meancurv, 0.0); |
395 |
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, normGrad, 0.00); |
396 | |||
397 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
398 | affine, dense_4th); | ||
399 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( | |
400 | affine, dense_4th); | ||
401 |
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, meancurv, 0.00); |
402 |
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, normGrad, 0.00); |
403 | |||
404 | UniformScaleMap uniform; | ||
405 | 1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( | |
406 | uniform, dense_6th); | ||
407 | 1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( | |
408 | uniform, dense_6th); | ||
409 |
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, meancurv, 0.0); |
410 |
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, normGrad, 0.0); |
411 | |||
412 | xyz.reset(35,10,40); | ||
413 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
414 | |||
415 | TranslationMap trans; | ||
416 | 1 | meancurv = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::result( | |
417 | trans, dense_6th); | ||
418 | 1 | normGrad = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::normGrad( | |
419 | trans, dense_6th); | ||
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, meancurv, 0.0); |
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, normGrad, 0.0); |
422 | } | ||
423 | |||
424 | { // unit-sized voxels | ||
425 | |||
426 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
427 | FloatTree& tree = grid->tree(); | ||
428 | |||
429 | const openvdb::Coord dim(64,64,64); | ||
430 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f);//i.e. (35,30,40) in index space | ||
431 | const float radius=0.0f; | ||
432 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
433 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
434 | |||
435 |
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()); |
436 | Coord xyz(35,30,30); | ||
437 | math::SecondOrderDenseStencil<FloatGrid> dense_2nd(*grid); | ||
438 | math::FourthOrderDenseStencil<FloatGrid> dense_4th(*grid); | ||
439 | math::SixthOrderDenseStencil<FloatGrid> dense_6th(*grid); | ||
440 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
441 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
442 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
443 | |||
444 | AccessorType::ValueType meancurv; | ||
445 | AccessorType::ValueType normGrad; | ||
446 | |||
447 | 1 | AffineMap affine; | |
448 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
449 | affine, dense_2nd); | ||
450 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( | |
451 | affine, dense_2nd); | ||
452 | |||
453 |
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/10.0, meancurv, 0.001); |
454 |
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/10.0, normGrad, 0.001); |
455 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
456 | affine, dense_4th); | ||
457 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( | |
458 | affine, dense_4th); | ||
459 | |||
460 |
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/10.0, meancurv, 0.001); |
461 |
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/10.0, normGrad, 0.001); |
462 | |||
463 | UniformScaleMap uniform; | ||
464 | 1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( | |
465 | uniform, dense_6th); | ||
466 | 1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( | |
467 | uniform, dense_6th); | ||
468 | |||
469 |
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/10.0, meancurv, 0.001); |
470 |
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/10.0, normGrad, 0.001); |
471 | |||
472 | xyz.reset(35,10,40); | ||
473 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
474 | |||
475 | TranslationMap trans; | ||
476 | 1 | meancurv = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::result( | |
477 | trans, dense_6th); | ||
478 | 1 | normGrad = math::MeanCurvature<TranslationMap, math::CD_SIXTH, math::CD_6TH>::normGrad( | |
479 | trans, dense_6th); | ||
480 | |||
481 | |||
482 |
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/20.0, meancurv, 0.001); |
483 |
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/20.0, normGrad, 0.001); |
484 | } | ||
485 | { // non-unit sized voxel | ||
486 | |||
487 | double voxel_size = 0.5; | ||
488 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = FloatGrid::create(/*backgroundValue=*/5.0); |
489 |
3/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 9 not taken.
✗ Branch 10 not taken.
|
2 | grid->setTransform(math::Transform::createLinearTransform(voxel_size)); |
490 |
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->empty()); |
491 | |||
492 | const openvdb::Coord dim(32,32,32); | ||
493 | const openvdb::Vec3f center(6.0f, 8.0f, 10.0f);//i.e. (12,16,20) in index space | ||
494 | const float radius=10.0f; | ||
495 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
496 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
497 | |||
498 | |||
499 | AccessorType::ValueType meancurv; | ||
500 | AccessorType::ValueType normGrad; | ||
501 | |||
502 | Coord xyz(20,16,20); | ||
503 | math::SecondOrderDenseStencil<FloatGrid> dense_2nd(*grid); | ||
504 | math::FourthOrderDenseStencil<FloatGrid> dense_4th(*grid); | ||
505 | math::SixthOrderDenseStencil<FloatGrid> dense_6th(*grid); | ||
506 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
507 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
508 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_6th.moveTo(xyz); |
509 | |||
510 |
2/4✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | AffineMap affine(voxel_size*math::Mat3d::identity()); |
511 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
512 | affine, dense_2nd); | ||
513 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( | |
514 | affine, dense_2nd); | ||
515 | |||
516 |
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/4.0, meancurv, 0.001); |
517 |
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/4.0, normGrad, 0.001); |
518 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
519 | affine, dense_4th); | ||
520 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( | |
521 | affine, dense_4th); | ||
522 | |||
523 | |||
524 |
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/4.0, meancurv, 0.001); |
525 |
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/4.0, normGrad, 0.001); |
526 | |||
527 | UniformScaleMap uniform(voxel_size); | ||
528 | 1 | meancurv = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::result( | |
529 | uniform, dense_6th); | ||
530 | 1 | normGrad = math::MeanCurvature<UniformScaleMap, math::CD_SIXTH, math::CD_6TH>::normGrad( | |
531 | uniform, dense_6th); | ||
532 | |||
533 |
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/4.0, meancurv, 0.001); |
534 |
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/4.0, normGrad, 0.001); |
535 | } | ||
536 | { // NON-UNIFORM SCALING AND ROTATION | ||
537 | |||
538 | Vec3d voxel_sizes(0.25, 0.45, 0.75); | ||
539 | FloatGrid::Ptr grid = FloatGrid::create(); | ||
540 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | math::MapBase::Ptr base_map( new math::ScaleMap(voxel_sizes)); |
541 | // apply rotation | ||
542 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | math::MapBase::Ptr rotated_map = base_map->preRotate(1.5, math::X_AXIS); |
543 |
4/10✓ 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.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
3 | grid->setTransform(math::Transform::Ptr(new math::Transform(rotated_map))); |
544 |
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->empty()); |
545 | |||
546 | const openvdb::Coord dim(32,32,32); | ||
547 | const openvdb::Vec3f center(6.0f, 8.0f, 10.0f);//i.e. (12,16,20) in index space | ||
548 | const float radius=10.0f; | ||
549 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
550 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
551 | |||
552 | AccessorType::ValueType meancurv; | ||
553 | AccessorType::ValueType normGrad; | ||
554 | |||
555 | Coord xyz(20,16,20); | ||
556 | math::SecondOrderDenseStencil<FloatGrid> dense_2nd(*grid); | ||
557 | math::FourthOrderDenseStencil<FloatGrid> dense_4th(*grid); | ||
558 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_2nd.moveTo(xyz); |
559 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dense_4th.moveTo(xyz); |
560 | |||
561 | |||
562 | Vec3d location = grid->indexToWorld(xyz); | ||
563 | double dist = (center - location).length(); | ||
564 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | AffineMap::ConstPtr affine = grid->transform().map<AffineMap>(); |
565 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::result( |
566 | *affine, dense_2nd); | ||
567 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_SECOND, math::CD_2ND>::normGrad( | |
568 | *affine, dense_2nd); | ||
569 | |||
570 |
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/dist, meancurv, 0.001); |
571 |
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/dist, normGrad, 0.001); |
572 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | meancurv = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::result( |
573 | *affine, dense_4th); | ||
574 | 1 | normGrad = math::MeanCurvature<AffineMap, math::CD_FOURTH, math::CD_4TH>::normGrad( | |
575 | *affine, dense_4th); | ||
576 | |||
577 | |||
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_NEAR(1.0/dist, meancurv, 0.001); |
579 |
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/dist, normGrad, 0.001); |
580 | } | ||
581 | 1 | } | |
582 | |||
583 | |||
584 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testMeanCurvatureTool) |
585 | { | ||
586 | using namespace openvdb; | ||
587 | |||
588 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
589 | FloatTree& tree = grid->tree(); | ||
590 | |||
591 | const openvdb::Coord dim(64,64,64); | ||
592 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f);//i.e. (35,30,40) in index space | ||
593 | const float radius=0.0f; | ||
594 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
595 | |||
596 |
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()); |
597 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr curv = tools::meanCurvature(*grid); |
598 | FloatGrid::ConstAccessor accessor = curv->getConstAccessor(); | ||
599 | |||
600 | Coord xyz(35,30,30); | ||
601 |
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(1.0/10.0, accessor.getValue(xyz), 0.001); |
602 | |||
603 | xyz.reset(35,10,40); | ||
604 |
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(1.0/20.0, accessor.getValue(xyz), 0.001); |
605 | 1 | } | |
606 | |||
607 | |||
608 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testMeanCurvatureMaskedTool) |
609 | { | ||
610 | using namespace openvdb; | ||
611 | |||
612 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = createGrid<FloatGrid>(/*background=*/5.0); |
613 | FloatTree& tree = grid->tree(); | ||
614 | |||
615 | const openvdb::Coord dim(64,64,64); | ||
616 | const openvdb::Vec3f center(35.0f, 30.0f, 40.0f);//i.e. (35,30,40) in index space | ||
617 | const float radius=0.0f; | ||
618 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>(dim, center, radius, *grid, unittest_util::SPHERE_DENSE); |
619 | |||
620 |
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()); |
621 | |||
622 | |||
623 | 1 | const openvdb::CoordBBox maskbbox(openvdb::Coord(35, 30, 30), openvdb::Coord(41, 41, 41)); | |
624 |
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); |
625 |
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*/); |
626 | |||
627 | |||
628 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | FloatGrid::Ptr curv = tools::meanCurvature(*grid, *maskGrid); |
629 | FloatGrid::ConstAccessor accessor = curv->getConstAccessor(); | ||
630 | |||
631 | // test inside | ||
632 | Coord xyz(35,30,30); | ||
633 |
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)); |
634 |
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(1.0/10.0, accessor.getValue(xyz), 0.001); |
635 | |||
636 | // test outside | ||
637 | xyz.reset(35,10,40); | ||
638 |
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)); |
639 |
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(0.0, accessor.getValue(xyz), 0.001); |
640 | 1 | } | |
641 | |||
642 | |||
643 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestMeanCurvature, testCurvatureStencil) |
644 | { | ||
645 | using namespace openvdb; | ||
646 | |||
647 | {// test of level set to sphere at (6,8,10) with R=10 and dx=0.5 | ||
648 | |||
649 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = FloatGrid::create(/*backgroundValue=*/5.0); |
650 |
3/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 9 not taken.
✗ Branch 10 not taken.
|
2 | grid->setTransform(math::Transform::createLinearTransform(/*voxel size=*/0.5)); |
651 |
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->empty()); |
652 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | math::CurvatureStencil<FloatGrid> cs(*grid); |
653 | Coord xyz(20,16,20);//i.e. 8 voxel or 4 world units away from the center | ||
654 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cs.moveTo(xyz); |
655 | |||
656 | // First test on an empty grid | ||
657 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(0.0, cs.meanCurvature(), 0.0); |
658 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(0.0, cs.meanCurvatureNormGrad(), 0.0); |
659 | |||
660 | // Next test on a level set sphere | ||
661 | const openvdb::Coord dim(32,32,32); | ||
662 | const openvdb::Vec3f center(6.0f, 8.0f, 10.0f);//i.e. (12,16,20) in index space | ||
663 | const float radius=10.0f; | ||
664 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unittest_util::makeSphere<FloatGrid>( |
665 | dim, center, radius, *grid, unittest_util::SPHERE_DENSE); | ||
666 | |||
667 |
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->empty()); |
668 |
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(dim[0]*dim[1]*dim[2], int(grid->activeVoxelCount())); |
669 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cs.moveTo(xyz); |
670 | |||
671 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/4.0, cs.meanCurvature(), 0.01);// 1/distance from center |
672 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/4.0, cs.meanCurvatureNormGrad(), 0.01);// 1/distance from center |
673 | |||
674 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/16.0, cs.gaussianCurvature(), 0.01);// 1/distance^2 from center |
675 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/16.0, cs.gaussianCurvatureNormGrad(), 0.01);// 1/distance^2 from center |
676 | |||
677 | float mean, gaussian; | ||
678 | 1 | cs.curvatures(mean, gaussian); | |
679 |
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/4.0, mean, 0.01);// 1/distance from center |
680 |
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/16.0, gaussian, 0.01);// 1/distance^2 from center |
681 | |||
682 | 1 | auto principalCurvatures = cs.principalCurvatures(); | |
683 |
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/4.0, principalCurvatures.first, 0.01);// 1/distance from center |
684 |
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/4.0, principalCurvatures.second, 0.01);// 1/distance from center |
685 | |||
686 | xyz.reset(12,16,10);//i.e. 10 voxel or 5 world units away from the center | ||
687 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cs.moveTo(xyz); |
688 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/5.0, cs.meanCurvature(), 0.01);// 1/distance from center |
689 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR( |
690 | 1.0/5.0, cs.meanCurvatureNormGrad(), 0.01);// 1/distance from center | ||
691 | |||
692 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/25.0, cs.gaussianCurvature(), 0.01);// 1/distance^2 from center |
693 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR( |
694 | 1.0/25.0, cs.gaussianCurvatureNormGrad(), 0.01);// 1/distance^2 from center | ||
695 | |||
696 | 1 | principalCurvatures = cs.principalCurvatures(); | |
697 |
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/5.0, principalCurvatures.first, 0.01);// 1/distance from center |
698 |
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/5.0, principalCurvatures.second, 0.01);// 1/distance from center |
699 |
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( |
700 | 1.0/5.0, principalCurvatures.first, 0.01);// 1/distance from center | ||
701 |
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( |
702 | 1.0/5.0, principalCurvatures.second, 0.01);// 1/distance from center | ||
703 | |||
704 | 1 | cs.curvaturesNormGrad(mean, gaussian); | |
705 |
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/5.0, mean, 0.01);// 1/distance from center |
706 |
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/25.0, gaussian, 0.01);// 1/distance^2 from center |
707 | } | ||
708 | {// test sparse level set sphere | ||
709 | const double percentage = 0.1/100.0;//i.e. 0.1% | ||
710 | const int dim = 256; | ||
711 | |||
712 | // sparse level set sphere | ||
713 | Vec3f C(0.35f, 0.35f, 0.35f); | ||
714 | Real r = 0.15, voxelSize = 1.0/(dim-1); | ||
715 | 1 | FloatGrid::Ptr sphere = tools::createLevelSetSphere<FloatGrid>(float(r), C, float(voxelSize)); | |
716 | |||
717 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | math::CurvatureStencil<FloatGrid> cs(*sphere); |
718 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | const Coord ijk = Coord::round(sphere->worldToIndex(Vec3d(0.35, 0.35, 0.35 + 0.15))); |
719 | 1 | const double radius = (sphere->indexToWorld(ijk)-Vec3d(0.35)).length(); | |
720 | //std::cerr << "\rRadius = " << radius << std::endl; | ||
721 | //std::cerr << "Index coord =" << ijk << std::endl; | ||
722 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cs.moveTo(ijk); |
723 | |||
724 | //std::cerr << "Mean curvature = " << cs.meanCurvature() << ", 1/r=" << 1.0/radius << std::endl; | ||
725 | //std::cerr << "Gaussian curvature = " << cs.gaussianCurvature() << ", 1/(r*r)=" << 1.0/(radius*radius) << std::endl; | ||
726 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/radius, cs.meanCurvature(), percentage*1.0/radius); |
727 |
2/16✓ Branch 2 taken 1 times.
✗ Branch 3 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_NEAR(1.0/(radius*radius), cs.gaussianCurvature(), percentage*1.0/(radius*radius)); |
728 | float mean, gauss; | ||
729 | 1 | cs.curvatures(mean, gauss); | |
730 | //std::cerr << "Mean curvature = " << mean << ", 1/r=" << 1.0/radius << std::endl; | ||
731 | //std::cerr << "Gaussian curvature = " << gauss << ", 1/(r*r)=" << 1.0/(radius*radius) << std::endl; | ||
732 |
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/radius, mean, percentage*1.0/radius); |
733 |
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/(radius*radius), gauss, percentage*1.0/(radius*radius)); |
734 | } | ||
735 | 1 | } | |
736 | |||
737 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestMeanCurvature, testIntersection) |
738 | { | ||
739 | using namespace openvdb; | ||
740 | const Coord ijk(1,4,-9); | ||
741 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | FloatGrid grid(0.0f); |
742 | auto acc = grid.getAccessor(); | ||
743 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | math::GradStencil<FloatGrid> stencil(grid); |
744 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | acc.setValue(ijk,-1.0f); |
745 | 1 | int cases = 0; | |
746 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (int mx=0; mx<2; ++mx) { |
747 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
3 | acc.setValue(ijk.offsetBy(-1,0,0), mx ? 1.0f : -1.0f); |
748 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
|
6 | for (int px=0; px<2; ++px) { |
749 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
6 | acc.setValue(ijk.offsetBy(1,0,0), px ? 1.0f : -1.0f); |
750 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
|
12 | for (int my=0; my<2; ++my) { |
751 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
|
12 | acc.setValue(ijk.offsetBy(0,-1,0), my ? 1.0f : -1.0f); |
752 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
|
24 | for (int py=0; py<2; ++py) { |
753 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
|
24 | acc.setValue(ijk.offsetBy(0,1,0), py ? 1.0f : -1.0f); |
754 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
|
48 | for (int mz=0; mz<2; ++mz) { |
755 |
3/4✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
|
48 | acc.setValue(ijk.offsetBy(0,0,-1), mz ? 1.0f : -1.0f); |
756 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 32 times.
|
96 | for (int pz=0; pz<2; ++pz) { |
757 |
3/4✓ Branch 0 taken 32 times.
✓ Branch 1 taken 32 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
|
96 | acc.setValue(ijk.offsetBy(0,0,1), pz ? 1.0f : -1.0f); |
758 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | ++cases; |
759 |
2/16✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 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.
|
64 | EXPECT_EQ(7, int(grid.activeVoxelCount())); |
760 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | stencil.moveTo(ijk); |
761 | 64 | const size_t count = mx + px + my + py + mz + pz;// number of intersections | |
762 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(stencil.intersects() == (count > 0)); |
763 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
|
64 | auto mask = stencil.intersectionMask(); |
764 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.none() == (count == 0)); |
765 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.any() == (count > 0)); |
766 |
2/16✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 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.
|
64 | EXPECT_EQ(count, mask.count()); |
767 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(0) == mx); |
768 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(1) == px); |
769 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(2) == my); |
770 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(3) == py); |
771 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(4) == mz); |
772 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 64 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.
|
64 | EXPECT_TRUE(mask.test(5) == pz); |
773 | }//pz | ||
774 | }//mz | ||
775 | }//py | ||
776 | }//my | ||
777 | }//px | ||
778 | }//mx | ||
779 |
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(64, cases);// = 2^6 |
780 | 1 | }//testIntersection | |
781 |