# 业务空间 Item 示例

目录

# 源代码

查看源代码:/persagy-web-big/src/items/floor/ZoneItem.ts

    

# 代码说明

# 数据说明

Zone: {
        xxx: xxx,                           // 等业务空间属性
        OutLine: [
            [
                [{X:0,Y:0,Z:0},...],        // 第一个空间的外轮廓
                ...                         // 第一个空间的内轮廓
            ],
            [
                [{X:0,Y:0,Z:0},...],        // 第二个空间的外轮廓
                ...                         // 第二个空间的内轮廓
            ],
            ...                             // ...
        ],                                  // 轮廓线
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14

1、业务空间由多个空间组成
2、每个空间可能挖洞,所以 outline 是三维数组
3、外轮廓数据顺时针排序,内轮廓为逆时针排序
4、轮廓数据单位均为毫米

# 计算边界矩阵

不能在绘制的时候计算,因为绘制是高频调用方法,尽量不要在绘制方法中做大量计算工作;
计算方法一般在数据变化的时候做,如果只是展示的话,则只需要在构造函数中计算一次;

# Y轴取反

业务空间轮廓线由空间轮廓线直接组成或者由空间轮廓线计算而来
revit 使用的坐标系与 canvas 使用的坐标系 Y 轴是相反的; revit 坐标使用的是数学坐标系, Y 轴方向是向上的, canvas 坐标使用的绘图坐标系, Y 轴方向是向下的;
数据是通过 revit 模型导出

# 绘制示例

查看代码
<template>
    <div>
        <canvas id="wall" width="800" height="400"  tabindex="0" />
    </div>
</template>

<script lang="ts">
    import {SGraphScene, SGraphView} from "@persagy-web/graph/";
    import {SZoneItem} from "@persagy-web/big/lib/items/floor/ZoneItem";
    import { Component, Vue } from "vue-property-decorator";

    @Component
    export default class ZoneCanvas extends Vue {
        outline = [
            [
                // 未掏洞的空间
                [
                    {"X":30150.15,"Y":82300.04,"Z":59400.0},
                    {"X":30150.15,"Y":81400.04,"Z":59400.0},
                    {"X":33400.15,"Y":82300.04,"Z":59400.0},
                    {"X":30150.15,"Y":82300.04,"Z":59400.0}
                ],
            ],
            [
                // 掏洞的空间
                [
                    {"X":25500.15,"Y":77100.04,"Z":59400.0},
                    {"X":28200.15,"Y":77100.04,"Z":59400.0},
                    {"X":28200.15,"Y":82300.04,"Z":59400.0},
                    {"X":25500.15,"Y":82300.04,"Z":59400.0},
                    {"X":25500.15,"Y":77100.04,"Z":59400.0}
                ],
                [
                    {"X":25900.15,"Y":80300.04,"Z":59400.0},
                    {"X":27200.15,"Y":80300.04,"Z":59400.0},
                    {"X":27200.15,"Y":77900.04,"Z":59400.0},
                    {"X":25900.15,"Y":77900.04,"Z":59400.0},
                ]
            ]
        ];
        view: SGraphView | undefined;
        mounted() {
            this.init();
        };
        init(){
            this.view = new SGraphView('wall');
            const scene = new SGraphScene();
            this.view.scene = scene;
            // 只模拟了轮廓数据
            // @ts-ignore
            const item = new SZoneItem(null,{OutLine:this.outline});
            scene.addItem(item);
            this.view.fitSceneToView();
            this.view.scalable = false;
        }
    }
</script>

<style scoped>

</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Last Updated: 9/1/2020, 4:56:05 PM