huangxingxing 8 сар өмнө
parent
commit
47abdeb225

BIN
src/assets/3d/fire.ply


BIN
src/assets/3d/jiancd.ply


BIN
src/assets/3d/name.ply


+ 94 - 0
src/assets/3d/pipname.json

@@ -0,0 +1,94 @@
+[
+    {
+        "name":"西翼轨道大巷",
+        "x":495345.213,
+        "y":5403869.811,
+        "z":339.26
+
+    },
+    {
+        "name":"西翼上仓带式输送机斜巷与大巷",
+        "x":495293.6855,
+        "y":5403830.616,
+        "z":386.48
+
+    },
+    {
+        "name":"西翼回风大巷",
+        "x":495109.953,
+        "y":5403790.044,
+        "z":345.8
+
+    },
+    {
+        "name":"风井",
+        "x":495755.000,
+        "y":5403754.971,
+        "z":353.2
+
+    },
+    {
+        "name":"东翼轨道大巷",
+        "x":496027.107,
+        "y":5403868.875,
+        "z":342.03
+
+    },
+    {
+        "name":"东翼带式传送大巷",
+        "x":495962.689,
+        "y":5403826.384,
+        "z":341.77
+
+    },
+    {
+        "name":"东翼回风大巷",
+        "x":496027.64,
+        "y":5403789.066,
+        "z":352.44
+
+    },
+    {
+        "name":"南一采区轨道大巷",
+        "x":495961.763,
+        "y":5403599.688,
+        "z":365.57
+
+    },
+    {
+        "name":"南一采区上仓带式输送机斜巷与大巷",
+        "x":495917.024,
+        "y":5403344.007,
+        "z":391.69
+
+    },
+    {
+        "name":"南一采区回风大巷",
+        "x":495873.775,
+        "y":5403338.601,
+        "z":404.02
+
+    },
+    {
+        "name":"北翼回风大巷",
+        "x":495465.437,
+        "y":5404792.492,
+        "z":301.47
+
+    },
+    {
+        "name":"北翼上仓带式输送及斜巷",
+        "x":495507.217,
+        "y":5404793.32,
+        "z":301.47
+
+    },
+    {
+        "name":"北翼轨道大巷",
+        "x":495545.048,
+        "y":5404735.588,
+        "z":298.95
+
+    }
+
+]

BIN
src/assets/3d/东翼回风大巷.ply


BIN
src/assets/3d/东翼带式传送大巷.ply


BIN
src/assets/3d/东翼轨道大巷.ply


BIN
src/assets/3d/北翼上仓带式输送及斜巷.ply


BIN
src/assets/3d/北翼回风大巷.ply


BIN
src/assets/3d/北翼轨道大巷.ply


BIN
src/assets/3d/南一采区上仓带式输送机斜巷与大巷.ply


BIN
src/assets/3d/南一采区回风大巷.ply


BIN
src/assets/3d/南一采区轨道大巷.ply


BIN
src/assets/3d/西翼上仓带式输送机斜巷与大巷.ply


BIN
src/assets/3d/西翼回风大巷.ply


BIN
src/assets/3d/西翼轨道大巷.ply


BIN
src/assets/3d/风井.ply


+ 238 - 51
src/control/vtkModel.js

@@ -34,6 +34,13 @@ import vtkOrientationMarkerWidget from '@kitware/vtk.js/Interaction/Widgets/Orie
 
 import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
 
