|
@@ -20,6 +20,11 @@ import vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource';
|
|
import vtkLineSource from '@kitware/vtk.js/Filters/Sources/LineSource';
|
|
import vtkLineSource from '@kitware/vtk.js/Filters/Sources/LineSource';
|
|
import vtkSphereMapper from '@kitware/vtk.js/Rendering/Core/SphereMapper';
|
|
import vtkSphereMapper from '@kitware/vtk.js/Rendering/Core/SphereMapper';
|
|
|
|
|
|
|
|
+import vtk2DShape from '@kitware/vtk.js/Filters/Sources/Arrow2DSource';
|
|
|
|
+import vtkArrowSource from '@kitware/vtk.js/Filters/Sources/ArrowSource';
|
|
|
|
+import vtkArrow2DSource from '@kitware/vtk.js/Filters/Sources/Arrow2DSource';
|
|
|
|
+import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
|
|
|
|
+
|
|
|
|
|
|
import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
|
|
|
|
@@ -41,7 +46,7 @@ export class VtkModel {
|
|
this.selectObj = null;
|
|
this.selectObj = null;
|
|
|
|
|
|
//结果选择的点数据
|
|
//结果选择的点数据
|
|
- this.selectJgPointId=0;
|
|
|
|
|
|
+ this.selectJgPointId = 0;
|
|
this.validNodes = [];//节点数据
|
|
this.validNodes = [];//节点数据
|
|
this.pipes = [];//管道数据
|
|
this.pipes = [];//管道数据
|
|
|
|
|
|
@@ -103,7 +108,9 @@ export class VtkModel {
|
|
this.scalarBarActor.setScalarsToColors(lut);
|
|
this.scalarBarActor.setScalarsToColors(lut);
|
|
this.jgActor.setMapper(this.jgMapper);
|
|
this.jgActor.setMapper(this.jgMapper);
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //箭头
|
|
|
|
+ this.arrowActors = [];
|
|
}
|
|
}
|
|
generateTicks(numberOfTicks) {
|
|
generateTicks(numberOfTicks) {
|
|
return (helper) => {
|
|
return (helper) => {
|
|
@@ -126,6 +133,54 @@ export class VtkModel {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //添加箭头
|
|
|
|
+ addArrow(velocitys) {
|
|
|
|
+ this.clearArrow();
|
|
|
|
+ this.arrowActors=[];
|
|
|
|
+ velocitys.forEach(velocity => {
|
|
|
|
+ velocity.points.forEach(point => {
|
|
|
|
+ // const initialValues = {
|
|
|
|
+ // base:0,
|
|
|
|
+ // shape: 'arrow4points',
|
|
|
|
+ // center: [point.x,point.y,point.z],
|
|
|
|
+ // width: 3,height:10,direction:[
|
|
|
|
+ // velocity.vector[2],
|
|
|
|
+ // velocity.vector[0],
|
|
|
|
+ // velocity.vector[1]
|
|
|
|
+ // ] };
|
|
|
|
+ // const vtk2d = vtk2DShape.newInstance(initialValues);
|
|
|
|
+
|
|
|
|
+ const initialValues = {
|
|
|
|
+ base:0,
|
|
|
|
+ center: [point.x,point.y,point.z],
|
|
|
|
+ height:7,
|
|
|
|
+ radius:2,
|
|
|
|
+ resolution:3,
|
|
|
|
+ direction:[
|
|
|
|
+ velocity.vector[0],
|
|
|
|
+ velocity.vector[1],
|
|
|
|
+ velocity.vector[2]
|
|
|
|
+ ] };
|
|
|
|
+ const vtk2d = vtkConeSource.newInstance(initialValues);
|
|
|
|
+ const mapper = vtkMapper.newInstance();
|
|
|
|
+ mapper.setInputConnection(vtk2d.getOutputPort());
|
|
|
|
+ const actor = vtkActor.newInstance();
|
|
|
|
+ actor.setMapper(mapper);
|
|
|
|
+ this.arrowActors.push(actor);
|
|
|
|
+ // this.renderer.addActor(actor);
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ // this.renderWindow.render();
|
|
|
|
+ }
|
|
|
|
+ clearArrow(){
|
|
|
|
+ if(this.arrowActors){
|
|
|
|
+ this.arrowActors.forEach(actor =>{
|
|
|
|
+ this.renderer.removeActor(actor);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
modelInit(validNodes, pipes) {
|
|
modelInit(validNodes, pipes) {
|
|
this.validNodes = validNodes;
|
|
this.validNodes = validNodes;
|
|
this.pipes = pipes;
|
|
this.pipes = pipes;
|
|
@@ -187,7 +242,7 @@ export class VtkModel {
|
|
|
|
|
|
this.modelShow();
|
|
this.modelShow();
|
|
this.renderer.resetCamera();
|
|
this.renderer.resetCamera();
|
|
- const cam =this.renderer.getActiveCamera();
|
|
|
|
|
|
+ const cam = this.renderer.getActiveCamera();
|
|
|
|
|
|
// const cam = vtkCamera.newInstance();
|
|
// const cam = vtkCamera.newInstance();
|
|
// const cam =this.renderer.getActiveCamera();
|
|
// const cam =this.renderer.getActiveCamera();
|
|
@@ -204,41 +259,41 @@ export class VtkModel {
|
|
// );
|
|
// );
|
|
|
|
|
|
|
|
|
|
- // 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());
|
|
|
|
|
|
+ // 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);
|
|
// cam.setParallelProjection(true);
|
|
// console.log("透视或平行相机",cam.getParallelProjection());
|
|
// console.log("透视或平行相机",cam.getParallelProjection());
|
|
- console.log("水平视角使用",cam.getUseHorizontalViewAngle());
|
|
|
|
- cam.setUseHorizontalViewAngle(true);
|
|
|
|
- console.log("平行位置投影比例",cam.getParallelScale());
|
|
|
|
- cam.setParallelScale(600);
|
|
|
|
- console.log("窗口中心位置",cam.getWindowCenter());
|
|
|
|
|
|
+ console.log("水平视角使用", cam.getUseHorizontalViewAngle());
|
|
|
|
+ cam.setUseHorizontalViewAngle(true);
|
|
|
|
+ console.log("平行位置投影比例", cam.getParallelScale());
|
|
|
|
+ cam.setParallelScale(600);
|
|
|
|
+ console.log("窗口中心位置", cam.getWindowCenter());
|
|
// cam.setWindowCenter([1,-1]);
|
|
// cam.setWindowCenter([1,-1]);
|
|
// cam.setViewAngle(15);
|
|
// cam.setViewAngle(15);
|
|
- console.log("相机视角",cam.getViewAngle());
|
|
|
|
- console.log("相机焦点",cam.getFocalPoint());
|
|
|
|
|
|
+ console.log("相机视角", cam.getViewAngle());
|
|
|
|
+ console.log("相机焦点", cam.getFocalPoint());
|
|
// cam.setViewUp([-1,0,0]);
|
|
// cam.setViewUp([-1,0,0]);
|
|
- console.log("相机方向",cam.getViewUp());
|
|
|
|
|
|
+ console.log("相机方向", cam.getViewUp());
|
|
// cam.setClippingRange(9241.491986233214,9300.53967078369);
|
|
// cam.setClippingRange(9241.491986233214,9300.53967078369);
|
|
// console.log("近远平面",cam.getClippingRange());
|
|
// console.log("近远平面",cam.getClippingRange());
|
|
this.renderWindow.render();
|
|
this.renderWindow.render();
|
|
@@ -274,6 +329,8 @@ export class VtkModel {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
selectNodes() {
|
|
selectNodes() {
|
|
this.isSelectNode = true;
|
|
this.isSelectNode = true;
|
|
this.isSelectPipe = false;
|
|
this.isSelectPipe = false;
|
|
@@ -286,7 +343,7 @@ export class VtkModel {
|
|
this.modelShow();
|
|
this.modelShow();
|
|
this.renderWindow.render();
|
|
this.renderWindow.render();
|
|
}
|
|
}
|
|
- selectNoting(){
|
|
|
|
|
|
+ selectNoting() {
|
|
this.isSelectNode = false;
|
|
this.isSelectNode = false;
|
|
this.isSelectPipe = false;
|
|
this.isSelectPipe = false;
|
|
this.modelShow();
|
|
this.modelShow();
|
|
@@ -313,6 +370,9 @@ export class VtkModel {
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
clearModeAddJg() {
|
|
clearModeAddJg() {
|
|
this.renderer.addActor(this.jgActor);
|
|
this.renderer.addActor(this.jgActor);
|
|
this.renderer.addActor(this.scalarBarActor);
|
|
this.renderer.addActor(this.scalarBarActor);
|
|
@@ -322,47 +382,51 @@ export class VtkModel {
|
|
clearJgAddMode() {
|
|
clearJgAddMode() {
|
|
this.renderer.removeActor(this.scalarBarActor);
|
|
this.renderer.removeActor(this.scalarBarActor);
|
|
this.renderer.removeActor(this.jgActor);
|
|
this.renderer.removeActor(this.jgActor);
|
|
|
|
+ this.clearArrow();
|
|
this.modelShow();
|
|
this.modelShow();
|
|
this.isJg = false; //不显示结果
|
|
this.isJg = false; //不显示结果
|
|
}
|
|
}
|
|
- clearAll(){
|
|
|
|
|
|
+ clearAll() {
|
|
this.renderer.removeActor(this.jgActor);
|
|
this.renderer.removeActor(this.jgActor);
|
|
this.renderer.removeActor(this.scalarBarActor);
|
|
this.renderer.removeActor(this.scalarBarActor);
|
|
|
|
+ this.clearArrow();
|
|
this.modelClearShow();
|
|
this.modelClearShow();
|
|
this.renderWindow.render();
|
|
this.renderWindow.render();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
//选中指定点
|
|
//选中指定点
|
|
- selectByNodeId(nid){
|
|
|
|
- console.log("selectByNodeId",nid);
|
|
|
|
- if(this.isSelectNode){
|
|
|
|
|
|
+ selectByNodeId(nid) {
|
|
|
|
+ console.log("selectByNodeId", nid);
|
|
|
|
+ if (this.isSelectNode) {
|
|
if (this.lastActor != null) {
|
|
if (this.lastActor != null) {
|
|
this.lastActor.getProperty().setColor(WHITE);
|
|
this.lastActor.getProperty().setColor(WHITE);
|
|
}
|
|
}
|
|
- this.nodeActors.forEach(nodeActor=>{
|
|
|
|
- if(nid==nodeActor.node.id){
|
|
|
|
|
|
+ this.nodeActors.forEach(nodeActor => {
|
|
|
|
+ if (nid == nodeActor.node.id) {
|
|
nodeActor.actor.getProperty().setColor(GREEN);
|
|
nodeActor.actor.getProperty().setColor(GREEN);
|
|
-
|
|
|
|
|
|
+
|
|
this.renderWindow.render();
|
|
this.renderWindow.render();
|
|
- this.lastActor=nodeActor.actor;
|
|
|
|
- this.selectObj=nodeActor.node;
|
|
|
|
|
|
+ this.lastActor = nodeActor.actor;
|
|
|
|
+ this.selectObj = nodeActor.node;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//选中指定管道
|
|
//选中指定管道
|
|
- selectByPipeId(pid){
|
|
|
|
- console.log("selectByPipeId",pid);
|
|
|
|
- if(this.isSelectPipe){
|
|
|
|
|
|
+ selectByPipeId(pid) {
|
|
|
|
+ console.log("selectByPipeId", pid);
|
|
|
|
+ if (this.isSelectPipe) {
|
|
if (this.lastActor != null) {
|
|
if (this.lastActor != null) {
|
|
this.lastActor.getProperty().setColor(WHITE);
|
|
this.lastActor.getProperty().setColor(WHITE);
|
|
}
|
|
}
|
|
- this.pipeActors.forEach(pipeActor=>{
|
|
|
|
- if(pid==pipeActor.pipe.id){
|
|
|
|
|
|
+ this.pipeActors.forEach(pipeActor => {
|
|
|
|
+ if (pid == pipeActor.pipe.id) {
|
|
pipeActor.actor.getProperty().setColor(GREEN);
|
|
pipeActor.actor.getProperty().setColor(GREEN);
|
|
this.renderWindow.render();
|
|
this.renderWindow.render();
|
|
- this.lastActor=pipeActor.actor;
|
|
|
|
- this.selectObj=pipeActor.node;
|
|
|
|
|
|
+ this.lastActor = pipeActor.actor;
|
|
|
|
+ this.selectObj = pipeActor.node;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -445,39 +509,39 @@ function processSelections(selections) {
|
|
});
|
|
});
|
|
|
|
|
|
if (vtkmodel.isJg) {//结果数据选择cell
|
|
if (vtkmodel.isJg) {//结果数据选择cell
|
|
- if( vtkmodel.hardwareSelector.getFieldAssociation() ===
|
|
|
|
- FieldAssociations.FIELD_ASSOCIATION_POINTS){//选择点
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- //选择Cell
|
|
|
|
- const input = prop.getMapper().getInputData();
|
|
|
|
- if (!input.getCells()) {
|
|
|
|
- input.buildCells();
|
|
|
|
- // return;
|
|
|
|
- }
|
|
|
|
- const cellPoints = input.getCellPoints(attributeID);
|
|
|
|
- if (cellPoints) {
|
|
|
|
- const pointIds = cellPoints.cellPointIds;
|
|
|
|
- // Find the closest cell point, and use that as cursor position
|
|
|
|
- const points = Array.from(pointIds).map((pointId) =>
|
|
|
|
- input.getPoints().getPoint(pointId)
|
|
|
|
- );
|
|
|
|
- const scalarDataArray=input.getPointData().getScalars().getData();
|
|
|
|
- console.log(scalarDataArray[pointIds[0]]);//节点标量数据
|
|
|
|
- // pointIds.forEach(pointId=>{
|
|
|
|
- // console.log(input.getPointData().getScalars().getName());
|
|
|
|
- // console.log(scalarDataArray[pointId]);//节点标量数据
|
|
|
|
- // });
|
|
|
|
- vtkmodel.selectJgPointId =pointIds[0];
|
|
|
|
- }
|
|
|
|
|
|
+ if (vtkmodel.hardwareSelector.getFieldAssociation() ===
|
|
|
|
+ FieldAssociations.FIELD_ASSOCIATION_POINTS) {//选择点
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //选择Cell
|
|
|
|
+ const input = prop.getMapper().getInputData();
|
|
|
|
+ if (!input.getCells()) {
|
|
|
|
+ input.buildCells();
|
|
|
|
+ // return;
|
|
|
|
+ }
|
|
|
|
+ const cellPoints = input.getCellPoints(attributeID);
|
|
|
|
+ if (cellPoints) {
|
|
|
|
+ const pointIds = cellPoints.cellPointIds;
|
|
|
|
+ // Find the closest cell point, and use that as cursor position
|
|
|
|
+ const points = Array.from(pointIds).map((pointId) =>
|
|
|
|
+ input.getPoints().getPoint(pointId)
|
|
|
|
+ );
|
|
|
|
+ const scalarDataArray = input.getPointData().getScalars().getData();
|
|
|
|
+ console.log(scalarDataArray[pointIds[0]]);//节点标量数据
|
|
|
|
+ // pointIds.forEach(pointId=>{
|
|
|
|
+ // console.log(input.getPointData().getScalars().getName());
|
|
|
|
+ // console.log(scalarDataArray[pointId]);//节点标量数据
|
|
|
|
+ // });
|
|
|
|
+ vtkmodel.selectJgPointId = pointIds[0];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- }else{
|
|
|
|
|
|
+
|
|
|
|
+ } else {
|
|
vtkmodel.renderWindow.render();
|
|
vtkmodel.renderWindow.render();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
const throttleMouseHandler = throttle(pickOnMouseEvent, 20);
|
|
const throttleMouseHandler = throttle(pickOnMouseEvent, 20);
|
|
const WHITE = [0, 0, 1];
|
|
const WHITE = [0, 0, 1];
|