|  | @@ -1,7 +1,7 @@
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  |    <div>
 | 
	
		
			
				|  |  |      <div>
 | 
	
		
			
				|  |  | -    <button @click="increment">Count is: {{ count }}</button>
 | 
	
		
			
				|  |  | +    <button @click="increment">步数: {{ count }}</button>
 | 
	
		
			
				|  |  |      <button @click="inOpacity">透明度: {{ opacity }}</button>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  |      <div id="vtkContainer" />
 | 
	
	
		
			
				|  | @@ -25,26 +25,25 @@ import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransf
 | 
	
		
			
				|  |  |  // 响应式状态
 | 
	
		
			
				|  |  |  const count = ref(0);
 | 
	
		
			
				|  |  |  const opacity = ref(0.1);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  const min=ref(0.0);
 | 
	
		
			
				|  |  |  const max=ref(1.0);
 | 
	
		
			
				|  |  |  const scalarAll = ref([]);
 | 
	
		
			
				|  |  |  /*
 | 
	
		
			
				|  |  | -Temperature:温度
 | 
	
		
			
				|  |  | -Pressure:压强
 | 
	
		
			
				|  |  | -SO2:SO2
 | 
	
		
			
				|  |  | -CO2:CO2
 | 
	
		
			
				|  |  | -Height:水位高度
 | 
	
		
			
				|  |  | +  Temperature:温度
 | 
	
		
			
				|  |  | +  Pressure:压强
 | 
	
		
			
				|  |  | +  SO2:SO2
 | 
	
		
			
				|  |  | +  CO2:CO2
 | 
	
		
			
				|  |  | +  Height:水位高度
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | -// const scalarName = ref("CO2");
 | 
	
		
			
				|  |  | -// const filedir =ref("data/Fire/");
 | 
	
		
			
				|  |  | -const scalarName = ref("Height");
 | 
	
		
			
				|  |  | -const filedir =ref("data/Water/");
 | 
	
		
			
				|  |  | +const scalarName = ref("SO2");
 | 
	
		
			
				|  |  | +const filedir =ref("data/Fire/");
 | 
	
		
			
				|  |  | +// const scalarName = ref("Height");
 | 
	
		
			
				|  |  | +// const filedir =ref("data/Water/");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const renderWindowWith = vtkRenderWindowWithControlBar.newInstance({
 | 
	
		
			
				|  |  | -    controlSize: 11,
 | 
	
		
			
				|  |  | +    controlSize: 2,
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  const renderer = renderWindowWith.getRenderer();
 | 
	
		
			
				|  |  |  // renderer.setBackground([0.1,0.2,0]); 
 | 
	
		
			
				|  |  |  const renderWindow = renderWindowWith.getRenderWindow();
 | 
	
	
		
			
				|  | @@ -56,12 +55,13 @@ const mapper = vtkMapper.newInstance();
 | 
	
		
			
				|  |  |  const actor = vtkActor.newInstance();
 | 
	
		
			
				|  |  |  const reader = vtkUnstructuredDataReader.newInstance();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// 用来修改状态、触发更新的函数
 | 
	
		
			
				|  |  | +// 设置透明度
 | 
	
		
			
				|  |  |  function inOpacity() {
 | 
	
		
			
				|  |  |    opacity.value=opacity.value+0.1;
 | 
	
		
			
				|  |  |    actor.getProperty().setOpacity(opacity.value);
 | 
	
		
			
				|  |  |    renderWindow.render();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +//计算最大最小值
 | 
	
		
			
				|  |  |  function getMinMax(scalars){
 | 
	
		
			
				|  |  |    // console.log("getMinMax:",scalars);
 | 
	
		
			
				|  |  |         min.value=scalars[0];
 | 
	
	
		
			
				|  | @@ -75,7 +75,7 @@ function getMinMax(scalars){
 | 
	
		
			
				|  |  |          max.value=scalar;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  console.log("max,min:",max.value,min.value);
 | 
	
		
			
				|  |  | +  // console.log("max,min:",max.value,min.value);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  // 用来修改状态、触发更新的函数
 | 
	
		
			
				|  |  |  function increment() {
 | 
	
	
		
			
				|  | @@ -92,7 +92,7 @@ function increment() {
 | 
	
		
			
				|  |  |    polydata.getPointData().setScalars(dataArray); 
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  |    mapper.clearColorArrays();//强制重建颜色
 | 
	
		
			
				|  |  | -  actor.getProperty().setOpacity(count.value);//设置错误的透明度使得页面重新加载  不设置不刷新页面
 | 
	
		
			
				|  |  | +  actor.getProperty().setOpacity(count.value+2);//设置错误的透明度使得页面重新加载  不设置不刷新页面
 | 
	
		
			
				|  |  |    renderWindow.render();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  //加载所有 标量数据
 | 
	
	
		
			
				|  | @@ -104,7 +104,6 @@ function loadScalarAll(){
 | 
	
		
			
				|  |  |      scalarAll.value[index]=scalars;
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  //  console.log("scalarAll.value:",scalarAll.value);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  //设置 
 | 
	
		
			
				|  |  |  function generateTicks(numberOfTicks) {
 | 
	
	
		
			
				|  | @@ -142,14 +141,12 @@ onMounted(() => {
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  |    renderWindowWith.setContainer(rootContainer);
 | 
	
		
			
				|  |  |    // fullScreenRenderer.setBackground([0,0,0]);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |    // const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
 | 
	
		
			
				|  |  | - 
 | 
	
		
			
				|  |  | -  reader.setUrl(filedir.value+'POST1.vtk').then(() => {
 | 
	
		
			
				|  |  | +  reader.setUrl(filedir.value+'POST0.vtk').then(() => {
 | 
	
		
			
				|  |  |      const polydata = reader.getOutputData(0);        
 | 
	
		
			
				|  |  |      const scalars = reader.getOutputData(1);    
 | 
	
		
			
				|  |  |      const scalarArray=scalars.get(scalarName.value);
 | 
	
		
			
				|  |  | -    console.log("scalarArray:",scalarArray);
 | 
	
		
			
				|  |  | +    // console.log("scalarArray:",scalarArray);
 | 
	
		
			
				|  |  |      const dataArray = vtkDataArray.newInstance({
 | 
	
		
			
				|  |  |        name:scalarName.value,
 | 
	
		
			
				|  |  |        size:polydata.getNumberOfPoints()
 | 
	
	
		
			
				|  | @@ -167,7 +164,7 @@ onMounted(() => {
 | 
	
		
			
				|  |  |      const scalarBarActor = vtkScalarBarActor.newInstance();
 | 
	
		
			
				|  |  |      renderer.addActor(scalarBarActor);
 | 
	
		
			
				|  |  |      scalarBarActor.setScalarsToColors(lut);
 | 
	
		
			
				|  |  | -    console.log("lut:",lut.getRange());    
 | 
	
		
			
				|  |  | +    // console.log("lut:",lut.getRange());    
 | 
	
		
			
				|  |  |      // Change the number of ticks (TODO: add numberOfTicks to ScalarBarActor)
 | 
	
		
			
				|  |  |      scalarBarActor.setGenerateTicks(generateTicks(5));
 | 
	
		
			
				|  |  |      scalarBarActor.setAxisLabel(scalarName.value);
 | 
	
	
		
			
				|  | @@ -181,15 +178,11 @@ onMounted(() => {
 | 
	
		
			
				|  |  |      ctf.addRGBPoint(3.0, 1.0, 0.5, 0.0);
 | 
	
		
			
				|  |  |      ctf.addRGBPoint(4.0, 1.0, 0.0, 0.0);
 | 
	
		
			
				|  |  |      mapper.setLookupTable(ctf);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      lut = mapper.getLookupTable();
 | 
	
		
			
				|  |  |      scalarBarActor.setScalarsToColors(lut);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      resetCamera();
 | 
	
		
			
				|  |  |      render();
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  | -  // renderWindow.render();
 | 
	
		
			
				|  |  |    loadScalarAll();
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  </script>
 |