@@ -214,7 +214,7 @@ an inclusive range, so includes the maximum voxel.)"));
214214 Expand the active area by at least the specified number of voxels. Does not
215215 support operation or setting of values.
216216*/
217- parms.add (hutil::ParmFactory (PRM_INT, " expand" , " Voxels to Expand" )
217+ parms.add (hutil::ParmFactory (PRM_INT, " expand" , " Expand Voxels " )
218218 .setDefault (PRMoneDefaults)
219219 .setRange (PRM_RANGE_FREE, -5 , PRM_RANGE_FREE, 5 )
220220 .setTooltip (" Expand the active area by at least the specified number of voxels." )
@@ -233,6 +233,20 @@ operation or setting of values.)"));
233233 .setDocumentation (
234234 R"( Expand the active area by at least the specified distance. Does not support operation or setting of values.)" ));
235235
236+ /*
237+ Specifies which nearby voxels are considered neighbors for expansion.
238+ */
239+ parms.add (hutil::ParmFactory (PRM_STRING, " expansionpattern" , " Expansion Pattern" )
240+ .setChoiceListItems (PRM_CHOICELIST_SINGLE, {
241+ " face" , " Plus" ,
242+ " faceedge" , " Diamond" ,
243+ " faceedgevertex" , " Box"
244+ })
245+ .setDefault (" face" )
246+ .setTooltip (" Set pattern used to identify neighbor voxels for expansion." )
247+ .setDocumentation (
248+ R"( Specifies which nearby voxels are considered neighbors for expansion.)" ));
249+
236250 parms.addFolder (" Reference" );
237251/*
238252 Uses the second input to determine the selected region.
@@ -490,16 +504,16 @@ sopFillSDF(GridType &grid, int dummy)
490504
491505template <typename GridType>
492506static void
493- sopDilateVoxels (GridType& grid, exint count)
507+ sopDilateVoxels (GridType& grid, exint count, openvdb::tools::NearestNeighbors nn )
494508{
495- openvdb::tools::dilateActiveValues (grid.tree (), static_cast <int >(count));
509+ openvdb::tools::dilateActiveValues (grid.tree (), static_cast <int >(count), nn );
496510}
497511
498512template <typename GridType>
499513static void
500- sopErodeVoxels (GridType& grid, exint count)
514+ sopErodeVoxels (GridType& grid, exint count, openvdb::tools::NearestNeighbors nn )
501515{
502- openvdb::tools::erodeActiveValues (grid.tree (), static_cast <int >(count));
516+ openvdb::tools::erodeActiveValues (grid.tree (), static_cast <int >(count), nn );
503517 if (grid.getGridClass () == openvdb::GRID_LEVEL_SET) {
504518 openvdb::tools::pruneLevelSet (grid.tree ());
505519 }
@@ -557,6 +571,7 @@ SOP_VDBActivate::Cache::cookVDBSop(OP_Context &context)
557571{
558572 using namespace openvdb ;
559573 using namespace openvdb ::math;
574+ using namespace openvdb ::tools;
560575
561576 try
562577 {
@@ -672,14 +687,22 @@ SOP_VDBActivate::Cache::cookVDBSop(OP_Context &context)
672687 evalFloat (" expanddist" , 0 , t),
673688 vdb->getVoxelDiameter ())));
674689
690+ NearestNeighbors nn = NN_FACE;
691+ const auto str = evalStdString (" expansionpattern" , t);
692+ if (str == " faceedge" )
693+ nn = NN_FACE_EDGE;
694+ else if (str == " faceedgevertex" )
695+ nn = NN_FACE_EDGE_VERTEX;
696+
675697 exint maxdilate = SYSmax (dilatevoxels, dilatedist);
676698 if (maxdilate > 0 )
677699 {
678700 if (boss->opInterrupt ())
679701 break ;
702+
680703 UTvdbCallAllTopology (vdb->getStorageType (),
681704 sopDilateVoxels,
682- vdb->getGrid (), maxdilate);
705+ vdb->getGrid (), maxdilate, nn );
683706 }
684707
685708 exint mindilate = SYSmin (dilatevoxels, dilatedist);
@@ -689,7 +712,7 @@ SOP_VDBActivate::Cache::cookVDBSop(OP_Context &context)
689712 break ;
690713 UTvdbCallAllTopology (vdb->getStorageType (),
691714 sopErodeVoxels,
692- vdb->getGrid (), -mindilate);
715+ vdb->getGrid (), -mindilate, nn );
693716 }
694717 if (mindilate < 0 && maxdilate > 0 )
695718 {
0 commit comments