@@ -771,7 +771,7 @@ void Tool::init()
771771 {" keep" , " true" , " 1|0|true|false" , " toggle wether the input VDB is preserved or deleted after the processing" },
772772 {" file" , " slice" , " slice" , " name of ppm file(s) of slices" },
773773 {" force" , " 0" , " 1|0|true|false" , " force computations of min/max, else use expected values for LS and FOG volumes (default)" },
774- {" image " , " 512x512 " , " 1920x1080" , " image size defined in terms of pixel resolution " },
774+ {" scale " , " 512 " , " 1920x1080" , " pixel size of image (aspect ratio is derived from the vdb unless both dimensions are given) " },
775775 {" X" , " 0.5" , " 1" , " One or more X-slices in range 0 -> 1. Defaults to 0.5, i.e. mid-point" },
776776 {" Y" , " " , " 1" , " One or more Y-slices in range 0 -> 1. Defaults to 0.5, i.e. mid-point" },
777777 {" Z" , " " , " 1" , " One or more Z-slices in range 0 -> 1. Defaults to 0.5, i.e. mid-point" }},
@@ -2624,7 +2624,7 @@ void Tool::slice()
26242624 const bool keep = mParser .get <bool >(" keep" );
26252625 const bool force = mParser .get <bool >(" force" );
26262626 const std::string file = mParser .get <std::string>(" file" );
2627- const VecI image = mParser .getVec <int >(" image " , " x" );
2627+ const VecI scale = mParser .getVec <int >(" scale " , " x" );
26282628 const std::vector<Axis> axes = {{mParser , ' X' , 0 , 1 , 2 }, {mParser , ' Y' , 1 , 0 , 2 }, {mParser , ' Z' , 2 , 0 , 1 }};
26292629
26302630 auto it = this ->getGrid (age);
@@ -2649,25 +2649,25 @@ void Tool::slice()
26492649 ex = tools::extrema (grid->cbeginValueOn ());
26502650 }
26512651
2652- tools::Film film (image[0 ], image[1 ]);
26532652 for (const Axis &axis : axes) {
2653+ tools::Film image (scale[0 ], scale.size ()==2 ? scale[1 ] : int (scale[0 ]*dim[axis.abc [2 ]]/float (dim[axis.abc [1 ]])));
26542654 for (const float slice : axis.slices ) {
2655- tbb::parallel_for (RangeT (0 , image[ 0 ] , 0 , image[ 1 ] ), [&](const RangeT &range){
2655+ tbb::parallel_for (RangeT (0 , image. width () , 0 , image. height () ), [&](const RangeT &range){
26562656 const int a = axis.abc [0 ], b = axis.abc [1 ], c = axis.abc [2 ];
26572657 Vec3R xyz;
26582658 xyz[a] = slice * (dim[a]+1 ) + bbox.min ()[a];
26592659 auto acc = grid->getAccessor ();// thread local copy
26602660 for (auto row=range.rows ().begin (); row!=range.rows ().end (); ++row) {
2661- xyz[b] = row/float (image[ 0 ] )*(dim[b]+1 ) + bbox.min ()[b];
2661+ xyz[b] = row/float (image. width () )*(dim[b]+1 ) + bbox.min ()[b];
26622662 for (int col=range.cols ().begin (); col<range.cols ().end (); ++col) {
2663- xyz[c] = col/float (image[ 1 ] )*(dim[c]+1 ) + bbox.min ()[c];
2663+ xyz[c] = col/float (image. height () )*(dim[c]+1 ) + bbox.min ()[c];
26642664 const float v = tools::BoxSampler::sample (acc, xyz);
26652665 const unsigned char *p = LUT[uint8_t (255 .0f *(v - ex.min ())/(ex.max () - ex.min ()))];
2666- film .pixel (row,col) = tools::Film::RGBA (p[0 ]/255 .0f , p[1 ]/255 .0f , p[2 ]/255 .0f );
2666+ image .pixel (row,col) = tools::Film::RGBA (p[0 ]/255 .0f , p[1 ]/255 .0f , p[2 ]/255 .0f );
26672667 }// loop over colums in image
26682668 }// loop over rows in image
26692669 });// end parallel_for
2670- film .savePPM (file + " _" + axis.label + " _" + std::to_string (slice)+ " .ppm" );
2670+ image .savePPM (file + " _" + axis.label + " _" + std::to_string (slice)+ " .ppm" );
26712671 }// loop over slices within an axis (singular)
26722672 }// loop over axes (plural)
26732673
0 commit comments