dxf-json 0.0.21 → 0.0.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.
Files changed (165) hide show
  1. package/package.json +8 -1
  2. package/.github/FUNDING.yml +0 -1
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  4. package/.github/ISSUE_TEMPLATE/custom.md +0 -10
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  6. package/.github/pull_request_template.md +0 -23
  7. package/.github/workflows/npm-publish.yml +0 -55
  8. package/.swcrc +0 -8
  9. package/jest.config.js +0 -20
  10. package/src/consts/block.ts +0 -22
  11. package/src/consts/color.ts +0 -6
  12. package/src/consts/config.ts +0 -2
  13. package/src/consts/dimension.ts +0 -69
  14. package/src/consts/hatch.ts +0 -52
  15. package/src/consts/header.ts +0 -10
  16. package/src/consts/index.ts +0 -9
  17. package/src/consts/lineweight.ts +0 -5
  18. package/src/consts/measurement.ts +0 -4
  19. package/src/consts/obscuredLineTypes.ts +0 -21
  20. package/src/consts/scene.ts +0 -2
  21. package/src/consts/viewport.ts +0 -62
  22. package/src/index.ts +0 -3
  23. package/src/parser/AutoCadColorIndex.ts +0 -265
  24. package/src/parser/DxfArrayScanner.ts +0 -161
  25. package/src/parser/DxfParser.ts +0 -109
  26. package/src/parser/ParseHelpers.ts +0 -124
  27. package/src/parser/blocks/blocks.test.ts +0 -97
  28. package/src/parser/blocks/index.ts +0 -88
  29. package/src/parser/blocks/types.ts +0 -15
  30. package/src/parser/entities/arc/index.ts +0 -2
  31. package/src/parser/entities/arc/parser.ts +0 -67
  32. package/src/parser/entities/arc/types.ts +0 -13
  33. package/src/parser/entities/attdef/consts.ts +0 -12
  34. package/src/parser/entities/attdef/index.ts +0 -3
  35. package/src/parser/entities/attdef/parser.ts +0 -119
  36. package/src/parser/entities/attdef/types.ts +0 -19
  37. package/src/parser/entities/attribute/consts.ts +0 -6
  38. package/src/parser/entities/attribute/index.ts +0 -3
  39. package/src/parser/entities/attribute/parser.ts +0 -198
  40. package/src/parser/entities/attribute/types.ts +0 -31
  41. package/src/parser/entities/circle/index.ts +0 -2
  42. package/src/parser/entities/circle/parser.ts +0 -58
  43. package/src/parser/entities/circle/types.ts +0 -11
  44. package/src/parser/entities/dimension/common.ts +0 -98
  45. package/src/parser/entities/dimension/index.ts +0 -24
  46. package/src/parser/entities/dimension/types.ts +0 -65
  47. package/src/parser/entities/ellipse/index.ts +0 -2
  48. package/src/parser/entities/ellipse/parser.ts +0 -66
  49. package/src/parser/entities/ellipse/types.ts +0 -13
  50. package/src/parser/entities/entities.test.ts +0 -86
  51. package/src/parser/entities/hatch/boundaryPathData/edge.ts +0 -190
  52. package/src/parser/entities/hatch/boundaryPathData/index.ts +0 -27
  53. package/src/parser/entities/hatch/boundaryPathData/polyline.ts +0 -43
  54. package/src/parser/entities/hatch/boundaryPathData/shared.ts +0 -16
  55. package/src/parser/entities/hatch/index.ts +0 -189
  56. package/src/parser/entities/hatch/patternData.ts +0 -57
  57. package/src/parser/entities/hatch/types/boundaryPath.ts +0 -72
  58. package/src/parser/entities/hatch/types/definitionLine.ts +0 -14
  59. package/src/parser/entities/hatch/types/hatch.ts +0 -47
  60. package/src/parser/entities/hatch/types/index.ts +0 -3
  61. package/src/parser/entities/index.ts +0 -87
  62. package/src/parser/entities/insert/index.ts +0 -2
  63. package/src/parser/entities/insert/parser.ts +0 -106
  64. package/src/parser/entities/insert/types.ts +0 -19
  65. package/src/parser/entities/leader/consts.ts +0 -6
  66. package/src/parser/entities/leader/index.ts +0 -3
  67. package/src/parser/entities/leader/parser.ts +0 -119
  68. package/src/parser/entities/leader/types.ts +0 -24
  69. package/src/parser/entities/line/index.ts +0 -2
  70. package/src/parser/entities/line/parser.ts +0 -55
  71. package/src/parser/entities/line/types.ts +0 -11
  72. package/src/parser/entities/lwpolyline/consts.ts +0 -4
  73. package/src/parser/entities/lwpolyline/index.ts +0 -3
  74. package/src/parser/entities/lwpolyline/parser.ts +0 -122
  75. package/src/parser/entities/lwpolyline/types.ts +0 -21
  76. package/src/parser/entities/mtext/consts.ts +0 -5
  77. package/src/parser/entities/mtext/index.ts +0 -3
  78. package/src/parser/entities/mtext/parser.ts +0 -195
  79. package/src/parser/entities/mtext/types.ts +0 -34
  80. package/src/parser/entities/point/index.ts +0 -2
  81. package/src/parser/entities/point/parser.ts +0 -60
  82. package/src/parser/entities/point/types.ts +0 -10
  83. package/src/parser/entities/polyline/consts.ts +0 -17
  84. package/src/parser/entities/polyline/index.ts +0 -3
  85. package/src/parser/entities/polyline/parser.ts +0 -126
  86. package/src/parser/entities/polyline/types.ts +0 -20
  87. package/src/parser/entities/section/index.ts +0 -2
  88. package/src/parser/entities/section/parser.ts +0 -104
  89. package/src/parser/entities/section/types.ts +0 -20
  90. package/src/parser/entities/shared.ts +0 -166
  91. package/src/parser/entities/solid/index.ts +0 -2
  92. package/src/parser/entities/solid/parser.ts +0 -56
  93. package/src/parser/entities/solid/types.ts +0 -10
  94. package/src/parser/entities/spline/consts.ts +0 -8
  95. package/src/parser/entities/spline/index.ts +0 -3
  96. package/src/parser/entities/spline/parser.ts +0 -121
  97. package/src/parser/entities/spline/types.ts +0 -22
  98. package/src/parser/entities/text/consts.ts +0 -21
  99. package/src/parser/entities/text/index.ts +0 -3
  100. package/src/parser/entities/text/parser.ts +0 -117
  101. package/src/parser/entities/text/types.ts +0 -21
  102. package/src/parser/entities/vertex/consts.ts +0 -10
  103. package/src/parser/entities/vertex/index.ts +0 -3
  104. package/src/parser/entities/vertex/parser.ts +0 -90
  105. package/src/parser/entities/vertex/types.ts +0 -17
  106. package/src/parser/entities/viewport/index.ts +0 -178
  107. package/src/parser/entities/viewport/types.ts +0 -58
  108. package/src/parser/filterDummyBlocks.ts +0 -49
  109. package/src/parser/header/index.ts +0 -30
  110. package/src/parser/objects/common.ts +0 -55
  111. package/src/parser/objects/dictionary.ts +0 -61
  112. package/src/parser/objects/index.ts +0 -45
  113. package/src/parser/objects/layout.ts +0 -136
  114. package/src/parser/objects/plotSettings.ts +0 -231
  115. package/src/parser/objects/treefy.ts +0 -53
  116. package/src/parser/objects/types.ts +0 -17
  117. package/src/parser/shared/index.ts +0 -21
  118. package/src/parser/shared/parsePoint.ts +0 -37
  119. package/src/parser/shared/parserGenerator.test.ts +0 -164
  120. package/src/parser/shared/parserGenerator.ts +0 -180
  121. package/src/parser/shared/xdata/index.ts +0 -3
  122. package/src/parser/shared/xdata/interpreter.test.ts +0 -85
  123. package/src/parser/shared/xdata/interpreter.ts +0 -65
  124. package/src/parser/shared/xdata/parser.test.ts +0 -66
  125. package/src/parser/shared/xdata/parser.ts +0 -140
  126. package/src/parser/shared/xdata/types.ts +0 -22
  127. package/src/parser/tables/blockRecord/index.ts +0 -2
  128. package/src/parser/tables/blockRecord/parser.ts +0 -49
  129. package/src/parser/tables/blockRecord/types.ts +0 -11
  130. package/src/parser/tables/dimStyle/consts.ts +0 -428
  131. package/src/parser/tables/dimStyle/index.ts +0 -3
  132. package/src/parser/tables/dimStyle/parser.ts +0 -37
  133. package/src/parser/tables/dimStyle/types.ts +0 -164
  134. package/src/parser/tables/index.ts +0 -2
  135. package/src/parser/tables/layer/index.ts +0 -2
  136. package/src/parser/tables/layer/parser.ts +0 -58
  137. package/src/parser/tables/layer/types.ts +0 -14
  138. package/src/parser/tables/ltype/consts.ts +0 -6
  139. package/src/parser/tables/ltype/index.ts +0 -3
  140. package/src/parser/tables/ltype/parser.ts +0 -110
  141. package/src/parser/tables/ltype/types.ts +0 -23
  142. package/src/parser/tables/parser.ts +0 -100
  143. package/src/parser/tables/shared.ts +0 -32
  144. package/src/parser/tables/style/index.ts +0 -2
  145. package/src/parser/tables/style/parser.ts +0 -70
  146. package/src/parser/tables/style/types.ts +0 -15
  147. package/src/parser/tables/types.ts +0 -15
  148. package/src/parser/tables/vport/index.ts +0 -2
  149. package/src/parser/tables/vport/parser.ts +0 -205
  150. package/src/parser/tables/vport/types.ts +0 -48
  151. package/src/parser/types.ts +0 -30
  152. package/src/types/color.ts +0 -5
  153. package/src/types/dxfHeader.ts +0 -21
  154. package/src/types/entity.ts +0 -7
  155. package/src/types/index.ts +0 -30
  156. package/src/utils/binarySearch.ts +0 -20
  157. package/src/utils/disjointSet.ts +0 -52
  158. package/src/utils/flooding.ts +0 -37
  159. package/src/utils/functional.ts +0 -124
  160. package/src/utils/graph.ts +0 -53
  161. package/src/utils/index.ts +0 -102
  162. package/src/utils/queue.ts +0 -77
  163. package/src/utils/triangle.ts +0 -28
  164. package/tsconfig.json +0 -37
  165. package/webpack.config.js +0 -53
@@ -1,97 +0,0 @@
1
- import DxfArrayScanner from '../DxfArrayScanner';
2
- import { parseBlock, parseBlocks } from '.';
3
- import { isMatched } from '../shared';
4
-
5
- const content = ` 0
6
- BLOCK
7
- 2
8
- block-0
9
- 100
10
- AcDbEntity
11
- 0
12
- ENDBLK
13
- 5
14
- endblk-0
15
- 100
16
- AcDbEntity
17
- 100
18
- AcDbBlockEnd
19
- 0
20
- BLOCK
21
- 2
22
- block-1
23
- 100
24
- AcDbEntity
25
- 0
26
- ENDBLK
27
- 5
28
- endblk-1
29
- 100
30
- AcDbEntity
31
- 100
32
- AcDbBlockEnd
33
- 0
34
- ENDSEC
35
- 0
36
- SECTION
37
- 0
38
- EOF
39
- `.split('\n');
40
-
41
- describe('BLOCK section', () => {
42
- describe('parseBlock', () => {
43
- it('parseBlock 한 번 실행하고 나면 scanner.next()가 다음 BLOCK의 <0, BLOCK>를 반환한다.', () => {
44
- const scanner = new DxfArrayScanner(content);
45
- let curr = scanner.next();
46
-
47
- curr = scanner.next(); // 집어넣을 때 이미 <0, BLOCK>을 소모한 상태여야 함
48
- parseBlock(curr, scanner);
49
-
50
- curr = scanner.next();
51
-
52
- expect(curr.code).toBe(0);
53
- expect(curr.value).toBe('BLOCK');
54
- });
55
-
56
- it('parseBlock은 모든 BLOCK을 소모하여야 한다.', () => {
57
- const scanner = new DxfArrayScanner(content);
58
- let curr = scanner.next();
59
-
60
- curr = scanner.next();
61
- const block0 = parseBlock(curr, scanner);
62
-
63
- curr = scanner.next();
64
- expect(isMatched(curr, 0, 'BLOCK')).toBeTruthy();
65
-
66
- curr = scanner.next();
67
- const block1 = parseBlock(curr, scanner);
68
-
69
- expect(block0.name).toBe('block-0');
70
- expect(block1.name).toBe('block-1');
71
- });
72
- });
73
-
74
- describe('parseBlocks', () => {
75
- it('parseBlocks 한 번 실행하고 나면 scanner.next()가 다음 SECTION의 <0, SECTION>을 반환한다.', () => {
76
- const scanner = new DxfArrayScanner(content);
77
- let curr = scanner.next();
78
-
79
- parseBlocks(curr, scanner);
80
-
81
- curr = scanner.next();
82
-
83
- expect(curr.code).toBe(0);
84
- expect(curr.value).toBe('SECTION');
85
- });
86
-
87
- it('parseBlocks는 모든 BLOCK을 반환해야 한다.', () => {
88
- const scanner = new DxfArrayScanner(content);
89
- let curr = scanner.next();
90
-
91
- const blocks = parseBlocks(curr, scanner);
92
-
93
- expect(blocks['block-0']).toMatchObject({ name: 'block-0' });
94
- expect(blocks['block-1']).toMatchObject({ name: 'block-1' });
95
- });
96
- });
97
- });
@@ -1,88 +0,0 @@
1
- import type DxfArrayScanner from '../DxfArrayScanner';
2
- import type { ScannerGroup } from '../DxfArrayScanner';
3
- import { parseEntities } from '../entities';
4
- import { parsePoint } from '../shared/parsePoint';
5
- import { ensureHandle, isMatched } from '../shared';
6
-
7
- export function parseBlocks(curr: ScannerGroup, scanner: DxfArrayScanner) {
8
- let blocks: any = {};
9
-
10
- while (!isMatched(curr, 0, 'EOF')) {
11
- if (isMatched(curr, 0, 'ENDSEC')) {
12
- break;
13
- }
14
-
15
- if (isMatched(curr, 0, 'BLOCK')) {
16
- curr = scanner.next();
17
- const block = parseBlock(curr, scanner);
18
-
19
- ensureHandle(block);
20
- if (block.name) {
21
- blocks[block.name] = block;
22
- }
23
- }
24
-
25
- curr = scanner.next();
26
- }
27
- return blocks;
28
- }
29
-
30
- export function parseBlock(curr: ScannerGroup, scanner: DxfArrayScanner) {
31
- let block: any = {};
32
-
33
- while (!isMatched(curr, 0, 'EOF')) {
34
- if (isMatched(curr, 0, 'ENDBLK')) {
35
- // 당장 ENDBLK 파싱이 없어서 임시로 대충 소비함
36
- // 소비 안하면 ENTITY에 딸려들어가서 문제 생김
37
- curr = scanner.next();
38
- while (!isMatched(curr, 0, 'EOF')) {
39
- if (isMatched(curr, 100, 'AcDbBlockEnd')) {
40
- return block;
41
- }
42
- curr = scanner.next();
43
- }
44
- break;
45
- }
46
-
47
- switch (curr.code) {
48
- case 1:
49
- block.xrefPath = curr.value;
50
- break;
51
- case 2:
52
- block.name = curr.value;
53
- break;
54
- case 3:
55
- block.name2 = curr.value;
56
- break;
57
- case 5:
58
- block.handle = curr.value;
59
- break;
60
- case 8:
61
- block.layer = curr.value;
62
- break;
63
- case 10:
64
- block.position = parsePoint(scanner);
65
- break;
66
- case 67:
67
- block.paperSpace = curr.value && curr.value == 1 ? true : false;
68
- break;
69
- case 70:
70
- if (curr.value !== 0) {
71
- block.type = curr.value;
72
- }
73
- break;
74
- case 100:
75
- // ignore class markers
76
- break;
77
- case 330:
78
- block.ownerHandle = curr.value;
79
- break;
80
- case 0:
81
- block.entities = parseEntities(curr, scanner);
82
- break;
83
- }
84
-
85
- curr = scanner.next();
86
- }
87
- return block;
88
- }
@@ -1,15 +0,0 @@
1
- import type { Point3D } from '../../types';
2
- import type { CommonDxfEntity } from '../entities/shared';
3
-
4
- export interface DxfBlock {
5
- type: number; // bit flag of BlockTypeFlag
6
- name: string;
7
- name2: string;
8
- handle: string;
9
- ownerHandle: string;
10
- layer: string;
11
- position: Point3D;
12
- paperSpace: boolean;
13
- xrefPath: string;
14
- entities?: CommonDxfEntity[];
15
- }
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './parser';
@@ -1,67 +0,0 @@
1
- import type DxfArrayScanner from '../../DxfArrayScanner';
2
- import type { ScannerGroup } from '../../DxfArrayScanner';
3
- import {
4
- createParser,
5
- DXFParserSnippet,
6
- Identity,
7
- PointParser,
8
- } from '../../shared/parserGenerator';
9
- import { CommonEntitySnippets } from '../shared';
10
-
11
- const DefaultArcEntity = {
12
- extrusionDirection: { x: 0, y: 0, z: 1 },
13
- };
14
-
15
- const ArcEntityParserSnippets: DXFParserSnippet[] = [
16
- {
17
- code: 210,
18
- name: 'extrusionDirection',
19
- parser: PointParser,
20
- },
21
- {
22
- code: 51,
23
- name: 'endAngle',
24
- parser: Identity,
25
- },
26
- {
27
- code: 50,
28
- name: 'startAngle',
29
- parser: Identity,
30
- },
31
- {
32
- code: 100,
33
- name: 'subclassMarker',
34
- parser: Identity,
35
- },
36
- {
37
- code: 40,
38
- name: 'radius',
39
- parser: Identity,
40
- },
41
- {
42
- code: 10,
43
- name: 'center',
44
- parser: PointParser,
45
- },
46
- {
47
- code: 39,
48
- name: 'thickness',
49
- parser: Identity,
50
- },
51
- {
52
- // skip for AcDbCircle
53
- code: 100,
54
- },
55
- ...CommonEntitySnippets,
56
- ];
57
-
58
- export class ArcEntityParser {
59
- static ForEntityName = 'ARC';
60
- private parser = createParser(ArcEntityParserSnippets, DefaultArcEntity);
61
-
62
- parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
63
- const entity = {} as any;
64
- this.parser(curr, scanner, entity);
65
- return entity;
66
- }
67
- }
@@ -1,13 +0,0 @@
1
- import type { Point3D } from '../../../types';
2
- import type { CommonDxfEntity } from '../shared';
3
-
4
- export interface ArcEntity extends CommonDxfEntity {
5
- type: 'ARC';
6
- subclassMarker: 'AcDbArc';
7
- thickness: number;
8
- center: Point3D;
9
- radius: number;
10
- startAngle: number;
11
- endAngle: number;
12
- extrusionDirection: Point3D;
13
- }
@@ -1,12 +0,0 @@
1
- export enum AttributeFlag {
2
- NONE = 0,
3
- INVISIBLE = 1,
4
- CONSTANT = 2,
5
- VERIFICATION_REQUIRED = 4,
6
- PRESET = 8,
7
- }
8
-
9
- export enum AttDefMTextFlag {
10
- MULTILINE = 2,
11
- CONSTANT_MULTILINE = 4,
12
- }
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './consts';
3
- export * from './parser';
@@ -1,119 +0,0 @@
1
- import type DxfArrayScanner from '../../DxfArrayScanner';
2
- import type { ScannerGroup } from '../../DxfArrayScanner';
3
- import {
4
- createParser,
5
- DXFParserSnippet,
6
- Identity,
7
- PointParser,
8
- ToBoolean,
9
- } from '../../shared/parserGenerator';
10
- import { DefaultTextEntity, TextEntityParserSnippets } from '../text';
11
- import type { AttdefEntity } from './types';
12
-
13
- const DefaultAttDefEntity = {
14
- ...DefaultTextEntity,
15
- };
16
-
17
- const AttDefEntityParserSnippets: DXFParserSnippet[] = [
18
- {
19
- code: 2, // tag. 왜 다시 나오는지 모르겠음
20
- },
21
- {
22
- code: 40,
23
- name: 'annotationScale',
24
- parser: Identity,
25
- },
26
- {
27
- code: 10,
28
- name: 'alignmentPoint',
29
- parser: PointParser,
30
- },
31
- {
32
- code: 340,
33
- name: 'secondaryAttributesHardIds',
34
- isMultiple: true,
35
- parser: Identity,
36
- },
37
- {
38
- code: 70,
39
- name: 'numberOfSecondaryAttributes',
40
- parser: Identity,
41
- },
42
- {
43
- code: 70,
44
- name: 'isReallyLocked',
45
- parser: ToBoolean,
46
- },
47
- {
48
- code: 70,
49
- name: 'mtextFlag',
50
- parser: Identity,
51
- },
52
- {
53
- code: 280,
54
- name: 'isDuplicatedRecord',
55
- parser: ToBoolean,
56
- },
57
- {
58
- code: 100, // AcDbXrecord, skip
59
- },
60
- {
61
- code: 280,
62
- name: 'isLocked',
63
- parser: ToBoolean,
64
- },
65
- {
66
- code: 74,
67
- name: 'valign',
68
- parser: Identity,
69
- },
70
- {
71
- code: 73, // field length, useless
72
- },
73
- {
74
- code: 70,
75
- name: 'attributeFlag',
76
- parser: Identity,
77
- },
78
- {
79
- code: 2,
80
- name: 'tag',
81
- parser: Identity,
82
- },
83
- {
84
- code: 3,
85
- name: 'prompt',
86
- parser: Identity,
87
- },
88
- {
89
- code: 280, // version number, always 0, useless
90
- },
91
- {
92
- code: 100,
93
- name: 'subclassMarker',
94
- parser: Identity,
95
- },
96
- ...TextEntityParserSnippets.slice(2),
97
- ];
98
-
99
- export class AttDefEntityParser {
100
- static ForEntityName = 'ATTDEF';
101
- private parser = createParser(
102
- AttDefEntityParserSnippets,
103
- DefaultAttDefEntity,
104
- );
105
-
106
- parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
107
- const entity = {} as any;
108
- this.parser(curr, scanner, entity);
109
- return entity as AttdefEntity;
110
- }
111
- }
112
-
113
- // entity.invisible = !!(curr.value & 0x01);
114
- // entity.constant = !!(curr.value & 0x02);
115
- // entity.verificationRequired = !!(curr.value & 0x04);
116
- // entity.preset = !!(curr.value & 0x08);
117
-
118
- // entity.backwards = !!(curr.value & 0x02);
119
- // entity.mirrored = !!(curr.value & 0x04);
@@ -1,19 +0,0 @@
1
- import type { Point3D } from '../../../types';
2
- import type { TextEntity } from '../text';
3
-
4
- export interface AttdefEntity
5
- extends Omit<TextEntity, 'type' | 'subclassMarker'> {
6
- type: 'ATTDEF';
7
- subclassMarker: 'AcDbAttributeDefinition';
8
- prompt: string;
9
- tag: string;
10
- attributeFlag: number;
11
- isLocked: boolean;
12
- isDuplicatedRecord: boolean;
13
- mtextFlag: number;
14
- isReallyLocked: boolean;
15
- numberOfSecondaryAttributes: number;
16
- secondaryAttributesHardIds: string[];
17
- alignmentPoint: Point3D;
18
- annotationScale: number;
19
- }
@@ -1,6 +0,0 @@
1
- export enum AttributeFlag {
2
- INVISIBLE = 1,
3
- CONSTANT = 2,
4
- REQUIRE_VERIFICATION = 4,
5
- PRESET = 8,
6
- }
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './consts';
3
- export * from './parser';
@@ -1,198 +0,0 @@
1
- import type DxfArrayScanner from '../../DxfArrayScanner';
2
- import type { ScannerGroup } from '../../DxfArrayScanner';
3
- import {
4
- Abort,
5
- createParser,
6
- DXFParserSnippet,
7
- Identity,
8
- PointParser,
9
- ToBoolean,
10
- } from '../../shared/parserGenerator';
11
- import { isMatched } from '../../shared';
12
- import { CommonEntitySnippets } from '../shared';
13
- import { MTextEntityParserSnippets } from '../mtext';
14
- import { AttributeEntity } from './types';
15
-
16
- const DefaultAttributeEntity = {
17
- thickness: 0,
18
- rotation: 0,
19
- scale: 1,
20
- obliqueAngle: 0,
21
- textStyle: 'STANDARD',
22
- textGenerationFlag: 0,
23
- horizontalJustification: 0,
24
- verticalJustification: 0,
25
- extrusionDirection: { x: 0, y: 0, z: 1 },
26
- };
27
-
28
- const AttributeSnippets: DXFParserSnippet[] = [
29
- ...MTextEntityParserSnippets.slice(
30
- MTextEntityParserSnippets.findIndex(
31
- ({ name }) => name === 'columnType',
32
- ),
33
- MTextEntityParserSnippets.findIndex(
34
- ({ name }) => name === 'subclassMarker',
35
- ) + 1,
36
- ),
37
- // 67, 8은 common에 있음
38
- {
39
- code: 100, // AcDbEntity
40
- },
41
- {
42
- // MTEXT가 필수로 따라오지 않는 경우도 있기 때문에 이 경우 탈출 필요
43
- code: 0,
44
- parser(curr) {
45
- if (!isMatched(curr, 0, 'MTEXT')) return Abort;
46
- return undefined;
47
- },
48
- },
49
- {
50
- code: 2,
51
- name: 'definitionTag',
52
- parser: Identity,
53
- },
54
- {
55
- code: 40,
56
- name: 'annotationScale',
57
- parser: Identity,
58
- },
59
- {
60
- code: 10,
61
- name: 'alignmentPoint',
62
- parser: PointParser,
63
- },
64
- {
65
- code: 340,
66
- name: 'secondaryAttributesHardId',
67
- parser: Identity,
68
- },
69
- {
70
- code: 70,
71
- name: 'numberOfSecondaryAttributes',
72
- parser: Identity,
73
- },
74
- {
75
- code: 70,
76
- name: 'isReallyLocked',
77
- parser: ToBoolean,
78
- },
79
- {
80
- code: 70,
81
- name: 'mtextFlag',
82
- parser: Identity,
83
- },
84
- {
85
- code: 280,
86
- name: 'isDuplicatedEntriesKeep',
87
- parser: ToBoolean,
88
- },
89
- {
90
- code: 100, // AcDbXRecord
91
- },
92
- {
93
- code: 280,
94
- name: 'lockPositionFlag',
95
- parser: ToBoolean,
96
- },
97
- {
98
- code: 210,
99
- name: 'extrusionDirection',
100
- parser: PointParser,
101
- },
102
- {
103
- code: 11,
104
- name: 'alignmentPoint',
105
- parser: PointParser,
106
- },
107
- {
108
- code: 74,
109
- name: 'verticalJustification',
110
- parser: Identity,
111
- },
112
- {
113
- code: 72,
114
- name: 'horizontalJustification',
115
- parser: Identity,
116
- },
117
- {
118
- code: 71,
119
- name: 'textGenerationFlag', // attachmentPoint
120
- parser: Identity,
121
- },
122
- {
123
- code: 7,
124
- name: 'textStyle',
125
- parser: Identity,
126
- },
127
- {
128
- code: 51,
129
- name: 'obliqueAngle',
130
- parser: Identity,
131
- },
132
- {
133
- code: 41,
134
- name: 'scale',
135
- parser: Identity,
136
- },
137
- {
138
- code: 50,
139
- name: 'rotation',
140
- parser: Identity,
141
- },
142
- {
143
- code: 73, // 미사용
144
- },
145
- {
146
- code: 70,
147
- name: 'attributeFlag',
148
- parser: Identity,
149
- },
150
- {
151
- code: 2,
152
- name: 'tag',
153
- parser: Identity,
154
- },
155
- {
156
- code: 280, // version number, 미사용
157
- },
158
- {
159
- code: 100, // AcDbAttribute
160
- name: 'subclassMarker',
161
- parser: Identity,
162
- },
163
- {
164
- code: 1,
165
- name: 'text',
166
- parser: Identity,
167
- },
168
- {
169
- code: 40,
170
- name: 'textHeight',
171
- parser: Identity,
172
- },
173
- {
174
- code: 10,
175
- name: 'startPoint',
176
- parser: PointParser,
177
- },
178
- {
179
- code: 39,
180
- name: 'thickness',
181
- parser: Identity,
182
- },
183
- {
184
- code: 100, // AcDbText
185
- },
186
- ...CommonEntitySnippets,
187
- ];
188
-
189
- export class AttributeEntityParser {
190
- static ForEntityName = 'ATTRIB';
191
- private parser = createParser(AttributeSnippets, DefaultAttributeEntity);
192
-
193
- parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
194
- const entity = {} as any;
195
- this.parser(curr, scanner, entity);
196
- return entity as AttributeEntity;
197
- }
198
- }
@@ -1,31 +0,0 @@
1
- import type { Point3D } from '../../../types';
2
- import type { CommonDxfEntity } from '../shared';
3
-
4
- export interface AttributeEntity extends CommonDxfEntity {
5
- type: 'ATTRIB';
6
- subclassMarker: 'AcDbAttribute';
7
- thickness: number;
8
- startPoint: Point3D;
9
- textHeight: number;
10
- text: string;
11
- tag: string; // cannot contain spaces
12
- attributeFlag: number;
13
- lineSpacing?: number;
14
- rotation: number;
15
- scale: number;
16
- obliqueAngle: number;
17
- textStyle: string;
18
- textGenerationFlag: number;
19
- horizontalJustification: number;
20
- verticalJustification: number;
21
- extrusionDirection: Point3D;
22
- lockPositionFlag: boolean;
23
- isDuplicatedEntriesKeep?: boolean;
24
- mtextFlag: 2 | 4;
25
- isReallyLocked?: boolean;
26
- numberOfSecondaryAttributes?: number;
27
- secondaryAttributesHardId?: string;
28
- alignmentPoint: Point3D;
29
- annotationScale?: number;
30
- definitionTag?: string;
31
- }
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './parser';