UNPKG

gs-json

Version:

gs-JSON is a domain agnostic unifying 3D file format for geometric and semantic modelling (hence the 'gs').

147 lines (130 loc) 4.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Attrib abstract class. * An class that represents a semantic attribute. * An attribute is data that is attached to either: * entities (points and objects) or * topological components (vertices, edges, wires, faces). * An instance of this class stores a list of attributes values. */ var Attrib = exports.Attrib = function () { /** * Creates an instance of the Attrib class. * The attribute data must already exists in the model. * Do not use this constructor if you want to add a new attribute to the model. * Instead, you should use the "addAttrib()" methdod in the model class. * @param model The Model object in which this attribute will be created. * @param data The attribute data in the model. * @return The Attrib object. */ function Attrib(kernel, name, geom_type) { _classCallCheck(this, Attrib); this._kernel = kernel; this._name = name; this._geom_type = geom_type; } /** * Check if this group exists * @return The model */ _createClass(Attrib, [{ key: "exists", value: function exists() { return this._kernel.modelGetAttrib(this._name, this._geom_type) === undefined; } /** * Get the model to which this group belongs. * @return The model */ }, { key: "getModel", value: function getModel() { return this._kernel.getModel(); } /** * Get the Geom object * @return The Model object */ }, { key: "getGeom", value: function getGeom() { return this._kernel.getGeom(); } // This attribute ----------------------------------------------------------------------------- /** * Get the name of the attribute. * @return The name. */ }, { key: "getName", value: function getName() { return this._name; } /** * Set the geometry type for the attribute. * @return The geometry type. */ }, { key: "getGeomType", value: function getGeomType() { return this._geom_type; } /** * Set the name of the attribute. * @param name The new name. * @return The old name. */ }, { key: "setName", value: function setName(name) { var old_name = this._name; this._kernel.attribSetName(old_name, name, this._geom_type); this._name = name; return old_name; } /** * Set the data type for the attribute values. * @return The data type. */ }, { key: "getDataType", value: function getDataType() { return this._kernel.attribGetDataType(this._name, this._geom_type); } /** * Get all the attribute values for this attribte. * @return The array of attribute values. */ }, { key: "getValues", value: function getValues() { return this._kernel.attribGetValues(this._name, this._geom_type); } /** * Get all the attribute labels for this attribte. * @return The array of attribute labels. */ }, { key: "getLabels", value: function getLabels() { // Do not implement this method. throw new Error("Method to be overridden by subclass."); } /** * Get the number of attribute values. * @return The number of attribute values. */ }, { key: "count", value: function count() { return this._kernel.attribCount(this._name, this._geom_type); } }]); return Attrib; }(); //# sourceMappingURL=attrib.js.map