+import vtkPLYReader from '@kitware/vtk.js/IO/Geometry/PLYReader';
+import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
+import vtkMatrixBuilder from '@kitware/vtk.js/Common/Core/MatrixBuilder';
+
+import axios from 'axios';
+
+
 export class VtkModel {
   constructor() {
 
@@ -159,13 +166,176 @@ export class VtkModel {
     // this.actorpipsite.setPosition(parseFloat(node.x), parseFloat(node.y), parseFloat(node.z));
     this.actorpipsite.getProperty().setColor(WHITE);
 
+    this.jcdActors = []; //检测点数据
+    this.jcreader = vtkPLYReader.newInstance();
+    fetchJSFileAsArrayBuffer('src/assets/3d/jiancd.ply').then(arrayBuffer => {
+        // 读取PLY数据
+        this.jcreader.parseAsArrayBuffer(arrayBuffer);
+    });
+    this.pnameActors =[];
+  
+    this.soureActors =[];
+    this.soureReader = vtkPLYReader.newInstance();
+    fetchJSFileAsArrayBuffer('src/assets/3d/fire.ply').then(arrayBuffer => {
+        // 读取PLY数据
+        this.soureReader.parseAsArrayBuffer(arrayBuffer);
+    });
+  }
+  
+  xyz_back(){ 
+    this.renderer.resetCamera();
+  }
+  x_up(){
+    cam.setViewUp([0,0,1]);
+    cam.setPosition(495544.15625+7000, 5403554.25, 467.62999725341797);//相机位置
+  }
+  x_down(){
+    this.renderer.getActiveCamera();
+    cam.setViewUp([0,0,1]);
+    cam.setPosition(-1*(495544.15625+7000), 5403554.25, 467.62999725341797);//相机位置
+  }
+  y_up(){
+    this.renderer.getActiveCamera();
+    cam.setViewUp([0,0,1]);
+    cam.setPosition(495544.15625, 5403554.25+7000, 467.62999725341797);//相机位置
+  }
+  y_down(){
+    this.renderer.getActiveCamera();
+    cam.setViewUp([0,0,1]);
+    cam.setPosition(495544.15625, -1*(5403554.25+7000), 467.62999725341797);//相机位置
+  }
+  z_up(){
+    this.renderer.getActiveCamera();
+    cam.setViewUp([0,1,0]);
+    cam.setPosition(495544.15625, 5403554.25, 467.62999725341797+7000);//相机位置
+  }
+  z_down(){
+    this.renderer.getActiveCamera();
+    cam.setViewUp([0,1,0]);
+    cam.setPosition(495544.15625, 5403554.25, 1*(467.62999725341797+7000));//相机位置
   }
 
+   //显示巷道名称
+ initPname() {
+  fetch('src/assets/3d/pipname.json')
+  .then(response => response.json()).then(data => {
+      let pipnames  =  data;
+        pipnames.forEach((pipname)=>{
+          let pnameReader = vtkPLYReader.newInstance();
+          fetchJSFileAsArrayBuffer('src/assets/3d/'+pipname.name+'.ply').then(arrayBuffer => {
+              // 读取PLY数据
+              pnameReader.parseAsArrayBuffer(arrayBuffer);
+          });
+          const mapper = vtkMapper.newInstance();
+          mapper.setInputConnection(pnameReader.getOutputPort());
+          const actor = vtkActor.newInstance();
+          actor.setPosition(pipname.x,pipname.y,pipname.z);
+          actor.getProperty().setColor(TEXTCOLOR);
+          actor.setMapper(mapper);
+          actor.setScale(20,20,20);//放大
+          this.pnameActors.push(actor);
+          // this.renderer.addActor(actor);
+      });
+  }).catch(error => {
+    console.error('Error fetching JSON:', error);
+  });
+}
+//显示巷道名称
+showPname(){
+  this.pnameActors.forEach((actor)=>{
+    this.renderer.addActor(actor);
+  });
+}
+//隐藏巷道名称
+removePname(){
+  this.pnameActors.forEach((actor)=>{
+    this.renderer.removeActor(actor);
+  });
+}
+
+
+ //添加一个灾源点
+ initSoures(pid,site){
+  let pipe =this.pipeByPid(pid);
+  let point1 = this.pointByPipeNodeId(pipe.snId);
+  let point2 = this.pointByPipeNodeId(pipe.enId);
+  let py = site/(1-site);
+  let pipsite_point=[
+    (point1[0]+py*point2[0])/(1+py),
+    (point1[1]+py*point2[1])/(1+py),
+    (point1[2]+py*point2[2])/(1+py),
+    ] 
+    this.initSoure(pipsite_point[0],pipsite_point[1],pipsite_point[2]);
+ }
+ initSoure(x,y,z) {
+  const mapper = vtkMapper.newInstance();
+  mapper.setInputConnection(this.soureReader.getOutputPort());
+  const actor = vtkActor.newInstance();
+  actor.setPosition(x,y,z);
+  actor.getProperty().setColor(SOURECOLOR);
+  actor.setMapper(mapper);
+    // 旋转actor
+  actor.rotateY(45);// 绕y轴旋转
+  actor.setScale(5,5,5);//放大
+  this.soureActors.push(actor);
+  this.renderer.addActor(actor);
+ }
+ //显示灾源点
+showSoure(){
+  this.soureActors.forEach((actor)=>{
+    this.renderer.addActor(actor);
+  });
+}
+//隐藏灾源点
+removeSoure(){
+  this.soureActors.forEach((actor)=>{
+    this.renderer.removeActor(actor);
+  });
+}
+
+//初始化监测点
+initCheckNodes(checkNodes){
+  checkNodes.forEach((checkNode) => {
+    let pipe =this.pipeByPid(checkNode.pid);
+    let site =checkNode.site;
+    let point1 = this.pointByPipeNodeId(pipe.snId);
+    let point2 = this.pointByPipeNodeId(pipe.enId);
+    let py = site/(1-site);
+    let pipsite_point=[
+      (point1[0]+py*point2[0])/(1+py),
+      (point1[1]+py*point2[1])/(1+py),
+      (point1[2]+py*point2[2])/(1+py),
+      ] 
+      this.initjc(pipsite_point[0],pipsite_point[1],pipsite_point[2]);
+  });
+}
+initjc(x,y,z) {
+  const mapper = vtkMapper.newInstance();
+  mapper.setInputConnection(this.jcreader.getOutputPort());
+  const actor = vtkActor.newInstance();
+  actor.setPosition(x,y,z);
+  actor.getProperty().setColor(JCDCOLOR);
+  actor.setMapper(mapper);
+  this.jcdActors.push(actor);
+  // this.renderer.addActor(actor);
+}
+//显示监测点
+showjc(){
+  this.jcdActors.forEach((actor)=>{
+    this.renderer.addActor(actor);
+  });
+}
+//隐藏监测点
+removejc(){
+  this.jcdActors.forEach((actor)=>{
+    this.renderer.removeActor(actor);
+  });
+}
+
   //显示所选择巷道位置
   addpipsite(pipe,site){
     let point1 = this.pointByPipeNodeId(pipe.snId);
     let point2 = this.pointByPipeNodeId(pipe.enId);
-    console.log(point1[0],point2[0],site,(point1[0]+point2[0])*site);
 
     let py = site/(1-site);
     let pipsite_point=[
@@ -441,6 +611,7 @@ export class VtkModel {
   }
   modelCreate() {
     console.log("modelInit..");
+    
     const points = this.polyData.getPoints();
     const lines = this.polyData.getLines();
 
@@ -497,39 +668,6 @@ export class VtkModel {
     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.getParallelProjection());
     // cam.setParallelProjection(true);
@@ -541,34 +679,33 @@ export class VtkModel {
     console.log("窗口中心位置", cam.getWindowCenter());//[0, 0]
     //  cam.setWindowCenter([1,-1]);
     console.log("相机视角", cam.getViewAngle());//30
-    cam.setViewAngle(15);
+    // cam.setViewAngle(90);
 
     console.log("摄像头位置", cam.getPosition());//[495544.15625, 5403554.25, 9989.55990464236]
-    cam.setPosition(495544.15625, 5403554.25, 9989.55990464236);
+    // cam.setPosition(495544.15625, 5403554.25, 9989.55990464236);
     console.log("相机焦点", cam.getFocalPoint());// [495544.15625, 5403554.25, 467.62999725341797]
-    cam.setFocalPoint(495544.15625, 5403554.25, 467.62999725341797);
+    // cam.setFocalPoint(495544.15625, 5403554.25, 467.62999725341797);
     console.log("相机方向", cam.getViewUp());//[0,1,0]
     // cam.setViewUp([0,1,1]);
     console.log("近远平面", cam.getClippingRange());// [9141.491986233214, 9913.53967078369]
     // cam.setClippingRange(9241.491986233214,9300.53967078369);
   
     // 设置环境光和光照
-    const light = vtkLight.newInstance();
-    light.setColor(1.0, 1.0, 1.0); // 白色环境光
-    light.setIntensity(3.0); // 强度为1.0
-    this.renderer.addLight(light);
-
-    // const cameraLight = vtkLight.newInstance();
-    // cameraLight.setColor(1.0, 0.0, 0.0); // 红色光照
-    // cameraLight.setPositional(true); // 定向光源
-    // cameraLight.setConeAngle(-30.0); // 光束角度
-    // cameraLight.setPosition(this.renderer.getActiveCamera().getFocalPoint());
-    // cameraLight.setIntensity(0.8);
-    // this.renderer.addLight(cameraLight);
-
-    this.renderer.resetCamera();
+    // const light = vtkLight.newInstance();
+    // light.setColor(1.0, 1.0, 1.0); // 白色环境光
+    // light.setIntensity(3.0); // 强度为1.0
+    // this.renderer.addLight(light);
+    // this.renderer.resetCamera();
+    // cam.setPosition(0, 0, 9989); 
+    //相机焦点 495544.15625  5403554.25  467.62999725341797
+    // cam.setPosition( 495544.15625+500, 5403554.25, 467.62999725341797); 
+    // cam.setPosition( 495544.15625-500, 5403554.25, 467.62999725341797); 
+    // cam.setViewUp([0,0,1]);
+    // this.renderer.updateCamera();
   }
 
+
+
   modelClearShow() {
     this.renderer.removeActor(this.actor);
     this.renderer.removeActor(this.actor2);
@@ -603,7 +740,13 @@ export class VtkModel {
         this.renderer.addActor(pipeActor.actor);
       });
     }
+    // this.addjc(495530.903,5403828.821,432.40);
+    // this.addpname(495530.903,5403829.821,432.40);
+    // this.addSoure(495530.903,5403829.821,432.40);
+    // this.addpname(495530.903,5403829.821,432.40);
+    this.initPname();
     this.renderer.addActor(this.axesActor);
+    // this.rotateY();
   }
 
 
@@ -639,6 +782,15 @@ export class VtkModel {
     }
     return 0;
   }
+  pipeByPid(pid) {
+    console.log("pipeByPid",this.pipes.length)
+    for (let index = 0; index < this.pipes.length; index++) {
+      const pipe = this.pipes[index];
+      if (pipe.id == pid) {
+       return pipe;
+      }
+    }
+  }
   pointByPipeNodeId(nid) {
     for (let index = 0; index < this.validNodes.length; index++) {
       const node = this.validNodes[index];
@@ -860,9 +1012,44 @@ function processSelections(selections) {
 
 
 }
+
+// 异步函数,用于读取JS文件并转换为ArrayBuffer
+async function fetchJSFileAsArrayBuffer(url) {
+  try {
+      // 使用fetch API异步加载JS文件
+      const response = await fetch(url, {
+          method: 'GET',
+          responseType: 'arraybuffer'  // 指定响应类型为arraybuffer
+      });
+
+      // 确保响应成功
+      if (!response.ok) {
+          throw new Error(`HTTP error! status: ${response.status}`);
+      }
+
+      // 获取ArrayBuffer对象
+      const arrayBuffer = await response.arrayBuffer();
+
+      // 可选:验证转换后的ArrayBuffer内容
+      const decoder = new TextDecoder();  // 使用TextDecoder将ArrayBuffer解码为字符串
+      const content = decoder.decode(arrayBuffer);
+      // console.log('File content:', content);
+
+      return arrayBuffer;
+  } catch (error) {
+      console.error('Error fetching the file:', error);
+      throw error;  // 重新抛出错误以便上层处理
+  }
+}
+
 const throttleMouseHandler = throttle(pickOnMouseEvent, 20);
 const WHITE = [1, 0.2, 1];
 const GREEN = [0.1, 0.8, 0.1];
 const REA = [1, 0, 0];
+
+const JCDCOLOR = [0.5, 0, 0];
+const SOURECOLOR = [0.5, 0.5, 0];
+const TEXTCOLOR = [1, 1, 1];
+
 const vtkmodel = new VtkModel();
 export { vtkmodel };

+ 20 - 2
src/view/components/InfoVtkmodel.vue

@@ -28,6 +28,8 @@ const pipes = ref([]); //管道数据
 const delNodes = ref([]); //无效节点
 const validNodes = ref([]); //有效节点
 
+const checkNodes = ref([]); //监测点
+
 async function readNodeAndPipe() {
   const params = {
     transCode: "D00000",
@@ -59,6 +61,7 @@ async function readePipe() {
       if (res.returnCode == "000000000") {
         pipes.value = res.rows;
         lineShow();
+     
       } else {
         ElMessage({
           message: res.returnMsg,
@@ -69,11 +72,25 @@ async function readePipe() {
     .catch((err) => {});
 }
 
+// 查询监测点
+async function readCheckNode(){
+    const params = {
+        transCode: 'D10004',
+    }
+    request(params)
+        .then((res) => {
+          checkNodes.value= res.rows;
+          vtkmodel.initCheckNodes(checkNodes.value);
+        })
+        .catch((err) => {
+            
+        })
+}
+
 /**
  * 在管道中已存在的点才可以使用
  */
-function 
-nodeIsValid(node) {
+function nodeIsValid(node) {
   let isValid = false;
   pipes.value.forEach((pipe) => {
     if (node.id == pipe.snId || node.id == pipe.enId) {
@@ -95,6 +112,7 @@ function lineShow() {
     }
   });
   vtkmodel.modelInit(validNodes.value, pipes.value);
+     readCheckNode();
   // vtkmodel.selectNodes();
   // vtkmodel.selectByNodeId(178);
   // vtkmodel.selectPipes();