@mlightcad/data-model 1.2.21 → 1.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,224 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { AcGeBox3d, AcGePoint3d } from '@mlightcad/geometry-engine';
17
+ import { AcDbEntity } from './AcDbEntity';
18
+ /**
19
+ * Represents a three-dimensional surface patch — specifically, a flat polygon that
20
+ * can have three or four vertices (triangular or quadrilateral). It’s one of the
21
+ * simplest types of 3D geometry in AutoCAD — used mainly for visual representation
22
+ * of 3D models, not for solid modeling.
23
+ */
24
+ var AcDbFace = /** @class */ (function (_super) {
25
+ __extends(AcDbFace, _super);
26
+ /**
27
+ * Creates a new face entity.
28
+ *
29
+ * This constructor initializes a face with default values.
30
+ * All vertices are set to the origin.
31
+ */
32
+ function AcDbFace() {
33
+ var _this = _super.call(this) || this;
34
+ _this._vertices = [new AcGePoint3d(), new AcGePoint3d(), new AcGePoint3d()];
35
+ _this._edgeInvisibilities = 0;
36
+ return _this;
37
+ }
38
+ /**
39
+ * Gets the point at the specified index in this face.
40
+ *
41
+ * The index can be 0, 1, 2, or 3, representing the four vertices of the face.
42
+ * If the index is out of range, it returns the first or last vertex accordingly.
43
+ *
44
+ * @param index - The index (0-3) of the vertex to get
45
+ * @returns The point at the specified index in WCS coordinates
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const point0 = face.getVertexAt(0);
50
+ * const point1 = face.getVertexAt(1);
51
+ * console.log(`Vertex 0: ${point0.x}, ${point0.y}, ${point0.z}`);
52
+ * ```
53
+ */
54
+ AcDbFace.prototype.getVertexAt = function (index) {
55
+ if (index < 0)
56
+ return this._vertices[0];
57
+ if (index > this._vertices.length) {
58
+ return this._vertices[this._vertices.length - 1];
59
+ }
60
+ return this._vertices[index];
61
+ };
62
+ /**
63
+ * Sets the point at the specified index in this face.
64
+ *
65
+ * The index must be 0, 1, 2, or 3, representing the four vertices of the face.
66
+ * If the index is out of range, it sets the first or last vertex accordingly.
67
+ *
68
+ * @param index - The index (0-3) of the vertex to set
69
+ * @param point - The new point in WCS coordinates
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * face.setVertexAt(0, new AcGePoint3d(0, 0, 0));
74
+ * face.setVertexAt(1, new AcGePoint3d(10, 0, 0));
75
+ * face.setVertexAt(2, new AcGePoint3d(10, 5, 0));
76
+ * face.setVertexAt(3, new AcGePoint3d(0, 5, 0));
77
+ * ```
78
+ */
79
+ AcDbFace.prototype.setVertexAt = function (index, point) {
80
+ if (index < 0)
81
+ this._vertices[0].copy(point);
82
+ if (index >= 3) {
83
+ if (this._vertices.length === 3) {
84
+ this._vertices.push(new AcGePoint3d());
85
+ }
86
+ return this._vertices[3].copy(point);
87
+ }
88
+ this._vertices[index].copy(point);
89
+ };
90
+ /**
91
+ * Sets the invisibilities of the edges of the face.
92
+ *
93
+ * The invisibilities are represented as a bitmask, where each bit corresponds to an edge.
94
+ * If the bit is set, the edge is invisible, otherwise it is visible.
95
+ *
96
+ * @param invisibilities - The bitmask representing the invisibilities of the edges
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * face.setEdgeInvisibilities(0b1111); // All edges are visible
101
+ * face.setEdgeInvisibilities(0b0000); // All edges are invisible
102
+ * face.setEdgeInvisibilities(0b1010); // Edge 0 and 2 are visible, edge 1 and 3 are invisible
103
+ * ```
104
+ */
105
+ AcDbFace.prototype.setEdgeInvisibilities = function (invisibilities) {
106
+ this._edgeInvisibilities = invisibilities;
107
+ };
108
+ /**
109
+ * Checks if the edge at the specified index is visible.
110
+ *
111
+ * The index must be 0, 1, 2, or 3, representing the four edges of the face.
112
+ * If the index is out of range, it throws an error.
113
+ *
114
+ * @param index - The index (0-3) of the edge to check
115
+ * @returns True if the edge is visible, false otherwise
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const isVisible = face.isEdgeVisibleAt(0);
120
+ * console.log(`Edge 0 is visible: ${isVisible}`);
121
+ * ```
122
+ */
123
+ AcDbFace.prototype.isEdgeVisibleAt = function (index) {
124
+ if (index < 0 || index > 3) {
125
+ throw new Error('Index out of range');
126
+ }
127
+ return (this._edgeInvisibilities & (1 << index)) === 0;
128
+ };
129
+ /**
130
+ * Makes the edge at the specified index invisible.
131
+ *
132
+ * The index must be 0, 1, 2, or 3, representing the four edges of the face.
133
+ * If the index is out of range, it throws an error.
134
+ *
135
+ * @param index - The index (0-3) of the edge to make invisible
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * face.makeEdgeInvisibleAt(0);
140
+ * face.makeEdgeInvisibleAt(1);
141
+ * face.makeEdgeInvisibleAt(2);
142
+ * face.makeEdgeInvisibleAt(3);
143
+ * ```
144
+ */
145
+ AcDbFace.prototype.makeEdgeInvisibleAt = function (index) {
146
+ if (index < 0 || index > 3) {
147
+ throw new Error('Index out of range');
148
+ }
149
+ this._edgeInvisibilities = this._edgeInvisibilities | (1 << index);
150
+ };
151
+ Object.defineProperty(AcDbFace.prototype, "geometricExtents", {
152
+ /**
153
+ * Gets the geometric extents (bounding box) of this face.
154
+ *
155
+ * @returns The bounding box that encompasses the entire face
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const extents = face.geometricExtents;
160
+ * console.log(`Trace bounds: ${extents.minPoint} to ${extents.maxPoint}`);
161
+ * ```
162
+ */
163
+ get: function () {
164
+ return new AcGeBox3d().setFromPoints(this._vertices);
165
+ },
166
+ enumerable: false,
167
+ configurable: true
168
+ });
169
+ /**
170
+ * Gets the grip points for this face.
171
+ *
172
+ * Grip points are control points that can be used to modify the face.
173
+ * For a face, the grip points are all four vertices.
174
+ *
175
+ * @returns Array of grip points (all four vertices)
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const gripPoints = face.subGetGripPoints();
180
+ * // gripPoints contains all four vertices of the face
181
+ * ```
182
+ */
183
+ AcDbFace.prototype.subGetGripPoints = function () {
184
+ var gripPoints = new Array();
185
+ for (var index = 0; index < this._vertices.length; ++index) {
186
+ gripPoints.push(this.getVertexAt(index));
187
+ }
188
+ return gripPoints;
189
+ };
190
+ /**
191
+ * Draws this face using the specified renderer.
192
+ *
193
+ * This method renders the face as a filled area using the face's
194
+ * current style properties.
195
+ *
196
+ * @param renderer - The renderer to use for drawing
197
+ * @returns The rendered face entity, or undefined if drawing failed
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const renderedFace = face.draw(renderer);
202
+ * ```
203
+ */
204
+ AcDbFace.prototype.draw = function (renderer) {
205
+ var num = this._vertices.length;
206
+ var buffer = new Float32Array(num * 3);
207
+ var indices = new Uint16Array(num * 2);
208
+ for (var i = 0; i < num; i++) {
209
+ buffer[i * 3] = this._vertices[i].x;
210
+ buffer[i * 3 + 1] = this._vertices[i].y;
211
+ buffer[i * 3 + 2] = this._vertices[i].z;
212
+ if (this.isEdgeVisibleAt(i)) {
213
+ indices[i * 2] = i;
214
+ indices[i * 2 + 1] = (i + 1) % 4;
215
+ }
216
+ }
217
+ return renderer.lineSegments(buffer, 3, indices, this.lineStyle);
218
+ };
219
+ /** The entity type name */
220
+ AcDbFace.typeName = 'Face';
221
+ return AcDbFace;
222
+ }(AcDbEntity));
223
+ export { AcDbFace };
224
+ //# sourceMappingURL=AcDbFace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcDbFace.js","sourceRoot":"","sources":["../../src/entity/AcDbFace.ts"],"names":[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AQ"}
@@ -1,10 +1,11 @@
1
+ export * from './AcDbArc';
1
2
  export * from './AcDbBlockReference';
