Can I get an .stl from a spreadsheet?

5 visualizaciones (últimos 30 días)
Kate Hruby
Kate Hruby el 15 de En. de 2018
Respondida: DGM el 8 de Abr. de 2025
I have a spreadsheet with coordinate data (lat/long) and height for the surface and the bed of a glacier. I'm looking to take this data and convert it to an .stl geometry file that I can use for modeling in other programs like COMSOL or Elmer/Ice. I have been able to plot the data using boundaryFacets and trisurf to visually get a good geometry, but how do I transfer that to an .stl?
What I've tried:
iso2mesh (surf2stl command) "wrote 0 facets" when I tried surf2stl('GeoSTL',X,Y,Z);
Using delaunayTriangulation and tetramesh gives me a shape that is not similar enough to my glacier to use.
Attached is my code and an arbitrary set of coordinates and depths to represent a glacier.

Respuestas (2)

Darshan Ramakant Bhat
Darshan Ramakant Bhat el 18 de En. de 2018
I hope below File Exchange Submission will help you:
  2 comentarios
Kate Hruby
Kate Hruby el 18 de En. de 2018
Hi Darshan,
When I try surf2stl the program runs, but the output file is nonexistent (it "wrote 0 facets" like I stated above). Am I missing something with that command?
Darshan Ramakant Bhat
Darshan Ramakant Bhat el 19 de En. de 2018
Hi Kate,
surf2stl is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Feel free to contact the author of this submission directly for specific questions about the implementation.

Iniciar sesión para comentar.


DGM
DGM el 8 de Abr. de 2025
Surf2stl() expects gridded data unambiguously defining a surface. All you have is a list of scattered points. The way the data is sampled does allow the problem to be simplified.
% the points consist of fixed z-offset pairs at each x,y location
% we can triangulate the projection in 2D
V = xlsread('mycoordinatedata.xls');
% rearrange the data into the top and bottom surfaces
V = [V(2:2:end,:); V(1:2:end,:)]; % [top; bottom]
% just manually find the boundary curve for one surface
% by sorting vertices ccw around the shape
boundary = [10 9 7 5 4 2 1 3 6 8]; % row subs of V
boundary = [boundary.' circshift(boundary.',-1)]; % express as an edge list
% do the triangulation of the xy data alone
nverts = size(V,1)/2; % the number of points in the top surface
T = delaunayTriangulation(V(1:nverts,1:2),boundary); % only x,y data
F = T.ConnectivityList(isInterior(T),:); % the top faces
F = [F; fliplr(F)+nverts]; % the bottom faces
% go along the boundary and generate wall triangles
va = boundary(:,1); % top
vb = va + nverts; % bottom
vc = circshift(va,-1); % top
vd = vc + nverts; % bottom
wallF = [va vb vc; vd vc vb];
F = [F; wallF]; % add them to the list
% write to an STL
stlwrite(triangulation(F,V),'geostl.stl')
% display it using patch()
patch('faces',F,'vertices',V,'facecolor','w','edgecolor','k');
view(3); camlight; view(-35,20); grid on
xlabel('X'); ylabel('Y'); zlabel('Z')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by