dxf-json 0.0.1
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/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/pull_request_template.md +23 -0
- package/.github/workflows/npm-publish.yml +55 -0
- package/.swcrc +8 -0
- package/LICENSE +674 -0
- package/README.md +567 -0
- package/jest.config.js +20 -0
- package/package.json +56 -0
- package/src/consts/block.ts +22 -0
- package/src/consts/color.ts +6 -0
- package/src/consts/config.ts +2 -0
- package/src/consts/dimension.ts +69 -0
- package/src/consts/hatch.ts +52 -0
- package/src/consts/header.ts +10 -0
- package/src/consts/index.ts +9 -0
- package/src/consts/lineweight.ts +5 -0
- package/src/consts/measurement.ts +4 -0
- package/src/consts/obscuredLineTypes.ts +21 -0
- package/src/consts/scene.ts +2 -0
- package/src/consts/viewport.ts +62 -0
- package/src/index.ts +6 -0
- package/src/parser/AutoCadColorIndex.ts +265 -0
- package/src/parser/DxfArrayScanner.ts +161 -0
- package/src/parser/DxfParser.ts +108 -0
- package/src/parser/ParseHelpers.ts +124 -0
- package/src/parser/blocks/blocks.test.ts +97 -0
- package/src/parser/blocks/index.ts +88 -0
- package/src/parser/blocks/types.ts +15 -0
- package/src/parser/entities/arc/index.ts +2 -0
- package/src/parser/entities/arc/parser.ts +67 -0
- package/src/parser/entities/arc/types.ts +13 -0
- package/src/parser/entities/attdef/consts.ts +12 -0
- package/src/parser/entities/attdef/index.ts +3 -0
- package/src/parser/entities/attdef/parser.ts +119 -0
- package/src/parser/entities/attdef/types.ts +19 -0
- package/src/parser/entities/attribute/consts.ts +6 -0
- package/src/parser/entities/attribute/index.ts +3 -0
- package/src/parser/entities/attribute/parser.ts +198 -0
- package/src/parser/entities/attribute/types.ts +31 -0
- package/src/parser/entities/circle/index.ts +2 -0
- package/src/parser/entities/circle/parser.ts +58 -0
- package/src/parser/entities/circle/types.ts +11 -0
- package/src/parser/entities/dimension/common.ts +98 -0
- package/src/parser/entities/dimension/index.ts +24 -0
- package/src/parser/entities/dimension/types.ts +65 -0
- package/src/parser/entities/ellipse/index.ts +2 -0
- package/src/parser/entities/ellipse/parser.ts +66 -0
- package/src/parser/entities/ellipse/types.ts +13 -0
- package/src/parser/entities/entities.test.ts +86 -0
- package/src/parser/entities/hatch/boundaryPathData/edge.ts +190 -0
- package/src/parser/entities/hatch/boundaryPathData/index.ts +27 -0
- package/src/parser/entities/hatch/boundaryPathData/polyline.ts +43 -0
- package/src/parser/entities/hatch/boundaryPathData/shared.ts +16 -0
- package/src/parser/entities/hatch/index.ts +189 -0
- package/src/parser/entities/hatch/patternData.ts +57 -0
- package/src/parser/entities/hatch/types/boundaryPath.ts +72 -0
- package/src/parser/entities/hatch/types/definitionLine.ts +14 -0
- package/src/parser/entities/hatch/types/hatch.ts +47 -0
- package/src/parser/entities/hatch/types/index.ts +3 -0
- package/src/parser/entities/index.ts +87 -0
- package/src/parser/entities/insert/index.ts +2 -0
- package/src/parser/entities/insert/parser.ts +106 -0
- package/src/parser/entities/insert/types.ts +19 -0
- package/src/parser/entities/leader/consts.ts +6 -0
- package/src/parser/entities/leader/index.ts +3 -0
- package/src/parser/entities/leader/parser.ts +119 -0
- package/src/parser/entities/leader/types.ts +24 -0
- package/src/parser/entities/line/index.ts +2 -0
- package/src/parser/entities/line/parser.ts +55 -0
- package/src/parser/entities/line/types.ts +11 -0
- package/src/parser/entities/lwpolyline/consts.ts +4 -0
- package/src/parser/entities/lwpolyline/index.ts +3 -0
- package/src/parser/entities/lwpolyline/parser.ts +122 -0
- package/src/parser/entities/lwpolyline/types.ts +21 -0
- package/src/parser/entities/mtext/consts.ts +5 -0
- package/src/parser/entities/mtext/index.ts +3 -0
- package/src/parser/entities/mtext/parser.ts +195 -0
- package/src/parser/entities/mtext/types.ts +34 -0
- package/src/parser/entities/point/index.ts +2 -0
- package/src/parser/entities/point/parser.ts +60 -0
- package/src/parser/entities/point/types.ts +10 -0
- package/src/parser/entities/polyline/consts.ts +17 -0
- package/src/parser/entities/polyline/index.ts +3 -0
- package/src/parser/entities/polyline/parser.ts +126 -0
- package/src/parser/entities/polyline/types.ts +20 -0
- package/src/parser/entities/section/index.ts +2 -0
- package/src/parser/entities/section/parser.ts +104 -0
- package/src/parser/entities/section/types.ts +20 -0
- package/src/parser/entities/shared.ts +166 -0
- package/src/parser/entities/solid/index.ts +2 -0
- package/src/parser/entities/solid/parser.ts +56 -0
- package/src/parser/entities/solid/types.ts +10 -0
- package/src/parser/entities/spline/consts.ts +8 -0
- package/src/parser/entities/spline/index.ts +3 -0
- package/src/parser/entities/spline/parser.ts +121 -0
- package/src/parser/entities/spline/types.ts +22 -0
- package/src/parser/entities/text/consts.ts +21 -0
- package/src/parser/entities/text/index.ts +3 -0
- package/src/parser/entities/text/parser.ts +117 -0
- package/src/parser/entities/text/types.ts +21 -0
- package/src/parser/entities/vertex/consts.ts +10 -0
- package/src/parser/entities/vertex/index.ts +3 -0
- package/src/parser/entities/vertex/parser.ts +90 -0
- package/src/parser/entities/vertex/types.ts +17 -0
- package/src/parser/entities/viewport/index.ts +178 -0
- package/src/parser/entities/viewport/types.ts +58 -0
- package/src/parser/filterDummyBlocks.ts +49 -0
- package/src/parser/header/index.ts +30 -0
- package/src/parser/objects/common.ts +55 -0
- package/src/parser/objects/dictionary.ts +61 -0
- package/src/parser/objects/index.ts +45 -0
- package/src/parser/objects/layout.ts +136 -0
- package/src/parser/objects/plotSettings.ts +231 -0
- package/src/parser/objects/treefy.ts +53 -0
- package/src/parser/objects/types.ts +17 -0
- package/src/parser/shared/index.ts +21 -0
- package/src/parser/shared/parsePoint.ts +37 -0
- package/src/parser/shared/parserGenerator.test.ts +164 -0
- package/src/parser/shared/parserGenerator.ts +180 -0
- package/src/parser/shared/xdata/index.ts +3 -0
- package/src/parser/shared/xdata/interpreter.test.ts +85 -0
- package/src/parser/shared/xdata/interpreter.ts +65 -0
- package/src/parser/shared/xdata/parser.test.ts +66 -0
- package/src/parser/shared/xdata/parser.ts +140 -0
- package/src/parser/shared/xdata/types.ts +22 -0
- package/src/parser/tables/blockRecord/index.ts +2 -0
- package/src/parser/tables/blockRecord/parser.ts +49 -0
- package/src/parser/tables/blockRecord/types.ts +11 -0
- package/src/parser/tables/dimStyle/consts.ts +428 -0
- package/src/parser/tables/dimStyle/index.ts +3 -0
- package/src/parser/tables/dimStyle/parser.ts +37 -0
- package/src/parser/tables/dimStyle/types.ts +164 -0
- package/src/parser/tables/index.ts +2 -0
- package/src/parser/tables/layer/index.ts +2 -0
- package/src/parser/tables/layer/parser.ts +58 -0
- package/src/parser/tables/layer/types.ts +14 -0
- package/src/parser/tables/ltype/consts.ts +6 -0
- package/src/parser/tables/ltype/index.ts +3 -0
- package/src/parser/tables/ltype/parser.ts +110 -0
- package/src/parser/tables/ltype/types.ts +23 -0
- package/src/parser/tables/parser.ts +100 -0
- package/src/parser/tables/shared.ts +32 -0
- package/src/parser/tables/style/index.ts +2 -0
- package/src/parser/tables/style/parser.ts +70 -0
- package/src/parser/tables/style/types.ts +15 -0
- package/src/parser/tables/types.ts +15 -0
- package/src/parser/tables/vport/index.ts +2 -0
- package/src/parser/tables/vport/parser.ts +205 -0
- package/src/parser/tables/vport/types.ts +48 -0
- package/src/parser/types.ts +30 -0
- package/src/types/color.ts +5 -0
- package/src/types/dxfHeader.ts +21 -0
- package/src/types/entity.ts +7 -0
- package/src/types/index.ts +30 -0
- package/src/utils/binarySearch.ts +20 -0
- package/src/utils/disjointSet.ts +52 -0
- package/src/utils/flooding.ts +37 -0
- package/src/utils/functional.ts +124 -0
- package/src/utils/graph.ts +53 -0
- package/src/utils/index.ts +102 -0
- package/src/utils/queue.ts +77 -0
- package/src/utils/triangle.ts +28 -0
- package/tsconfig.json +34 -0
- package/webpack.config.js +46 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type DxfArrayScanner from '../DxfArrayScanner';
|
|
2
|
+
import { ScannerGroup } from '../DxfArrayScanner';
|
|
3
|
+
import { ensureHandle, isMatched } from '../shared';
|
|
4
|
+
|
|
5
|
+
import { ArcEntityParser } from './arc';
|
|
6
|
+
import { AttDefEntityParser } from './attdef';
|
|
7
|
+
import { AttributeEntityParser } from './attribute';
|
|
8
|
+
import { CircleEntityParser } from './circle';
|
|
9
|
+
import Dimension from './dimension';
|
|
10
|
+
import { EllipseEntityParser } from './ellipse';
|
|
11
|
+
import { InsertEntityParser } from './insert';
|
|
12
|
+
import { LeaderEntityParser } from './leader';
|
|
13
|
+
import { LineEntityParser } from './line/parser';
|
|
14
|
+
import { LWPolylineParser } from './lwpolyline';
|
|
15
|
+
import { MTextEntityParser } from './mtext/parser';
|
|
16
|
+
import { PointEntityParser } from './point';
|
|
17
|
+
import { PolylineParser } from './polyline';
|
|
18
|
+
import { SectionEntityParser } from './section';
|
|
19
|
+
import { SolidEntityParser } from './solid';
|
|
20
|
+
import { SplineEntityParser } from './spline';
|
|
21
|
+
import { TextEntityParser } from './text';
|
|
22
|
+
import { HatchEntityParser } from './hatch';
|
|
23
|
+
import Viewport from './viewport';
|
|
24
|
+
import { CommonDxfEntity } from './shared';
|
|
25
|
+
|
|
26
|
+
const Parsers = Object.fromEntries(
|
|
27
|
+
[
|
|
28
|
+
ArcEntityParser,
|
|
29
|
+
AttDefEntityParser,
|
|
30
|
+
AttributeEntityParser,
|
|
31
|
+
CircleEntityParser,
|
|
32
|
+
Dimension,
|
|
33
|
+
EllipseEntityParser,
|
|
34
|
+
InsertEntityParser,
|
|
35
|
+
LeaderEntityParser,
|
|
36
|
+
LineEntityParser,
|
|
37
|
+
LWPolylineParser,
|
|
38
|
+
MTextEntityParser,
|
|
39
|
+
PointEntityParser,
|
|
40
|
+
PolylineParser,
|
|
41
|
+
SectionEntityParser,
|
|
42
|
+
SolidEntityParser,
|
|
43
|
+
SplineEntityParser,
|
|
44
|
+
TextEntityParser,
|
|
45
|
+
HatchEntityParser,
|
|
46
|
+
Viewport,
|
|
47
|
+
].map((parser) => [parser.ForEntityName, new parser()]),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Is called after the parser first reads the 0:ENTITIES group. The scanner
|
|
52
|
+
* should be on the start of the first entity already.
|
|
53
|
+
*/
|
|
54
|
+
export function parseEntities(
|
|
55
|
+
curr: ScannerGroup,
|
|
56
|
+
scanner: DxfArrayScanner,
|
|
57
|
+
): CommonDxfEntity[] {
|
|
58
|
+
let entities: any[] = [];
|
|
59
|
+
|
|
60
|
+
while (!isMatched(curr, 0, 'EOF')) {
|
|
61
|
+
if (curr.code === 0) {
|
|
62
|
+
// BLOCK 섹션 안에 ENTITY 섹션이 있을 수도 있고
|
|
63
|
+
// ENTITY 섹션만 따로 있을 수도 있음
|
|
64
|
+
// BLOCK 섹션 안에 들어있는 ENTITY는 ENDBLK으로 끝남
|
|
65
|
+
if (curr.value === 'ENDBLK' || curr.value === 'ENDSEC') {
|
|
66
|
+
scanner.rewind();
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const handler = Parsers[curr.value];
|
|
71
|
+
if (handler) {
|
|
72
|
+
const entityType = curr.value;
|
|
73
|
+
curr = scanner.next();
|
|
74
|
+
|
|
75
|
+
const entity = handler.parseEntity(scanner, curr) as any;
|
|
76
|
+
entity.type = entityType;
|
|
77
|
+
ensureHandle(entity);
|
|
78
|
+
entities.push(entity);
|
|
79
|
+
} else {
|
|
80
|
+
console.warn(`Unsupported ENTITY type: ${curr.value}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
curr = scanner.next();
|
|
85
|
+
}
|
|
86
|
+
return entities;
|
|
87
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { CommonEntitySnippets } from '../shared';
|
|
11
|
+
import type { InsertEntity } from './types';
|
|
12
|
+
|
|
13
|
+
const DefaultInsertEntity = {
|
|
14
|
+
xScale: 1,
|
|
15
|
+
yScale: 1,
|
|
16
|
+
zScale: 1,
|
|
17
|
+
rotation: 0,
|
|
18
|
+
columnCount: 0,
|
|
19
|
+
rowCount: 0,
|
|
20
|
+
columnSpacing: 0,
|
|
21
|
+
rowSpacing: 0,
|
|
22
|
+
extrusionDirection: { x: 0, y: 0, z: 1 },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const InsertEntityParserSnippets: DXFParserSnippet[] = [
|
|
26
|
+
{
|
|
27
|
+
code: 210,
|
|
28
|
+
name: 'extrusionDirection',
|
|
29
|
+
parser: PointParser,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: 45,
|
|
33
|
+
name: 'rowSpacing',
|
|
34
|
+
parser: Identity,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: 44,
|
|
38
|
+
name: 'columnSpacing',
|
|
39
|
+
parser: Identity,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: 71,
|
|
43
|
+
name: 'rowCount',
|
|
44
|
+
parser: Identity,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: 70,
|
|
48
|
+
name: 'columnCount',
|
|
49
|
+
parser: Identity,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: 50,
|
|
53
|
+
name: 'rotation',
|
|
54
|
+
parser: Identity,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: 43,
|
|
58
|
+
name: 'zScale',
|
|
59
|
+
parser: Identity,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
code: 42,
|
|
63
|
+
name: 'yScale',
|
|
64
|
+
parser: Identity,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
code: 41,
|
|
68
|
+
name: 'xScale',
|
|
69
|
+
parser: Identity,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
code: 10,
|
|
73
|
+
name: 'insertionPoint',
|
|
74
|
+
parser: PointParser,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
code: 2,
|
|
78
|
+
name: 'name',
|
|
79
|
+
parser: Identity,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
code: 66,
|
|
83
|
+
name: 'isVariableAttributes',
|
|
84
|
+
parser: ToBoolean,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
code: 100,
|
|
88
|
+
name: 'subclassMarker',
|
|
89
|
+
parser: Identity,
|
|
90
|
+
},
|
|
91
|
+
...CommonEntitySnippets,
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
export class InsertEntityParser {
|
|
95
|
+
static ForEntityName = 'INSERT';
|
|
96
|
+
private parser = createParser(
|
|
97
|
+
InsertEntityParserSnippets,
|
|
98
|
+
DefaultInsertEntity,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
|
|
102
|
+
const entity = {} as any;
|
|
103
|
+
this.parser(curr, scanner, entity);
|
|
104
|
+
return entity as InsertEntity;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Point3D } from '../../../types';
|
|
2
|
+
import type { CommonDxfEntity } from '../shared';
|
|
3
|
+
|
|
4
|
+
export interface InsertEntity extends CommonDxfEntity {
|
|
5
|
+
type: 'INSERT';
|
|
6
|
+
subclassMarker: 'AcDbBlockReference';
|
|
7
|
+
isVariableAttributes?: boolean;
|
|
8
|
+
name: string;
|
|
9
|
+
insertionPoint: Point3D;
|
|
10
|
+
xScale: number;
|
|
11
|
+
yScale: number;
|
|
12
|
+
zScale: number;
|
|
13
|
+
rotation: number; // degree
|
|
14
|
+
columnCount: number;
|
|
15
|
+
rowCount: number;
|
|
16
|
+
columnSpacing: number;
|
|
17
|
+
rowSpacing: number;
|
|
18
|
+
extrusionDirection: Point3D;
|
|
19
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 { CommonEntitySnippets } from '../shared';
|
|
11
|
+
import type { LeaderEntity } from './types';
|
|
12
|
+
|
|
13
|
+
const DefaultLeaderEntity = {
|
|
14
|
+
isArrowheadEnabled: true,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const LeaderEntityParserSnippets: DXFParserSnippet[] = [
|
|
18
|
+
{
|
|
19
|
+
code: 213,
|
|
20
|
+
name: 'offsetFromAnnotation',
|
|
21
|
+
parser: PointParser,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: 212,
|
|
25
|
+
name: 'offsetFromBlock',
|
|
26
|
+
parser: PointParser,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: 211,
|
|
30
|
+
name: 'horizontalDirection',
|
|
31
|
+
parser: PointParser,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
code: 210,
|
|
35
|
+
name: 'normal',
|
|
36
|
+
parser: PointParser,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: 340,
|
|
40
|
+
name: 'associatedAnnotation',
|
|
41
|
+
parser: Identity,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
code: 77,
|
|
45
|
+
name: 'byBlockColor',
|
|
46
|
+
parser: Identity,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
code: 10,
|
|
50
|
+
name: 'vertices',
|
|
51
|
+
parser: PointParser,
|
|
52
|
+
isMultiple: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
code: 76,
|
|
56
|
+
name: 'numberOfVertices',
|
|
57
|
+
parser: Identity,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
code: 41,
|
|
61
|
+
name: 'textWidth',
|
|
62
|
+
parser: Identity,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
code: 40,
|
|
66
|
+
name: 'textHeight',
|
|
67
|
+
parser: Identity,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
code: 75,
|
|
71
|
+
name: 'isHooklineExists',
|
|
72
|
+
parser: ToBoolean,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
code: 74,
|
|
76
|
+
name: 'isHooklineSameDirection',
|
|
77
|
+
parser: ToBoolean,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
code: 73,
|
|
81
|
+
name: 'leaderCreationFlag',
|
|
82
|
+
parser: Identity,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
code: 72,
|
|
86
|
+
name: 'isSpline',
|
|
87
|
+
parser: ToBoolean,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
code: 71,
|
|
91
|
+
name: 'isArrowheadEnabled',
|
|
92
|
+
parser: ToBoolean,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: 3,
|
|
96
|
+
name: 'styleName',
|
|
97
|
+
parser: Identity,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
code: 100,
|
|
101
|
+
name: 'subclassMarker',
|
|
102
|
+
parser: Identity,
|
|
103
|
+
},
|
|
104
|
+
...CommonEntitySnippets,
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
export class LeaderEntityParser {
|
|
108
|
+
static ForEntityName = 'LEADER';
|
|
109
|
+
private parser = createParser(
|
|
110
|
+
LeaderEntityParserSnippets,
|
|
111
|
+
DefaultLeaderEntity,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
|
|
115
|
+
const entity = {} as any;
|
|
116
|
+
this.parser(curr, scanner, entity);
|
|
117
|
+
return entity as LeaderEntity;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Point3D } from '../../../types';
|
|
2
|
+
import type { CommonDxfEntity } from '../shared';
|
|
3
|
+
import type { LeaderCreationFlag } from './consts';
|
|
4
|
+
|
|
5
|
+
export interface LeaderEntity extends CommonDxfEntity {
|
|
6
|
+
type: 'LEADER';
|
|
7
|
+
subclassMarker: 'AcDbLeader';
|
|
8
|
+
styleName: string;
|
|
9
|
+
isArrowheadEnabled: boolean;
|
|
10
|
+
isSpline: boolean;
|
|
11
|
+
leaderCreationFlag: LeaderCreationFlag;
|
|
12
|
+
isHooklineSameDirection: boolean;
|
|
13
|
+
isHooklineExists: boolean;
|
|
14
|
+
textHeight?: number;
|
|
15
|
+
textWidth?: number;
|
|
16
|
+
numberOfVertices?: number;
|
|
17
|
+
vertices: Point3D[];
|
|
18
|
+
byBlockColor?: number;
|
|
19
|
+
associatedAnnotation?: string;
|
|
20
|
+
normal?: Point3D;
|
|
21
|
+
horizontalDirection?: Point3D;
|
|
22
|
+
offsetFromBlock?: Point3D;
|
|
23
|
+
offsetFromAnnotation?: Point3D;
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import type { LineEntity } from './types';
|
|
11
|
+
|
|
12
|
+
const DefaultLineEntity = {
|
|
13
|
+
thickness: 0,
|
|
14
|
+
extrusionDirection: { x: 0, y: 0, z: 1 },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const LineEntityParserSnippets: DXFParserSnippet[] = [
|
|
18
|
+
{
|
|
19
|
+
code: 210,
|
|
20
|
+
name: 'extrusionDirection',
|
|
21
|
+
parser: PointParser,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: 11,
|
|
25
|
+
name: 'endPoint',
|
|
26
|
+
parser: PointParser,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: 10,
|
|
30
|
+
name: 'startPoint',
|
|
31
|
+
parser: PointParser,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
code: 39,
|
|
35
|
+
name: 'thickness',
|
|
36
|
+
parser: Identity,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: 100,
|
|
40
|
+
name: 'subclassMarker',
|
|
41
|
+
parser: Identity,
|
|
42
|
+
},
|
|
43
|
+
...CommonEntitySnippets,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
export class LineEntityParser {
|
|
47
|
+
static ForEntityName = 'LINE';
|
|
48
|
+
private parser = createParser(LineEntityParserSnippets, DefaultLineEntity);
|
|
49
|
+
|
|
50
|
+
parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
|
|
51
|
+
const entity = {} as any;
|
|
52
|
+
this.parser(curr, scanner, entity);
|
|
53
|
+
return entity as LineEntity;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Point3D } from '../../../types';
|
|
2
|
+
import type { CommonDxfEntity } from '../shared';
|
|
3
|
+
|
|
4
|
+
export interface LineEntity extends CommonDxfEntity {
|
|
5
|
+
type: 'LINE';
|
|
6
|
+
subclassMarker: 'AcDbLine';
|
|
7
|
+
thickness: number;
|
|
8
|
+
startPoint: Point3D;
|
|
9
|
+
endPoint: Point3D;
|
|
10
|
+
extrusionDirection: Point3D;
|
|
11
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
import type { LWPolylineEntity } from './types';
|
|
11
|
+
|
|
12
|
+
const DefaultLWPolylineEntity = {
|
|
13
|
+
flag: 0,
|
|
14
|
+
elevation: 0,
|
|
15
|
+
thickness: 0,
|
|
16
|
+
extrusionDirection: { x: 0, y: 0, z: 1 },
|
|
17
|
+
vertices: [],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const DefaultLWPolylineVertex = {
|
|
21
|
+
bulge: 0,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const LWPolylineVertexSnippets: DXFParserSnippet[] = [
|
|
25
|
+
{
|
|
26
|
+
code: 42,
|
|
27
|
+
name: 'bulge',
|
|
28
|
+
parser: Identity,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
code: 41,
|
|
32
|
+
name: 'endWidth',
|
|
33
|
+
parser: Identity,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
code: 40,
|
|
37
|
+
name: 'startWidth',
|
|
38
|
+
parser: Identity,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
code: 91,
|
|
42
|
+
name: 'id',
|
|
43
|
+
parser: Identity,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
code: 20,
|
|
47
|
+
name: 'y',
|
|
48
|
+
parser: Identity,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
code: 10,
|
|
52
|
+
name: 'x',
|
|
53
|
+
parser: Identity,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const LWPolylineSnippets: DXFParserSnippet[] = [
|
|
58
|
+
{
|
|
59
|
+
code: 210,
|
|
60
|
+
name: 'extrusionDirection',
|
|
61
|
+
parser: PointParser,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
code: 10,
|
|
65
|
+
name: 'vertices',
|
|
66
|
+
isMultiple: true,
|
|
67
|
+
parser(curr, scanner) {
|
|
68
|
+
const entity = {} as any;
|
|
69
|
+
createParser(LWPolylineVertexSnippets, DefaultLWPolylineVertex)(
|
|
70
|
+
curr,
|
|
71
|
+
scanner,
|
|
72
|
+
entity,
|
|
73
|
+
);
|
|
74
|
+
return entity;
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
code: 39,
|
|
79
|
+
name: 'thickness',
|
|
80
|
+
parser: Identity,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
code: 38,
|
|
84
|
+
name: 'elevation',
|
|
85
|
+
parser: Identity,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
code: 43,
|
|
89
|
+
name: 'constantWidth',
|
|
90
|
+
parser: Identity,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
code: 70,
|
|
94
|
+
name: 'flag',
|
|
95
|
+
parser: Identity,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
code: 90,
|
|
99
|
+
name: 'numberOfVertices',
|
|
100
|
+
parser: Identity,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
code: 100,
|
|
104
|
+
name: 'subclassMarker',
|
|
105
|
+
parser: Identity,
|
|
106
|
+
},
|
|
107
|
+
...CommonEntitySnippets,
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
export class LWPolylineParser {
|
|
111
|
+
static ForEntityName = 'LWPOLYLINE';
|
|
112
|
+
|
|
113
|
+
parseEntity(scanner: DxfArrayScanner, curr: ScannerGroup) {
|
|
114
|
+
const entity = {} as any;
|
|
115
|
+
createParser(LWPolylineSnippets, DefaultLWPolylineEntity)(
|
|
116
|
+
curr,
|
|
117
|
+
scanner,
|
|
118
|
+
entity,
|
|
119
|
+
);
|
|
120
|
+
return entity as LWPolylineEntity;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Point2D, Point3D } from '../../../types';
|
|
2
|
+
import type { CommonDxfEntity } from '../shared';
|
|
3
|
+
|
|
4
|
+
export interface LWPolylineEntity extends CommonDxfEntity {
|
|
5
|
+
type: 'LWPOLYLINE';
|
|
6
|
+
subclassMarker: 'AcDbPolyline';
|
|
7
|
+
numberOfVertices: number;
|
|
8
|
+
flag: number;
|
|
9
|
+
constantWidth?: number;
|
|
10
|
+
elevation: number;
|
|
11
|
+
thickness: number;
|
|
12
|
+
extrusionDirection: Point3D;
|
|
13
|
+
vertices: LWPolylineVertex[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LWPolylineVertex extends Point2D {
|
|
17
|
+
id: number;
|
|
18
|
+
startWidth?: number;
|
|
19
|
+
endWidth?: number;
|
|
20
|
+
bulge: number;
|
|
21
|
+
}
|