3
// convert arbitrary 3D data to VoxBo CUB1
4
// Copyright (c) 1998-2004 by The VoxBo Development Team
6
// VoxBo is free software: you can redistribute it and/or modify it
7
// under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
11
// VoxBo is distributed in the hope that it will be useful, but
12
// WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with VoxBo. If not, see <http://www.gnu.org/licenses/>.
19
// For general information on VoxBo, including the latest complete
20
// source code and binary distributions, manual, and associated files,
21
// see the VoxBo home page at: http://www.voxbo.org/
23
// original version written by Dan Kimberg
32
#include "vb2cub.hlp.h"
35
void vb2cub_version();
38
main(int argc,char *argv[])
45
string infile,outfile;
46
int floatflag=0,nanflag=1;
50
ah.setArgs("-f","--nofloat",0);
51
ah.setArgs("-n","--nonan",0);
52
ah.setArgs("-h","--help",0);
53
ah.setArgs("-v","--version",0);
54
ah.parseArgs(argc,argv);
56
if ((errstr=ah.badArg()).size()) {
57
printf("[E] vb2cub: %s\n",errstr.c_str());
60
if (ah.flagPresent("-h")) {
64
if (ah.flagPresent("-v")) {
68
tokenlist filelist=ah.getUnflaggedArgs();
69
if (filelist.size()!=2) {
70
printf("[E] vb2cub: requires an input and an output file\n");
73
if (ah.flagPresent("-f"))
75
if (ah.flagPresent("-n"))
79
outfile = filelist[1];
80
printf("[I] vb2cub: converting %s to %s\n",infile.c_str(),outfile.c_str());
83
mycube.ReadFile(infile);
84
if (!(mycube.data_valid)) {
85
printf("[E] vb2cub: couldn't make a valid cube out of %s\n",infile.c_str());
89
// remove NaNs if requested
92
// convert to float if requested
93
if (floatflag && mycube.datatype != vb_float)
94
mycube.convert_type(vb_float,VBSETALT|VBNOSCALE);
96
if (mycube.SetFileFormat("cub1")) {
97
printf("[E] vb2cub: file format cub1 not available\n");
100
mycube.SetFileName(outfile);
101
if (mycube.WriteFile()) {
102
printf("[E] vb2cub: error writing file %s\n",outfile.c_str());
106
printf("[I] vb2cub: done.\n");
113
cout << boost::format(myhelp) % vbversion;
119
printf("VoxBo vb2cub (v%s)\n",vbversion.c_str());