Skip to content

feat(RasterImage): contiguous access to all the colors - #1375

Merged
BenPinet merged 3 commits into
nextfrom
fix/image-io-robustness
Oct 22, 2026
Merged

BenPinet merged 3 commits into
nextfrom
fix/image-io-robustness

Conversation

@BotellaA

Copy link
Copy Markdown
Member

Summary

  • RasterImage::colors() / modifiable_colors() return the color storage as spans, in cell index order.
  • Lets image readers/writers process whole images without one out-of-line call per cell. OpenGeode-IO uses it (same branch name fix/image-io-robustness) to let GDAL decode straight into the raster storage and to write VTI colors without any copy.

Test

  • test-raster-image: colors set through modifiable_colors() are read back by color() and colors().

🤖 Generated with Claude Code

colors() and modifiable_colors() expose the color storage as spans so
readers and writers can process whole images without a function call
per cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v21.1.8) reports: 23 concern(s)
  • include/geode/image/core/raster_image.hpp:42:11: warning: [cppcoreguidelines-special-member-functions]

    class 'RasterImage' defines a destructor, a move constructor and a move assignment operator but does not define a copy constructor or a copy assignment operator

       42 |     class RasterImage : public CellArray< dimension >, public Identifier
          |           ^
  • src/geode/image/core/raster_image.cpp:42:9: warning: [modernize-use-nodiscard]

    function 'color' should be marked [[nodiscard]]

       42 |         const RGBColor& color( index_t index ) const
          |         ^
          |         [[nodiscard]] 
  • src/geode/image/core/raster_image.cpp:55:30: warning: [hicpp-move-const-arg]

    std::move of the variable 'color' of the trivially-copyable type 'RGBColor' has no effect; remove std::move()

       55 |             colors_[index] = std::move( color );
          |                              ^~~~~~~~~~       ~
  • tests/image/test-raster-image.cpp:37:6: warning: [misc-use-internal-linkage]

    function 'test_raster' can be made static or moved into an anonymous namespace to enforce internal linkage

       37 | void test_raster( const geode::RasterImage2D& raster )
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:40:30: warning: [cppcoreguidelines-avoid-magic-numbers]

    100 is a magic number; consider replacing it with a named constant

       40 |         raster.nb_cells() == 100, "Wrong number of cells" );
          |                              ^
  • tests/image/test-raster-image.cpp:42:46: warning: [cppcoreguidelines-avoid-magic-numbers]

    10 is a magic number; consider replacing it with a named constant

       42 |         raster.nb_cells_in_direction( 0 ) == 10,
          |                                              ^
  • tests/image/test-raster-image.cpp:45:46: warning: [cppcoreguidelines-avoid-magic-numbers]

    10 is a magic number; consider replacing it with a named constant

       45 |         raster.nb_cells_in_direction( 1 ) == 10,
          |                                              ^
  • tests/image/test-raster-image.cpp:55:6: warning: [misc-use-internal-linkage]

    function 'test_save_failure' can be made static or moved into an anonymous namespace to enforce internal linkage

       55 | void test_save_failure( const geode::RasterImage2D& raster )
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:57:5: warning: [llvm-qualified-auto]

    'const auto folder' can be declared as 'const auto *const folder'

       57 |     const auto folder = "raster_folder.og_img2d";
          |     ^~~~~~~~~~
          |     const auto *const 
  • tests/image/test-raster-image.cpp:71:5: warning: [llvm-qualified-auto]

    'const auto file' can be declared as 'const auto *const file'

       71 |     const auto file = "raster_regular_file";
          |     ^~~~~~~~~~
          |     const auto *const 
  • tests/image/test-raster-image.cpp:72:5: warning: [bugprone-unused-raii]

    object destroyed immediately after creation; did you mean to name the object?

       72 |     std::ofstream{ file };
          |     ^            
          |                   give_me_a_name
  • tests/image/test-raster-image.cpp:88:6: warning: [misc-use-internal-linkage]

    function 'test_missing_colors' can be made static or moved into an anonymous namespace to enforce internal linkage

       88 | void test_missing_colors()
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:93:30: warning: [cppcoreguidelines-avoid-magic-numbers]

    64 is a magic number; consider replacing it with a named constant

       93 |         raster.nb_cells() == 64, "[TEST] Wrong number of repaired cells" );
          |                              ^
  • tests/image/test-raster-image.cpp:110:6: warning: [misc-use-internal-linkage]

    function 'load_throws' can be made static or moved into an anonymous namespace to enforce internal linkage

      110 | bool load_throws( std::string_view filename )
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:124:6: warning: [misc-use-internal-linkage]

    function 'test_too_many_cells' can be made static or moved into an anonymous namespace to enforce internal linkage

      124 | void test_too_many_cells()
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:131:6: warning: [misc-use-internal-linkage]

    function 'test_extra_colors' can be made static or moved into an anonymous namespace to enforce internal linkage

      131 | void test_extra_colors()
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:138:6: warning: [misc-use-internal-linkage]

    function 'test_colors_access' can be made static or moved into an anonymous namespace to enforce internal linkage

      138 | void test_colors_access()
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:169:6: warning: [misc-use-internal-linkage]

    function 'test_io' can be made static or moved into an anonymous namespace to enforce internal linkage

      169 | void test_io( std::array< geode::index_t, dimension > cells_number )
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:203:6: warning: [misc-use-internal-linkage]

    function 'test' can be made static or moved into an anonymous namespace to enforce internal linkage

      203 | void test()
          |      ^
          | static 
  • tests/image/test-raster-image.cpp:206:36: warning: [cppcoreguidelines-avoid-magic-numbers]

    10 is a magic number; consider replacing it with a named constant

      206 |     geode::RasterImage2D raster{ { 10, 10 } };
          |                                    ^
  • tests/image/test-raster-image.cpp:206:40: warning: [cppcoreguidelines-avoid-magic-numbers]

    10 is a magic number; consider replacing it with a named constant

      206 |     geode::RasterImage2D raster{ { 10, 10 } };
          |                                        ^
  • tests/image/test-raster-image.cpp:218:21: warning: [cppcoreguidelines-avoid-magic-numbers]

    7 is a magic number; consider replacing it with a named constant

      218 |     test_io< 1 >( { 7 } );
          |                     ^
  • tests/image/test-raster-image.cpp:226:31: warning: [cppcoreguidelines-avoid-magic-numbers]

    100 is a magic number; consider replacing it with a named constant

      226 |         raster2.nb_cells() == 100, "Wrong number of cells after move" );
          |                               ^

Have any feedback or feature suggestions? Share it here.

@BenPinet
BenPinet merged commit e01d52c into next Oct 22, 2026
26 checks passed
@BenPinet
BenPinet deleted the fix/image-io-robustness branch October 22, 2026 12:17
@geode-ci

geode-ci Bot commented Oct 22, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 19.2.0-rc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants