Przeglądaj źródła

Merge branch 'master' of http://106.3.96.219:13000/CQ_ADI/airoptweb

tangjunhao 3 miesięcy temu
rodzic
commit
792984ea35

+ 11 - 12
src/components/cloudChart/dialog/DomainDialog.vue

@@ -60,6 +60,17 @@
 import { ref, defineProps, defineEmits } from 'vue'
 import SubDialog from './SubDialog.vue'
 import SurfaceDialog from './SurfaceDialog.vue'
+import { usePltDataStore } from '@/store/modules/pltData'
+
+const pltStore = usePltDataStore()
+const tableData = computed(() => {
+  return pltStore.getDomainNames().map(name => ({
+    domain: name,
+    status: 'show',
+    drawType: 'Exposed',
+    planeRange: '(1,1,1)'
+  }))
+})
 
 const props = defineProps({
   modelValue: Boolean,
@@ -130,18 +141,6 @@ const reverseAll = () => {
 let domainbtnbox1 = ref(['显示全部','隐藏全部','倒转互换'])
 let domainbtnbox2 = ref(['显示','隐藏','表面绘制'])
 
-// 表格数据
-let tableData = ref([
-  {domain:"Z1", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z2", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z3", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z4", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z1", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z2", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z3", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-  {domain:"Z4", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
-])
-
 // 表格列配置
 let tabledomainColumns = ref([
   {label:"状态", prop:'state'},

+ 1 - 1
src/components/cloudChart/dialog/FileSelectDialog.vue

@@ -204,7 +204,7 @@ const handleConfirm = () => {
     // selectedFiles: fileList.value.filter(
     //   file => selectedFiles.value.includes(file.value)
     // )
-  fid: 'f96450bc33fd407b89c27fb481c07b83'
+  fid: '9305c3e01b5d44e6a1964148d34e02f4'
   })
   emit('update:modelValue', false)
 }

+ 35 - 31
src/components/cloudChart/index.vue

@@ -67,6 +67,7 @@ import ColorCardDialog from "./dialog/ColorCardDialog.vue"
 import ContourDialog from "./dialog/ContourDialog.vue"
 import cloudChart from "@/views/threejsView/index.vue" // 云图
 import h5wasm from 'h5wasm'
+import { usePltDataStore } from '@/store/modules/pltData'
 const props = defineProps({
   modelValue: {
     type: Boolean,
@@ -208,10 +209,9 @@ const getPltData = async (fpid) => {
 
 // HDF5转Three.js格式的解析器
 const parseHDF5ToThreeJS = (h5file) => {
+  const pltStore = usePltDataStore()
   const result = {
-    "data" : {
-      "datasetType": "plt",
-    },
+    "data": { "datasetType": "plt" },
     metadata: {
       title: h5file.attrs.title?.value || '',
       variables: JSON.parse(h5file.attrs.variables?.value || "[]"),
@@ -219,25 +219,21 @@ const parseHDF5ToThreeJS = (h5file) => {
     },
     zones: []
   }
+  const zones = []
 
-  // 新版h5wasm数据提取方法
+  // 增强型数据提取方法
   const extractDataset = (group, name) => {
     try {
-      // 方法1:直接访问
-      if (group[name] && group[name].value) {
-        return group[name].value
-      }
+      // 尝试多种访问方式
+      const dataset = group.get?.(name) ||  // 方法1: get()
+                     group[name]?.value ||  // 方法2: 直接访问
+                     Object.entries(group).find(([k]) => k === name)?.[1]?.value // 方法3: 遍历查找
       
-      // 方法2:遍历entries
-      for (const [key, obj] of Object.entries(group)) {
-        if (key === name && obj?.value) {
-          return obj.value
-        }
+      // 特殊处理数组类型数据
+      if (dataset && typeof dataset === 'object' && 'value' in dataset) {
+        return dataset.value
       }
-      
-      // 方法3:get方法
-      const dataset = group.get?.(name)
-      return dataset?.value
+      return dataset
     } catch (e) {
       console.warn(`提取 ${name} 失败:`, e)
       return null
@@ -246,26 +242,34 @@ const parseHDF5ToThreeJS = (h5file) => {
 
   // 处理每个区域
   for (const zoneKey of h5file.keys()) {
-    if (!zoneKey.startsWith('zone_')) continue
+    try {
+      // 正确获取组对象
+      const zone = h5file.get(zoneKey)
+      if (!zone || typeof zone !== 'object') continue
 
-    const zone = h5file[zoneKey] || h5file.get(zoneKey)
-    console.log(`处理 ${zoneKey}:`, zone)
+      console.log(`处理 ${zoneKey}:`, zone)
 
-    const zoneData = {
-      name: zoneKey,
-      vertices: extractDataset(zone, 'vertices'),
-      indices: extractDataset(zone, 'indices'),
-      variables: {}
-    }
+      const zoneData = {
+        name: zoneKey.replace(/^zone_\d+_/, ''), // 去除可能的zone_前缀
+        vertices: extractDataset(zone, 'vertices'),
+        indices: extractDataset(zone, 'indices'),
+        variables: {}
+      }
 
-    // 提取变量数据
-    result.metadata.variables.forEach(varName => {
-      zoneData.variables[varName] = extractDataset(zone, `var_${varName}`)
-    })
+      // 提取变量数据
+      result.metadata.variables.forEach(varName => {
+        const data = extractDataset(zone, `var_${varName}`)
+        if (data) zoneData.variables[varName] = data
+      })
 
-    result.zones.push(zoneData)
+      zones.push(zoneData)
+    } catch (e) {
+      console.warn(`处理区域 ${zoneKey} 时出错:`, e)
+    }
   }
 
+  pltStore.setZones(zones)
+  result.zones = zones
   console.log('最终解析结果:', result)
   return result
 }

+ 32 - 0
src/store/modules/pltData.ts

@@ -0,0 +1,32 @@
+import { defineStore } from 'pinia'
+
+export const usePltDataStore = defineStore('pltData', {
+  state: () => ({
+    domains: {} as Record<string, { visible: boolean }>,
+    zones: [] as Array<{ 
+      name: string 
+      vertices?: any[]
+      indices?: any[]
+    }>
+  }),
+  actions: {
+    initializeDomains(names: string[]) {
+      names.forEach(name => {
+        if (!this.domains[name]) {
+          this.domains[name] = { visible: true }
+        }
+      });
+    },
+    toggleDomain(name: string) {
+      if (this.domains[name]) {
+        this.domains[name].visible = !this.domains[name].visible
+      }
+    },
+    setZones(zones: any[]) {
+      this.zones = zones
+    },
+    getDomainNames() {
+      return this.zones.map(zone => zone.name)
+    }
+  }
+})