chunk-5a43e972.8df9a8ed.js 8.5 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5a43e972"],{"0fea":function(e,t,n){"use strict";var i=n("1f92"),s=n.n(i);s.a},"1f92":function(e,t,n){},3846:function(e,t,n){n("9e1e")&&"g"!=/./g.flags&&n("86cc").f(RegExp.prototype,"flags",{configurable:!0,get:n("0bfb")})},"6b54":function(e,t,n){"use strict";n("3846");var i=n("cb7c"),s=n("0bfb"),a=n("9e1e"),o="toString",r=/./[o],c=function(e){n("2aba")(RegExp.prototype,o,e,!0)};n("79e5")((function(){return"/a/b"!=r.call({source:"a",flags:"b"})}))?c((function(){var e=i(this);return"/".concat(e.source,"/","flags"in e?e.flags:!a&&e instanceof RegExp?s.call(e):void 0)})):r.name!=o&&c((function(){return r.call(this)}))},c09f:function(e,t,n){"use strict";n.r(t);var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{directives:[{name:"show",rawName:"v-show",value:e.container_show,expression:"container_show"}],ref:"container_vtk"}),e._v(" "),n("div",{staticClass:"divb"},[n("h1",[e._v("cp")]),e._v(" "),e._l(e.baseColors,(function(e,t){return n("el-tag",{key:t,attrs:{color:e}})})),e._v(" "),n("vtkLoad",{ref:"vtkLoad",attrs:{urls:e.urls,vectorFactor:e.vectorFactor,contourLevel:e.contourLevel}}),e._v(" "),n("el-input-number",{attrs:{min:1,max:20,label:"contour level"},model:{value:e.contourLevel,callback:function(t){e.contourLevel=t},expression:"contourLevel"}})],2)])},s=[],a=(n("5df3"),n("f400"),n("ac6a"),n("6b54"),n("a481"),n("28a5"),n("c5f6"),n("5a89")),o=(n("e3d9"),n("4721")),r={data:function(){return{contourLevel:3,container_show:!0,scene:null,renderer:null,camera:null,controls:null,maxX:0,maxY:0,maxZ:0,minX:0,minY:0,minZ:0,camerahight:5,mufactor:.2,meshs:[],zones:[],percentage:0,movetage:0,nowIndex:0,moveflag:!1,clock:null,baseColors:[]}},props:{urls:Array,vectorFactor:Number},mounted:function(){this.initScene(),this.initBaseColors()},watch:{contourLevel:{handler:function(e){this.initBaseColors()},deep:!0,immediate:!1}},methods:{getColor:function(e,t,n){for(var i=(t-e)/this.contourLevel,s=0;s<this.contourLevel;s++){var a=e+s*i;if(Math.max(a,n)==a){var o=this.baseColors[s];return o}}return this.baseColors[this.contourLevel-1]},initBaseColors:function(){this.baseColors=[];var e=0,t=240;this.baseColors.push(this.colorHex(this.hsltorgb(e,100,50)));for(var n=Math.round((t-e)/this.contourLevel),i=1;i<this.contourLevel-1;i++)this.baseColors.push(this.colorHex(this.hsltorgb(e+n*i,100,50)));this.baseColors.push(this.colorHex(this.hsltorgb(t,100,50)))},hsltorgb:function(e,t,n){e/=360,t/=100,n/=100;var i=[];if(0==t)i=[Math.round(255*n),Math.round(255*n),Math.round(255*n)];else for(var s=n>=.5?n+t-n*t:n*(1+t),a=2*n-s,o=(i[0]=e+1/3,i[1]=e,i[2]=e-1/3,0);o<i.length;o++){var r=i[o];switch(r<0?r+=1:r>1&&(r-=1),!0){case r<1/6:r=a+6*(s-a)*r;break;case 1/6<=r&&r<.5:r=s;break;case.5<=r&&r<2/3:r=a+(s-a)*(4-6*r);break;default:r=a;break}i[o]=Math.round(255*r)}return this.colorHex("rgb("+i[0]+","+i[1]+","+i[2]+")")},colorHex:function(e){var t=/^(rgb|RGB)/;if(t.test(e)){for(var n="#",i=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),s=0;s<i.length;s++){var a=Number(i[s]).toString(16);"0"===a&&(a+=a),n+=a}return n}return String(e)},init:function(){this.clock=new a["j"],this.scene=new a["P"],this.renderer=new a["W"]({antialias:!0,alpha:!0}),this.camera=new a["H"](20,1,.2,1e4),this.controls=new o["a"](this.camera,this.renderer.domElement)},initScene:function(){null==this.scene&&this.init(),this.renderer.setSize(500,500),this.$refs.container_vtk.appendChild(this.renderer.domElement)},load:function(){var e=this,t=0;e.urls.forEach((function(n){e.loadone(n,(function(){t++,e.percentage=Math.round(t/e.urls.length*100)}))}))},show:function(e){var t=this;this.movetage=Math.round(e/this.zones.length*100);var n=this.zones[e].cells,i=this.zones[e].positions,s=this.zones[e].colorMap,o=this.zones[e].vectors,r=new a["h"];r.setIndex(n),r.setAttribute("position",new a["t"](i,3));var c=new a["X"](r),h=new a["A"](c,new a["y"]({color:65280}));h.position.x=-1*(this.maxX+this.minX)/2,h.position.y=-1*(this.maxY+this.minY)/2,h.position.z=-1*(this.maxZ+this.minZ)/2,this.meshs.push(h),this.scene.add(h);for(var l=i.slice(0),u=0;u<l.length;u++)l[u]=l[u]+o[u]*this.vectorFactor;var m=new a["h"],f=[],p=new a["k"];if(s.get("Displacement-magnitude")){var v=s.get("Displacement-magnitude").scalars,d=0,x=0;v.forEach((function(e){d=Math.max(e,d),x=Math.min(e,x)}));var g=new a["a"](4473924);if(this.scene.add(g),v.forEach((function(e){var n=t.getColor(x,d,e);p.setHex(n),f.push(p.r),f.push(p.g),f.push(p.b)})),m.setIndex(n),m.setAttribute("position",new a["t"](l,3)),1===this.meshType){var b=new a["X"](m),w=new a["A"](b,new a["y"]({color:65280}));w.position.x=-1*(this.maxX+this.minX)/2,w.position.y=-1*(this.maxY+this.minY)/2,w.position.z=-1*(this.maxZ+this.minZ)/2,this.meshs.push(w),this.scene.add(w)}else if(2===this.meshType){m.setAttribute("color",new a["t"](f,3));var E=new a["F"]({vertexColors:a["V"],side:a["n"]}),S=new a["E"](m,E);S.position.x=-1*(this.maxX+this.minX)/2,S.position.y=-1*(this.maxY+this.minY)/2,S.position.z=-1*(this.maxZ+this.minZ)/2,this.meshs.push(S),this.scene.add(S)}}},clear:function(){var e=this;this.meshs.forEach((function(t){e.scene.remove(t)})),this.meshs=[]},loadone:function(e,t){var n=this,i=new a["s"];i.load(e,(function(e){n.vtk(e),t()}),(function(e){}),(function(e){console.error("An error happened")}))},vtk:function(e){var t,n=this,i=/^POINTS /,s=/^CELLS[ ]+(\d+)/,a=/^VECTORS /,o=/^CELL_TYPES[ ]+(\d+)/,r=/(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g,c=/(\-?\d+\.?[\d\-\+E]*)\s+(\-?\d+\.?[\d\-\+E]*)\s+(\-?\d+\.?[\d\-\+E]*)/g,h=/^[^\d.\s-]+/,l=/(\-?\d+)\s+([\s\d]*)/,u=/(\-?\d+\.?[\d\-\+E]*)\s/,m=!1,f=!1,p=!1,v=[],d=[],x=[],g=new Map,b=e.split("\n");b.forEach((function(e){if(0===e.indexOf("SCALARS")){var b=e.split(" ")[1];"undefined"==typeof g.get(b)&&g.set(b,{inSection:!0,scalars:[]}),m=!1,f=!1,!1,p=!1,g.forEach((function(e,t){t!==b&&(e.inSection=!1)}))}if(g.forEach((function(n,i){n.inSection&&null!==(t=u.exec(e))&&n.scalars.push(parseFloat(t[0]))})),m)while(null!==(t=r.exec(e))){if(null!==h.exec(e))break;var w=parseFloat(t[1]),E=parseFloat(t[2]),S=parseFloat(t[3]);n.maxX=w>n.maxX?w:n.maxX,n.maxY=E>n.maxY?E:n.maxY,n.maxZ=S>n.maxZ?S:n.maxZ,n.minX=w<n.minX?w:n.minX,n.minY=E<n.minY?E:n.minY,n.minZ=S<n.minZ?S:n.minZ,v.push(w,E,S)}if(f&&null!==(t=l.exec(e))){var k=parseInt(t[1]),M=t[2].split(/\s+/);if(k>=3)for(var C,L,X=parseInt(M[0]),Y=1,y=0;y<k-2;++y)C=parseInt(M[Y]),L=parseInt(M[Y+1]),d.push(X,C,L),Y++}if(p)while(null!==(t=c.exec(e))){if(null!==h.exec(e))break;w=parseFloat(t[1]),E=parseFloat(t[2]),S=parseFloat(t[3]);x.push(w,E,S)}null!==i.exec(e)&&(m=!0,f=!1,!1,p=!1,g.forEach((function(e,t){e.inSection=!1}))),null!==s.exec(e)&&(m=!1,f=!0,!1,p=!1,g.forEach((function(e,t){e.inSection=!1}))),null!==o.exec(e)&&(m=!1,f=!1,!0,p=!1,g.forEach((function(e,t){e.inSection=!1}))),null!==a.exec(e)&&(m=!1,f=!1,!1,p=!0,g.forEach((function(e,t){e.inSection=!1})))})),this.zones.push({cells:d,positions:v,colorMap:g,vectors:x}),this.initShow()},initShow:function(){var e=this;e.camerahight=Math.max(Math.abs(e.maxX),Math.abs(e.maxY),Math.abs(e.maxZ),Math.abs(e.minX),Math.abs(e.minY),Math.abs(e.minZ)),e.controls.target.set(0,0,0),e.controls.update(),e.camera.position.set(-1,3*e.camerahight,4*e.camerahight),e.camera.lookAt(e.scene.position),e.camera.updateMatrix(),e.renderer.render(e.scene,e.camera);var t=function t(){e.renderer.render(e.scene,e.camera),requestAnimationFrame(t)};t();setInterval((function(){e.moveflag&&e.nowIndex<e.zones.length&&(e.clear(),e.show(e.nowIndex),e.nowIndex++,e.renderer.render(e.scene,e.camera))}),1e3)},moveReStart:function(){this.moveflag=!0,this.nowIndex=0},moveStart:function(){this.moveflag=!0},moveStop:function(){this.moveflag=!1},positive:function(e){"x"==e&&this.camera.position.set(4*this.camerahight,0,0),"y"==e&&this.camera.position.set(0,4*this.camerahight,0),"z"==e&&this.camera.position.set(0,0,4*this.camerahight),this.camera.lookAt(scene.position),this.camera.updateMatrix()},negative:function(e){"x"==e&&this.camera.position.set(-4*this.camerahight,0,0),"y"==e&&this.camera.position.set(0,-4*this.camerahight,0),"z"==e&&this.camera.position.set(0,0,-4*this.camerahight),this.camera.lookAt(scene.position),this.camera.updateMatrix()},large:function(){var e=this;this.meshs.forEach((function(t){var n=t.scale.x*(1+e.mufactor),i=t.scale.y*(1+e.mufactor),s=t.scale.z*(1+e.mufactor);t.scale.set(n,i,s)}))},small:function(){var e=this;this.meshs.forEach((function(t){var n=t.scale.x*(1-e.mufactor),i=t.scale.y*(1-e.mufactor),s=t.scale.z*(1-e.mufactor);t.scale.set(n,i,s)}))}}},c=r,h=(n("0fea"),n("2877")),l=Object(h["a"])(c,i,s,!1,null,"797fbbf7",null);t["default"]=l.exports}}]);