<commit_before>import * as THREE from 'three';

// A BufferGeometryMutator is similar to a BufferGeometry with
// additional neighbor information.  The neighbor information
// maintains which face is connected to which face by which edge.
class BufferGeometryMutator {
    constructor() {
        // An array of numbers.  Every triple represents a point.
        // Every 3 points is a face.
        this.positions = [];
        // An array of numbers.  Every triple represents the RGB of a
        // vertex.  If it's undefined, that means that the input
        // BufferGeometry didn't have any colors.
        this.colors = undefined;
        // neighbors has length the same as faces*3.  Each element is
        // the position of the neighboring faceEdge.
        this.neighbors = [];
        // A list as long as the number of faces.  Each element is a
        // number that identifies an island.  All faces that have the
        // same island number are part of the same shape.  faces that
        // have null island are degenerate and not part of any shape.
        this.reverseIslands = [];

        // static variables needed temporarily for methods below.
        this.faceNormalVector3s = [new THREE.Vector3(),
                                   new THREE.Vector3(),
                                   new THREE.Vector3()];
        this.faceNormalTriangle = new THREE.Triangle();
        this.vertexLeft = new THREE.Vector3();
        this.vertexMiddle = new THREE.Vector3();
        this.vertexRight = new THREE.Vector3();
    }

    clone() {
        let newBufferGeometryMutator = new BufferGeometryMutator();
        newBufferGeometryMutator.positions = this.positions.slice(0);
        if (this.colors) {
            newBufferGeometryMutator.colors = this.colors.slice(0);
        }
        newBufferGeometryMutator.neighbors = this.neighbors.slice(0);
        newBufferGeometryMutator.reverseIslands = this.reverseIslands.slice(0);
        return newBufferGeometryMutator;
    }

    range(x) {
        // eslint should allow Symbol
        /* global Symbol */
        return {[Symbol.iterator]:
                function* () {
                    for (let i = 0; i < x; i++) {
                        yield i;
                    }
                }};
    }

    // Uses only the positions from a THREE.BufferGeometry.
    fromBufferGeometry(bufferGeometry) {
        this.positions = Array.from(bufferGeometry.getAttribute('position').array);
        if (bufferGeometry.getAttribute('color')) {
            this.colors = Array.from(bufferGeometry.getAttribute('color').array);
        } else {
            this.colors = undefined;
        }
        if (!this.findNeighbors()) {
            return null;
        }

        this.removeDegenerates(this.range(this.positions.length/9));
        this.deleteDegenerates();

        return this;
    }

    // Convert 3 consecutive positions into a string usable as a key in a Map.
    keyForTrio(startIndex) {
        let array = this.positions;
        let [v1, v2, v3] = [array[startIndex], array[startIndex+1], array[startIndex+2]];
        return v1 + '_' + v2 + '_' + v3;
    }

    // Returns a Map of keyForTrio to positions in this.positions.
    vertexPositionMap() {
        let map = new Map();
        for (var posIndex = 0; posIndex < this.positions.length; posIndex += 3) {
            let key = this.keyForTrio(posIndex);
            if (!map.has(key)) {
                map.set(key, []);
            }
            map.get(key).push(posIndex);
        }
        return map;
    }

    // Given a faceIndex (0 to faceCount-1), return an index in this.positions.
    positionFromFace(faceIndex) {
        return faceIndex*9;
    }

    // Given an index in this.positions, return the face (0 to facecount-1).<commit_msg>remove blank lines<commit_after>import * as THREE from 'three';

// A BufferGeometryMutator is similar to a BufferGeometry with
// additional neighbor information.  The neighbor information
// maintains which face is connected to which face by which edge.
class BufferGeometryMutator {
    constructor() {
        // An array of numbers.  Every triple represents a point.
        // Every 3 points is a face.
        this.positions = [];
        // An array of numbers.  Every triple represents the RGB of a
        // vertex.  If it's undefined, that means that the input
        // BufferGeometry didn't have any colors.
        this.colors = undefined;
        // neighbors has length the same as faces*3.  Each element is
        // the position of the neighboring faceEdge.
        this.neighbors = [];
        // A list as long as the number of faces.  Each element is a
        // number that identifies an island.  All faces that have the
        // same island number are part of the same shape.  faces that
        // have null island are degenerate and not part of any shape.
        this.reverseIslands = [];

        // static variables needed temporarily for methods below.
        this.faceNormalVector3s = [new THREE.Vector3(),
                                   new THREE.Vector3(),
                                   new THREE.Vector3()];
        this.faceNormalTriangle = new THREE.Triangle();
        this.vertexLeft = new THREE.Vector3();
        this.vertexMiddle = new THREE.Vector3();
        this.vertexRight = new THREE.Vector3();
    }

    clone() {
        let newBufferGeometryMutator = new BufferGeometryMutator();
        newBufferGeometryMutator.positions = this.positions.slice(0);
        if (this.colors) {
            newBufferGeometryMutator.colors = this.colors.slice(0);
        }
        newBufferGeometryMutator.neighbors = this.neighbors.slice(0);
        newBufferGeometryMutator.reverseIslands = this.reverseIslands.slice(0);
        return newBufferGeometryMutator;
    }

    range(x) {
        // eslint should allow Symbol
        /* global Symbol */
        return {[Symbol.iterator]:
                function* () {
                    for (let i = 0; i < x; i++) {
                        yield i;
                    }
                }};
    }

    // Uses only the positions from a THREE.BufferGeometry.
    fromBufferGeometry(bufferGeometry) {
        this.positions = Array.from(bufferGeometry.getAttribute('position').array);
        if (bufferGeometry.getAttribute('color')) {
            this.colors = Array.from(bufferGeometry.getAttribute('color').array);
        } else {
            this.colors = undefined;
        }
        if (!this.findNeighbors()) {
            return null;
        }
        this.removeDegenerates(this.range(this.positions.length/9));
        this.deleteDegenerates();
        return this;
    }

    // Convert 3 consecutive positions into a string usable as a key in a Map.
    keyForTrio(startIndex) {
        let array = this.positions;
        let [v1, v2, v3] = [array[startIndex], array[startIndex+1], array[startIndex+2]];
        return v1 + '_' + v2 + '_' + v3;
    }

    // Returns a Map of keyForTrio to positions in this.positions.
    vertexPositionMap() {
        let map = new Map();
        for (var posIndex = 0; posIndex < this.positions.length; posIndex += 3) {
            let key = this.keyForTrio(posIndex);
            if (!map.has(key)) {
                map.set(key, []);
            }
            map.get(key).push(posIndex);
        }
        return map;
    }

    // Given a faceIndex (0 to faceCount-1), return an index in this.positions.
    positionFromFace(faceIndex) {
        return faceIndex*9;
    }

    // Given an index in this.positions, return the face (0 to facecount-1).
{'fraction_non_alphanumeric': 0.09864527160331447, 'fraction_numerical': 0.008154675785873998, 'mean_word_length': 1.9599065784351888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '916781', 'n_tokens_mistral': 2085, 'n_tokens_neox': 1976, 'n_words': 623}