Skip to content

Conversation

@Lestropie
Copy link
Member

Creating draft PR to preclude dangling branches without PRs.

Very simple command. Was I think primarily used for cross-checking the interpretation of surface vertex locations between softwares.

@Lestropie Lestropie self-assigned this Aug 27, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions



// TODO This could be centralised and shared across multiple commands
const char* interp_choices[] = { "nearest", "linear", "cubic", "sinc", nullptr };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]

const char* interp_choices[] = { "nearest", "linear", "cubic", "sinc", nullptr };
      ^



// TODO This could be centralised and shared across multiple commands
const char* interp_choices[] = { "nearest", "linear", "cubic", "sinc", nullptr };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'interp_choices' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

const char* interp_choices[] = { "nearest", "linear", "cubic", "sinc", nullptr };
            ^

OPTIONS
+ Option ("interp",
"set the interpolation method to use when reslicing (choices: nearest, linear, cubic, sinc. Default: cubic).")
+ Argument ("method").type_choice (interp_choices);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: reference to type 'const std::vectorstd::string' (aka 'const vector<basic_string>') could not bind to an lvalue of type 'const char *[5]' [clang-diagnostic-error]

    + Argument ("method").type_choice (interp_choices);
                                       ^
Additional context

cpp/core/cmdline_option.h:214: passing argument to parameter 'choices' here

  Argument &type_choice(const std::vector<std::string> &choices) {
                                                        ^

vector_type sample (const Mesh& mesh, const Image<float>& image)
{
InterpType interp (image);
vector_type result = vector_type::Zero (mesh.num_vertices());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

  vector_type result = vector_type::Zero (mesh.num_vertices());
                                          ^

vector_type result = vector_type::Zero (mesh.num_vertices());
for (size_t i = 0; i != mesh.num_vertices(); ++i) {
if (interp.scanner (mesh.vert (i)))
result[i] = interp.value();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

      result[i] = interp.value();
             ^

if (interp.scanner (mesh.vert (i)))
result[i] = interp.value();
else
result[i] = std::numeric_limits<float>::quiet_NaN();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

      result[i] = std::numeric_limits<float>::quiet_NaN();
             ^

{

const Mesh mesh (argument[0]);
Image<float> image = Image<float>::open (argument[1]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'image' of type 'Image' can be declared 'const' [misc-const-correctness]

Suggested change
Image<float> image = Image<float>::open (argument[1]);
Image<float> const image = Image<float>::open (argument[1]);

const Mesh mesh (argument[0]);
Image<float> image = Image<float>::open (argument[1]);
auto opt = get_options ("interp");
const size_t interp_type = opt.size() ? opt[0][0] : 2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: implicit conversion 'size_type' (aka 'unsigned long') -> bool [readability-implicit-bool-conversion]

Suggested change
const size_t interp_type = opt.size() ? opt[0][0] : 2;
const size_t interp_type = opt.size() != 0u ? opt[0][0] : 2;

const Mesh mesh (argument[0]);
Image<float> image = Image<float>::open (argument[1]);
auto opt = get_options ("interp");
const size_t interp_type = opt.size() ? opt[0][0] : 2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]

Suggested change
const size_t interp_type = opt.size() ? opt[0][0] : 2;
const size_t interp_type = !opt.empty() ? opt[0][0] : 2;
Additional context

/usr/include/c++/13/bits/stl_vector.h:1087: method 'vector'::empty() defined here

      empty() const _GLIBCXX_NOEXCEPT
      ^

case 3: data = sample<Interp::Sinc <Image<float>>> (mesh, image); break;
default: assert (false);
}
MR::save_vector (data, argument[2]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no member named 'save_vector' in namespace 'MR' [clang-diagnostic-error]

  MR::save_vector (data, argument[2]);
      ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants