Skip to content

Conversation

lumurillo
Copy link
Contributor

Add serialization and deserialization methods to the Octree.

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Copy link

update-docs bot commented Aug 19, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@ssheorey ssheorey requested review from Copilot and ssheorey August 22, 2025 07:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds binary serialization and deserialization support to the Octree class, complementing the existing JSON-based I/O functionality. The implementation allows Octree objects to be saved and loaded in a binary format (.bin) for more efficient storage and transmission.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
cpp/open3d/geometry/Octree.h Adds binary serialization method declarations to all Octree node classes
cpp/open3d/geometry/Octree.cpp Implements binary serialization/deserialization for all Octree node types
cpp/open3d/io/OctreeIO.h Adds function declarations for binary I/O operations
cpp/open3d/io/OctreeIO.cpp Implements high-level binary I/O functions and registers .bin format support
cpp/open3d/io/file_format/FileBIN.cpp Adds low-level binary file read/write utilities
cpp/tests/geometry/Octree.cpp Adds unit test for binary stream serialization/deserialization
cpp/tests/io/OctreeIO.cpp Updates existing tests to verify both JSON and binary formats
cpp/pybind/t/geometry/pointcloud.cpp Minor formatting fix for function definition

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

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

Hi @lumurillo thanks for this nice addition. Some thoughts:

  • Can we use msgpack, instead of raw binary format for serialization? This is already used elsewhere in Open3D, is simple to use, should provide good speed and smaller size and will also be cross-platform. Raw binary format sometimes has issues if you write on Windows and read in Linux or vice versa. It will also enable reading / writing from plain Python through the Python msgpack library.
  • msgpack in Open3D:
    // macro for creating the serialization/deserialization code
    (and other places - search for msgpack). We use *.msgpack files to store tensor geometries in the Tensorboard plugin, for example.
  • Tutorial: https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_tutorial

@ssheorey
Copy link
Member

From Github Copilot, about the macOS errors:

The build is failing due to missing override specifiers for functions that override virtual methods in the Octree classes. The compiler treats this as an error because of the -Werror,-Winconsistent-missing-override flag. For example:

error: 'SerializeToBinaryStream' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]

To fix this, add the override keyword to all overriding methods in the derived classes. Specifically, in cpp/open3d/geometry/Octree.h (ref: 1fada55), update the relevant function declarations as follows:

For OctreeInternalNode:

bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override;

For OctreeInternalPointNode:

bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override;

For OctreeColorLeafNode:

bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override;

For OctreePointColorLeafNode:

bool SerializeToBinaryStream(std::string& out) const override;
bool DeserializeFromBinaryStream(const std::string& in, size_t& offset) override;

Add override to all other similar functions that are overriding a base class method but are missing it. This will resolve the compilation errors and allow the build to succeed.

You can see the problematic lines in Octree.h here:
https://github.com/isl-org/Open3D/blob/1fada55e1c46344d4b0bd63d3668240a0ff2f9dc/cpp/open3d/geometry/Octree.h

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