build-dxf 0.0.52 → 0.0.54
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/README.md +167 -156
- package/package.json +45 -45
- package/src/build.js +431 -373
- package/src/index.css +1 -1
- package/src/utils/DxfSystem/components/Dxf.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/index.d.ts +1 -1
- package/src/utils/DxfSystem/utils/CAD.d.ts +16 -0
- package/src/utils/LineSegment.d.ts +5 -0
- package/src/utils/Polygon.d.ts +11 -1
package/README.md
CHANGED
|
@@ -1,157 +1,168 @@
|
|
|
1
|
-
# build-dxf
|
|
2
|
-
|
|
3
|
-
# 安装
|
|
4
|
-
```
|
|
5
|
-
npm i build-dxf
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
# node 使用示例
|
|
9
|
-
```typescript
|
|
10
|
-
import { DxfSystem, ModelDataPlugin, components, utils } from "build-dxf"
|
|
11
|
-
/**
|
|
12
|
-
* json 文件格式为{ start: {x: number, y: number}, end: {x: number, y: number } , insetionArr: {index: number}[] }[]
|
|
13
|
-
*/
|
|
14
|
-
const path = process.argv[2] ?? "./json/d10.json"
|
|
15
|
-
const dxfSystem = new DxfSystem()
|
|
16
|
-
|
|
17
|
-
// 使用模型数据生成插件
|
|
18
|
-
dxfSystem.usePlugin(ModelDataPlugin)
|
|
19
|
-
|
|
20
|
-
// 获取白模数据生成组件
|
|
21
|
-
const whiteModel = dxfSystem.findComponentByType(components.WhiteModel)
|
|
22
|
-
// 获取详情点数据生成组件
|
|
23
|
-
const detailsPoint = dxfSystem.findComponentByType(components.DetailsPoint)
|
|
24
|
-
const threeVJia = dxfSystem.findComponentByName("ThreeVJia")
|
|
25
|
-
|
|
26
|
-
dxfSystem.Dxf.set(path).then(()=> {
|
|
27
|
-
// 监听详情点数据处理完成
|
|
28
|
-
detailsPoint.addEventListener("handleSuccess", () => {
|
|
29
|
-
// 下载dxf文件
|
|
30
|
-
dxfSystem.Dxf.download("01.dxf")
|
|
31
|
-
// 下载白模,obj格式
|
|
32
|
-
whiteModel.downloadOBJ("001.obj")
|
|
33
|
-
// 下载白模,gltf或glb格式, 第二个参数为true时是glb,默认为true
|
|
34
|
-
whiteModel.downloadGltf("001.glb", true)
|
|
35
|
-
|
|
36
|
-
// 下载三维家 json
|
|
37
|
-
threeVJia.download("json.json")
|
|
38
|
-
|
|
39
|
-
// 下载为图片
|
|
40
|
-
dxfSystem.AngleCorrectionDxf.downloadImage("001.jpg")
|
|
41
|
-
|
|
42
|
-
// 下载新json
|
|
43
|
-
dxfSystem.Dxf.downloadOriginalData("data.json")
|
|
44
|
-
|
|
45
|
-
// desPoints 为射线点集合,根据需要使用
|
|
46
|
-
console.log("handleSuccess", detailsPoint.desPoints)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
// trajectory222为轨迹文件数据
|
|
50
|
-
dxfSystem.Dxf.addEventListener("preprocessing", ({ setData, data }) => {
|
|
51
|
-
setData( utils.BoundExt.boundExtbyTraj(data, trajectory222 ) )
|
|
52
|
-
}, { once: true })
|
|
53
|
-
|
|
54
|
-
dxfSystem.Dxf.axisAlignCorr({ groupMethod: "cross", fittingMethod: "max", crossAxistThreshold: 0.08 })
|
|
55
|
-
dxfSystem.Dxf.lineOffset()
|
|
56
|
-
|
|
57
|
-
detailsPoint.set("./json/dp8.json")
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
1.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
2.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
1.
|
|
143
|
-
2.
|
|
144
|
-
3.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
1
|
+
# build-dxf
|
|
2
|
+
|
|
3
|
+
# 安装
|
|
4
|
+
```
|
|
5
|
+
npm i build-dxf
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
# node 使用示例
|
|
9
|
+
```typescript
|
|
10
|
+
import { DxfSystem, ModelDataPlugin, components, utils } from "build-dxf"
|
|
11
|
+
/**
|
|
12
|
+
* json 文件格式为{ start: {x: number, y: number}, end: {x: number, y: number } , insetionArr: {index: number}[] }[]
|
|
13
|
+
*/
|
|
14
|
+
const path = process.argv[2] ?? "./json/d10.json"
|
|
15
|
+
const dxfSystem = new DxfSystem()
|
|
16
|
+
|
|
17
|
+
// 使用模型数据生成插件
|
|
18
|
+
dxfSystem.usePlugin(ModelDataPlugin)
|
|
19
|
+
|
|
20
|
+
// 获取白模数据生成组件
|
|
21
|
+
const whiteModel = dxfSystem.findComponentByType(components.WhiteModel)
|
|
22
|
+
// 获取详情点数据生成组件
|
|
23
|
+
const detailsPoint = dxfSystem.findComponentByType(components.DetailsPoint)
|
|
24
|
+
const threeVJia = dxfSystem.findComponentByName("ThreeVJia")
|
|
25
|
+
|
|
26
|
+
dxfSystem.Dxf.set(path).then(()=> {
|
|
27
|
+
// 监听详情点数据处理完成
|
|
28
|
+
detailsPoint.addEventListener("handleSuccess", () => {
|
|
29
|
+
// 下载dxf文件
|
|
30
|
+
dxfSystem.Dxf.download("01.dxf")
|
|
31
|
+
// 下载白模,obj格式
|
|
32
|
+
whiteModel.downloadOBJ("001.obj")
|
|
33
|
+
// 下载白模,gltf或glb格式, 第二个参数为true时是glb,默认为true
|
|
34
|
+
whiteModel.downloadGltf("001.glb", true)
|
|
35
|
+
|
|
36
|
+
// 下载三维家 json
|
|
37
|
+
threeVJia.download("json.json")
|
|
38
|
+
|
|
39
|
+
// 下载为图片
|
|
40
|
+
dxfSystem.AngleCorrectionDxf.downloadImage("001.jpg")
|
|
41
|
+
|
|
42
|
+
// 下载新json
|
|
43
|
+
dxfSystem.Dxf.downloadOriginalData("data.json")
|
|
44
|
+
|
|
45
|
+
// desPoints 为射线点集合,根据需要使用
|
|
46
|
+
console.log("handleSuccess", detailsPoint.desPoints)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// trajectory222为轨迹文件数据
|
|
50
|
+
dxfSystem.Dxf.addEventListener("preprocessing", ({ setData, data }) => {
|
|
51
|
+
setData( utils.BoundExt.boundExtbyTraj(data, trajectory222 ) )
|
|
52
|
+
}, { once: true })
|
|
53
|
+
|
|
54
|
+
dxfSystem.Dxf.axisAlignCorr({ groupMethod: "cross", fittingMethod: "max", crossAxistThreshold: 0.08 })
|
|
55
|
+
dxfSystem.Dxf.lineOffset()
|
|
56
|
+
|
|
57
|
+
detailsPoint.set("./json/dp8.json")
|
|
58
|
+
|
|
59
|
+
// 获取外扩后的三维家json
|
|
60
|
+
const lines = utils.BoundExt.boundExtbyTraj({
|
|
61
|
+
lines: dxfSystem.Dxf.getLineSegments(),
|
|
62
|
+
trajectory: trajectoryJson // 轨迹json对象,
|
|
63
|
+
wallWidth: 0.12,
|
|
64
|
+
updateDoubleWallGroup: true
|
|
65
|
+
}).lines
|
|
66
|
+
|
|
67
|
+
// 三维家json
|
|
68
|
+
const json = utils.lineDataToThreeVJiaJson(lines, dxfSystem.AngleCorrectionDxf.angle).toJson("测试")
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
# 浏览器编辑功能使用示例
|
|
73
|
+
```html
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div class="w-[100vw] h-[100vh]" ref="dom"> </div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<style scoped></style>
|
|
80
|
+
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import data from "../data/d9.json"
|
|
83
|
+
import { createEditor } from "build-dxf"
|
|
84
|
+
import { onMounted, ref } from "vue"
|
|
85
|
+
import * as THREE from "three"
|
|
86
|
+
import "build-dxf/index.css"
|
|
87
|
+
|
|
88
|
+
const dom = ref<HTMLDivElement>()
|
|
89
|
+
|
|
90
|
+
onMounted(async ()=>{
|
|
91
|
+
if(dom.value) {
|
|
92
|
+
const camera = new THREE.OrthographicCamera( -100, 100, 100, -100, 0.1, 1000 )
|
|
93
|
+
const { dxfSystem } = await createEditor( dom.value, camera )
|
|
94
|
+
dxfSystem.Dxf.set( (data as any) )
|
|
95
|
+
dxfSystem.Dxf.lineOffset()
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
</script>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# 浏览器 使用示例
|
|
104
|
+
```html
|
|
105
|
+
<template>
|
|
106
|
+
<div class="w-[100vw] h-[100vh]">
|
|
107
|
+
<Dxf3DView :lines="(data as any)" :details-point="dp8" />
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<style scoped></style>
|
|
112
|
+
|
|
113
|
+
<script setup lang="ts">
|
|
114
|
+
import { Dxf3DView } from "build-dxf/RenderPlugin"
|
|
115
|
+
import "build-dxf/index.css"
|
|
116
|
+
import data from "../data/d4.json"
|
|
117
|
+
import dp8 from "../data/dp8.json"
|
|
118
|
+
</script>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
# 内置类
|
|
122
|
+
### 1. 核心类
|
|
123
|
+
1. DxfSystem
|
|
124
|
+
|
|
125
|
+
### 核心组件类
|
|
126
|
+
1. Dxf
|
|
127
|
+
2. AngleCorrectionDxf
|
|
128
|
+
3. DoorsAnalysis
|
|
129
|
+
4. ThreeVJia
|
|
130
|
+
5. Variable
|
|
131
|
+
|
|
132
|
+
### 2. 渲染插件组件类
|
|
133
|
+
1. Renderer
|
|
134
|
+
2. DomContainer
|
|
135
|
+
3. DomEventRegister
|
|
136
|
+
4. EventInput
|
|
137
|
+
5. DetailsPointRender
|
|
138
|
+
6. ModelDataRender
|
|
139
|
+
7. OriginalLineRender
|
|
140
|
+
|
|
141
|
+
### 3. 模型数据提供插件组件类
|
|
142
|
+
1. DetailsPoint
|
|
143
|
+
2. DxfLineModel
|
|
144
|
+
3. WhiteModel
|
|
145
|
+
|
|
146
|
+
### 4. 编辑器插件组件类
|
|
147
|
+
|
|
148
|
+
##### 编辑器管理组件类
|
|
149
|
+
1. RenderManager
|
|
150
|
+
2. Editor
|
|
151
|
+
|
|
152
|
+
##### 命令流组件类
|
|
153
|
+
1. CommandFlowComponent
|
|
154
|
+
2. Default
|
|
155
|
+
3. ClippingLine
|
|
156
|
+
4. ConnectionLine
|
|
157
|
+
5. DeleteSelectLine
|
|
158
|
+
6. DeleteSelectWindow
|
|
159
|
+
7. DrawDoorLine
|
|
160
|
+
8. DrawLine
|
|
161
|
+
9. DrawWindow
|
|
162
|
+
10. IntersectionConnectionLine
|
|
163
|
+
11. MergeLine
|
|
164
|
+
12. PointDrag
|
|
165
|
+
13. SelectAll
|
|
166
|
+
14. VerticalCorrection
|
|
167
|
+
15. VerticalReferenceLine
|
|
157
168
|
16. ViewAngle
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "build-dxf",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "线段构建双线墙壁的dxf版本",
|
|
5
|
-
"main": "./src/index.js",
|
|
6
|
-
"types": "./src/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"import": {
|
|
13
|
-
"types": "./src/build.d.ts",
|
|
14
|
-
"default": "./src/index.js",
|
|
15
|
-
"style": "./src/index.css"
|
|
16
|
-
},
|
|
17
|
-
"require": {
|
|
18
|
-
"types": "./src/build.d.ts",
|
|
19
|
-
"default": "./src/index.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"./RenderPlugin": {
|
|
23
|
-
"import": {
|
|
24
|
-
"types": "./src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts",
|
|
25
|
-
"default": "./src/index2.js"
|
|
26
|
-
},
|
|
27
|
-
"require": {
|
|
28
|
-
"types": "./src/index.d.ts",
|
|
29
|
-
"default": "./src/index2.js"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"./index.css": "./src/index.css"
|
|
33
|
-
},
|
|
34
|
-
"style": "src/index.css",
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@tweenjs/tween.js": ">=25.0.0",
|
|
37
|
-
"build-dxf": "^0.0.20-21",
|
|
38
|
-
"clipper-lib": ">=6.4.2",
|
|
39
|
-
"dxf-writer": ">=1.18.4",
|
|
40
|
-
"vue": ">=3.0.0",
|
|
41
|
-
"canvas": "^3.2.0"
|
|
42
|
-
},
|
|
43
|
-
"author": "夏过初秋",
|
|
44
|
-
"license": "
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "build-dxf",
|
|
3
|
+
"version": "0.0.54",
|
|
4
|
+
"description": "线段构建双线墙壁的dxf版本",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./src/build.d.ts",
|
|
14
|
+
"default": "./src/index.js",
|
|
15
|
+
"style": "./src/index.css"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./src/build.d.ts",
|
|
19
|
+
"default": "./src/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./RenderPlugin": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts",
|
|
25
|
+
"default": "./src/index2.js"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./src/index.d.ts",
|
|
29
|
+
"default": "./src/index2.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./index.css": "./src/index.css"
|
|
33
|
+
},
|
|
34
|
+
"style": "src/index.css",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@tweenjs/tween.js": ">=25.0.0",
|
|
37
|
+
"build-dxf": "^0.0.20-21",
|
|
38
|
+
"clipper-lib": ">=6.4.2",
|
|
39
|
+
"dxf-writer": ">=1.18.4",
|
|
40
|
+
"vue": ">=3.0.0",
|
|
41
|
+
"canvas": "^3.2.0"
|
|
42
|
+
},
|
|
43
|
+
"author": "夏过初秋",
|
|
44
|
+
"license": "UNLICENSED"
|
|
45
|
+
}
|