2020. 3. 3. 01:05ㆍ카테고리 없음
I have the following matlab code: clear allclose allclcnp = 10;% number of points along cylinder heightnc = 15;% points in circumferenceh = 5.;% cylinder heightr = 1.;% cylinder radiust = linspace(0, 2.pi, nc);% angle in raddh = h/(np-1);% height difference between two pointsfor i = 1:npfor j = 1:ncx(i,j) = r.cos(t(j));y(i,j) = r.sin(t(j));z(i,j) = (i-1). dh;endend% a colormap for reference, i am using sthing else in my codef = sqrt(x.^2 + y.^2 + z.^2);subplot(1,2,1)surf(x,y,z,f)axis equalsubplot(1,2,2)mesh(x,y,z,f)axis equalThat generates a mesh out of a cylinder shape. Now, I can convert this grid file to stl format with script entering the command surf2stl('test.stl',x,y,z,'ascii') and can open it with paraview.But in that case if it's stl i loose the colormap (f variable from matlab script). What I want is either to be possible to have stl with shaded surfaces. OR i would prefer if I could export this mesh to a VTK file format but I don't know how. So I am looking how to convert matlab's surf or mesh data to VTK format. (edit: Or a third option to convert matlab grid to stl and then convert stl to vtk and add the scalar f to vtk file).I searched first in stackoverflow for possible duplicates but is not the same and doesn't have an answer.
Mat2vtk
As of the 2017 R3 release, Tecplot 360 now includes the ability to read VTU and VTM files, one of the many variations of file formats supported by VTK, the visualization toolkit.Learn more atVTK Unstructured Grid files, VTU for short, is an XML based format which contains unstructured cell types. Tecplot 360’s VTU reader supports classical unstructured grids composed of triangles, quads, tetrahedrons, pyramids, prisms, and bricks. We also support ASCII, Binary, and Binary Appended variants.Vtk MultiBlock files, VTM for short, are also an XML based file format which simply lists a set of VTU files to load. VTM files are often used with unsteady simulations and as a convenience to load many VTU files at once.We’ve worked with simulation codes like SimVascular, Envenio, COMSOL, and PyFr on the development of this loader to ensure compatibility and are pleased to offer the VTU and VTM readers to these user communities.