// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include <OgnTutorialTupleArraysDatabase.h>
#include <algorithm>

class OgnTutorialTupleArrays
{
public:
    static bool compute(OgnTutorialTupleArraysDatabase& db)
    {
        // Use the "auto&" declarations to avoid long type names, prone to error
        const auto& a = db.inputs.a();
        const auto& b = db.inputs.b();
        auto& result = db.outputs.result();

        // Some simple error checking never hurts
        if (a.size() != b.size())
        {
            db.logWarning("Input sizes did not match (%zu versus %zu)", a.size(), b.size());
            return false;
        }

        // The output contents are unrelated to the input contents so resize rather than copying
        result.resize(a.size());

        // Illustrating how simple these operations are thanks to iterators and the built-in operator*
        std::transform(a.begin(), a.end(), b.begin(), result.begin(),
                       [](const GfVec3f& valueA, const GfVec3f& valueB) -> float { return valueA * valueB; });

        return true;
    }
};

REGISTER_OGN_NODE()
