InfoVtkmodel.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template></template>
  2. <script setup>
  3. import { ref, onMounted, reactive } from "vue";
  4. import { RouterView, RouterLink } from "vue-router";
  5. import { request, uploadFile } from "@/utils/request";
  6. import { vtkmodel } from "@/control/vtkModel.js";
  7. import { throttle } from "@kitware/vtk.js/macros";
  8. import vtkSphereSource from "@kitware/vtk.js/Filters/Sources/SphereSource";
  9. import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
  10. import vtkMapper from "@kitware/vtk.js/Rendering/Core/Mapper";
  11. import vtkLineSource from "@kitware/vtk.js/Filters/Sources/LineSource";
  12. import vtkPointSource from "@kitware/vtk.js/Filters/Sources/PointSource";
  13. onMounted(() => {
  14. readNodeAndPipe();
  15. vtkmodel.clearJgAddMode();
  16. });
  17. const nodes = ref([]); //节点数据
  18. const pipes = ref([]); //管道数据
  19. const delNodes = ref([]); //无效节点
  20. const validNodes = ref([]); //有效节点
  21. async function readNodeAndPipe() {
  22. const params = {
  23. transCode: "D00000",
  24. count: 1000,
  25. page: 1,
  26. };
  27. await request(params)
  28. .then((res) => {
  29. if (res.returnCode == "000000000") {
  30. nodes.value = res.rows;
  31. readePipe();
  32. } else {
  33. ElMessage({
  34. message: res.returnMsg,
  35. type: "error",
  36. });
  37. }
  38. })
  39. .catch((err) => {});
  40. }
  41. async function readePipe() {
  42. const params = {
  43. transCode: "D00001",
  44. count: 1000,
  45. page: 1,
  46. };
  47. await request(params)
  48. .then((res) => {
  49. if (res.returnCode == "000000000") {
  50. pipes.value = res.rows;
  51. lineShow();
  52. } else {
  53. ElMessage({
  54. message: res.returnMsg,
  55. type: "error",
  56. });
  57. }
  58. })
  59. .catch((err) => {});
  60. }
  61. /**
  62. * 在管道中已存在的点才可以使用
  63. */
  64. function nodeIsValid(node) {
  65. let isValid = false;
  66. pipes.value.forEach((pipe) => {
  67. if (node.id == pipe.snId || node.id == pipe.enId) {
  68. isValid = true;
  69. return isValid;
  70. }
  71. });
  72. return isValid;
  73. }
  74. function lineShow() {
  75. console.log("模板加载..");
  76. //判断NODE 是否在管道中使用
  77. nodes.value.forEach((node) => {
  78. if (!nodeIsValid(node)) {
  79. delNodes.value.push(node);
  80. } else {
  81. validNodes.value.push(node);
  82. }
  83. });
  84. vtkmodel.modelInit(validNodes.value, pipes.value);
  85. // vtkmodel.selectNodes();
  86. vtkmodel.selectPipes();
  87. }
  88. </script>
  89. <style scoped>
  90. .vtk {
  91. position: absolute;
  92. z-index: 150;
  93. top: 70px;
  94. }
  95. span {
  96. position: absolute;
  97. top: 2px;
  98. }
  99. </style>