Skip to content

Commit 644f1cb

Browse files
committed
Update Test Fast Sweeping to run faster.
Signed-off-by: Andre Pradhana <[email protected]>
1 parent d1beee0 commit 644f1cb

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

openvdb/openvdb/unittest/TestFastSweeping.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ TEST_F(TestFastSweeping, dilateSignedDistance)
5252
{
5353
using namespace openvdb;
5454
// Define parameters for the level set sphere to be re-normalized
55-
const float radius = 200.0f;
55+
const float radius = 60.0f;
5656
const Vec3f center(0.0f, 0.0f, 0.0f);
5757
const float voxelSize = 1.0f;//half width
58-
const int width = 3, new_width = 50;//half width
58+
const int width = 3, new_width = 12;
5959

6060
FloatGrid::Ptr grid = tools::createLevelSetSphere<FloatGrid>(radius, center, voxelSize, float(width));
6161
const size_t oldVoxelCount = grid->activeVoxelCount();
@@ -118,16 +118,16 @@ TEST_F(TestFastSweeping, dilateSignedDistance)
118118
TEST_F(TestFastSweeping, testMaskSdf)
119119
{
120120
using namespace openvdb;
121-
// Define parameterS FOR the level set sphere to be re-normalized
122-
const float radius = 200.0f;
121+
// Define parameters for the level set sphere to be re-normalized
122+
const float radius = 60.0f;
123123
const Vec3f center(0.0f, 0.0f, 0.0f);
124124
const float voxelSize = 1.0f, width = 3.0f;//half width
125-
const float new_width = 50;
125+
const float new_width = 12;
126126

127127
{// Use box as a mask
128128
//std::cerr << "\nUse box as a mask" << std::endl;
129129
FloatGrid::Ptr grid = tools::createLevelSetSphere<FloatGrid>(radius, center, voxelSize, width);
130-
CoordBBox bbox(Coord(150,-50,-50), Coord(250,50,50));
130+
CoordBBox bbox(Coord(60,-25,-25), Coord(100,25,25));
131131
MaskGrid mask;
132132
mask.sparseFill(bbox, true);
133133

@@ -295,7 +295,7 @@ TEST_F(TestFastSweeping, testSdfToFogVolume)
295295
{
296296
using namespace openvdb;
297297
// Define parameterS FOR the level set sphere to be re-normalized
298-
const float radius = 200.0f;
298+
const float radius = 50.0f;
299299
const Vec3f center(0.0f, 0.0f, 0.0f);
300300
const float voxelSize = 1.0f, width = 3.0f;//half width
301301

@@ -333,7 +333,7 @@ TEST_F(TestFastSweeping, testSdfToFogVolume)
333333
//std::cerr << "Failures = " << percent << "%" << std::endl;
334334
//std::cerr << "Failure count = " << diagnose.failureCount() << std::endl;
335335
//std::cerr << "Total active voxel count = " << grid2->activeVoxelCount() << std::endl;
336-
EXPECT_TRUE(percent < 3.0);
336+
EXPECT_TRUE(percent < 10.0);
337337
}
338338
}// testSdfToFogVolume
339339

@@ -451,19 +451,19 @@ TEST_F(TestFastSweeping, fogToSdfAndExt)
451451
{
452452
using namespace openvdb;
453453
const float isoValue = 0.5f;
454-
const float radius = 100.0f;
454+
const float radius = 50.0f;
455455
const float background = 0.0f;
456456
const float tolerance = 0.00001f;
457457
const Vec3f center(0.0f, 0.0f, 0.0f);
458458
const float voxelSize = 1.0f, width = 3.0f;//half width
459459
FloatGrid::Ptr grid = tools::createLevelSetSphere<FloatGrid>(radius, center, voxelSize, float(width));
460460
tools::sdfToFogVolume(*grid);
461461
EXPECT_TRUE(grid);
462-
const float fog[] = {grid->tree().getValue( Coord(102, 0, 0) ),
463-
grid->tree().getValue( Coord(101, 0, 0) ),
464-
grid->tree().getValue( Coord(100, 0, 0) ),
465-
grid->tree().getValue( Coord( 99, 0, 0) ),
466-
grid->tree().getValue( Coord( 98, 0, 0) )};
462+
const float fog[] = {grid->tree().getValue( Coord(52, 0, 0) ),
463+
grid->tree().getValue( Coord(51, 0, 0) ),
464+
grid->tree().getValue( Coord(50, 0, 0) ),
465+
grid->tree().getValue( Coord(49, 0, 0) ),
466+
grid->tree().getValue( Coord(48, 0, 0) )};
467467
//for (auto v : fog) std::cerr << v << std::endl;
468468
EXPECT_TRUE( math::isApproxEqual(fog[0], 0.0f, tolerance) );
469469
EXPECT_TRUE( math::isApproxEqual(fog[1], 0.0f, tolerance) );
@@ -475,17 +475,17 @@ TEST_F(TestFastSweeping, fogToSdfAndExt)
475475
auto op = [radius](const Vec3R &xyz) {return math::Sin(2*3.14*(xyz[0]+xyz[1]+xyz[2])/radius);};
476476
auto grids = tools::fogToSdfAndExt(*grid, op, background, isoValue);
477477

478-
const auto sdf1 = grids.first->tree().getValue( Coord(100, 0, 0) );
479-
const auto sdf2 = grids.first->tree().getValue( Coord( 99, 0, 0) );
480-
const auto sdf3 = grids.first->tree().getValue( Coord( 98, 0, 0) );
478+
const auto sdf1 = grids.first->tree().getValue( Coord(50, 0, 0) );
479+
const auto sdf2 = grids.first->tree().getValue( Coord(49, 0, 0) );
480+
const auto sdf3 = grids.first->tree().getValue( Coord(48, 0, 0) );
481481
//std::cerr << "\nsdf1 = " << sdf1 << ", sdf2 = " << sdf2 << ", sdf3 = " << sdf3 << std::endl;
482482
EXPECT_TRUE( sdf1 > sdf2 );
483483
EXPECT_TRUE( math::isApproxEqual( sdf2, 0.5f, tolerance) );
484484
EXPECT_TRUE( math::isApproxEqual( sdf3,-0.5f, tolerance) );
485485

486-
const auto ext1 = grids.second->tree().getValue( Coord(100, 0, 0) );
487-
const auto ext2 = grids.second->tree().getValue( Coord( 99, 0, 0) );
488-
const auto ext3 = grids.second->tree().getValue( Coord( 98, 0, 0) );
486+
const auto ext1 = grids.second->tree().getValue( Coord(50, 0, 0) );
487+
const auto ext2 = grids.second->tree().getValue( Coord(49, 0, 0) );
488+
const auto ext3 = grids.second->tree().getValue( Coord(48, 0, 0) );
489489
//std::cerr << "\next1 = " << ext1 << ", ext2 = " << ext2 << ", ext3 = " << ext3 << std::endl;
490490
EXPECT_TRUE( math::isApproxEqual(ext1, background, tolerance) );
491491
EXPECT_TRUE( math::isApproxEqual(ext2, ext3, tolerance) );

0 commit comments

Comments
 (0)