Skip to content

Commit 3df4a48

Browse files
committed
introduced level dependent erosion count
Signed-off-by: Ken Museth <kmuseth@wsmp-data-001.nvidia.com>
1 parent ad297d8 commit 3df4a48

File tree

1 file changed

+10
-10
lines changed
  • openvdb_cmd/vdb_tool/include

1 file changed

+10
-10
lines changed

openvdb_cmd/vdb_tool/include/Tool.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,22 +1714,21 @@ void Tool::soupToLevelSet()
17141714
auto it = this->getGeom(geo_age);
17151715
const Geometry &mesh = **it;
17161716
if (mesh.isPoints()) this->warning("Warning: -soup2ls was called on points, not a mesh! Hint: use -points2ls instead!");
1717-
bool isSDF = false;
17181717
util::CpuTimer timer;
17191718
double t_offset = 0.0, t_deform = 0.0, t_upscale = 0.0;// all in milliseconds
1719+
bool isGridSDF = true;
17201720

17211721
auto myUpsample = [&](const GridT &grid)->GridT::Ptr{
17221722
timer.start();
17231723
const float dx = grid.voxelSize()[0];
1724-
isSDF = true;
1725-
//if (mParser.verbose) mTimer.restart("upsample("+std::to_string(dx)+")");
17261724
#if 0
17271725
auto xform = math::Transform::createLinearTransform(dx/2);// upsample
17281726
return tools::levelSetRebuild(grid, 0.0f, width, xform.get());// SDF -> mesh -> SDF
17291727
#else
17301728
GridT::Ptr outGrid = createLevelSet<GridT>(dx/2, width);
17311729
tools::resampleToMatch<tools::BoxSampler>(grid, *outGrid);
17321730
t_upscale += timer.milliseconds();
1731+
//isGridSDF = true;
17331732
return outGrid;
17341733
#endif
17351734
};// myUpsample
@@ -1749,33 +1748,34 @@ void Tool::soupToLevelSet()
17491748
const int space = 1, time = 1;
17501749
auto filter = this->createFilter(grid, space, time);
17511750
#if 1
1752-
if (isSDF == false) {
1753-
filter->normalize();
1754-
isSDF = true;
1755-
}
1751+
if (isGridSDF == false) filter->normalize();
17561752
filter->offset(dx);// erode by dx
17571753
auto tmp = tools::csgUnionCopy(grid, gridB);
1758-
isSDF = false;// the CSG operation messed up the SDF
17591754
#else
17601755
filter->offset(dx);// erode by dx
17611756
auto tmp = tools::csgUnionCopy(grid, gridB);
17621757
filter = this->createFilter(*tmp, space, time);
17631758
filter->normalize();
17641759
#endif
17651760
t_deform += timer.milliseconds();
1761+
isGridSDF = false;// the CSG operation messed up the SDF
17661762
return tmp;
17671763
};// myLevelSetDeform
17681764

17691765
//if (mParser.verbose) mTimer.start("Soup -> SDF");
17701766

17711767
// Main algorithm
17721768
float dx = voxel * pow(2, nLOD);
1769+
const float factor = float(nErode-1)/(nLOD-1);
17731770
auto grid = myOffset(dx);
1774-
while(dx > voxel) {
1771+
for (int i=0; i<nLOD; ++i) {
1772+
//while(dx > voxel) {
17751773
dx *= 0.5f;// refinement
17761774
grid = myUpsample(*grid);
17771775
auto base = myOffset(dx);
1778-
for (int j = 0; j<nErode; ++j) grid = myLevelSetDeform(*grid, *base);
1776+
const int end = nErode - int(i*factor);
1777+
std::cerr << "Level: " << i << ", erosions: " << end << std::endl;
1778+
for (int j = 0; j<end; ++j) grid = myLevelSetDeform(*grid, *base);
17791779
}
17801780
//grid = tools::levelSetRebuild(*grid, /*iso-value=*/0.0f, width);// SDF -> mesh -> SDF
17811781
if (dx!=voxel) std::cerr << "dx = " << dx << ", expected dx = " << voxel << std::endl;

0 commit comments

Comments
 (0)