@mlightcad/data-model 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@mlightcad/data-model",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "keywords": [
6
7
  "autocad",
@@ -32,11 +33,14 @@
32
33
  "uid": "^2.0.2"
33
34
  },
34
35
  "devDependencies": {
35
- "@mlightcad/common": "0.0.1",
36
- "@mlightcad/geometry-engine": "0.0.1",
37
- "@mlightcad/graphic-interface": "0.0.1",
38
36
  "@types/lodash-es": "^4.17.12"
39
37
  },
38
+ "peerDependencies": {
39
+ "@mlightcad/common": "1.0.1",
40
+ "@mlightcad/geometry-engine": "1.0.1",
41
+ "@mlightcad/graphic-interface": "1.0.1",
42
+ "lodash-es": "*"
43
+ },
40
44
  "scripts": {
41
45
  "clean": "rimraf dist lib tsconfig.tsbuildinfo",
42
46
  "build": "tsc && vite build",
package/README.md DELETED
@@ -1,116 +0,0 @@
1
- # ReadDWG-Web
2
-
3
- AutoCAD RealDWG is a software development toolkit (SDK) provided by Autodesk that allows developers to read, write, and create DWG and DXF files (AutoCAD’s native drawing file formats) without needing AutoCAD installed.
4
-
5
- The target of this project is to create one web-version of AutoCAD RealDWG by providing the similar API. For now, it supports reading DWG and DXF file only. In the future, it will support write DWG and DXF too.
6
-
7
- You can access its API doc [here](https://mlight-lee.github.io/realdwg-web/).
8
-
9
- ## Converter Registration Mechanism
10
-
11
- To support reading both DXF and DWG files (and potentially other formats in the future), this project provides a flexible mechanism for registering and unregistering file converters. This is managed by the `AcDbDatabaseConverterManager` class.
12
-
13
- ### How It Works
14
-
15
- - Each file type (e.g., DXF, DWG) is associated with a converter class that knows how to parse and import that file format into the drawing database.
16
- - The `AcDbDatabaseConverterManager` maintains a registry of these converters, allowing you to register or unregister converters for specific file types at runtime.
17
- - By default, the DXF converter is registered. You can add your own DWG converter or replace existing ones as needed.
18
-
19
- ### Registering a Converter
20
-
21
- To register a converter for a file type:
22
-
23
- ```ts
24
- import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
25
- import { MyDwgConverter } from './my-dwg-converter';
26
-
27
- // Register a DWG converter
28
- AcDbDatabaseConverterManager.instance.register(AcDbFileType.DWG, new MyDwgConverter());
29
- ```
30
-
31
- ### Unregistering a Converter
32
-
33
- To unregister a converter for a file type:
34
-
35
- ```ts
36
- import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
37
-
38
- // Unregister the DWG converter
39
- AcDbDatabaseConverterManager.instance.unregister(AcDbFileType.DWG);
40
- ```
41
-
42
- ### Getting a Converter
43
-
44
- To get the converter for a specific file type:
45
-
46
- ```ts
47
- const converter = AcDbDatabaseConverterManager.instance.get(AcDbFileType.DXF);
48
- ```
49
-
50
- ### Extensibility
51
-
52
- This mechanism allows you to:
53
- - Add support for new file types by implementing and registering new converters.
54
- - Replace or remove converters at runtime as needed.
55
- - Listen for registration/unregistration events if you need to react to changes in available converters.
56
-
57
- This design ensures the system is open for extension and can easily adapt to new requirements or file formats in the future.
58
-
59
- ## Architecture
60
-
61
- AutoCAD holds an absolute dominant position in the 2D CAD field. A large number of vertical applications and third-party plugins have been developed based on AutoCAD ObjectARX, and there are many software engineers familiar with AutoCAD ObjectARX. Therefore, this project mimics the architecture of AutoCAD ObjectARX and adopts similar API interfaces to AutoCAD ObjectARX.
62
-
63
- ## geometry-engine (AcGe classes in AutoCAD ObjectARX)
64
-
65
- This module provides geometric entities, operations, and transformations. It consists of two kinds of classes.
66
-
67
- - Math: focuses on mathematical operations that underpin geometric calculations. This includes concepts such as vectors, matrices, transformations, and other linear algebra operations that are essential for performing geometric calculations in AutoCAD. To simplify implementation of math classes, most of math classes are 'stolen' from [THREE.js](https://threejs.org/docs/index.html) by modifying their class name.
68
- - Geometry: focuses on more complex geometric entities and their operations. This includes lines, curves, surfaces, and intersections, among others. These classes define how geometric objects behave and how they interact in 2D or 3D space.
69
-
70
- The key classes in this module are as follows.
71
-
72
- - AcGePoint3d, AcGePoint2d: Represent 3D and 2D points.
73
- - AcGeVector3d, AcGeVector2d: Represent 3D and 2D vectors.
74
- - AcGeMatrix3d: AcGeMatrix2d: transformations in 3D space.
75
- - AcGeLine3d, AcGeLine2d: Represent lines in 3D and 2D.
76
- - AcGeCurve3d, AcGeCurve2d: Abstract base class for curves in 3D and 2D.
77
- - ...
78
-
79
- ### data-model (AcDb classes in AutoCAD ObjectARX)
80
-
81
- The same drawing database structure is used in this project so that it is easier for AutoCAD ObjectARX developers to develop their own application based on SDK of this project. Please refer to [AutoCAD Database Overview](https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-4F4766EC-7BFC-456E-BE5B-7676B4658E15) to get more information on AutoCAD drawing database structure.
82
-
83
- This module contains the core classes for interacting with AutoCAD's database and entities (e.g., lines, circles, blocks, etc.).
84
-
85
- - Defining and manipulating AutoCAD entities.
86
- - Handling entity attributes and geometric data.
87
- - Storing and retrieving data from the drawing database.
88
-
89
- The key classes in this module are as follows.
90
-
91
- - AcDbObject: Base class for database-resident objects.
92
- - AcDbEntity: The base class for all objects that can be drawn in AutoCAD (e.g., lines, circles).
93
- - AcDbBlockReference: Represents a reference to a block.
94
- - AcDbPolyline: Represents a polyline entity.
95
- - ...
96
-
97
- Please refer to [AcDb classes](https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-RefGuide-AcDb_Classes) in [AutoCAD ObjectARX Reference Guide](https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-RefGuide-ObjectARX_Reference_Guide) to get more details on those classes.
98
-
99
- ### graphic-interface (AcGi classes in AutoCAD ObjectARX)
100
-
101
- The differnt API interfaces from AutoCAD ObjectARX are used in this module because of the following reasons.
102
-
103
- - It isn't friendly to implement API interfaces defined in AcGi classes in AutoCAD ObjectARX.
104
- - Classes in AcGi module aren't used very frequently by AutoCAD ObjectARX developers.
105
-
106
- This module provides the graphics interface to control how AutoCAD entities are displayed on the screen.
107
-
108
- - Rendering entities to drawble objects.
109
- - Customizing how objects are displayed, including handling colors, layers, and visibility.
110
-
111
- The key classes in this module are as follows.
112
-
113
- - AcGiEntity: Base class for drawable objects.
114
- - AcGiRenderer: Interface used to render entities to drawble objects.
115
- - ...
116
-
@@ -1,54 +0,0 @@
1
- import { AcCmEventManager } from '@mlightcad/common';
2
- import { AcDbDatabaseConverter } from './AcDbDatabaseConverter';
3
- /**
4
- * Drawing file type
5
- */
6
- export declare enum AcDbFileType {
7
- /**
8
- * DXF file
9
- */
10
- DXF = "dxf",
11
- /**
12
- * DWG file
13
- */
14
- DWG = "dwg"
15
- }
16
- export interface AcDbDatabaseConverterRegisterEventArgs {
17
- fileType: AcDbFileType;
18
- converter: AcDbDatabaseConverter;
19
- }
20
- /**
21
- * Used to register database converter by file type. For example, you can register 'dxf' converter
22
- * and 'dwg' converter to handle different file types by different converter.
23
- */
24
- export declare class AcDbDatabaseConverterRegister {
25
- private static _instance?;
26
- private _converters;
27
- readonly events: {
28
- registered: AcCmEventManager<AcDbDatabaseConverterRegisterEventArgs>;
29
- unregistered: AcCmEventManager<AcDbDatabaseConverterRegisterEventArgs>;
30
- };
31
- static createInstance(): AcDbDatabaseConverterRegister | undefined;
32
- /**
33
- * The singlton instance of this class.
34
- */
35
- static get instance(): AcDbDatabaseConverterRegister;
36
- private constructor();
37
- /**
38
- * All of registered file types
39
- */
40
- get fileTypes(): IterableIterator<AcDbFileType>;
41
- /**
42
- * Register one database convert for the specified file type
43
- * @param fileType Input one file type value.
44
- * @param converter Input the database converter associated with the specified file type.
45
- */
46
- register(fileType: AcDbFileType, converter: AcDbDatabaseConverter): void;
47
- /**
48
- * Get the database converter associated with the specified file type.
49
- * @param fileType Input one file type value.
50
- * @returns Return the database converter associated with the specified file type.
51
- */
52
- get(fileType: AcDbFileType): AcDbDatabaseConverter<unknown> | undefined;
53
- }
54
- //# sourceMappingURL=AcDbDatabaseConverterRegister.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AcDbDatabaseConverterRegister.d.ts","sourceRoot":"","sources":["../../src/database/AcDbDatabaseConverterRegister.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D;;GAEG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,GAAG,QAAQ;IACX;;OAEG;IACH,GAAG,QAAQ;CACZ;AAED,MAAM,WAAW,sCAAsC;IACrD,QAAQ,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,qBAAqB,CAAA;CACjC;AAED;;;GAGG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA+B;IACxD,OAAO,CAAC,WAAW,CAA0C;IAE7D,SAAgB,MAAM;;;MAGrB;IAED,MAAM,CAAC,cAAc;IAQrB;;OAEG;IACH,MAAM,KAAK,QAAQ,kCAMlB;IAED,OAAO;IAKP;;OAEG;IACH,IAAI,SAAS,mCAEZ;IAED;;;;OAIG;IACI,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,qBAAqB;IAQxE;;;;OAIG;IACI,GAAG,CAAC,QAAQ,EAAE,YAAY;CAGlC"}
@@ -1,84 +0,0 @@
1
- import { AcCmEventManager } from '@mlightcad/common';
2
- import { AcDbDxfConverter } from '../converter';
3
- /**
4
- * Drawing file type
5
- */
6
- export var AcDbFileType;
7
- (function (AcDbFileType) {
8
- /**
9
- * DXF file
10
- */
11
- AcDbFileType["DXF"] = "dxf";
12
- /**
13
- * DWG file
14
- */
15
- AcDbFileType["DWG"] = "dwg";
16
- })(AcDbFileType || (AcDbFileType = {}));
17
- /**
18
- * Used to register database converter by file type. For example, you can register 'dxf' converter
19
- * and 'dwg' converter to handle different file types by different converter.
20
- */
21
- var AcDbDatabaseConverterRegister = /** @class */ (function () {
22
- function AcDbDatabaseConverterRegister() {
23
- this.events = {
24
- registered: new AcCmEventManager(),
25
- unregistered: new AcCmEventManager()
26
- };
27
- this._converters = new Map();
28
- this.register(AcDbFileType.DXF, new AcDbDxfConverter());
29
- }
30
- AcDbDatabaseConverterRegister.createInstance = function () {
31
- if (AcDbDatabaseConverterRegister._instance == null) {
32
- AcDbDatabaseConverterRegister._instance =
33
- new AcDbDatabaseConverterRegister();
34
- }
35
- return this._instance;
36
- };
37
- Object.defineProperty(AcDbDatabaseConverterRegister, "instance", {
38
- /**
39
- * The singlton instance of this class.
40
- */
41
- get: function () {
42
- if (!AcDbDatabaseConverterRegister._instance) {
43
- AcDbDatabaseConverterRegister._instance =
44
- new AcDbDatabaseConverterRegister();
45
- }
46
- return AcDbDatabaseConverterRegister._instance;
47
- },
48
- enumerable: false,
49
- configurable: true
50
- });
51
- Object.defineProperty(AcDbDatabaseConverterRegister.prototype, "fileTypes", {
52
- /**
53
- * All of registered file types
54
- */
55
- get: function () {
56
- return this._converters.keys();
57
- },
58
- enumerable: false,
59
- configurable: true
60
- });
61
- /**
62
- * Register one database convert for the specified file type
63
- * @param fileType Input one file type value.
64
- * @param converter Input the database converter associated with the specified file type.
65
- */
66
- AcDbDatabaseConverterRegister.prototype.register = function (fileType, converter) {
67
- this._converters.set(fileType, converter);
68
- this.events.registered.dispatch({
69
- fileType: fileType,
70
- converter: converter
71
- });
72
- };
73
- /**
74
- * Get the database converter associated with the specified file type.
75
- * @param fileType Input one file type value.
76
- * @returns Return the database converter associated with the specified file type.
77
- */
78
- AcDbDatabaseConverterRegister.prototype.get = function (fileType) {
79
- return this._converters.get(fileType);
80
- };
81
- return AcDbDatabaseConverterRegister;
82
- }());
83
- export { AcDbDatabaseConverterRegister };
84
- //# sourceMappingURL=AcDbDatabaseConverterRegister.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AcDbDatabaseConverterRegister.js","sourceRoot":"","sources":["../../src/database/AcDbDatabaseConverter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