3
+ export * from './AcDbCircle';
4
+ export * from './AcDbCurve';
2
5
  export * from './AcDbEllipse';
3
6
  export * from './AcDbEntity';
4
- export * from './AcDbArc';
5
- export * from './AcDbCircle';
7
+ export * from './AcDbFace';
6
8
  export * from './AcDbHatch';
7
- export * from './AcDbCurve';
8
9
  export * from './AcDbLeader';
9
10
  export * from './AcDbLine';
10
11
  export * from './AcDbMText';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -1,10 +1,11 @@
1
+ export * from './AcDbArc';
1
2
  export * from './AcDbBlockReference';
3
+ export * from './AcDbCircle';
4
+ export * from './AcDbCurve';
2
5
  export * from './AcDbEllipse';
3
6
  export * from './AcDbEntity';
4
- export * from './AcDbArc';
5
- export * from './AcDbCircle';
7
+ export * from './AcDbFace';
6
8
  export * from './AcDbHatch';
7
- export * from './AcDbCurve';
8
9
  export * from './AcDbLeader';
9
10
  export * from './AcDbLine';
10
11
  export * from './AcDbMText';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/data-model",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -36,9 +36,9 @@
36
36
  "uid": "^2.0.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@mlightcad/common": "1.2.1",
39
+ "@mlightcad/geometry-engine": "3.0.2",
40
40
  "@mlightcad/graphic-interface": "3.0.3",
41
- "@mlightcad/geometry-engine": "3.0.2"
41
+ "@mlightcad/common": "1.2.1"
42
42
  },
43
43
  "scripts": {
44
44
  "analyze": "pnpm run analyze:lib && pnpm run analyze:worker",