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.
- package/package.json +8 -1
- package/.github/FUNDING.yml +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/custom.md +0 -10
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/pull_request_template.md +0 -23
- package/.github/workflows/npm-publish.yml +0 -55
- package/.swcrc +0 -8
- package/jest.config.js +0 -20
- package/src/consts/block.ts +0 -22
- package/src/consts/color.ts +0 -6
- package/src/consts/config.ts +0 -2
- package/src/consts/dimension.ts +0 -69
- package/src/consts/hatch.ts +0 -52
- package/src/consts/header.ts +0 -10
- package/src/consts/index.ts +0 -9
- package/src/consts/lineweight.ts +0 -5
- package/src/consts/measurement.ts +0 -4
- package/src/consts/obscuredLineTypes.ts +0 -21
- package/src/consts/scene.ts +0 -2
- package/src/consts/viewport.ts +0 -62
- package/src/index.ts +0 -3
- package/src/parser/AutoCadColorIndex.ts +0 -265
- package/src/parser/DxfArrayScanner.ts +0 -161
- package/src/parser/DxfParser.ts +0 -109
- package/src/parser/ParseHelpers.ts +0 -124
- package/src/parser/blocks/blocks.test.ts +0 -97
- package/src/parser/blocks/index.ts +0 -88
- package/src/parser/blocks/types.ts +0 -15
- package/src/parser/entities/arc/index.ts +0 -2
- package/src/parser/entities/arc/parser.ts +0 -67
- package/src/parser/entities/arc/types.ts +0 -13
- package/src/parser/entities/attdef/consts.ts +0 -12
- package/src/parser/entities/attdef/index.ts +0 -3
- package/src/parser/entities/attdef/parser.ts +0 -119
- package/src/parser/entities/attdef/types.ts +0 -19
- package/src/parser/entities/attribute/consts.ts +0 -6
- package/src/parser/entities/attribute/index.ts +0 -3
- package/src/parser/entities/attribute/parser.ts +0 -198
- package/src/parser/entities/attribute/types.ts +0 -31
- package/src/parser/entities/circle/index.ts +0 -2
- package/src/parser/entities/circle/parser.ts +0 -58
- package/src/parser/entities/circle/types.ts +0 -11
- package/src/parser/entities/dimension/common.ts +0 -98
- package/src/parser/entities/dimension/index.ts +0 -24
- package/src/parser/entities/dimension/types.ts +0 -65
- package/src/parser/entities/ellipse/index.ts +0 -2
- package/src/parser/entities/ellipse/parser.ts +0 -66
- package/src/parser/entities/ellipse/types.ts +0 -13
- package/src/parser/entities/entities.test.ts +0 -86
- package/src/parser/entities/hatch/boundaryPathData/edge.ts +0 -190
- package/src/parser/entities/hatch/boundaryPathData/index.ts +0 -27
- package/src/parser/entities/hatch/boundaryPathData/polyline.ts +0 -43
- package/src/parser/entities/hatch/boundaryPathData/shared.ts +0 -16
- package/src/parser/entities/hatch/index.ts +0 -189
- package/src/parser/entities/hatch/patternData.ts +0 -57
- package/src/parser/entities/hatch/types/boundaryPath.ts +0 -72
- package/src/parser/entities/hatch/types/definitionLine.ts +0 -14
- package/src/parser/entities/hatch/types/hatch.ts +0 -47
- package/src/parser/entities/hatch/types/index.ts +0 -3
- package/src/parser/entities/index.ts +0 -87
- package/src/parser/entities/insert/index.ts +0 -2
- package/src/parser/entities/insert/parser.ts +0 -106
- package/src/parser/entities/insert/types.ts +0 -19
- package/src/parser/entities/leader/consts.ts +0 -6
- package/src/parser/entities/leader/index.ts +0 -3
- package/src/parser/entities/leader/parser.ts +0 -119
- package/src/parser/entities/leader/types.ts +0 -24
- package/src/parser/entities/line/index.ts +0 -2
- package/src/parser/entities/line/parser.ts +0 -55
- package/src/parser/entities/line/types.ts +0 -11
- package/src/parser/entities/lwpolyline/consts.ts +0 -4
- package/src/parser/entities/lwpolyline/index.ts +0 -3
- package/src/parser/entities/lwpolyline/parser.ts +0 -122
- package/src/parser/entities/lwpolyline/types.ts +0 -21
- package/src/parser/entities/mtext/consts.ts +0 -5
- package/src/parser/entities/mtext/index.ts +0 -3
- package/src/parser/entities/mtext/parser.ts +0 -195
- package/src/parser/entities/mtext/types.ts +0 -34
- package/src/parser/entities/point/index.ts +0 -2
- package/src/parser/entities/point/parser.ts +0 -60
- package/src/parser/entities/point/types.ts +0 -10
- package/src/parser/entities/polyline/consts.ts +0 -17
- package/src/parser/entities/polyline/index.ts +0 -3
- package/src/parser/entities/polyline/parser.ts +0 -126
- package/src/parser/entities/polyline/types.ts +0 -20
- package/src/parser/entities/section/index.ts +0 -2
- package/src/parser/entities/section/parser.ts +0 -104
- package/src/parser/entities/section/types.ts +0 -20
- package/src/parser/entities/shared.ts +0 -166
- package/src/parser/entities/solid/index.ts +0 -2
- package/src/parser/entities/solid/parser.ts +0 -56
- package/src/parser/entities/solid/types.ts +0 -10
- package/src/parser/entities/spline/consts.ts +0 -8
- package/src/parser/entities/spline/index.ts +0 -3
- package/src/parser/entities/spline/parser.ts +0 -121
- package/src/parser/entities/spline/types.ts +0 -22
- package/src/parser/entities/text/consts.ts +0 -21
- package/src/parser/entities/text/index.ts +0 -3
- package/src/parser/entities/text/parser.ts +0 -117
- package/src/parser/entities/text/types.ts +0 -21
- package/src/parser/entities/vertex/consts.ts +0 -10
- package/src/parser/entities/vertex/index.ts +0 -3
- package/src/parser/entities/vertex/parser.ts +0 -90
- package/src/parser/entities/vertex/types.ts +0 -17
- package/src/parser/entities/viewport/index.ts +0 -178
- package/src/parser/entities/viewport/types.ts +0 -58
- package/src/parser/filterDummyBlocks.ts +0 -49
- package/src/parser/header/index.ts +0 -30
- package/src/parser/objects/common.ts +0 -55
- package/src/parser/objects/dictionary.ts +0 -61
- package/src/parser/objects/index.ts +0 -45
- package/src/parser/objects/layout.ts +0 -136
- package/src/parser/objects/plotSettings.ts +0 -231
- package/src/parser/objects/treefy.ts +0 -53
- package/src/parser/objects/types.ts +0 -17
- package/src/parser/shared/index.ts +0 -21
- package/src/parser/shared/parsePoint.ts +0 -37
- package/src/parser/shared/parserGenerator.test.ts +0 -164
- package/src/parser/shared/parserGenerator.ts +0 -180
- package/src/parser/shared/xdata/index.ts +0 -3
- package/src/parser/shared/xdata/interpreter.test.ts +0 -85
- package/src/parser/shared/xdata/interpreter.ts +0 -65
- package/src/parser/shared/xdata/parser.test.ts +0 -66
- package/src/parser/shared/xdata/parser.ts +0 -140
- package/src/parser/shared/xdata/types.ts +0 -22
- package/src/parser/tables/blockRecord/index.ts +0 -2
- package/src/parser/tables/blockRecord/parser.ts +0 -49
- package/src/parser/tables/blockRecord/types.ts +0 -11
- package/src/parser/tables/dimStyle/consts.ts +0 -428
- package/src/parser/tables/dimStyle/index.ts +0 -3
- package/src/parser/tables/dimStyle/parser.ts +0 -37
- package/src/parser/tables/dimStyle/types.ts +0 -164
- package/src/parser/tables/index.ts +0 -2
- package/src/parser/tables/layer/index.ts +0 -2
- package/src/parser/tables/layer/parser.ts +0 -58
- package/src/parser/tables/layer/types.ts +0 -14
- package/src/parser/tables/ltype/consts.ts +0 -6
- package/src/parser/tables/ltype/index.ts +0 -3
- package/src/parser/tables/ltype/parser.ts +0 -110
- package/src/parser/tables/ltype/types.ts +0 -23
- package/src/parser/tables/parser.ts +0 -100
- package/src/parser/tables/shared.ts +0 -32
- package/src/parser/tables/style/index.ts +0 -2
- package/src/parser/tables/style/parser.ts +0 -70
- package/src/parser/tables/style/types.ts +0 -15
- package/src/parser/tables/types.ts +0 -15
- package/src/parser/tables/vport/index.ts +0 -2
- package/src/parser/tables/vport/parser.ts +0 -205
- package/src/parser/tables/vport/types.ts +0 -48
- package/src/parser/types.ts +0 -30
- package/src/types/color.ts +0 -5
- package/src/types/dxfHeader.ts +0 -21
- package/src/types/entity.ts +0 -7
- package/src/types/index.ts +0 -30
- package/src/utils/binarySearch.ts +0 -20
- package/src/utils/disjointSet.ts +0 -52
- package/src/utils/flooding.ts +0 -37
- package/src/utils/functional.ts +0 -124
- package/src/utils/graph.ts +0 -53
- package/src/utils/index.ts +0 -102
- package/src/utils/queue.ts +0 -77
- package/src/utils/triangle.ts +0 -28
- package/tsconfig.json +0 -37
- package/webpack.config.js +0 -53
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type DxfArrayScanner from '../DxfArrayScanner';
|
|
2
|
-
import { ScannerGroup } from '../DxfArrayScanner';
|
|
3
|
-
import { createParser, DXFParserSnippet } from '../shared/parserGenerator';
|
|
4
|
-
import { LayoutSnippets } from './layout';
|
|
5
|
-
import { CommonObjectSnippets } from './common';
|
|
6
|
-
import { PlotSettingsSnippets } from './plotSettings';
|
|
7
|
-
import { DictionarySnippets } from './dictionary';
|
|
8
|
-
import { createObjectTree } from './treefy';
|
|
9
|
-
import { classify } from '../../utils';
|
|
10
|
-
|
|
11
|
-
const ObjectSchemas: Record<string, DXFParserSnippet[]> = {
|
|
12
|
-
LAYOUT: LayoutSnippets,
|
|
13
|
-
PLOTSETTINGS: PlotSettingsSnippets,
|
|
14
|
-
DICTIONARY: DictionarySnippets,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function parseObjects(curr: ScannerGroup, scanner: DxfArrayScanner) {
|
|
18
|
-
const result = [] as any[];
|
|
19
|
-
|
|
20
|
-
while (curr.code !== 0 || !['EOF', 'ENDSEC'].includes(curr.value)) {
|
|
21
|
-
const objectName = curr.value as string;
|
|
22
|
-
const snippets = ObjectSchemas[objectName];
|
|
23
|
-
|
|
24
|
-
if (curr.code === 0 && snippets?.length) {
|
|
25
|
-
const parser = createParser([...CommonObjectSnippets, ...snippets]);
|
|
26
|
-
const parsedObject = { name: objectName } as any;
|
|
27
|
-
|
|
28
|
-
curr = scanner.next();
|
|
29
|
-
|
|
30
|
-
if (parser(curr, scanner, parsedObject)) {
|
|
31
|
-
result.push(parsedObject);
|
|
32
|
-
curr = scanner.peek();
|
|
33
|
-
} else {
|
|
34
|
-
curr = scanner.next();
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
curr = scanner.next();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
byName: classify(result, ({ name }) => name),
|
|
43
|
-
byTree: createObjectTree(result),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { OrthographicType } from '../../consts';
|
|
2
|
-
import type { Point2D, Point3D } from '../../types';
|
|
3
|
-
import {
|
|
4
|
-
DXFParserSnippet,
|
|
5
|
-
Identity,
|
|
6
|
-
PointParser,
|
|
7
|
-
} from '../shared/parserGenerator';
|
|
8
|
-
import { PlotSettingDXFObject, PlotSettingsSnippets } from './plotSettings';
|
|
9
|
-
|
|
10
|
-
// Snippet이 code별로 스택에 들어가기 때문에 일부로 역순으로 적음
|
|
11
|
-
export const LayoutSnippets: DXFParserSnippet[] = [
|
|
12
|
-
{
|
|
13
|
-
code: 333,
|
|
14
|
-
name: 'shadePlotId',
|
|
15
|
-
parser: Identity,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
code: 346,
|
|
19
|
-
name: 'orthographicUcsId',
|
|
20
|
-
parser: Identity,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
code: 345,
|
|
24
|
-
name: 'namedUcsId',
|
|
25
|
-
parser: Identity,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
code: 331,
|
|
29
|
-
name: 'viewportId',
|
|
30
|
-
parser: Identity,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
code: 330,
|
|
34
|
-
name: 'paperSpaceTableId',
|
|
35
|
-
parser: Identity,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
code: 76,
|
|
39
|
-
name: 'orthographicType',
|
|
40
|
-
parser: Identity,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
code: 17,
|
|
44
|
-
name: 'ucsYAxis',
|
|
45
|
-
parser: PointParser,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
code: 16,
|
|
49
|
-
name: 'ucsXAxis',
|
|
50
|
-
parser: PointParser,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
code: 13,
|
|
54
|
-
name: 'ucsOrigin',
|
|
55
|
-
parser: PointParser,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
code: 146,
|
|
59
|
-
name: 'elevation',
|
|
60
|
-
parser: Identity,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
code: 15,
|
|
64
|
-
name: 'maxExtent',
|
|
65
|
-
parser: PointParser,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
code: 14,
|
|
69
|
-
name: 'minExtent',
|
|
70
|
-
parser: PointParser,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
code: 12,
|
|
74
|
-
name: 'insertionBase',
|
|
75
|
-
parser: PointParser,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
code: 11,
|
|
79
|
-
name: 'maxLimit',
|
|
80
|
-
parser: PointParser,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
code: 10,
|
|
84
|
-
name: 'minLimit',
|
|
85
|
-
parser: PointParser,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
code: 71,
|
|
89
|
-
name: 'tabOrder',
|
|
90
|
-
parser: Identity,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
code: 70,
|
|
94
|
-
name: 'controlFlag',
|
|
95
|
-
parser: Identity,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
code: 1,
|
|
99
|
-
name: 'layoutName',
|
|
100
|
-
parser: Identity,
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
code: 100,
|
|
104
|
-
name: 'subclassMarker',
|
|
105
|
-
parser: Identity,
|
|
106
|
-
},
|
|
107
|
-
...PlotSettingsSnippets,
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
export enum LayoutControlFlag {
|
|
111
|
-
PSLTSCALE = 1,
|
|
112
|
-
LIMCHECK = 2,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface LayoutDXFObject
|
|
116
|
-
extends Omit<PlotSettingDXFObject, 'subclassMarker'> {
|
|
117
|
-
subclassMarker: 'AcDbLayout';
|
|
118
|
-
layoutName: string;
|
|
119
|
-
controlFlag: LayoutControlFlag;
|
|
120
|
-
tabOrder: number;
|
|
121
|
-
minLimit: Point2D;
|
|
122
|
-
maxLimit: Point2D;
|
|
123
|
-
insertionPoint: Point3D;
|
|
124
|
-
minExtent: Point3D;
|
|
125
|
-
maxExtent: Point3D;
|
|
126
|
-
elevation: number;
|
|
127
|
-
ucsOrigin: Point3D;
|
|
128
|
-
ucsXAxis: Point3D;
|
|
129
|
-
ucsYAxis: Point3D;
|
|
130
|
-
orthographicType: OrthographicType;
|
|
131
|
-
paperSpaceTableId: string;
|
|
132
|
-
viewportId: string;
|
|
133
|
-
namedUcsId?: string;
|
|
134
|
-
orthographicUcsId?: string;
|
|
135
|
-
shadePlotId: string;
|
|
136
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { DXFParserSnippet, Identity } from '../shared/parserGenerator';
|
|
2
|
-
import type { CommonDXFObject } from './common';
|
|
3
|
-
|
|
4
|
-
export const PlotSettingsSnippets: DXFParserSnippet[] = [
|
|
5
|
-
{
|
|
6
|
-
code: 333,
|
|
7
|
-
name: 'shadePlotId',
|
|
8
|
-
parser: Identity,
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
code: 149,
|
|
12
|
-
name: 'imageOriginY',
|
|
13
|
-
parser: Identity,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
code: 148,
|
|
17
|
-
name: 'imageOriginX',
|
|
18
|
-
parser: Identity,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
code: 147,
|
|
22
|
-
name: 'scaleFactor',
|
|
23
|
-
parser: Identity,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
code: 78,
|
|
27
|
-
name: 'shadePlotCustomDPI',
|
|
28
|
-
parser: Identity,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
code: 77,
|
|
32
|
-
name: 'shadePlotResolution',
|
|
33
|
-
parser: Identity,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
code: 76,
|
|
37
|
-
name: 'shadePlotMode',
|
|
38
|
-
parser: Identity,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
code: 75,
|
|
42
|
-
name: 'standardScaleType',
|
|
43
|
-
parser: Identity,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
code: 7,
|
|
47
|
-
name: 'currentStyleSheet',
|
|
48
|
-
parser: Identity,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
code: 74,
|
|
52
|
-
name: 'plotType',
|
|
53
|
-
parser: Identity,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
code: 73,
|
|
57
|
-
name: 'plotRotation',
|
|
58
|
-
parser: Identity,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
code: 72,
|
|
62
|
-
name: 'paperUnit',
|
|
63
|
-
parser: Identity,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
code: 70,
|
|
67
|
-
name: 'layoutFlag',
|
|
68
|
-
parser: Identity,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
code: 143,
|
|
72
|
-
name: 'printScaleDenominator',
|
|
73
|
-
parser: Identity,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
code: 142,
|
|
77
|
-
name: 'printScaleNominator',
|
|
78
|
-
parser: Identity,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
code: 141,
|
|
82
|
-
name: 'windowAreaYMax',
|
|
83
|
-
parser: Identity,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
code: 140,
|
|
87
|
-
name: 'windowAreaYMin',
|
|
88
|
-
parser: Identity,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
code: 49,
|
|
92
|
-
name: 'windowAreaXMax',
|
|
93
|
-
parser: Identity,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
code: 48,
|
|
97
|
-
name: 'windowAreaXMin',
|
|
98
|
-
parser: Identity,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
code: 47,
|
|
102
|
-
name: 'plotOriginY',
|
|
103
|
-
parser: Identity,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
code: 46,
|
|
107
|
-
name: 'plotOriginX',
|
|
108
|
-
parser: Identity,
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
code: 45,
|
|
112
|
-
name: 'paperHeight',
|
|
113
|
-
parser: Identity,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
code: 44,
|
|
117
|
-
name: 'paperWidth',
|
|
118
|
-
parser: Identity,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
code: 43,
|
|
122
|
-
name: 'marginTop',
|
|
123
|
-
parser: Identity,
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
code: 42,
|
|
127
|
-
name: 'marginRight',
|
|
128
|
-
parser: Identity,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
code: 41,
|
|
132
|
-
name: 'marginBottom',
|
|
133
|
-
parser: Identity,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
code: 40,
|
|
137
|
-
name: 'marginLeft',
|
|
138
|
-
parser: Identity,
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
code: 6,
|
|
142
|
-
name: 'plotViewName',
|
|
143
|
-
parser: Identity,
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
code: 4,
|
|
147
|
-
name: 'paperSize',
|
|
148
|
-
parser: Identity,
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
code: 2,
|
|
152
|
-
name: 'configName',
|
|
153
|
-
parser: Identity,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
code: 1,
|
|
157
|
-
name: 'pageSetupName',
|
|
158
|
-
parser: Identity,
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
code: 100,
|
|
162
|
-
name: 'subclassMarker',
|
|
163
|
-
parser: Identity,
|
|
164
|
-
},
|
|
165
|
-
];
|
|
166
|
-
|
|
167
|
-
export enum PlotPaperUnit {
|
|
168
|
-
INCHES = 0,
|
|
169
|
-
MILLIMETERS = 1,
|
|
170
|
-
PIXELS = 2,
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export enum PlotType {
|
|
174
|
-
LAST_SCREEN_DISPLAY = 0,
|
|
175
|
-
DRAWING_EXTENTS = 1,
|
|
176
|
-
DRAWING_LIMITS = 2,
|
|
177
|
-
VIEW_SPECIFIED = 3, // specified in plotViewName
|
|
178
|
-
WINDOW_SPECIFIED = 4, // specified in plotViewName
|
|
179
|
-
LAYOUT_INFORMATION = 5,
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export enum ShadePlotMode {
|
|
183
|
-
AS_DISPLAYED = 0,
|
|
184
|
-
WIREFRAME = 1,
|
|
185
|
-
HIDDEN = 2,
|
|
186
|
-
RENDERED = 3,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export enum ShadePlotResolution {
|
|
190
|
-
DRAFT = 0,
|
|
191
|
-
PREVIEW = 1,
|
|
192
|
-
NORMAL = 2,
|
|
193
|
-
PRESENTATION = 3,
|
|
194
|
-
MAXIMUM = 4,
|
|
195
|
-
CUSTOM = 5,
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export interface PlotSettingDXFObject extends CommonDXFObject {
|
|
199
|
-
subclassMarker: 'AcDbPlotSettings7';
|
|
200
|
-
pageSetupName: string;
|
|
201
|
-
configName: string;
|
|
202
|
-
paperSize: string;
|
|
203
|
-
plotViewName: string;
|
|
204
|
-
marginLeft: number;
|
|
205
|
-
marginBottom: number;
|
|
206
|
-
marginRight: number;
|
|
207
|
-
marginTop: number;
|
|
208
|
-
paperWidth: number;
|
|
209
|
-
paperHeight: number;
|
|
210
|
-
plotOriginX: number;
|
|
211
|
-
plotOriginY: number;
|
|
212
|
-
windowAreaXMin: number;
|
|
213
|
-
windowAreaYMin: number;
|
|
214
|
-
windowAreaXMax: number;
|
|
215
|
-
windowAreaYMax: number;
|
|
216
|
-
printScaleNominator: number;
|
|
217
|
-
printScaleDenominator: number;
|
|
218
|
-
layoutFlag: number;
|
|
219
|
-
plotPaperUnit: PlotPaperUnit;
|
|
220
|
-
plotRotation: 0 | 1 | 2 | 3;
|
|
221
|
-
plotType: PlotType;
|
|
222
|
-
currentStyleSheet: string;
|
|
223
|
-
standardScaleType: number; // see https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-1113675E-AB07-4567-801A-310CDE0D56E9
|
|
224
|
-
shadePlotMode: ShadePlotMode;
|
|
225
|
-
shadePlotResolution: ShadePlotResolution;
|
|
226
|
-
shadePlotCustomDPI?: number; // 100 ~ 32767
|
|
227
|
-
scaleFactor: number;
|
|
228
|
-
imageOriginX: number;
|
|
229
|
-
imageOriginY: number;
|
|
230
|
-
shadePlotId: string;
|
|
231
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { HydratedDxfObject, DxfDictionary, DxfObject } from './types';
|
|
2
|
-
|
|
3
|
-
export function createObjectTree(objects: DxfObject[]) {
|
|
4
|
-
const objectMap = Object.fromEntries(
|
|
5
|
-
objects.map((object) => [object.handle, object as HydratedDxfObject]),
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
for (const object of objects) {
|
|
9
|
-
hydrateParent(object, objectMap);
|
|
10
|
-
hydrateDictionary(object, objectMap);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return objects[0];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function hydrateParent(
|
|
17
|
-
object: HydratedDxfObject,
|
|
18
|
-
objectMap: Record<string, HydratedDxfObject>,
|
|
19
|
-
) {
|
|
20
|
-
if (isDictionary(object) && object.ownerDictionaryIdSoft === '0') return;
|
|
21
|
-
|
|
22
|
-
if (object.ownerDictionaryIdSoft) {
|
|
23
|
-
object.ownerDictionarySoft = objectMap[object.ownerDictionaryIdSoft];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (object.ownerDictionaryIdHard) {
|
|
27
|
-
object.ownerDictionaryHard = objectMap[object.ownerDictionaryIdHard];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (object.ownerObjectId) {
|
|
31
|
-
object.ownerObject = objectMap[object.ownerObjectId];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function hydrateDictionary(
|
|
36
|
-
object: HydratedDxfObject,
|
|
37
|
-
objectMap: Record<string, HydratedDxfObject>,
|
|
38
|
-
) {
|
|
39
|
-
if (!isDictionary(object) || !object.entries) return;
|
|
40
|
-
|
|
41
|
-
object.entries = Object.fromEntries(
|
|
42
|
-
(object.entries as any).map(
|
|
43
|
-
({ name, objectId }: Record<string, string>) => [
|
|
44
|
-
name,
|
|
45
|
-
objectMap[objectId],
|
|
46
|
-
],
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isDictionary(object: HydratedDxfObject): object is DxfDictionary {
|
|
52
|
-
return (object as any).subclassMarker === 'AcDbDictionary';
|
|
53
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface DxfObject {
|
|
2
|
-
name: string;
|
|
3
|
-
handle: string;
|
|
4
|
-
ownerDictionaryIdSoft: string;
|
|
5
|
-
ownerDictionaryIdHard?: string;
|
|
6
|
-
ownerObjectId?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface HydratedDxfObject extends DxfObject {
|
|
10
|
-
ownerDictionarySoft?: HydratedDxfObject;
|
|
11
|
-
ownerDictionaryHard?: HydratedDxfObject;
|
|
12
|
-
ownerObject?: HydratedDxfObject;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface DxfDictionary extends HydratedDxfObject {
|
|
16
|
-
entries?: Record<string, HydratedDxfObject>;
|
|
17
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ScannerGroup } from '../DxfArrayScanner';
|
|
2
|
-
|
|
3
|
-
let lastHandle = 0;
|
|
4
|
-
|
|
5
|
-
export function ensureHandle(entity: any) {
|
|
6
|
-
if (!entity) {
|
|
7
|
-
throw new TypeError('entity cannot be undefined or null');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!entity.handle) {
|
|
11
|
-
entity.handle = lastHandle++;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* group이 `code`와 `value`를 갖는지 확인
|
|
17
|
-
* `value`가 `null`이나 `undefined`인 경우 아무거나 다 매칭한다고 가정한다.
|
|
18
|
-
*/
|
|
19
|
-
export function isMatched(group: ScannerGroup, code: number, value?: any) {
|
|
20
|
-
return group.code === code && (value == null || group.value === value);
|
|
21
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Point2D, Point3D } from '../../types';
|
|
2
|
-
import type DxfArrayScanner from '../DxfArrayScanner';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Parses the 2D or 3D coordinate, vector, or point. When complete,
|
|
6
|
-
* the scanner remains on the last group of the coordinate.
|
|
7
|
-
*/
|
|
8
|
-
export function parsePoint(scanner: DxfArrayScanner): Point3D | Point2D {
|
|
9
|
-
const point = {} as Point3D;
|
|
10
|
-
|
|
11
|
-
// Reread group for the first coordinate
|
|
12
|
-
scanner.rewind();
|
|
13
|
-
let curr = scanner.next();
|
|
14
|
-
const firstCode = curr.code;
|
|
15
|
-
point.x = curr.value as number;
|
|
16
|
-
|
|
17
|
-
curr = scanner.next();
|
|
18
|
-
if (curr.code !== firstCode + 10)
|
|
19
|
-
throw new Error(
|
|
20
|
-
'Expected code for point value to be ' +
|
|
21
|
-
20 +
|
|
22
|
-
' but got ' +
|
|
23
|
-
curr.code +
|
|
24
|
-
'.',
|
|
25
|
-
);
|
|
26
|
-
point.y = curr.value as number;
|
|
27
|
-
|
|
28
|
-
curr = scanner.next();
|
|
29
|
-
if (curr.code !== firstCode + 20) {
|
|
30
|
-
// Only the x and y are specified. Don't read z.
|
|
31
|
-
scanner.rewind(); // Let the calling code advance off the point
|
|
32
|
-
return point;
|
|
33
|
-
}
|
|
34
|
-
point.z = curr.value as number;
|
|
35
|
-
|
|
36
|
-
return point;
|
|
37
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import DxfArrayScanner from '../DxfArrayScanner';
|
|
2
|
-
import { createParser, Identity } from './parserGenerator';
|
|
3
|
-
|
|
4
|
-
describe('createParser', () => {
|
|
5
|
-
it('snippet을 소모하고 name이 있으면 object에 넣어야 한다.', () => {
|
|
6
|
-
const parse = createParser([
|
|
7
|
-
{
|
|
8
|
-
code: 1,
|
|
9
|
-
name: 'a',
|
|
10
|
-
parser: Identity,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
code: 2,
|
|
14
|
-
name: 'b',
|
|
15
|
-
parser: Identity,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
code: 3,
|
|
19
|
-
name: 'c',
|
|
20
|
-
parser: Identity,
|
|
21
|
-
},
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
const scanner = new DxfArrayScanner([
|
|
25
|
-
'1',
|
|
26
|
-
'x',
|
|
27
|
-
'2',
|
|
28
|
-
'y',
|
|
29
|
-
'3',
|
|
30
|
-
'z',
|
|
31
|
-
'0',
|
|
32
|
-
'EOF',
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
const obj = {} as any;
|
|
36
|
-
let curr = scanner.next();
|
|
37
|
-
parse(curr, scanner, obj);
|
|
38
|
-
|
|
39
|
-
expect(obj.a).toBe('x');
|
|
40
|
-
expect(obj.b).toBe('y');
|
|
41
|
-
expect(obj.c).toBe('z');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('정해진 snippet을 소모하고 나면 파서가 종료해야한다.', () => {
|
|
45
|
-
const parse = createParser([
|
|
46
|
-
{
|
|
47
|
-
code: 1,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
code: 2,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
code: 3,
|
|
54
|
-
},
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
const scanner = new DxfArrayScanner([
|
|
58
|
-
'1',
|
|
59
|
-
'',
|
|
60
|
-
'2',
|
|
61
|
-
'',
|
|
62
|
-
'3',
|
|
63
|
-
'',
|
|
64
|
-
'1',
|
|
65
|
-
'',
|
|
66
|
-
'2',
|
|
67
|
-
'',
|
|
68
|
-
'0',
|
|
69
|
-
'EOF',
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
let curr = scanner.next();
|
|
73
|
-
parse(curr, scanner, {});
|
|
74
|
-
|
|
75
|
-
curr = scanner.next();
|
|
76
|
-
expect(curr.code).toBe(1);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('isMultiple이 걸린 경우 snippet을 소모해선 안된다', () => {
|
|
80
|
-
const parse = createParser([
|
|
81
|
-
{
|
|
82
|
-
code: 1,
|
|
83
|
-
name: 'a',
|
|
84
|
-
isMultiple: true,
|
|
85
|
-
parser: Identity,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
code: 2,
|
|
89
|
-
name: 'b',
|
|
90
|
-
parser: Identity,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
code: 3,
|
|
94
|
-
name: 'c',
|
|
95
|
-
parser: Identity,
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
|
|
99
|
-
const scanner = new DxfArrayScanner([
|
|
100
|
-
'1',
|
|
101
|
-
'x',
|
|
102
|
-
'2',
|
|
103
|
-
'y',
|
|
104
|
-
'3',
|
|
105
|
-
'z',
|
|
106
|
-
'1',
|
|
107
|
-
'u',
|
|
108
|
-
'2',
|
|
109
|
-
'v',
|
|
110
|
-
'0',
|
|
111
|
-
'EOF',
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
const obj = {} as any;
|
|
115
|
-
let curr = scanner.next();
|
|
116
|
-
parse(curr, scanner, obj);
|
|
117
|
-
|
|
118
|
-
expect(obj.a instanceof Array).toBeTruthy();
|
|
119
|
-
expect(obj.a[0]).toBe('x');
|
|
120
|
-
expect(obj.a[1]).toBe('u');
|
|
121
|
-
|
|
122
|
-
curr = scanner.next();
|
|
123
|
-
expect(curr.code).toBe(2);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('pushContext가 걸린 경우, 새로 생긴 맥락부터 뒤져본다.', () => {
|
|
127
|
-
const parse = createParser([
|
|
128
|
-
{
|
|
129
|
-
code: 1,
|
|
130
|
-
name: 'a',
|
|
131
|
-
parser: Identity,
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
code: 2,
|
|
135
|
-
name: 'b',
|
|
136
|
-
parser: Identity,
|
|
137
|
-
pushContext: true,
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
code: 1,
|
|
141
|
-
name: 'c',
|
|
142
|
-
parser: Identity,
|
|
143
|
-
},
|
|
144
|
-
]);
|
|
145
|
-
|
|
146
|
-
const scanner = new DxfArrayScanner([
|
|
147
|
-
'1',
|
|
148
|
-
'x',
|
|
149
|
-
'2',
|
|
150
|
-
'y',
|
|
151
|
-
'1',
|
|
152
|
-
'z',
|
|
153
|
-
'0',
|
|
154
|
-
'EOF',
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
const obj = {} as any;
|
|
158
|
-
let curr = scanner.next();
|
|
159
|
-
parse(curr, scanner, obj);
|
|
160
|
-
|
|
161
|
-
expect(obj.a).toBe('z');
|
|
162
|
-
expect(obj.c).toBe('x');
|
|
163
|
-
});
|
|
164
|
-
});
|