commit 3a2deb29bcf559cd393981cbc5167683f3604901
parent af4f2ee09a63b58c82e799aad3740d8a2e0fb70c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 20 Feb 2025 16:44:22 +0100
Write suvm_voxelize manual page
The man page replaces the short program help as reference documentation.
The program now only displays the command synopsis.
Diffstat:
2 files changed, 99 insertions(+), 31 deletions(-)
diff --git a/doc/suvm-voxelize.1 b/doc/suvm-voxelize.1
@@ -0,0 +1,92 @@
+.\" Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com)
+.\"
+.\" This program is free software: you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation, either version 3 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
+.Dd February 20, 2025
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Dt SUVM_VOXELIZE 1
+.Os
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh NAME
+.Nm suvm_voxelize
+.Nd voxelize a tetrahedral mesh
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SYNOPSIS
+.Nm
+.Op Fl hnv
+.Op Fl d Ar x , Ns Ar y , Ns Ar z
+.Op Fl o Ar output
+.Op Ar input
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh DESCRIPTION
+.Nm
+voxelize a tetrahedral mesh stored in the
+.Xr smsh 5
+file format.
+Generated voxels are parallelepipeds saved in VTK format.
+.Pp
+If input is not defined, the mesh is read from standard input.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl d Ar x , Ns Ar y , Ns Ar z
+definition of voxelization along the 3 axes.
+Default is 64,64,64.
+.It Fl h
+Display short help and exit.
+.It Fl n
+pre-calculate tetrahedron normals.
+This should speed up voxelization speed by calculating normals once and
+for all, rather than re-evaluating them each time a tetrahedron is
+tested against a voxel.
+On the other hand, the memory space used to store normals increases the
+memory footprint.
+.It Fl o Ar output
+Output file.
+Voxels are stored in VTK format.
+If not defined, data is written to standard output.
+.It Fl v
+Make
+.Nm
+verbose.
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXIT STATUS
+.Ex -std
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXAMPLES
+Voxelize
+.Pa volumic_mesh.smsh
+and save the results in
+.Pa voxels.vtk :
+.Bd -literal -offset Ds
+suvm-voxelize -o voxels.vtk volumic_mesh.smsh
+.Ed
+.Pp
+Same as above but with a voxelization definition of 256^3:
+.Bd -literal -offset Ds
+suvm-voxelize -d256,256,256 -o voxels.vtk volumic_mesh.smsh
+.Ed
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SEE ALSO
+.Xr smsh 5
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh STANDARDS
+.Rs
+.%B The VTK User's Guide
+.%O Simple Legacy Formats
+.%I Kitware, Inc
+.%N 11
+.%D 2010
+.%P 470--482
+.Re
diff --git a/src/suvm_voxelize.c b/src/suvm_voxelize.c
@@ -45,36 +45,11 @@ static const struct args ARGS_DEFAULT = {
/*******************************************************************************
* Helper functions
******************************************************************************/
-static void
-print_help(const char* cmd)
+static INLINE void
+usage(FILE* stream)
{
- ASSERT(cmd);
- printf(
-"Usage: %s [options] [file]\n"
-"Voxelize a smsh(5) file and save result following VTK file format.\n"
-"With no file option, mesh is read from standard input\n",
- cmd);
- printf("\n");
- printf(
-" -d X:Y:Z voxelisation definition along the 3 axes.\n"
-" Default definition is %u:%u:%u.\n",
- ARGS_DEFAULT.def[0],
- ARGS_DEFAULT.def[1],
- ARGS_DEFAULT.def[2]);
- printf(
-" -h display this help and exit.\n");
- printf(
-" -n precompute the tetrahedra normals.\n");
- printf(
-" -o <output> filename of the output VTK file. If not defined, write\n"
-" results to standard ouput\n");
- printf(
-" -v make the program verobse.\n");
- printf("\n");
- printf(
-"This is free software released under the GNU GPL license, version 3 or\n"
-"later. You are free to change or redistribute it under certain\n"
-"conditions <http://gnu.org.licenses/gpl.html>\n");
+ fprintf(stream,
+ "usage: suvm_voxelize [-hnv] [-d x,y,z] [-o output] [input]\n");
}
static void
@@ -97,12 +72,12 @@ args_init(struct args* args, const int argc, char** argv)
while((opt = getopt(argc, argv, "d:hno:v")) != -1) {
switch(opt) {
case 'd':
- res = cstr_to_list_uint(optarg, ':', args->def, &n, 3);
+ res = cstr_to_list_uint(optarg, ',', args->def, &n, 3);
if(res == RES_OK && n != 3) res = RES_BAD_ARG;
if(!args->def[0] || !args->def[1] || !args->def[2]) res = RES_BAD_ARG;
break;
case 'h':
- print_help(argv[0]);
+ usage(stdin);
args_release(args);
args->quit = 1;
break;
@@ -132,6 +107,7 @@ exit:
optind = 1;
return res;
error:
+ usage(stderr);
args_release(args);
goto exit;
}