Skip to content

Reduce verbosity of quest's file readers - #1967

Merged
kennyweiss merged 12 commits into
developfrom
bugfix/kweiss/reduce-reader-verbosity
Aug 28, 2026
Merged

Reduce verbosity of quest's file readers#1967
kennyweiss merged 12 commits into
developfrom
bugfix/kweiss/reduce-reader-verbosity

Conversation

@kennyweiss

Copy link
Copy Markdown
Member

Summary

  • This PR reduces the verbosity of the quest readers and writers
  • It also modernizes them via nested namespaces, constexpr, [[nodiscard]]
  • The [[nodiscard]] changes the contract and requires callers to check the return values.

@kennyweiss kennyweiss self-assigned this Aug 27, 2026
@kennyweiss kennyweiss added Quest Issues related to Axom's 'quest' component User Request Issues related to user requests maintenance Issues related to code maintenance labels Aug 27, 2026
quest::STLReader reader;
reader.setFileName(inputFile);
reader.read();
SLIC_ERROR_IF(reader.read() != 0, "Failed to load STL file '" << inputFile << "'.");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We now require users to check the return values of several quest IO functions.
Seems like a worthwhile thing to do, but will require callers to slightly modify their code.
I can roll the [[nodiscard]] back if it's controversial.

const c2c::LengthUnit c2cLengthUnit = toC2CLengthUnit(m_lengthUnit);

SLIC_INFO(fmt::format("Loading contour with {} pieces", contour.getPieces().size()));
SLIC_INFO_ROOT(fmt::format("Loading contour with {} pieces", contour.getPieces().size()));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dylan-copeland -- this is the line that was getting in your way

Uses nested namespaces, [[nodiscard]], empty() instead of size() == 0, and constexpr.
Updates callsites w/ [[nodiscard]] to check the return values.
@kennyweiss
kennyweiss force-pushed the bugfix/kweiss/reduce-reader-verbosity branch from f522d15 to 90872e5 Compare August 27, 2026 17:04
Comment thread src/axom/quest/io/C2CReader.hpp Outdated
* \return A view that contains the curves.
*/
CurveArrayView getCurvesView() { return m_nurbsData.view(); }
[[nodiscard]] CurveArrayView getCurvesView() { return m_nurbsData.view(); }

@BradWhitlock BradWhitlock Aug 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can understand adding [[nodiscard]] to read/write methods where there is a chance at failing due to the file system. [[nodiscard]] here seems unnecessary since you would not call these methods if you were not using the curve views for something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed -- I'll remove [[nodiscard]] from these.

The idea was that there is no reason to call these functions if you're not using the values. But I agree they can be a bit heavy handed.

Comment thread src/axom/quest/io/ProEReader.hpp Outdated
* \return numNodes the number of nodes.
*/
int getNumNodes() const { return static_cast<int>(m_num_nodes); };
[[nodiscard]] int getNumNodes() const { return static_cast<int>(m_num_nodes); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same [[nodiscard]] complaint here.

Comment thread src/axom/quest/io/STEPReader.hpp Outdated
[[nodiscard]] virtual int read(bool validate);

std::string getFileUnits() const;
[[nodiscard]] std::string getFileUnits() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same [[nodiscard]] complaint and for the next several methods.

Comment thread src/axom/quest/io/STLReader.cpp Outdated
const std::size_t BINARY_HEADER_SIZE = 80; // bytes
const std::size_t BINARY_TRI_SIZE = 50; // bytes
constexpr std::size_t binary_header_size = 80; // bytes
constexpr std::size_t binary_tri_size = 50; // bytes

@BradWhitlock BradWhitlock Aug 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I saw the capitalized variable name it was reminiscent of a macro and made me think "this is a constant". As a lower-case variable name it made me think the variable was computed dynamically somewhere close to its use. While this may conform to some coding guideline, I find it less intuitive. My 2 cents.

This comment probably makes more sense further down where the values are used.

Comment thread src/axom/quest/io/STLReader.cpp Outdated
union BinarySTLTri
{
std::int8_t raw[BINARY_TRI_SIZE];
std::int8_t raw[binary_tri_size];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is another place where if I saw capital letters, I'd be more likely to think constant whereas I associate lower-case with runtime computed values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree -- I'll revert the capital -> lowecase constants

@kennyweiss
kennyweiss force-pushed the bugfix/kweiss/reduce-reader-verbosity branch from 90872e5 to 388ea5b Compare August 27, 2026 19:48

@BradWhitlock BradWhitlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @kennyweiss !

@rhornung67 rhornung67 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice changeset. Thanks @BradWhitlock

@kennyweiss
kennyweiss merged commit 695d16e into develop Aug 28, 2026
24 checks passed
@kennyweiss
kennyweiss deleted the bugfix/kweiss/reduce-reader-verbosity branch August 28, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Issues related to code maintenance Quest Issues related to Axom's 'quest' component User Request Issues related to user requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants