@@ -1609,8 +1609,7 @@ void Tool::write()
16091609
16101610void Tool::writeVDB (const std::string &fileName)
16111611{
1612- const std::string &action_name = mParser .getAction ().names [0 ];
1613- OPENVDB_ASSERT (action_name == " write" );
1612+ OPENVDB_ASSERT (mParser .getAction ().names [0 ] == " write" );
16141613 try {
16151614 mParser .printAction ();
16161615 const std::string age = mParser .get <std::string>(" vdb" );
@@ -1800,8 +1799,7 @@ void Tool::writeNVDB(const std::string&)
18001799
18011800void Tool::writeGeo (const std::string &fileName)
18021801{
1803- const std::string &action_name = mParser .getAction ().names [0 ];
1804- OPENVDB_ASSERT (action_name == " write" );
1802+ OPENVDB_ASSERT (mParser .getAction ().names [0 ] == " write" );
18051803 const int age = mParser .get <int >(" geo" );
18061804 const bool keep = mParser .get <bool >(" keep" );
18071805 const bool ascii = mParser .get <bool >(" ascii" );
@@ -2025,7 +2023,7 @@ void Tool::levelSetToFog()
20252023 }
20262024 if (mParser .verbose ) mTimer .start (" SDF to FOG" );
20272025 FloatGrid::Ptr fog = keep ? sdf->deepCopy () : sdf;
2028- const float cutoffDistance = cutoff <= 0 .0f ? sdf->background () : cutoff * sdf->voxelSize ()[0 ];
2026+ const float cutoffDistance = cutoff <= 0 .0f ? sdf->background () : cutoff * float ( sdf->voxelSize ()[0 ]) ;
20292027 tools::sdfToFogVolume (*fog, cutoffDistance);// fog <- sdf > 0 ? 0 : -sdf / |cutoffDistance|
20302028 if (!keep) mGrid .erase (std::next (it).base ());
20312029 if (grid_name.empty ()) grid_name = " ls2fog_" +sdf->getName ();
@@ -2855,7 +2853,6 @@ void Tool::forValues()
28552853 }
28562854 if (grid_name.empty ()) grid_name = action_name + " _" + grid->getName ();
28572855 grid->setName (grid_name);
2858- const std::string &voxel_var = voxel_vars[0 ];// the OUTPUT grid's kernel name
28592856
28602857 if (mParser .verbose ) mTimer .start (action_name);
28612858 if (!kernel.empty ()) {
@@ -3058,8 +3055,7 @@ void Tool::forValues()
30583055void Tool::sdf2udf ()
30593056{
30603057 const std::string &action_name = mParser .getAction ().names [0 ];
3061- const int mode = findMatch (action_name, {" sdf2udf" });// 1-based index
3062- OPENVDB_ASSERT (mode);// mode = 0 for no match
3058+ OPENVDB_ASSERT (findMatch (action_name, {" sdf2udf" }));// mode = 0 for no match
30633059 try {
30643060 const int age = mParser .get <int >(" vdb" );
30653061 const bool keep = mParser .get <bool >(" keep" );
@@ -3426,22 +3422,25 @@ void Tool::slice()
34263422 for (const Axis &axis : axes) {
34273423 tools::Film image (scale[0 ], scale.size ()==2 ? scale[1 ] : scale[0 ]*dim[axis.abc [2 ]]/dim[axis.abc [1 ]]);
34283424 for (const float slice : axis.slices ) {
3429- tbb::parallel_for (RangeT (0 , image.width (), 0 , image.height ()), [&](const RangeT &range){
3425+ tbb::parallel_for (RangeT (0 , int ( image.width ()) , 0 , int ( image.height () )), [&](const RangeT &range){
34303426 const int a = axis.abc [0 ], b = axis.abc [1 ], c = axis.abc [2 ];
34313427 Vec3R xyz;
3432- xyz[a] = slice * (dim[a]+1 ) + bbox.min ()[a];
3428+ // Compute in double (Vec3R's element type) so the Int32 dim/bbox
3429+ // operands widen losslessly; mixing them with float triggers
3430+ // -Wimplicit-int-float-conversion under -Werror.
3431+ xyz[a] = double (slice) * (dim[a]+1 ) + bbox.min ()[a];
34333432 auto acc = grid->getAccessor ();// thread local copy
34343433 for (auto row=range.rows ().begin (); row!=range.rows ().end (); ++row) {
3435- xyz[b] = row/float (image.width ())*(dim[b]+1 ) + bbox.min ()[b];
3434+ xyz[b] = row/double (image.width ())*(dim[b]+1 ) + bbox.min ()[b];
34363435 for (int col=range.cols ().begin (); col<range.cols ().end (); ++col) {
3437- xyz[c] = col/float (image.height ())*(dim[c]+1 ) + bbox.min ()[c];
3436+ xyz[c] = col/double (image.height ())*(dim[c]+1 ) + bbox.min ()[c];
34383437 const float v = tools::BoxSampler::sample (acc, xyz);
34393438 // Clamp before the integer cast: float-to-uint8_t conversion is
34403439 // UB when the value falls outside [0,255], and clang on ARM64
34413440 // emits an unmasked fcvtzu — values outside ex's range (e.g. the
34423441 // background of a level set whose active values have been
34433442 // rewritten by forOnValues) yield huge indices and an OOB read.
3444- const float t = ( v - ex.min ()) / (ex.max () - ex.min ());
3443+ const float t = float (( v - ex.min ()) / (ex.max () - ex.min () ));
34453444 const int k = int (255 .0f * math::Clamp (t, 0 .0f , 1 .0f ));
34463445 const unsigned char *p = LUT [k];
34473446 image.pixel (row,col) = tools::Film::RGBA (p[0 ]/255 .0f , p[1 ]/255 .0f , p[2 ]/255 .0f );
@@ -3731,15 +3730,15 @@ void saveJPG(const std::string& fname, const tools::Film& film)
37313730 FILE * fp = std::fopen (fname.c_str (), " wb" );
37323731 if (!fp) OPENVDB_THROW (IoError," Unable to open '" + fname + " ' for writing" );
37333732 jpeg_stdio_dest (&cinfo, fp);
3734- cinfo.image_width = film.width ();
3735- cinfo.image_height = film.height ();
3733+ cinfo.image_width = static_cast < JDIMENSION >( film.width () );
3734+ cinfo.image_height = static_cast < JDIMENSION >( film.height () );
37363735 cinfo.input_components = 3 ;
37373736 cinfo.in_color_space = JCS_RGB ;
37383737 jpeg_set_defaults (&cinfo);
37393738 jpeg_start_compress (&cinfo, TRUE );
37403739 auto buf = film.convertToBitBuffer <uint8_t >(/* alpha=*/ false );
37413740 uint8_t *row = buf.get ();
3742- const uint32_t stride = film.width () * 3 ;
3741+ const uint32_t stride = static_cast < uint32_t >( film.width () * 3 ) ;
37433742 for (int y = 0 ; y < film.height (); ++y) {
37443743 jpeg_write_scanlines (&cinfo, &row, 1 );
37453744 row += stride;
0 commit comments