# 柱子 Item 示例

目录

# 源代码

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

    

# 代码说明

# 数据说明

Columns:[
    {
        Name: '',                           // 名称
        OutLine: [
            [{X:0,Y:0,Z:0},...],            // 外轮廓 
            ...                             // 内轮廓
        ],                                  // 轮廓线
        RoomBoundary: '',                   // 房间边界
        Location: {X:0,Y:0,Z:0},            // 位置
        ModelId: '',                        // 模型id
        SourceId: '',                       // 对应Revit模型id
    },
    ...
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14

TIP

1、柱子可能有多个块组成
2、柱子不会挖洞,是累加
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 {SColumnItem} from "@persagy-web/big/lib/items/floor/SColumnItem";
    import { Component, Vue } from "vue-property-decorator";

    @Component
    export default class ColumnCanvas extends Vue {
        view: SGraphView | undefined;
        // 图中靠上位置的黑色矩形轮廓
        outline1 = [[{X:120,Y:10},{X:120,Y:30},{X:10,Y:30},{X:10,Y:10}]];
        // 图中靠下位置的,绘制多个图形,会覆盖
        outline2 = [
            [{X:120,Y:-30},{X:120,Y:-50},{X:10,Y:-50},{X:10,Y:-30}],
            [{X:20,Y:-30},{X:20,Y:-85},{X:110,Y:-85},{X:110,Y:-40}]
        ];
        mounted(): void {
            this.init();
        };
        init(): void {
            this.view = new SGraphView('wall');
            const scene = new SGraphScene();
            this.view.scene = scene;
            // 只模拟了轮廓数据
            const item = new SColumnItem(null,{OutLine:this.outline1});
            scene.addItem(item);
            // 只模拟了轮廓数据
            const item2 = new SColumnItem(null,{OutLine:this.outline2});
            scene.addItem(item2);
            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
Last Updated: 9/1/2020, 4:56:05 PM