//火灾 控制类
import vtkUnstructuredDataReader from "../reader/UnstructuredDataReader.js";

export class fireControl {
    constructor(){
        //事故编号
        this.aid=5 ;
        //当前步数
        this.step;
        //总步数
        this.stepsum=10;
        //url
        this._url =import.meta.env.VITE_BASE_URL+"/TransServlet?channelNo=service&clientToken=e47b87eec69545559d1e81e56626da68&userId=5f06c8bc77234f969d13e160b54c27e3&aid=";
        //几何数据
        this.polydata;
        //Scalars 数据 array[setp]=Map(scalars,value[points]=array),
        this.scalars=new Array();
        this.scalar=new Map();
        this.reader =vtkUnstructuredDataReader.newInstance();
    }
    //几何数据初始化
   async initGemetry() {
    const url =this._url+this.aid+"&transCode=D000014";
    await this.reader.setUrl(url).then(() => {
            this.polydata= this.reader.getOutputData(0);
        });
    }
    //标量数据初始化
    async initScalrs(){
        for (let index = 0; index <= this.stepsum; index++) {
           await this.reader.setUrl(this._url+"&transCode=D00009&step="+ index ).then(() => {
            const scalarMap = this.reader.getOutputData(1);
            this.scalars.push(scalarMap);
            });
        }
    }
    //获取第几步标量数据
    async getScalrsByStep(step){
        this.step =step;
        const url =this._url+this.aid+"&transCode=D00009&step="+ this.step;
        await  this.reader.setUrl(url).then(() => {
            const scalarMap = this.reader.getOutputData(1);
            this.scalar=scalarMap;
        });
    }  
}

export function createFireControl(){
    return new fireControl();
}