UNPKG

gs-json

Version:

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

131 lines (111 loc) 5.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Polyline = 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 _entity_obj = require("./entity_obj"); 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; } /** * Class Polyline. * A polyline consists of one wire and no faces. * The wire has a sequence of vertices. * The wire may be open or closed. * A polyline may be part of a group and may have attributes. */ var Polyline = exports.Polyline = function (_Obj) { _inherits(Polyline, _Obj); function Polyline() { _classCallCheck(this, Polyline); return _possibleConstructorReturn(this, (Polyline.__proto__ || Object.getPrototypeOf(Polyline)).apply(this, arguments)); } _createClass(Polyline, [{ key: "getObjType", /** * Get the object type: "polyline". * @return Polyline object type. */ value: function getObjType() { return 100 /* polyline */; } /** * Checks if the polyline is closed. * @return Return true if the polyline is closed. */ }, { key: "isClosed", value: function isClosed() { return this.getWires()[0].isClosed(); } /** * Sets if the polyline is closed. * @param is_closed Ture if closed, false if open. * @return Return the old value for is_closed. */ }, { key: "setIsClosed", value: function setIsClosed(is_closed) { var path = this.getWires()[0].getTopoPath(); return this._kernel.topoSetIsClosed(path, is_closed); } /** * Returns the number of vertices in this polyline. * @return Return the number of vertices. */ }, { key: "numVertices", value: function numVertices() { return this.getWires()[0].numVertices(); } /** * Returns the number of edges in this polyline. * @return Return the number of edges. */ }, { key: "numEdges", value: function numEdges() { return this.getWires()[0].numEdges(); } /** * Insert an extra vertex. * @return The new vertex. */ }, { key: "insertVertex", value: function insertVertex(edge, point) { if (edge.getObjID() !== this._id) { throw new Error("Edge must belong to polyline."); } var path = edge.getTopoPath(); this._kernel.edgeSplit(path, point.getID()); var new_edge_path = this._kernel.edgeSplit(path, point.getID()); return new _topo_sub.Vertex(this._kernel, new_edge_path); } /** * Add n extra vertex to the start or end. * @return The new vertex. */ }, { key: "addVertex", value: function addVertex(point, to_start) { var path = this.getWires()[0].getTopoPath(); this._kernel.topoAddVertex(path, point.getID(), to_start); var new_vertex_path = this._kernel.edgeSplit(path, point.getID()); return new _topo_sub.Vertex(this._kernel, new_vertex_path); } /** * Delete a vertex. * @return The next vertex that replaces it, or null if it was teh last vertex of an open polyline. */ }, { key: "delVertex", value: function delVertex(vertex) { throw new Error("Method not implemented."); } }]); return Polyline; }(_entity_obj.Obj); //# sourceMappingURL=entity_obj_polyline.js.map