// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/store/re_sdk_types/definitions/rerun/archetypes/transform_axes3d.fbs".

#include "transform_axes3d.hpp"

#include "../collection_adapter_builtins.hpp"

namespace rerun::archetypes {
    TransformAxes3D TransformAxes3D::clear_fields() {
        auto archetype = TransformAxes3D();
        archetype.axis_length =
            ComponentBatch::empty<rerun::components::AxisLength>(Descriptor_axis_length)
                .value_or_throw();
        archetype.show_frame =
            ComponentBatch::empty<rerun::components::ShowLabels>(Descriptor_show_frame)
                .value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> TransformAxes3D::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(2);
        if (axis_length.has_value()) {
            columns.push_back(axis_length.value().partitioned(lengths_).value_or_throw());
        }
        if (show_frame.has_value()) {
            columns.push_back(show_frame.value().partitioned(lengths_).value_or_throw());
        }
        return columns;
    }

    Collection<ComponentColumn> TransformAxes3D::columns() {
        if (axis_length.has_value()) {
            return columns(std::vector<uint32_t>(axis_length.value().length(), 1));
        }
        if (show_frame.has_value()) {
            return columns(std::vector<uint32_t>(show_frame.value().length(), 1));
        }
        return Collection<ComponentColumn>();
    }
} // namespace rerun::archetypes

namespace rerun {

    Result<Collection<ComponentBatch>> AsComponents<archetypes::TransformAxes3D>::as_batches(
        const archetypes::TransformAxes3D& archetype
    ) {
        using namespace archetypes;
        std::vector<ComponentBatch> cells;
        cells.reserve(2);

        if (archetype.axis_length.has_value()) {
            cells.push_back(archetype.axis_length.value());
        }
        if (archetype.show_frame.has_value()) {
            cells.push_back(archetype.show_frame.value());
        }

        return rerun::take_ownership(std::move(cells));
    }
} // namespace rerun
