Parcourir la source

Merge branch 'master' of http://192.168.0.130:13000/huangxingxing/disaster

liuqiao il y a 1 an
Parent
commit
5091efe587
3 fichiers modifiés avec 110 ajouts et 32 suppressions
  1. 32 24
      src/control/fireControl.js
  2. 67 1
      src/control/vtkModel.js
  3. 11 7
      src/view/components/InfoAnimation.vue

+ 32 - 24
src/control/fireControl.js

@@ -2,49 +2,57 @@
 import vtkUnstructuredDataReader from "../reader/UnstructuredDataReader.js";
 
 export class fireControl {
-    constructor(){
+    constructor() {
         //事故编号
-        this.aid=5 ;
+        this.aid = 5;
         //当前步数
         this.step;
         //总步数
-        this.stepsum=10;
+        this.stepsum = 10;
         //url
-        this._url =import.meta.env.VITE_BASE_URL+"/TransServlet?channelNo=service&clientToken=e47b87eec69545559d1e81e56626da68&userId=5f06c8bc77234f969d13e160b54c27e3&aid=";
+        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();
+        this.scalars = new Map();
+        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 initGemetry() {
+        const url = this._url + this.aid + "&transCode=D000014";
+        await this.reader.setUrl(url).then(() => {
+            this.polydata = this.reader.getOutputData(0);
         });
     }
     //标量数据初始化
-    async initScalrs(){
+    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);
+            await this.reader.setUrl(this._url + "&transCode=D00009&step=" + index).then(() => {
+                const scalarMap = this.reader.getOutputData(1);
+                this.scalars.set(index, 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;
-        });
-    }  
+    async getScalrsByStep(step) {
+        this.step = step;
+        // console.log(this.scalars.get(step));
+        if (this.scalars.get(step)) {
+            this.scalar = this.scalars.get(step);
+        } else {
+            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;
+                this.scalars.set(step, scalarMap);
+            });
+        }
+
+
+    }
 }
 
