InfoVtkmodel.vue 2.7 KB

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