@mlightcad/dxf-json-converter 1.9.0

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,276 @@
1
+ import { AcDbConversionProgressCallback, AcDbDatabase, AcDbDatabaseConverter, AcDbDatabaseConverterConfig } from '@mlightcad/data-model';
2
+ import { ParsedDxf } from '@mlightcad/dxf-json/types';
3
+ /**
4
+ * Default database converter for DXF files.
5
+ *
6
+ * This class extends AcDbDatabaseConverter to provide specialized functionality
7
+ * for converting DXF (Drawing Exchange Format) files into AcDbDatabase objects.
8
+ * It handles parsing DXF data, processing entities, blocks, tables, and other
9
+ * DXF-specific structures.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const converter = new AcDbDxfConverter();
14
+ * const database = await converter.convert(dxfData);
15
+ * ```
16
+ */
17
+ export declare class AcDbDxfConverter extends AcDbDatabaseConverter<ParsedDxf> {
18
+ constructor(config?: AcDbDatabaseConverterConfig);
19
+ /**
20
+ * Parses DXF data into a ParsedDxf object.
21
+ *
22
+ * @param data - The DXF data
23
+ * @returns Parsed DXF object containing all the parsed data
24
+ *
25
+ */
26
+ protected parse(data: ArrayBuffer, timeout?: number): Promise<{
27
+ model: ParsedDxf | undefined;
28
+ data: {
29
+ unknownEntityCount: number;
30
+ };
31
+ }>;
32
+ /**
33
+ * Gets all fonts used by entities in model space and paper space.
34
+ *
35
+ * This method analyzes the DXF data to extract all font names used by
36
+ * text entities, MText entities, and insert entities throughout the drawing.
37
+ *
38
+ * @param dxf - Input parsed DXF model
39
+ * @returns Array of font names used in the drawing
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const fonts = converter.getFonts(parsedDxf);
44
+ * console.log('Used fonts:', fonts);
45
+ * ```
46
+ */
47
+ protected getFonts(dxf: ParsedDxf): string[];
48
+ /**
49
+ * Iterates through entities in a block to get fonts used by text, MText, and insert entities.
50
+ *
51
+ * This is a helper method that recursively processes entities to extract font information
52
+ * from text-based entities and block references.
53
+ *
54
+ * @param entities - Array of DXF entities to process
55
+ * @param blockMap - Map of block definitions
56
+ * @param styleMap - Map of text styles to font names
57
+ * @param fonts - Set to collect font names
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const fonts = new Set<string>();
62
+ * converter.getFontsInBlock(entities, blocks, styleMap, fonts);
63
+ * ```
64
+ */
65
+ private getFontsInBlock;
66
+ /**
67
+ * Processes entities in batches to maintain UI responsiveness.
68
+ *
69
+ * This method breaks up the entity processing work into smaller chunks that are
70
+ * executed asynchronously. This is often referred to as "batch processing" or
71
+ * "cooperative multitasking," where the time-consuming task is broken into
72
+ * smaller pieces and executed in small intervals to allow the UI to remain responsive.
73
+ *
74
+ * @param dxf - Parsed DXF data
75
+ * @param db - Target database to add entities to
76
+ * @param minimumChunkSize - Minimum number of entities to process in each chunk
77
+ * @param startPercentage - Object containing the starting percentage for progress tracking
78
+ * @param progress - Optional callback for progress updates
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * await converter.processEntities(dxf, database, 100, { value: 0 }, progressCallback);
83
+ * ```
84
+ */
85
+ protected processEntities(dxf: ParsedDxf, db: AcDbDatabase, minimumChunkSize: number, startPercentage: {
86
+ value: number;
87
+ }, progress?: AcDbConversionProgressCallback): Promise<void>;
88
+ /**
89
+ * Processes entities within a specific block.
90
+ *
91
+ * This method handles the conversion and addition of entities to a specific
92
+ * block table record.
93
+ *
94
+ * @param entities - Array of DXF entities to process
95
+ * @param blockTableRecord - The block table record to use
96
+ * @param checkOwner - The flag whether to check the owner of entity is the passed
97
+ * blockTableRecord. If yes, convert it and append it to the block table record.
98
+ * Otherwise, ignore the entity.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * await converter.processEntitiesInBlock(entities, blockRecord);
103
+ * ```
104
+ */
105
+ private processEntitiesInBlock;
106
+ /**
107
+ * Processes blocks defined in the DXF file.
108
+ *
109
+ * This method iterates through all blocks in the DXF data and creates
110
+ * corresponding AcDbBlockTableRecord objects in the database.
111
+ *
112
+ * @param model - Parsed DXF model containing block definitions
113
+ * @param db - Target database to add blocks to
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * converter.processBlocks(parsedDxf, database);
118
+ * ```
119
+ */
120
+ protected processBlocks(model: ParsedDxf, db: AcDbDatabase): void;
121
+ /**
122
+ * Processes header variables from the DXF file.
123
+ *
124
+ * This method extracts and sets various header variables such as color settings,
125
+ * angle base, angle direction, units, and point display settings.
126
+ *
127
+ * @param model - Parsed DXF model containing header information
128
+ * @param db - Target database to set header variables on
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * converter.processHeader(parsedDxf, database);
133
+ * ```
134
+ */
135
+ protected processHeader(model: ParsedDxf, db: AcDbDatabase): void;
136
+ /**
137
+ * Processes block table records from the DXF file.
138
+ *
139
+ * This method creates AcDbBlockTableRecord objects for each block record
140
+ * defined in the DXF tables section.
141
+ *
142
+ * @param dxf - Parsed DXF data
143
+ * @param db - Target database to add block table records to
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * converter.processBlockTables(parsedDxf, database);
148
+ * ```
149
+ */
150
+ protected processBlockTables(dxf: ParsedDxf, db: AcDbDatabase): void;
151
+ /**
152
+ * Processes objects defined in the DXF file.
153
+ *
154
+ * This method handles the conversion of DXF objects such as layouts and
155
+ * image definitions into their corresponding AcDb objects.
156
+ *
157
+ * @param model - Parsed DXF model containing object definitions
158
+ * @param db - Target database to add objects to
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * converter.processObjects(parsedDxf, database);
163
+ * ```
164
+ */
165
+ protected processObjects(model: ParsedDxf, db: AcDbDatabase): void;
166
+ /**
167
+ * Processes viewport table records from the DXF file.
168
+ *
169
+ * This method creates AcDbViewportTableRecord objects for each viewport
170
+ * defined in the DXF tables section, including their properties like
171
+ * center, corners, snap settings, and grid settings.
172
+ *
173
+ * @param model - Parsed DXF model containing viewport definitions
174
+ * @param db - Target database to add viewport table records to
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * converter.processViewports(parsedDxf, database);
179
+ * ```
180
+ */
181
+ protected processViewports(model: ParsedDxf, db: AcDbDatabase): void;
182
+ /**
183
+ * Processes layer table records from the DXF file.
184
+ *
185
+ * This method creates AcDbLayerTableRecord objects for each layer
186
+ * defined in the DXF tables section, including their properties like
187
+ * color, linetype, lineweight, and visibility settings.
188
+ *
189
+ * @param model - Parsed DXF model containing layer definitions
190
+ * @param db - Target database to add layer table records to
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * converter.processLayers(parsedDxf, database);
195
+ * ```
196
+ */
197
+ protected processLayers(model: ParsedDxf, db: AcDbDatabase): void;
198
+ /**
199
+ * Processes linetype table records from the DXF file.
200
+ *
201
+ * This method creates AcDbLinetypeTableRecord objects for each linetype
202
+ * defined in the DXF tables section.
203
+ *
204
+ * @param model - Parsed DXF model containing linetype definitions
205
+ * @param db - Target database to add linetype table records to
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * converter.processLineTypes(parsedDxf, database);
210
+ * ```
211
+ */
212
+ protected processLineTypes(model: ParsedDxf, db: AcDbDatabase): void;
213
+ /**
214
+ * Processes text style table records from the DXF file.
215
+ *
216
+ * This method creates AcDbTextStyleTableRecord objects for each text style
217
+ * defined in the DXF tables section.
218
+ *
219
+ * @param model - Parsed DXF model containing text style definitions
220
+ * @param db - Target database to add text style table records to
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * converter.processTextStyles(parsedDxf, database);
225
+ * ```
226
+ */
227
+ protected processTextStyles(model: ParsedDxf, db: AcDbDatabase): void;
228
+ /**
229
+ * Processes dimension style table records from the DXF file.
230
+ *
231
+ * This method creates AcDbDimStyleTableRecord objects for each dimension style
232
+ * defined in the DXF tables section, including all dimension-related properties
233
+ * like text positioning, arrow settings, and tolerance settings.
234
+ *
235
+ * @param model - Parsed DXF model containing dimension style definitions
236
+ * @param db - Target database to add dimension style table records to
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * converter.processDimStyles(parsedDxf, database);
241
+ * ```
242
+ */
243
+ protected processDimStyles(model: ParsedDxf, db: AcDbDatabase): void;
244
+ private processCommonTableAttrs;
245
+ /**
246
+ * Processes common table entry attributes from DXF data.
247
+ *
248
+ * This helper method sets the common attributes (name, objectId, ownerId)
249
+ * that are shared across all table entries.
250
+ *
251
+ * @param entry - DXF table entry containing the source data
252
+ * @param dbEntry - AcDbSymbolTableRecord to populate with the data
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * converter.processCommonTableEntryAttrs(dxfEntry, dbRecord);
257
+ * ```
258
+ */
259
+ private processCommonTableEntryAttrs;
260
+ /**
261
+ * Groups entities by their `type` property and flattens the result into a single array.
262
+ *
263
+ * The order of `type` groups follows the order in which they first appear in the input array.
264
+ * Items within each group preserve their original order.
265
+ *
266
+ * This runs in O(n) time, which is generally faster than sorting when you
267
+ * don't care about alphabetical order of types.
268
+ *
269
+ * @param entities - The array of entities to group and flatten.
270
+ *
271
+ * @returns A new array of entities grouped by their `type` property.
272
+ */
273
+ private groupAndFlattenByType;
274
+ private normalizeHeaderStringValue;
275
+ }
276
+ //# sourceMappingURL=AcDbDxfConverter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcDbDxfConverter.d.ts","sourceRoot":"","sources":["../src/AcDbDxfConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,2BAA2B,EA+B5B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAgBL,SAAS,EAIV,MAAM,2BAA2B,CAAA;AAKlC;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,SAAQ,qBAAqB,CAAC,SAAS,CAAC;gBACxD,MAAM,GAAE,2BAAgC;IAOpD;;;;;;OAMG;cACa,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;IA+BzD;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS;IAmCjC;;;;;;;;;;;;;;;;OAgB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