Skip to content

Commit

Permalink
Merge pull request #322 from kerautret/AddMargeMesh2Vol
Browse files Browse the repository at this point in the history
Add margins in mesh2vol
  • Loading branch information
dcoeurjo committed Mar 14, 2018
2 parents 200dda1 + fca7e0b commit 4541eb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
13 changes: 8 additions & 5 deletions converters/mesh2vol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -132,6 +134,7 @@ int main( int argc, char** argv )
("help,h", "display this message")
("input,i", po::value<std::string>(), "mesh file (.off) " )
("output,o", po::value<std::string>(), "filename of ouput volumetric file (vol, pgm3d, ...).")
("margin,m", po::value<unsigned int>()->default_value(0), "add volume margin around the mesh bounding box.")
("separation,s", po::value<unsigned int>()->default_value(6), "voxelization 6-separated or 26-separated." )
("resolution,r", po::value<unsigned int>(), "digitization domain size (e.g. 128). The mesh will be scaled such that its bounding box maps to [0,resolution)^3." );

Expand Down Expand Up @@ -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>();
unsigned int separation = vm["separation"].as<unsigned int>();
unsigned int resolution;
if (vm.count("resolution"))
Expand All @@ -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;
}
Expand Down

0 comments on commit 4541eb1

Please sign in to comment.