<commit_before>#ifndef Magnum_MeshBuilder_h
#define Magnum_MeshBuilder_h
/*
    Copyright © 2010 <NAME> <<EMAIL>>

    This file is part of Magnum.

    Magnum is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License version 3
    only, as published by the Free Software Foundation.

    Magnum is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU Lesser General Public License version 3 for more details.
*/

/** @file
 * @brief Class Magnum::MeshBuilder
 */

#include <set>
#include <map>

#include "Buffer.h"
#include "IndexedMesh.h"

namespace Magnum {

/**
@brief Mesh builder

Class for building meshes with triangle primitive from scratch or from
prefabricated data and modifying them (adding/removing faces, cleaning duplicate
vertices etc.).

Vertex template can be absolutely anything (single integer, structure, class)
but it must have at least operator== implemented.
*/
template<class Vertex> class MeshBuilder {
    public:
        /** @brief Triangle face */
        struct Face {
            /** @brief Implicit constructor */
            Face() {}

            /** @brief Constructor */
            Face(Vertex* first, Vertex* second, Vertex* third) {
                vertices[0] = first;
                vertices[1] = second;
                vertices[2] = third;
            }

            /** @brief Vertex data */
            Vertex* vertices[3];
        };

        /**
         * @brief Destructor
         *
         * Removed all vertices and faces.
         */
        inline virtual ~MeshBuilder() { clear(); }

        /**
         * @brief Clear mesh data
         *
         * Should be called after the mesh is built and the builder is not
         * needed. This function is also automatically called in destructor or
         * when calling setData().
         */
        void clear() {
            for(typename std::set<Vertex*>::iterator it = _vertices.begin(); it != _vertices.end(); ++it)
                delete *it;

            for(typename std::set<Face*>::iterator it = _faces.begin(); it != _faces.end(); ++it)
                delete *it;

            _vertices.clear();
            _faces.clear();
            vertexFaces.clear();
        }

        /** @brief Array with vertices */
        inline const std::set<Vertex*>& vertices() const { return _vertices; }

        /** @brief Array with faces */
        inline const std::set<Face*>& faces() const { return _faces; }

        /**
         * @brief Set mesh data
         * @param vertices      Vertices
         * @param indices       Vertex indices
         * @param vertexCount   Vertex count
         * @param indexCount    Index count
         *
         * Replaces mesh builder data with given data. Type of indices is
         * detected from given pointer.
         */
        inline void setData(const Vertex* vertices, const GLubyte* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLubyte>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_BYTE);
        }

        /** @copydoc setData() */
        inline void setData(const Vertex* vertices, const GLushort* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLushort>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_SHORT);
        }

        /** @copydoc setData() */
        inline void setData(const Vertex* vertices, const GLuint* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLuint>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_INT);
        }

        /**<commit_msg>Function for getting vertex data from MeshBuilder.<commit_after>#ifndef Magnum_MeshBuilder_h
#define Magnum_MeshBuilder_h
/*
    Copyright © 2010 <NAME> <<EMAIL>>

    This file is part of Magnum.

    Magnum is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License version 3
    only, as published by the Free Software Foundation.

    Magnum is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU Lesser General Public License version 3 for more details.
*/

/** @file
 * @brief Class Magnum::MeshBuilder
 */

#include <set>
#include <map>

#include "Buffer.h"
#include "IndexedMesh.h"

namespace Magnum {

/**
@brief Mesh builder

Class for building meshes with triangle primitive from scratch or from
prefabricated data and modifying them (adding/removing faces, cleaning duplicate
vertices etc.).

Vertex template can be absolutely anything (single integer, structure, class)
but it must have at least operator== implemented.
*/
template<class Vertex> class MeshBuilder {
    public:
        /** @brief Triangle face */
        struct Face {
            /** @brief Implicit constructor */
            Face() {}

            /** @brief Constructor */
            Face(Vertex* first, Vertex* second, Vertex* third) {
                vertices[0] = first;
                vertices[1] = second;
                vertices[2] = third;
            }

            /** @brief Vertex data */
            Vertex* vertices[3];
        };

        /**
         * @brief Destructor
         *
         * Removed all vertices and faces.
         */
        inline virtual ~MeshBuilder() { clear(); }

        /**
         * @brief Clear mesh data
         *
         * Should be called after the mesh is built and the builder is not
         * needed. This function is also automatically called in destructor or
         * when calling setData().
         */
        void clear() {
            for(typename std::set<Vertex*>::iterator it = _vertices.begin(); it != _vertices.end(); ++it)
                delete *it;

            for(typename std::set<Face*>::iterator it = _faces.begin(); it != _faces.end(); ++it)
                delete *it;

            _vertices.clear();
            _faces.clear();
            vertexFaces.clear();
        }

        /** @brief Array with vertices */
        inline const std::set<Vertex*>& vertices() const { return _vertices; }

        /** @brief Array with fixed vertices */
        std::vector<Vertex> fixedVertices() const {
            std::vector<Vertex> vertices;
            for(typename std::set<Vertex*>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it)
                vertices.push_back(**it);

            return vertices;
        }

        /** @brief Array with faces */
        inline const std::set<Face*>& faces() const { return _faces; }

        /**
         * @brief Set mesh data
         * @param vertices      Vertices
         * @param indices       Vertex indices
         * @param vertexCount   Vertex count
         * @param indexCount    Index count
         *
         * Replaces mesh builder data with given data. Type of indices is
         * detected from given pointer.
         */
        inline void setData(const Vertex* vertices, const GLubyte* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLubyte>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_BYTE);
        }

        /** @copydoc setData() */
        inline void setData(const Vertex* vertices, const GLushort* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLushort>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_SHORT);
        }

        /** @copydoc setData() */
        inline void setData(const Vertex* vertices, const GLuint* indices, GLsizei vertexCount, GLsizei indexCount) {
            setData<GLuint>(vertices, indices, vertexCount, indexCount, GL_UNSIGNED_INT);
        }

        /**
{'fraction_non_alphanumeric': 0.09630102040816327, 'fraction_numerical': 0.002551020408163265, 'mean_word_length': 2.209578387228817, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '4073308', 'n_tokens_mistral': 2071, 'n_tokens_neox': 2011, 'n_words': 728}