<commit_before>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#include <type_traits>

#include <visionaray/math/aabb.h>

namespace visionaray
{

template <
    typename BVH,
    typename = typename std::enable_if<is_any_bvh<BVH>::value>::type,
    typename = typename std::enable_if<!is_any_bvh_inst<BVH>::value>::type
    >
MATH_FUNC
aabb get_bounds(BVH const& bvh)
{
    aabb result;
    result.invalidate();

    if (bvh.num_nodes() > 0)
    {
        result = bvh.node(0).get_bounds();
    }

    return result;
}

// Overload for BVH instances
template <
    typename BVH,
    typename = typename std::enable_if<is_any_bvh<BVH>::value>::type,
    typename = typename std::enable_if<is_any_bvh_inst<BVH>::value>::type,
    typename = void
    >
MATH_FUNC
aabb get_bounds(BVH const& bvh)
{
    mat3 affine = inverse(bvh.affine_inv());
    vec3 trans = -bvh.trans_inv();

    aabb bbox = get_bounds(bvh.get_ref());

    aabb result;
    result.invalidate();

    auto vertices = compute_vertices(bbox);

    for (vec3 v : vertices)
    {
        v = affine * v + trans;
        result.insert(v);
    }

    return result;
}

} // visionaray<commit_msg>Don't use math macros outside of math library<commit_after>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#include <type_traits>

#include <visionaray/math/aabb.h>

namespace visionaray
{

template <
    typename BVH,
    typename = typename std::enable_if<is_any_bvh<BVH>::value>::type,
    typename = typename std::enable_if<!is_any_bvh_inst<BVH>::value>::type
    >
VSNRAY_FUNC
aabb get_bounds(BVH const& bvh)
{
    aabb result;
    result.invalidate();

    if (bvh.num_nodes() > 0)
    {
        result = bvh.node(0).get_bounds();
    }

    return result;
}

// Overload for BVH instances
template <
    typename BVH,
    typename = typename std::enable_if<is_any_bvh<BVH>::value>::type,
    typename = typename std::enable_if<is_any_bvh_inst<BVH>::value>::type,
    typename = void
    >
VSNRAY_FUNC
aabb get_bounds(BVH const& bvh)
{
    mat3 affine = inverse(bvh.affine_inv());
    vec3 trans = -bvh.trans_inv();

    aabb bbox = get_bounds(bvh.get_ref());

    aabb result;
    result.invalidate();

    auto vertices = compute_vertices(bbox);

    for (vec3 v : vertices)
    {
        v = affine * v + trans;
        result.insert(v);
    }

    return result;
}

} // visionaray
{'fraction_non_alphanumeric': 0.1272652388797364, 'fraction_numerical': 0.004118616144975288, 'mean_word_length': 3.231707317073171, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6335453', 'n_tokens_mistral': 941, 'n_tokens_neox': 852, 'n_words': 190}