-export function createFireControl(){
+export function createFireControl() {
     return new fireControl();
 }

+ 67 - 1
src/control/vtkModel.js

@@ -20,6 +20,9 @@ import vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource';
 import vtkLineSource from '@kitware/vtk.js/Filters/Sources/LineSource';
 import vtkSphereMapper from '@kitware/vtk.js/Rendering/Core/SphereMapper';
 
+
+import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
+
 export class VtkModel {
   constructor() {
 
@@ -62,6 +65,8 @@ export class VtkModel {
     this.actor2.getProperty().setPointSize(2);
     this.actor2.setMapper(this.mapper);
 
+
+
     //选取
     this.lastActor = null;
     this.nodeActors = []; //节点actor 数据
@@ -182,7 +187,62 @@ export class VtkModel {
 
     this.modelShow();
     this.renderer.resetCamera();
+    const cam =this.renderer.getActiveCamera();
+
+    // const cam = vtkCamera.newInstance();
+    // const cam =this.renderer.getActiveCamera();
+    // this.renderer.setActiveCamera(cam);
+    // cam.setFocalPoint(0, 0, 0);
+    // cam.setPosition(0, 0, 10);
+    // cam.setClippingRange(0.1, 2.0);
+    // cam.setViewAngle(300);
+    // console.log(
+    //   cam.getPosition(),//摄像头位置
+    //   cam.getViewAngle(),//相机视角 默认30
+    //   cam.getFocalPoint(),//相机焦点
+    //   cam.getViewUp(),//相机方向
+    // );
+
+
+  //   position?: number[]; //摄像头位置
+	// focalPoint?: number[]; //相机焦点
+	// viewUp?: number[];//相机方向
+	// directionOfProjection?: number[]; //相机到焦点的方向
+	// parallelProjection?: boolean;//透视 平行
+	// useHorizontalViewAngle?: boolean;//水平视角使用
+	// viewAngle?: number;//相机视角
+	// parallelScale?: number;//平行位置投影比例
+	// clippingRange?: number[];//近远平面
+	// windowCenter?: number[];//窗口中心位置 范围 ([-1,+1],[-1,+1])
+	// viewPlaneNormal?: number[];//投影平面法线 (投影反方向)
+	// useOffAxisProjection?: boolean;//离轴投影
+	// screenBottomLeft?: number[];//左上角的点
+	// screenBottomRight?: number[];//右上角的点
+	// screenTopRight?: number[];//右上角的点 用于离轴投影
+	// freezeFocalPoint?: boolean;
+	// physicalTranslation?: number[];//物理翻译
+	// physicalScale?: number;//物理尺度
+	// physicalViewUp?: number[];//物理方向
+	// physicalViewNorth?: number[];//物理北
+    console.log("摄像头位置",cam.getPosition());
+    console.log("透视或平行相机",cam.getParallelProjection());
+    // cam.setParallelProjection(true);
+    //  console.log("透视或平行相机",cam.getParallelProjection());
+     console.log("水平视角使用",cam.getUseHorizontalViewAngle());
+     cam.setUseHorizontalViewAngle(true);
+     console.log("平行位置投影比例",cam.getParallelScale());
+     cam.setParallelScale(600);
+     console.log("窗口中心位置",cam.getWindowCenter());
+    //  cam.setWindowCenter([1,-1]);
+    // cam.setViewAngle(15);
+    console.log("相机视角",cam.getViewAngle());
+    console.log("相机焦点",cam.getFocalPoint());
+    // cam.setViewUp([-1,0,0]);
+    console.log("相机方向",cam.getViewUp());
+    // cam.setClippingRange(9241.491986233214,9300.53967078369);
+    // console.log("近远平面",cam.getClippingRange());
     this.renderWindow.render();
+
   }
 
   modelClearShow() {
@@ -316,7 +376,13 @@ function pickOnMouseEvent(event) {
   }
   const [x, y] = eventToWindowXY(event);
   // console.log([x,y]);
-  // vtkmodel.pointerActor.setVisibility(false);
+  // if(!vtkmodel.getPointData){//没有数据
+  //   return ;
+  // }
+  // console.log(vtkmodel.hardwareSelector.getPointData());
+  // if(!vtkmodel.renderer.getActors().size==0){
+  //   return;
+  // }
   vtkmodel.hardwareSelector
     .getSourceDataAsync(vtkmodel.renderer, x, y, x, y)
     .then((result) => {

+ 11 - 7
src/view/components/InfoAnimation.vue

@@ -362,10 +362,10 @@ function chengeMonitor(){
 
 }
 function regionchange(val) {
-  console.log(val)
+  // console.log(val)
   let newMap = new Map([['Temperature', '(℃)'], ['Pressure', '(kg/s)'],['Pressure', '(kg/s)'],['CO2', '(%)'],['CO2', '(%)'],['H2S', '(%)'],['Flow', '(Pa)'],['Height', 'm']])
   newMap.forEach((value, key) => {
-    console.log(key, value);
+    // console.log(key, value);
     if(key==val){
     danwei.value=key+value;
     }
@@ -547,8 +547,13 @@ function vtkShow() {
   const mapper = vtkmodel.jgMapper;
   const actor = vtkmodel.jgActor;
 
-  console.log(formInline.value.region);
+  // console.log(formInline.value.region);
+
+
   const scalarArray = fcon.scalar.get(formInline.value.region);
+  if(!scalarArray||!fcon.polydata){
+    return;
+  }
   // console.log("scalarArray:", scalarArray);
   const dataArray = vtkDataArray.newInstance({
     name: formInline.value.region,
@@ -557,14 +562,13 @@ function vtkShow() {
   // console.log(dataArray);
   dataArray.setData(scalarArray);
   fcon.polydata.getPointData().setScalars(dataArray);
-
   mapper.setInputData(fcon.polydata);
   getMinMax(scalarArray);
    mapper.setScalarRange(parseFloat(min.value.toFixed(3)), parseFloat(max.value.toFixed(3))); //设置范围
   // actor.setMapper(mapper);
   scalarBarActor.setAxisLabel(formInline.value.region);
   mapper.clearColorArrays(); //强制重建颜色
-  actor.getProperty().setOpacity(count.value); //设置错误的透明度使得页面重新加载  不设置不刷新页面
+  // actor.getProperty().setOpacity(count.value); //设置错误的透明度使得页面重新加载  不设置不刷新页面
 
   // vtkmodel.renderer.resetCamera();
   vtkmodel.renderWindow.render();
@@ -598,7 +602,7 @@ const timehandclick=()=>{
     timing.value = setInterval(() => {
       const timestamp = new Date().getTime();
       newtime.value = timestampToTime(timestamp);
-      console.log(   newtime.value );
+      // console.log(   newtime.value );
       reddate(new Date());
     }, 1000);
  
@@ -618,7 +622,7 @@ onMounted(() => {
 watch(
   newcount,
   (newVal, oldVal) => {
-    console.log("值改变了", newVal, oldVal);
+    // console.log("值改变了", newVal, oldVal);
     fcon.step = newVal;
     vtkScalarRead();
     getMonitor();