-
Notifications
You must be signed in to change notification settings - Fork 191
New command meshsample #3156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
New command meshsample #3156
Conversation
There was a problem hiding this 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 }; |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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]
| 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; |
There was a problem hiding this comment.
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]
| 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; |
There was a problem hiding this comment.
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]
| 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]); |
There was a problem hiding this comment.
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]);
^
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.