UNPKG

@mlightcad/data-model

Version:

The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.

158 lines 5.59 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { AcGeBox3d, AcGePoint3d, AcGePolyline2d } from '@mlightcad/geometry-engine'; import { AcDbCurve } from './AcDbCurve'; /** * Represents the spline-fit type for this 3D polyline. */ export var AcDbPoly3dType; (function (AcDbPoly3dType) { /** * A standard polyline with no spline fitting. */ AcDbPoly3dType[AcDbPoly3dType["SimplePoly"] = 0] = "SimplePoly"; /** * A spline-fit polyline that has a Quadratic B-spline path. */ AcDbPoly3dType[AcDbPoly3dType["QuadSplinePoly"] = 1] = "QuadSplinePoly"; /** * A spline-fit polyline that has a Cubic B-spline path. */ AcDbPoly3dType[AcDbPoly3dType["CubicSplinePoly"] = 2] = "CubicSplinePoly"; })(AcDbPoly3dType || (AcDbPoly3dType = {})); /** * Represents a 3d polyline entity in AutoCAD. */ var AcDb3dPolyline = /** @class */ (function (_super) { __extends(AcDb3dPolyline, _super); /** * Creates a new empty 2d polyline entity. */ function AcDb3dPolyline(type, vertices, closed) { if (closed === void 0) { closed = false; } var _this = _super.call(this) || this; _this._polyType = type; _this._geo = new AcGePolyline2d(vertices, closed); return _this; } Object.defineProperty(AcDb3dPolyline.prototype, "polyType", { /** * Gets the spline-fit type for this 3D polyline. * * @returns The spline-fit type for this 3D polyline. */ get: function () { return this._polyType; }, /** * Sets the spline-fit type for this 3D polyline. * * @param value - The spline-fit type for this 3D polyline. */ set: function (value) { this._polyType = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDb3dPolyline.prototype, "closed", { /** * Gets whether this polyline is closed. * * A closed polyline has a segment drawn from the last vertex to the first vertex, * forming a complete loop. * * @returns True if the polyline is closed, false otherwise * * @example * ```typescript * const isClosed = polyline.closed; * console.log(`Polyline is closed: ${isClosed}`); * ``` */ get: function () { return this._geo.closed; }, /** * Sets whether this polyline is closed. * * @param value - True to close the polyline, false to open it * * @example * ```typescript * polyline.closed = true; // Close the polyline * ``` */ set: function (value) { this._geo.closed = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDb3dPolyline.prototype, "geometricExtents", { /** * Gets the geometric extents (bounding box) of this polyline. * * @returns The bounding box that encompasses the entire polyline * * @example * ```typescript * const extents = polyline.geometricExtents; * console.log(`Polyline bounds: ${extents.minPoint} to ${extents.maxPoint}`); * ``` */ get: function () { var box = this._geo.box; // TODO: Set the correct z value for 3d box return new AcGeBox3d({ x: box.min.x, y: box.min.y, z: 0 }, { x: box.max.x, y: box.max.y, z: 0 }); }, enumerable: false, configurable: true }); /** * Gets the grip points for this polyline. * * Grip points are control points that can be used to modify the polyline. * For a polyline, the grip points are all the vertices. * * @returns Array of grip points (all vertices) */ AcDb3dPolyline.prototype.subGetGripPoints = function () { var gripPoints = new Array(); // TODO: Finish logic to get grip points return gripPoints; }; /** * Draws this polyline using the specified renderer. * * @param renderer - The renderer to use for drawing * @returns The rendered polyline entity, or undefined if drawing failed */ AcDb3dPolyline.prototype.draw = function (renderer) { var points = []; var tmp = this._geo.getPoints(100); // TODO: Set the correct z value tmp.forEach(function (point) { return points.push(new AcGePoint3d().set(point.x, point.y, 0)); }); return renderer.lines(points, this.lineStyle); }; /** The entity type name */ AcDb3dPolyline.typeName = '3dPolyline'; return AcDb3dPolyline; }(AcDbCurve)); export { AcDb3dPolyline }; //# sourceMappingURL=AcDb3dPolyline.js.map