gs-json
Version:
gs-JSON is a domain agnostic unifying 3D file format for geometric and semantic modelling (hence the 'gs').
107 lines (90 loc) • 4.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TopoAttrib = 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 _topo_sub = require("./topo_sub");
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; }
/**
* TopoAttrib class for topos (vertices, edges, wires, and faces).
* Semantic attributes that are attached to points or objects.
* An instance of this class stores a list of attributes values.
*/
var TopoAttrib = exports.TopoAttrib = function (_Attrib) {
_inherits(TopoAttrib, _Attrib);
function TopoAttrib() {
_classCallCheck(this, TopoAttrib);
return _possibleConstructorReturn(this, (TopoAttrib.__proto__ || Object.getPrototypeOf(TopoAttrib)).apply(this, arguments));
}
_createClass(TopoAttrib, [{
key: "getPaths",
/**
* Get all paths for this attribute.
* @return An array of paths.
*/
value: function getPaths() {
return this._kernel.topoAttribGetPaths(this._name, this._geom_type);
}
/**
* Get all topos for this attribute.
* @return An array of paths.
*/
}, {
key: "getTopos",
value: function getTopos() {
var _this2 = this;
var paths = this._kernel.topoAttribGetPaths(this._name, this._geom_type);
switch (this._geom_type) {
case _enums.EGeomType.vertices:
return paths.map(function (path) {
return new _topo_sub.Vertex(_this2._kernel, path);
});
case _enums.EGeomType.edges:
return paths.map(function (path) {
return new _topo_sub.Edge(_this2._kernel, path);
});
case _enums.EGeomType.wires:
return paths.map(function (path) {
return new _topo_sub.Wire(_this2._kernel, path);
});
case _enums.EGeomType.faces:
return paths.map(function (path) {
return new _topo_sub.Face(_this2._kernel, path);
});
}
}
/**
* Get all labels for this attribute.
* @return An array of labels.
*/
}, {
key: "getLabels",
value: function getLabels() {
switch (this._geom_type) {
case _enums.EGeomType.vertices:
return this.getPaths().map(function (path) {
return "o" + path.id + ":" + ["w", "f"][path.tt] + path.ti + ":v" + path.si;
});
case _enums.EGeomType.edges:
return this.getPaths().map(function (path) {
return "o" + path.id + ":" + ["w", "f"][path.tt] + path.ti + ":e" + path.si;
});
case _enums.EGeomType.wires:
return this.getPaths().map(function (path) {
return "o" + path.id + ":w" + path.ti;
});
case _enums.EGeomType.faces:
return this.getPaths().map(function (path) {
return "o" + path.id + ":f" + path.ti;
});
}
}
}]);
return TopoAttrib;
}(_attrib.Attrib);
//# sourceMappingURL=attrib_topoattrib.js.map