Skip to content

New command meshsample#3156

Draft
Lestropie wants to merge 2 commits intodevfrom
meshsample
Draft

New command meshsample#3156
Lestropie wants to merge 2 commits intodevfrom
meshsample

Conversation

@Lestropie
Copy link
Copy Markdown
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
Copy Markdown

@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

Comment thread cmd/meshsample.cpp


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

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 };
      ^

Comment thread cmd/meshsample.cpp


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

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 };
            ^

Comment thread cmd/meshsample.cpp
OPTIONS
+ Option ("interp",
"set the interpolation method to use when reslicing (choices: nearest, linear, cubic, sinc. Default: cubic).")
+ Argument ("method").type_choice (interp_choices);
Copy link
Copy Markdown

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) {
                                                        ^

Comment thread cmd/meshsample.cpp
vector_type sample (const Mesh& mesh, const Image<float>& image)
{
InterpType interp (image);
vector_type result = vector_type::Zero (mesh.num_vertices());
Copy link
Copy Markdown

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());
                                          ^

Comment thread cmd/meshsample.cpp
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();
Copy link
Copy Markdown

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();
             ^

Comment thread cmd/meshsample.cpp
if (interp.scanner (mesh.vert (i)))
result[i] = interp.value();
else
result[i] = std::numeric_limits<float>::quiet_NaN();
Copy link
Copy Markdown

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();
             ^

Comment thread cmd/meshsample.cpp
{

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

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]);

Comment thread cmd/meshsample.cpp
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;
Copy link
Copy Markdown

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;

Comment thread cmd/meshsample.cpp
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;
Copy link
Copy Markdown

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
      ^

Comment thread cmd/meshsample.cpp
case 3: data = sample<Interp::Sinc <Image<float>>> (mesh, image); break;
default: assert (false);
}
MR::save_vector (data, argument[2]);
Copy link
Copy Markdown

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.

1 participant