<commit_before>/* <NAME> Copyright @2014
 * Context for the overall CAD assembly
 */

"use strict";


/*************************************************************************/


define(["THREE"], function(THREE) {
    /* config:
        defaultColor
        debug
     */
    function Assembly(rootID, defaultColor, loader) {
        this._rootID = rootID;
        this._defaultColor = defaultColor;
        this._loader = loader;
        this._objects = [];
        this._product = undefined;
    }

    Assembly.prototype.getID = function() {
        if (this._product) {
            return this._product.getID();
        } else {
            return "id0";
        }
    };

    Assembly.prototype.isChild = function(id) {
        return (this._objects[id] !== undefined);
    };

    Assembly.prototype.getChild = function(id) {
        return this._objects[id];
    };

    Assembly.prototype.makeChild = function(id, fallback) {
//        console.log("Assembly.makeChild: " + id);
        if (!id) {
            throw new Error("null id");
        }
        var ret = this._objects[id];
        if (ret) {
            return ret;
        }
        this._objects[id] = fallback;
        return null;
    };

    Assembly.prototype.setRootProduct = function(product) {
        this._product = product;
    };

    Assembly.prototype.name = function() {
        if (this._product) {
            if (this._product._stepFile) return this._product._stepFile;
            else return this._product._name;
        } else {
            return "Assembly";
        }
    };

    Assembly.prototype.getBoundingBox = function() {
        if (this._product) {
            return this._product.getBoundingBox();
        }
        return new THREE.Box3();
    };

    Assembly.prototype.showBoundingBox = function() {
        if (this._product) {
            this._product.showBoundingBox();
        }
    };

    Assembly.prototype.hideBoundingBox = function() {
        if (this._product) {
            this._product.hideBoundingBox();
        }
    };

    Assembly.prototype.getByID = function(id) {
        var obj = undefined;
        // Special case for the root element
        if (id === "id0") {
            obj = this;
        } else {
            var parts = id.split("_");
            obj = this._objects[parts[0]];
            // Looks like an instance was selected
            if (parts.length > 1 && parts[1] !== "0") {
                obj = obj._instances[parts[1]-1];
            }
        }
        return obj;

    };

    Assembly.prototype.setOpacity = function (opacity) {
        if (this._product) {
            this._product.setOpacity(opacity);
        }
    };<commit_msg>account for empty selection in hide toggle handler<commit_after>/* <NAME> Copyright @2014
 * Context for the overall CAD assembly
 */

"use strict";


/*************************************************************************/


define(["THREE"], function(THREE) {
    /* config:
        defaultColor
        debug
     */
    function Assembly(rootID, defaultColor, loader) {
        this._rootID = rootID;
        this._defaultColor = defaultColor;
        this._loader = loader;
        this._objects = [];
        this._product = undefined;
    }

    Assembly.prototype.getID = function() {
        if (this._product) {
            return this._product.getID();
        } else {
            return "id0";
        }
    };

    Assembly.prototype.isChild = function(id) {
        return (this._objects[id] !== undefined);
    };

    Assembly.prototype.getChild = function(id) {
        return this._objects[id];
    };

    Assembly.prototype.makeChild = function(id, fallback) {
//        console.log("Assembly.makeChild: " + id);
        if (!id) {
            throw new Error("null id");
        }
        var ret = this._objects[id];
        if (ret) {
            return ret;
        }
        this._objects[id] = fallback;
        return null;
    };

    Assembly.prototype.setRootProduct = function(product) {
        this._product = product;
    };

    Assembly.prototype.name = function() {
        if (this._product) {
            if (this._product._stepFile) return this._product._stepFile;
            else return this._product._name;
        } else {
            return "Assembly";
        }
    };

    Assembly.prototype.getBoundingBox = function() {
        if (this._product) {
            return this._product.getBoundingBox();
        }
        return new THREE.Box3();
    };

    Assembly.prototype.showBoundingBox = function() {
        if (this._product) {
            this._product.showBoundingBox();
        }
    };

    Assembly.prototype.hideBoundingBox = function() {
        if (this._product) {
            this._product.hideBoundingBox();
        }
    };

    Assembly.prototype.getByID = function(id) {
        var obj = undefined;
        // Special case for the root element
        if (id === "id0") {
            obj = this;
        } else if (typeof(id) !== 'undefined') {
            var parts = id.split("_");
            obj = this._objects[parts[0]];
            // Looks like an instance was selected
            if (parts.length > 1 && parts[1] !== "0") {
                obj = obj._instances[parts[1]-1];
            }
        }
        return obj;

    };

    Assembly.prototype.setOpacity = function (opacity) {
        if (this._product) {
            this._product.setOpacity(opacity);
        }
    };
{'fraction_non_alphanumeric': 0.14988075582461935, 'fraction_numerical': 0.004769767015226564, 'mean_word_length': 1.795897435897436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3076755', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1467, 'n_words': 310}