UNPKG

gs-json

Version:

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

94 lines (76 loc) 4.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EntAttrib = undefined; 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; }; }(); var _enums = require("./enums"); var _attrib = require("./attrib"); var _entity_point = require("./entity_point"); var _entity_obj_cast = require("./entity_obj_cast"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * EntAttrib class for entities (points and objects). * An class that represents a semantic attribute that is attached to a point or object. * An instance of this class stores a list of attributes values. */ var EntAttrib = exports.EntAttrib = function (_Attrib) { _inherits(EntAttrib, _Attrib); function EntAttrib() { _classCallCheck(this, EntAttrib); return _possibleConstructorReturn(this, (EntAttrib.__proto__ || Object.getPrototypeOf(EntAttrib)).apply(this, arguments)); } _createClass(EntAttrib, [{ key: "getIDs", /** * Get all IDs for this attribute. These can be either point IDs or object IDs. * @return An array of IDs. */ value: function getIDs() { return this._kernel.entAttribGetIDs(this._name, this._geom_type); } /** * Get all entities for this attribute. These can be either points or objects. * @return An array of IDs. */ }, { key: "getEnts", value: function getEnts() { var _this2 = this; var ids = this._kernel.entAttribGetIDs(this._name, this._geom_type); switch (this._geom_type) { case _enums.EGeomType.points: return ids.map(function (id) { return new _entity_point.Point(_this2._kernel, id); }); case _enums.EGeomType.points: return ids.map(function (id) { return (0, _entity_obj_cast._castToObjType)(_this2._kernel, id); }); } } /** * Get all labels for this attribute. * @return An array of labels. */ }, { key: "getLabels", value: function getLabels() { var ids = this._kernel.entAttribGetIDs(this._name, this._geom_type); switch (this._geom_type) { case _enums.EGeomType.points: return ids.map(function (v) { return "p" + v; }); case _enums.EGeomType.objs: return ids.map(function (v) { return "o" + v; }); } } }]); return EntAttrib; }(_attrib.Attrib); //# sourceMappingURL=attrib_entattrib.js.map