29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/VolReader.h>
31 #include <DGtal/helpers/StdDefs.h>
32 #include <DGtal/images/Image.h>
33 #include <DGtal/images/ImageContainerBySTLVector.h>
34 #include <DGtal/io/writers/GenericWriter.h>
41 using namespace DGtal;
77 void missingParam (
const std::string ¶m )
79 trace.
error() <<
" Parameter: "<<param<<
" is required..";
92 template <
typename Word>
94 std::istream& read_word( std::istream& fin, Word& aValue )
98 for (
auto size = 0; size <
sizeof( Word ); ++size)
101 unsigned char cc=
static_cast<unsigned char>(c);
102 aValue |= (cc << (8 * size));
106 template <
typename Word>
108 std::ostream& write_word( std::ostream& outs, Word value )
110 for (
unsigned size =
sizeof( Word ); size; --size, value >>= 8)
111 outs.put(
static_cast <char> (value & 0xFF) );
127 int main(
int argc,
char**argv)
132 std::string inputFileName;
133 std::string outputFileName {
"result.vol"};
134 app.description(
"Convert a vox file to a vol. Basic usage:\n vox2vol <volFileName> <volOutputFileName> ");
135 app.add_option(
"-i,--input,1", inputFileName,
"" )
137 ->check(CLI::ExistingFile);
138 app.add_option(
"-o,--ouput,2", outputFileName,
"",
true );
140 app.get_formatter()->column_width(40);
141 CLI11_PARSE(app, argc, argv);
146 myfile.open (inputFileName, ios::in | ios::binary);
178 if ( ( a !=
'V' || (b !=
'O') || (c!=
'X') || (d !=
' ')))
180 trace.
error() <<
"Magic number error"<<std::endl;
181 trace.
error() << (int)a<<
" "<<(
int)b<<
" "<<(int) c<<
" "<<(
int)d<<std::endl;
182 trace.
error() << a<<
" "<<b<<
" "<< c<<
" "<<d<<std::endl;
192 trace.
info()<<
"Version = "<<version<<std::endl;
196 trace.
error() <<
"Version error "<<version<<std::endl;
197 trace.
error() << (
unsigned int)a<<
" "<<(
int)b<<
" "<<(int) c<<
" "<<(
int)d<<std::endl;
198 trace.
error() << a<<
" "<<b<<
" "<< c<<
" "<<d<<std::endl;
202 read_word(myfile, version);
206 if ( version !=
main)
208 trace.
error() <<
"MAIN number error"<<std::endl;
209 trace.
error() << (int)a<<
" "<<(
int)b<<
" "<<(int) c<<
" "<<(
int)d<<std::endl;
210 trace.
error() << a<<
" "<<b<<
" "<< c<<
" "<<d<<std::endl;
215 read_word(myfile,version);
216 while ( version != XYZI)
217 read_word(myfile,version);
220 read_word(myfile,version);
221 read_word(myfile,version);
223 read_word(myfile,cpt);
227 trace.
info()<<
"Number of voxels in this chunk = "<<version<<std::endl;
228 for(
auto i=0 ; i<cpt; ++i)
234 image.setValue(
Z3i::Point((
unsigned int)(
unsigned char)a,
235 (
unsigned int)(
unsigned char)b,
236 (
unsigned int)(
unsigned char)c),
240 image >> outputFileName;
int main(int argc, char **argv)
void beginBlock(const std::string &keyword="")
Trace trace(traceWriterTerm)