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

#pragma once

#ifndef VSNRAY_VIEWER_RENDER_BVH_H
#define VSNRAY_VIEWER_RENDER_BVH_H

#include <visionaray/detail/platform.h>

#if defined(VSNRAY_OS_DARWIN)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif

#include <visionaray/bvh.h>

namespace visionaray
{
namespace detail
{

void render(aabb const& box)
{
    glBegin(GL_LINES);

        glVertex3f(box.min.x, box.min.y, box.min.z);
        glVertex3f(box.max.x, box.min.y, box.min.z);

        glVertex3f(box.max.x, box.min.y, box.min.z);
        glVertex3f(box.max.x, box.max.y, box.min.z);

        glVertex3f(box.max.x, box.max.y, box.min.z);
        glVertex3f(box.min.x, box.max.y, box.min.z);

        glVertex3f(box.min.x, box.max.y, box.min.z);
        glVertex3f(box.min.x, box.min.y, box.min.z);

        glVertex3f(box.min.x, box.min.y, box.max.z);
        glVertex3f(box.max.x, box.min.y, box.max.z);

        glVertex3f(box.max.x, box.min.y, box.max.z);
        glVertex3f(box.max.x, box.max.y, box.max.z);

        glVertex3f(box.max.x, box.max.y, box.max.z);
        glVertex3f(box.min.x, box.max.y, box.max.z);

        glVertex3f(box.min.x, box.max.y, box.max.z);
        glVertex3f(box.min.x, box.min.y, box.max.z);


        glVertex3f(box.min.x, box.min.y, box.min.z);
        glVertex3f(box.min.x, box.min.y, box.max.z);

        glVertex3f(box.max.x, box.min.y, box.min.z);
        glVertex3f(box.max.x, box.min.y, box.max.z);

        glVertex3f(box.max.x, box.max.y, box.min.z);
        glVertex3f(box.max.x, box.max.y, box.max.z);

        glVertex3f(box.min.x, box.max.y, box.min.z);
        glVertex3f(box.min.x, box.max.y, box.max.z);

    glEnd();
}

} // detail

template <template <typename> class B, typename P>
void render(B<P> const& b)
{

    for (auto const& n : b.nodes_vector())
    {
        detail::render(n.bbox);
    }

}

} // visionaray

#endif // VSNRAY_VIEWER_RENDER_BVH_H

<commit_msg>Render BVH using OpenGL arrays<commit_after>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#pragma once

#ifndef VSNRAY_VIEWER_RENDER_BVH_H
#define VSNRAY_VIEWER_RENDER_BVH_H

#include <visionaray/detail/platform.h>

#if defined(VSNRAY_OS_DARWIN)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif

#include <visionaray/bvh.h>

namespace visionaray
{

template <template <typename> class B, typename P>
void render(B<P> const& b)
{

    std::vector<float> vertices;
    for (auto const& n : b.nodes_vector())
    {
        auto box = n.bbox;

        auto ilist =
        {
            box.min.x, box.min.y, box.min.z,
            box.max.x, box.min.y, box.min.z,

            box.max.x, box.min.y, box.min.z,
            box.max.x, box.max.y, box.min.z,

            box.max.x, box.max.y, box.min.z,
            box.min.x, box.max.y, box.min.z,

            box.min.x, box.max.y, box.min.z,
            box.min.x, box.min.y, box.min.z,

            box.min.x, box.min.y, box.max.z,
            box.max.x, box.min.y, box.max.z,

            box.max.x, box.min.y, box.max.z,
            box.max.x, box.max.y, box.max.z,

            box.max.x, box.max.y, box.max.z,
            box.min.x, box.max.y, box.max.z,

            box.min.x, box.max.y, box.max.z,
            box.min.x, box.min.y, box.max.z,

            box.min.x, box.min.y, box.min.z,
            box.min.x, box.min.y, box.max.z,

            box.max.x, box.min.y, box.min.z,
            box.max.x, box.min.y, box.max.z,

            box.max.x, box.max.y, box.min.z,
            box.max.x, box.max.y, box.max.z,

            box.min.x, box.max.y, box.min.z,
            box.min.x, box.max.y, box.max.z
        };

        vertices.insert(vertices.end(), ilist.begin(), ilist.end());
    }

    glVertexPointer(3, GL_FLOAT, 0, vertices.data());
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawArrays(GL_LINES, 0, vertices.size() / 3);
    glDisableClientState(GL_VERTEX_ARRAY);

}

} // visionaray

#endif // VSNRAY_VIEWER_RENDER_BVH_H


{'fraction_non_alphanumeric': 0.1688921859545005, 'fraction_numerical': 0.006923837784371909, 'mean_word_length': 2.135658914728682, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '4904812', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1716, 'n_words': 286}