diff --git a/ChangeLog.md b/ChangeLog.md index a14f02b5..19d00082 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,11 @@ # DGtalTools 0.9.4 - *converters* + + + - mesh2vol: add option to add margin in the generated volume + (to better extract the surfel boudary near domain limits). + (Bertrand Kerautret, [#322](https://github.com/DGtal-team/pull/322)) - vol2vox/vox2vol: tools to convert vol file to a MagicaVoxel VOX file and conversly. (David Coeurjolly, [#314](https://github.com/DGtal-team/pull/314)) diff --git a/converters/mesh2vol.cpp b/converters/mesh2vol.cpp index 9b46f126..5f17923a 100644 --- a/converters/mesh2vol.cpp +++ b/converters/mesh2vol.cpp @@ -59,6 +59,7 @@ namespace po = boost::program_options; -i [ --input ] arg mesh file (.off) -o [ --output ] arg filename of ouput volumetric file (vol, pgm3d, ...) (auto-generated by argument values if empty) + -m [ --margin ] arg (=0) add volume margin around the mesh bounding box. -s [ --separation ] arg (=6) voxelization 6-separated or 26-separated. -r [ --resolution ] digitization domain size (e.g. 128). The mesh will be scaled such that its bounding box maps to [0,resolution)^3. @@ -76,7 +77,8 @@ namespace po = boost::program_options; template< unsigned int SEP > void voxelizeAndExport(const std::string& inputFilename, const std::string& outputFilename, - const unsigned int resolution) + const unsigned int resolution, + const unsigned int margin) { using Domain = Z3i::Domain; using PointR3 = Z3i::RealPoint; @@ -105,7 +107,7 @@ void voxelizeAndExport(const std::string& inputFilename, trace.beginBlock("Voxelization"); trace.info() << "Voxelization " << SEP << "-separated ; " << resolution << "^3 "; - Domain aDomain(PointZ3().diagonal(0), PointZ3().diagonal(resolution)); + Domain aDomain(PointZ3().diagonal(-margin), PointZ3().diagonal(resolution+margin)); //Digitization step Z3i::DigitalSet mySet(aDomain); @@ -132,6 +134,7 @@ int main( int argc, char** argv ) ("help,h", "display this message") ("input,i", po::value(), "mesh file (.off) " ) ("output,o", po::value(), "filename of ouput volumetric file (vol, pgm3d, ...).") + ("margin,m", po::value()->default_value(0), "add volume margin around the mesh bounding box.") ("separation,s", po::value()->default_value(6), "voxelization 6-separated or 26-separated." ) ("resolution,r", po::value(), "digitization domain size (e.g. 128). The mesh will be scaled such that its bounding box maps to [0,resolution)^3." ); @@ -168,7 +171,7 @@ int main( int argc, char** argv ) trace.error() << " Separation should be 6 or 26" << endl; return -1; } - + unsigned int margin = vm["margin"].as(); unsigned int separation = vm["separation"].as(); unsigned int resolution; if (vm.count("resolution")) @@ -192,9 +195,9 @@ int main( int argc, char** argv ) if(separation == 6) - voxelizeAndExport<6>(inputFilename, outputFilename, resolution); + voxelizeAndExport<6>(inputFilename, outputFilename, resolution, margin); else if(separation == 26) - voxelizeAndExport<26>(inputFilename, outputFilename, resolution); + voxelizeAndExport<26>(inputFilename, outputFilename, resolution, margin); return 0; }