@mlightcad/libredwg-web 0.7.7 → 0.7.8
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.
- package/dist/libredwg-web.js +194 -5
- package/dist/libredwg-web.umd.cjs +194 -5
- package/lib/converter/converter.d.ts +3 -0
- package/lib/converter/converter.js +76 -1
- package/lib/converter/entityConverter.d.ts +1 -0
- package/lib/converter/entityConverter.js +53 -5
- package/lib/converter/mleaderColorCodec.d.ts +9 -0
- package/lib/converter/mleaderColorCodec.js +52 -0
- package/lib/converter/stringConverter.d.ts +3 -0
- package/lib/converter/stringConverter.js +7 -0
- package/lib/converter/utils.d.ts +21 -0
- package/lib/converter/utils.js +27 -0
- package/lib/database/database.d.ts +4 -1
- package/lib/database/entities/index.d.ts +1 -0
- package/lib/database/entities/index.js +1 -0
- package/lib/database/entities/solid3d.d.ts +32 -0
- package/lib/database/entities/solid3d.js +2 -0
- package/lib/database/entities/unknown.d.ts +7 -0
- package/lib/database/entities/unknown.js +2 -0
- package/lib/database/objects/index.d.ts +3 -0
- package/lib/database/objects/index.js +3 -0
- package/lib/database/objects/layerFilter.d.ts +12 -0
- package/lib/database/objects/layerFilter.js +2 -0
- package/lib/database/objects/layerIndex.d.ts +18 -0
- package/lib/database/objects/layerIndex.js +2 -0
- package/lib/database/objects/unknown.d.ts +7 -0
- package/lib/database/objects/unknown.js +2 -0
- package/lib/database/objects/xrecord.d.ts +30 -0
- package/lib/database/objects/xrecord.js +2 -0
- package/lib/debug.d.ts +13 -0
- package/lib/debug.js +48 -0
- package/lib/libredwg-core.d.ts +740 -0
- package/lib/libredwg-core.js +1121 -0
- package/lib/libredwg-web.d.ts +3 -0
- package/lib/libredwg-web.js +2318 -0
- package/lib/libredwg.d.ts +30 -1
- package/lib/libredwg.js +44 -0
- package/lib/memory64/index.d.ts +4 -0
- package/lib/memory64/index.js +4 -0
- package/lib/memory64/libredwg.d.ts +13 -0
- package/lib/memory64/libredwg.js +23 -0
- package/lib/types/common.d.ts +2 -0
- package/lib/utils/common.d.ts +4 -0
- package/lib/utils/common.js +12 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +2 -0
- package/package.json +2 -2
- package/wasm/libredwg-web.d.ts +548 -544
- package/wasm/libredwg-web.wasm +0 -0
package/dist/libredwg-web.js
CHANGED
|
@@ -1223,6 +1223,23 @@ const uint8ArrayToHexString = (bytes) => {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
return hexChars.join("");
|
|
1225
1225
|
};
|
|
1226
|
+
const decodeOle2FrameCornersFromData = (data) => {
|
|
1227
|
+
if (!data || data.length < 98) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1231
|
+
const readPoint = (offset) => ({
|
|
1232
|
+
x: view.getFloat64(offset, true),
|
|
1233
|
+
y: view.getFloat64(offset + 8, true),
|
|
1234
|
+
z: view.getFloat64(offset + 16, true)
|
|
1235
|
+
});
|
|
1236
|
+
const upperLeft = readPoint(2);
|
|
1237
|
+
const lowerRight = readPoint(2 + 48);
|
|
1238
|
+
if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
|
|
1239
|
+
return null;
|
|
1240
|
+
}
|
|
1241
|
+
return { upperLeft, lowerRight };
|
|
1242
|
+
};
|
|
1226
1243
|
class LibreEntityConverter {
|
|
1227
1244
|
constructor(instance) {
|
|
1228
1245
|
__publicField(this, "libredwg");
|
|
@@ -1267,6 +1284,8 @@ class LibreEntityConverter {
|
|
|
1267
1284
|
const fixedtype = libredwg.dwg_object_get_fixedtype(object_ptr);
|
|
1268
1285
|
if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
|
|
1269
1286
|
return this.convert3dFace(entity_tio, commonAttrs);
|
|
1287
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
|
|
1288
|
+
return this.convert3dSolid(entity_tio, commonAttrs);
|
|
1270
1289
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
1271
1290
|
return this.convertArc(entity_tio, commonAttrs);
|
|
1272
1291
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
|
|
@@ -1362,6 +1381,43 @@ class LibreEntityConverter {
|
|
|
1362
1381
|
flag
|
|
1363
1382
|
};
|
|
1364
1383
|
}
|
|
1384
|
+
convert3dSolid(entity, commonAttrs) {
|
|
1385
|
+
const libredwg = this.libredwg;
|
|
1386
|
+
const version = libredwg.dwg_dynapi_entity_data(entity, "version");
|
|
1387
|
+
const satCache = libredwg.dwg_dynapi_entity_data(entity, "acis_empty");
|
|
1388
|
+
const data = libredwg.dwg_dynapi_entity_data(entity, "acis_data");
|
|
1389
|
+
const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(
|
|
1390
|
+
entity,
|
|
1391
|
+
"has_revision_guid"
|
|
1392
|
+
);
|
|
1393
|
+
const historyRef = libredwg.dwg_dynapi_entity_data(entity, "history_id");
|
|
1394
|
+
const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
|
|
1395
|
+
const result = {
|
|
1396
|
+
type: "3DSOLID",
|
|
1397
|
+
subclassMarker: "AcDb3dSolid",
|
|
1398
|
+
...commonAttrs
|
|
1399
|
+
};
|
|
1400
|
+
if (version) {
|
|
1401
|
+
result.version = version;
|
|
1402
|
+
}
|
|
1403
|
+
result.satCache = satCache;
|
|
1404
|
+
if (data) {
|
|
1405
|
+
result.data = data;
|
|
1406
|
+
}
|
|
1407
|
+
if (hasRevisionGuid) {
|
|
1408
|
+
const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, "revision_guid");
|
|
1409
|
+
if (guidOffset >= 0) {
|
|
1410
|
+
const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
|
|
1411
|
+
if (guid) {
|
|
1412
|
+
result.guid = guid;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
if (historyObjectSoftId) {
|
|
1417
|
+
result.historyObjectSoftId = historyObjectSoftId;
|
|
1418
|
+
}
|
|
1419
|
+
return result;
|
|
1420
|
+
}
|
|
1365
1421
|
convertArc(entity, commonAttrs) {
|
|
1366
1422
|
const libredwg = this.libredwg;
|
|
1367
1423
|
const center = libredwg.dwg_dynapi_entity_data(entity, "center");
|
|
@@ -2509,12 +2565,20 @@ class LibreEntityConverter {
|
|
|
2509
2565
|
const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
|
|
2510
2566
|
const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
|
|
2511
2567
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
|
|
2512
|
-
|
|
2513
|
-
|
|
2568
|
+
let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
|
|
2569
|
+
let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
|
|
2514
2570
|
const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
|
|
2515
2571
|
const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
|
|
2516
2572
|
const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
|
|
2517
|
-
const
|
|
2573
|
+
const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
|
|
2574
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
|
|
2575
|
+
if (dataBytes) {
|
|
2576
|
+
const corners = decodeOle2FrameCornersFromData(dataBytes);
|
|
2577
|
+
if (corners) {
|
|
2578
|
+
leftUpPoint = corners.upperLeft;
|
|
2579
|
+
rightDownPoint = corners.lowerRight;
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2518
2582
|
return {
|
|
2519
2583
|
type: "OLE2FRAME",
|
|
2520
2584
|
...commonAttrs,
|
|
@@ -2534,7 +2598,8 @@ class LibreEntityConverter {
|
|
|
2534
2598
|
const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
|
|
2535
2599
|
const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
|
|
2536
2600
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
|
|
2537
|
-
const
|
|
2601
|
+
const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
|
|
2602
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
|
|
2538
2603
|
return {
|
|
2539
2604
|
type: "OLEFRAME",
|
|
2540
2605
|
...commonAttrs,
|
|
@@ -3308,9 +3373,12 @@ class LibreDwgConverter {
|
|
|
3308
3373
|
objects: {
|
|
3309
3374
|
DICTIONARY: [],
|
|
3310
3375
|
IMAGEDEF: [],
|
|
3376
|
+
LAYER_FILTER: [],
|
|
3377
|
+
LAYER_INDEX: [],
|
|
3311
3378
|
LAYOUT: [],
|
|
3312
3379
|
MLEADERSTYLE: [],
|
|
3313
|
-
SPATIAL_FILTER: []
|
|
3380
|
+
SPATIAL_FILTER: [],
|
|
3381
|
+
XRECORD: []
|
|
3314
3382
|
},
|
|
3315
3383
|
header: {},
|
|
3316
3384
|
entities: [],
|
|
@@ -3387,6 +3455,12 @@ class LibreDwgConverter {
|
|
|
3387
3455
|
case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
|
|
3388
3456
|
db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
|
|
3389
3457
|
break;
|
|
3458
|
+
case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
|
|
3459
|
+
db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
|
|
3460
|
+
break;
|
|
3461
|
+
case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
|
|
3462
|
+
db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
|
|
3463
|
+
break;
|
|
3390
3464
|
case Dwg_Object_Type.DWG_TYPE_LAYOUT:
|
|
3391
3465
|
db.objects.LAYOUT.push(this.convertLayout(tio, obj));
|
|
3392
3466
|
break;
|
|
@@ -3398,6 +3472,9 @@ class LibreDwgConverter {
|
|
|
3398
3472
|
this.convertSpatialFilter(tio, obj)
|
|
3399
3473
|
);
|
|
3400
3474
|
break;
|
|
3475
|
+
case Dwg_Object_Type.DWG_TYPE_XRECORD:
|
|
3476
|
+
db.objects.XRECORD.push(this.convertXRecord(tio, obj));
|
|
3477
|
+
break;
|
|
3401
3478
|
}
|
|
3402
3479
|
}
|
|
3403
3480
|
}
|
|
@@ -3962,6 +4039,59 @@ class LibreDwgConverter {
|
|
|
3962
4039
|
resolutionUnits
|
|
3963
4040
|
};
|
|
3964
4041
|
}
|
|
4042
|
+
convertLayerFilter(item, obj) {
|
|
4043
|
+
const libredwg = this.libredwg;
|
|
4044
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4045
|
+
const numNames = libredwg.dwg_dynapi_entity_data(item, "num_names") ?? 0;
|
|
4046
|
+
const namesPtr = libredwg.dwg_dynapi_entity_data(item, "names");
|
|
4047
|
+
const layerNames = namesPtr && numNames > 0 ? libredwg.dwg_ptr_to_wchar_string_array(namesPtr, numNames).filter((name) => name != null && name !== "") : [];
|
|
4048
|
+
return {
|
|
4049
|
+
...commonAttrs,
|
|
4050
|
+
...layerNames.length ? { layerNames } : {}
|
|
4051
|
+
};
|
|
4052
|
+
}
|
|
4053
|
+
convertLayerIndex(item, obj) {
|
|
4054
|
+
const libredwg = this.libredwg;
|
|
4055
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4056
|
+
const timeStamp = libredwg.dwg_dynapi_entity_data(item, "last_updated");
|
|
4057
|
+
const numEntries = libredwg.dwg_dynapi_entity_data(item, "num_entries") ?? 0;
|
|
4058
|
+
const entriesPtr = libredwg.dwg_dynapi_entity_data(item, "entries");
|
|
4059
|
+
const entrySize = libredwg.dwg_dynapi_subclass_size("LAYER_entry");
|
|
4060
|
+
const layerNames = [];
|
|
4061
|
+
const idBufferIds = [];
|
|
4062
|
+
const idBufferEntryCounts = [];
|
|
4063
|
+
if (entriesPtr && entrySize > 0) {
|
|
4064
|
+
for (let i = 0; i < numEntries; i++) {
|
|
4065
|
+
const entryPtr = entriesPtr + i * entrySize;
|
|
4066
|
+
const name = libredwg.dwg_dynapi_subclass_data(
|
|
4067
|
+
entryPtr,
|
|
4068
|
+
"LAYER_entry",
|
|
4069
|
+
"name"
|
|
4070
|
+
);
|
|
4071
|
+
layerNames.push(name ?? "");
|
|
4072
|
+
const handleRef = libredwg.dwg_dynapi_subclass_data(
|
|
4073
|
+
entryPtr,
|
|
4074
|
+
"LAYER_entry",
|
|
4075
|
+
"handle"
|
|
4076
|
+
);
|
|
4077
|
+
idBufferIds.push(handleRef ? libredwg.dwg_ref_get_id(handleRef) ?? "" : "");
|
|
4078
|
+
idBufferEntryCounts.push(
|
|
4079
|
+
libredwg.dwg_dynapi_subclass_data(
|
|
4080
|
+
entryPtr,
|
|
4081
|
+
"LAYER_entry",
|
|
4082
|
+
"numlayers"
|
|
4083
|
+
) ?? 0
|
|
4084
|
+
);
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
return {
|
|
4088
|
+
...commonAttrs,
|
|
4089
|
+
...timeStamp != null ? { timeStamp } : {},
|
|
4090
|
+
...layerNames.length ? { layerNames } : {},
|
|
4091
|
+
...idBufferIds.length ? { idBufferIds } : {},
|
|
4092
|
+
...idBufferEntryCounts.length ? { idBufferEntryCounts } : {}
|
|
4093
|
+
};
|
|
4094
|
+
}
|
|
3965
4095
|
convertLayout(item, obj) {
|
|
3966
4096
|
const libredwg = this.libredwg;
|
|
3967
4097
|
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
@@ -4101,6 +4231,21 @@ class LibreDwgConverter {
|
|
|
4101
4231
|
invertBlockMatrix
|
|
4102
4232
|
};
|
|
4103
4233
|
}
|
|
4234
|
+
convertXRecord(item, obj) {
|
|
4235
|
+
const libredwg = this.libredwg;
|
|
4236
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4237
|
+
const cloning = libredwg.dwg_dynapi_entity_data(item, "cloning");
|
|
4238
|
+
const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
|
|
4239
|
+
const objectObj = libredwg.dwg_object_get_tio(obj);
|
|
4240
|
+
const xdic = objectObj ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj) : null;
|
|
4241
|
+
const extensionDictionary = xdic && xdic.absolute_ref ? idToString(xdic.absolute_ref) : void 0;
|
|
4242
|
+
return {
|
|
4243
|
+
...commonAttrs,
|
|
4244
|
+
...cloning != null ? { cloning } : {},
|
|
4245
|
+
...extensionDictionary ? { extensionDictionary } : {},
|
|
4246
|
+
data
|
|
4247
|
+
};
|
|
4248
|
+
}
|
|
4104
4249
|
getCommonObjectAttrs(obj) {
|
|
4105
4250
|
const libredwg = this.libredwg;
|
|
4106
4251
|
const object_tio = libredwg.dwg_object_get_tio(obj);
|
|
@@ -6476,6 +6621,24 @@ const _LibreDwg = class _LibreDwg {
|
|
|
6476
6621
|
dwg_object_entity_get_xdata(ptr) {
|
|
6477
6622
|
return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
|
|
6478
6623
|
}
|
|
6624
|
+
/**
|
|
6625
|
+
* Returns the extension dictionary handle of a Dwg_Object_Object instance.
|
|
6626
|
+
* @group Dwg_Object_Object Methods
|
|
6627
|
+
* @param ptr Pointer to one Dwg_Object_Object instance.
|
|
6628
|
+
* @returns Object ref for the extension dictionary, or null when absent.
|
|
6629
|
+
*/
|
|
6630
|
+
dwg_object_object_get_xdicobjhandle_object(ptr) {
|
|
6631
|
+
return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
|
|
6632
|
+
}
|
|
6633
|
+
/**
|
|
6634
|
+
* Returns XRECORD payload as DXF group-code / value pairs.
|
|
6635
|
+
* @group Dwg_Object_XRECORD Methods
|
|
6636
|
+
* @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
|
|
6637
|
+
* @returns Array of `{ code, value }` groups.
|
|
6638
|
+
*/
|
|
6639
|
+
dwg_object_xrecord_get_xdata(ptr) {
|
|
6640
|
+
return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
|
|
6641
|
+
}
|
|
6479
6642
|
/**
|
|
6480
6643
|
* Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
|
|
6481
6644
|
* @group Dwg_Object_Entity Methods
|
|
@@ -6574,6 +6737,32 @@ const _LibreDwg = class _LibreDwg {
|
|
|
6574
6737
|
const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
|
|
6575
6738
|
return (result == null ? void 0 : result.data) ?? null;
|
|
6576
6739
|
}
|
|
6740
|
+
/**
|
|
6741
|
+
* Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
|
|
6742
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
6743
|
+
* @group Dwg_Entity_OLE2FRAME Methods
|
|
6744
|
+
*/
|
|
6745
|
+
dwg_entity_ole2frame_get_data(ptr) {
|
|
6746
|
+
const wasm = this.wasmInstance;
|
|
6747
|
+
if (typeof wasm.dwg_entity_ole2frame_get_data !== "function") {
|
|
6748
|
+
return null;
|
|
6749
|
+
}
|
|
6750
|
+
const result = wasm.dwg_entity_ole2frame_get_data(ptr);
|
|
6751
|
+
return (result == null ? void 0 : result.data) ?? null;
|
|
6752
|
+
}
|
|
6753
|
+
/**
|
|
6754
|
+
* Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
|
|
6755
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
6756
|
+
* @group Dwg_Entity_OLEFRAME Methods
|
|
6757
|
+
*/
|
|
6758
|
+
dwg_entity_oleframe_get_data(ptr) {
|
|
6759
|
+
const wasm = this.wasmInstance;
|
|
6760
|
+
if (typeof wasm.dwg_entity_oleframe_get_data !== "function") {
|
|
6761
|
+
return null;
|
|
6762
|
+
}
|
|
6763
|
+
const result = wasm.dwg_entity_oleframe_get_data(ptr);
|
|
6764
|
+
return (result == null ? void 0 : result.data) ?? null;
|
|
6765
|
+
}
|
|
6577
6766
|
/**
|
|
6578
6767
|
* Returns the first entity owned by the block header or null
|
|
6579
6768
|
* @group Dwg_Entity_BLOCK_HEADER Methods
|
|
@@ -1225,6 +1225,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1225
1225
|
}
|
|
1226
1226
|
return hexChars.join("");
|
|
1227
1227
|
};
|
|
1228
|
+
const decodeOle2FrameCornersFromData = (data) => {
|
|
1229
|
+
if (!data || data.length < 98) {
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1232
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1233
|
+
const readPoint = (offset) => ({
|
|
1234
|
+
x: view.getFloat64(offset, true),
|
|
1235
|
+
y: view.getFloat64(offset + 8, true),
|
|
1236
|
+
z: view.getFloat64(offset + 16, true)
|
|
1237
|
+
});
|
|
1238
|
+
const upperLeft = readPoint(2);
|
|
1239
|
+
const lowerRight = readPoint(2 + 48);
|
|
1240
|
+
if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
return { upperLeft, lowerRight };
|
|
1244
|
+
};
|
|
1228
1245
|
class LibreEntityConverter {
|
|
1229
1246
|
constructor(instance) {
|
|
1230
1247
|
__publicField(this, "libredwg");
|
|
@@ -1269,6 +1286,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1269
1286
|
const fixedtype = libredwg.dwg_object_get_fixedtype(object_ptr);
|
|
1270
1287
|
if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
|
|
1271
1288
|
return this.convert3dFace(entity_tio, commonAttrs);
|
|
1289
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
|
|
1290
|
+
return this.convert3dSolid(entity_tio, commonAttrs);
|
|
1272
1291
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
1273
1292
|
return this.convertArc(entity_tio, commonAttrs);
|
|
1274
1293
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
|
|
@@ -1364,6 +1383,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1364
1383
|
flag
|
|
1365
1384
|
};
|
|
1366
1385
|
}
|
|
1386
|
+
convert3dSolid(entity, commonAttrs) {
|
|
1387
|
+
const libredwg = this.libredwg;
|
|
1388
|
+
const version = libredwg.dwg_dynapi_entity_data(entity, "version");
|
|
1389
|
+
const satCache = libredwg.dwg_dynapi_entity_data(entity, "acis_empty");
|
|
1390
|
+
const data = libredwg.dwg_dynapi_entity_data(entity, "acis_data");
|
|
1391
|
+
const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(
|
|
1392
|
+
entity,
|
|
1393
|
+
"has_revision_guid"
|
|
1394
|
+
);
|
|
1395
|
+
const historyRef = libredwg.dwg_dynapi_entity_data(entity, "history_id");
|
|
1396
|
+
const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
|
|
1397
|
+
const result = {
|
|
1398
|
+
type: "3DSOLID",
|
|
1399
|
+
subclassMarker: "AcDb3dSolid",
|
|
1400
|
+
...commonAttrs
|
|
1401
|
+
};
|
|
1402
|
+
if (version) {
|
|
1403
|
+
result.version = version;
|
|
1404
|
+
}
|
|
1405
|
+
result.satCache = satCache;
|
|
1406
|
+
if (data) {
|
|
1407
|
+
result.data = data;
|
|
1408
|
+
}
|
|
1409
|
+
if (hasRevisionGuid) {
|
|
1410
|
+
const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, "revision_guid");
|
|
1411
|
+
if (guidOffset >= 0) {
|
|
1412
|
+
const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
|
|
1413
|
+
if (guid) {
|
|
1414
|
+
result.guid = guid;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
if (historyObjectSoftId) {
|
|
1419
|
+
result.historyObjectSoftId = historyObjectSoftId;
|
|
1420
|
+
}
|
|
1421
|
+
return result;
|
|
1422
|
+
}
|
|
1367
1423
|
convertArc(entity, commonAttrs) {
|
|
1368
1424
|
const libredwg = this.libredwg;
|
|
1369
1425
|
const center = libredwg.dwg_dynapi_entity_data(entity, "center");
|
|
@@ -2511,12 +2567,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2511
2567
|
const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
|
|
2512
2568
|
const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
|
|
2513
2569
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
|
|
2514
|
-
|
|
2515
|
-
|
|
2570
|
+
let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
|
|
2571
|
+
let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
|
|
2516
2572
|
const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
|
|
2517
2573
|
const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
|
|
2518
2574
|
const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
|
|
2519
|
-
const
|
|
2575
|
+
const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
|
|
2576
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
|
|
2577
|
+
if (dataBytes) {
|
|
2578
|
+
const corners = decodeOle2FrameCornersFromData(dataBytes);
|
|
2579
|
+
if (corners) {
|
|
2580
|
+
leftUpPoint = corners.upperLeft;
|
|
2581
|
+
rightDownPoint = corners.lowerRight;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2520
2584
|
return {
|
|
2521
2585
|
type: "OLE2FRAME",
|
|
2522
2586
|
...commonAttrs,
|
|
@@ -2536,7 +2600,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2536
2600
|
const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
|
|
2537
2601
|
const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
|
|
2538
2602
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
|
|
2539
|
-
const
|
|
2603
|
+
const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
|
|
2604
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
|
|
2540
2605
|
return {
|
|
2541
2606
|
type: "OLEFRAME",
|
|
2542
2607
|
...commonAttrs,
|
|
@@ -3310,9 +3375,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3310
3375
|
objects: {
|
|
3311
3376
|
DICTIONARY: [],
|
|
3312
3377
|
IMAGEDEF: [],
|
|
3378
|
+
LAYER_FILTER: [],
|
|
3379
|
+
LAYER_INDEX: [],
|
|
3313
3380
|
LAYOUT: [],
|
|
3314
3381
|
MLEADERSTYLE: [],
|
|
3315
|
-
SPATIAL_FILTER: []
|
|
3382
|
+
SPATIAL_FILTER: [],
|
|
3383
|
+
XRECORD: []
|
|
3316
3384
|
},
|
|
3317
3385
|
header: {},
|
|
3318
3386
|
entities: [],
|
|
@@ -3389,6 +3457,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3389
3457
|
case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
|
|
3390
3458
|
db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
|
|
3391
3459
|
break;
|
|
3460
|
+
case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
|
|
3461
|
+
db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
|
|
3462
|
+
break;
|
|
3463
|
+
case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
|
|
3464
|
+
db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
|
|
3465
|
+
break;
|
|
3392
3466
|
case Dwg_Object_Type.DWG_TYPE_LAYOUT:
|
|
3393
3467
|
db.objects.LAYOUT.push(this.convertLayout(tio, obj));
|
|
3394
3468
|
break;
|
|
@@ -3400,6 +3474,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3400
3474
|
this.convertSpatialFilter(tio, obj)
|
|
3401
3475
|
);
|
|
3402
3476
|
break;
|
|
3477
|
+
case Dwg_Object_Type.DWG_TYPE_XRECORD:
|
|
3478
|
+
db.objects.XRECORD.push(this.convertXRecord(tio, obj));
|
|
3479
|
+
break;
|
|
3403
3480
|
}
|
|
3404
3481
|
}
|
|
3405
3482
|
}
|
|
@@ -3964,6 +4041,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3964
4041
|
resolutionUnits
|
|
3965
4042
|
};
|
|
3966
4043
|
}
|
|
4044
|
+
convertLayerFilter(item, obj) {
|
|
4045
|
+
const libredwg = this.libredwg;
|
|
4046
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4047
|
+
const numNames = libredwg.dwg_dynapi_entity_data(item, "num_names") ?? 0;
|
|
4048
|
+
const namesPtr = libredwg.dwg_dynapi_entity_data(item, "names");
|
|
4049
|
+
const layerNames = namesPtr && numNames > 0 ? libredwg.dwg_ptr_to_wchar_string_array(namesPtr, numNames).filter((name) => name != null && name !== "") : [];
|
|
4050
|
+
return {
|
|
4051
|
+
...commonAttrs,
|
|
4052
|
+
...layerNames.length ? { layerNames } : {}
|
|
4053
|
+
};
|
|
4054
|
+
}
|
|
4055
|
+
convertLayerIndex(item, obj) {
|
|
4056
|
+
const libredwg = this.libredwg;
|
|
4057
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4058
|
+
const timeStamp = libredwg.dwg_dynapi_entity_data(item, "last_updated");
|
|
4059
|
+
const numEntries = libredwg.dwg_dynapi_entity_data(item, "num_entries") ?? 0;
|
|
4060
|
+
const entriesPtr = libredwg.dwg_dynapi_entity_data(item, "entries");
|
|
4061
|
+
const entrySize = libredwg.dwg_dynapi_subclass_size("LAYER_entry");
|
|
4062
|
+
const layerNames = [];
|
|
4063
|
+
const idBufferIds = [];
|
|
4064
|
+
const idBufferEntryCounts = [];
|
|
4065
|
+
if (entriesPtr && entrySize > 0) {
|
|
4066
|
+
for (let i = 0; i < numEntries; i++) {
|
|
4067
|
+
const entryPtr = entriesPtr + i * entrySize;
|
|
4068
|
+
const name = libredwg.dwg_dynapi_subclass_data(
|
|
4069
|
+
entryPtr,
|
|
4070
|
+
"LAYER_entry",
|
|
4071
|
+
"name"
|
|
4072
|
+
);
|
|
4073
|
+
layerNames.push(name ?? "");
|
|
4074
|
+
const handleRef = libredwg.dwg_dynapi_subclass_data(
|
|
4075
|
+
entryPtr,
|
|
4076
|
+
"LAYER_entry",
|
|
4077
|
+
"handle"
|
|
4078
|
+
);
|
|
4079
|
+
idBufferIds.push(handleRef ? libredwg.dwg_ref_get_id(handleRef) ?? "" : "");
|
|
4080
|
+
idBufferEntryCounts.push(
|
|
4081
|
+
libredwg.dwg_dynapi_subclass_data(
|
|
4082
|
+
entryPtr,
|
|
4083
|
+
"LAYER_entry",
|
|
4084
|
+
"numlayers"
|
|
4085
|
+
) ?? 0
|
|
4086
|
+
);
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
return {
|
|
4090
|
+
...commonAttrs,
|
|
4091
|
+
...timeStamp != null ? { timeStamp } : {},
|
|
4092
|
+
...layerNames.length ? { layerNames } : {},
|
|
4093
|
+
...idBufferIds.length ? { idBufferIds } : {},
|
|
4094
|
+
...idBufferEntryCounts.length ? { idBufferEntryCounts } : {}
|
|
4095
|
+
};
|
|
4096
|
+
}
|
|
3967
4097
|
convertLayout(item, obj) {
|
|
3968
4098
|
const libredwg = this.libredwg;
|
|
3969
4099
|
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
@@ -4103,6 +4233,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4103
4233
|
invertBlockMatrix
|
|
4104
4234
|
};
|
|
4105
4235
|
}
|
|
4236
|
+
convertXRecord(item, obj) {
|
|
4237
|
+
const libredwg = this.libredwg;
|
|
4238
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
4239
|
+
const cloning = libredwg.dwg_dynapi_entity_data(item, "cloning");
|
|
4240
|
+
const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
|
|
4241
|
+
const objectObj = libredwg.dwg_object_get_tio(obj);
|
|
4242
|
+
const xdic = objectObj ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj) : null;
|
|
4243
|
+
const extensionDictionary = xdic && xdic.absolute_ref ? idToString(xdic.absolute_ref) : void 0;
|
|
4244
|
+
return {
|
|
4245
|
+
...commonAttrs,
|
|
4246
|
+
...cloning != null ? { cloning } : {},
|
|
4247
|
+
...extensionDictionary ? { extensionDictionary } : {},
|
|
4248
|
+
data
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4106
4251
|
getCommonObjectAttrs(obj) {
|
|
4107
4252
|
const libredwg = this.libredwg;
|
|
4108
4253
|
const object_tio = libredwg.dwg_object_get_tio(obj);
|
|
@@ -6478,6 +6623,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6478
6623
|
dwg_object_entity_get_xdata(ptr) {
|
|
6479
6624
|
return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
|
|
6480
6625
|
}
|
|
6626
|
+
/**
|
|
6627
|
+
* Returns the extension dictionary handle of a Dwg_Object_Object instance.
|
|
6628
|
+
* @group Dwg_Object_Object Methods
|
|
6629
|
+
* @param ptr Pointer to one Dwg_Object_Object instance.
|
|
6630
|
+
* @returns Object ref for the extension dictionary, or null when absent.
|
|
6631
|
+
*/
|
|
6632
|
+
dwg_object_object_get_xdicobjhandle_object(ptr) {
|
|
6633
|
+
return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
|
|
6634
|
+
}
|
|
6635
|
+
/**
|
|
6636
|
+
* Returns XRECORD payload as DXF group-code / value pairs.
|
|
6637
|
+
* @group Dwg_Object_XRECORD Methods
|
|
6638
|
+
* @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
|
|
6639
|
+
* @returns Array of `{ code, value }` groups.
|
|
6640
|
+
*/
|
|
6641
|
+
dwg_object_xrecord_get_xdata(ptr) {
|
|
6642
|
+
return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
|
|
6643
|
+
}
|
|
6481
6644
|
/**
|
|
6482
6645
|
* Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
|
|
6483
6646
|
* @group Dwg_Object_Entity Methods
|
|
@@ -6576,6 +6739,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6576
6739
|
const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
|
|
6577
6740
|
return (result == null ? void 0 : result.data) ?? null;
|
|
6578
6741
|
}
|
|
6742
|
+
/**
|
|
6743
|
+
* Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
|
|
6744
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
6745
|
+
* @group Dwg_Entity_OLE2FRAME Methods
|
|
6746
|
+
*/
|
|
6747
|
+
dwg_entity_ole2frame_get_data(ptr) {
|
|
6748
|
+
const wasm = this.wasmInstance;
|
|
6749
|
+
if (typeof wasm.dwg_entity_ole2frame_get_data !== "function") {
|
|
6750
|
+
return null;
|
|
6751
|
+
}
|
|
6752
|
+
const result = wasm.dwg_entity_ole2frame_get_data(ptr);
|
|
6753
|
+
return (result == null ? void 0 : result.data) ?? null;
|
|
6754
|
+
}
|
|
6755
|
+
/**
|
|
6756
|
+
* Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
|
|
6757
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
6758
|
+
* @group Dwg_Entity_OLEFRAME Methods
|
|
6759
|
+
*/
|
|
6760
|
+
dwg_entity_oleframe_get_data(ptr) {
|
|
6761
|
+
const wasm = this.wasmInstance;
|
|
6762
|
+
if (typeof wasm.dwg_entity_oleframe_get_data !== "function") {
|
|
6763
|
+
return null;
|
|
6764
|
+
}
|
|
6765
|
+
const result = wasm.dwg_entity_oleframe_get_data(ptr);
|
|
6766
|
+
return (result == null ? void 0 : result.data) ?? null;
|
|
6767
|
+
}
|
|
6579
6768
|
/**
|
|
6580
6769
|
* Returns the first entity owned by the block header or null
|
|
6581
6770
|
* @group Dwg_Entity_BLOCK_HEADER Methods
|
|
@@ -27,9 +27,12 @@ export declare class LibreDwgConverter {
|
|
|
27
27
|
private getCommonTableEntryAttrs;
|
|
28
28
|
private convertDictionary;
|
|
29
29
|
private convertImageDef;
|
|
30
|
+
private convertLayerFilter;
|
|
31
|
+
private convertLayerIndex;
|
|
30
32
|
private convertLayout;
|
|
31
33
|
private convertMLeaderStyle;
|
|
32
34
|
private convertSpatialFilter;
|
|
35
|
+
private convertXRecord;
|
|
33
36
|
private getCommonObjectAttrs;
|
|
34
37
|
}
|
|
35
38
|
//# sourceMappingURL=converter.d.ts.map
|