Can't write isosurface to stl file
Show older comments
I've created an isosurface of a TPMS structure (Primitive, to be exact), but I'm having trouble writing it to an STL file. I've followed the example in this documentation practically to the letter:
extractIsosurface
However I keep running into two problems: First of all, trimesh(T) comes out looking like this:

And I can't figure out how to remove the lines. Second of all, I keep getting the error:
Error using fileparts
Input must be a row vector of characters, or a string scalar, or a cellstr, or a string matrix.
path = fileparts(filename);
Even though I used the exact same input format as the example. Am I missing something super obvious? Please help, my professor will rip my head off if I can't get this.
This is my code by the way
%% Input Parameters
unitcellsize = 5; % Cell size [mm]
length_x = 15; % Samplesize in x direction [mm]
length_y = 15; % Samplesize in y direction [mm]
length_z = 15; % Samplesize in z direction [mm]
step = 0.1; % To control the resolution [the smaller the better]
isovalue = 0.1;
%% Lactice Equation
syms x y z
f = @(x,y,z) cos((2.*pi.*x)./unitcellsize) + cos((2.*pi.*y)./unitcellsize) + cos((2.*pi.*z)./unitcellsize);
% ------------------ Sample Size -------------------
a = -length_x/2:step:length_x/2;
b = -length_y/2:step:length_y/2;
c = -length_z/2:step:length_z/2;
[X,Y,Z] = meshgrid(a,b,c);
%% Getting Coordinates
V = f(X,Y,Z);
co = isosurface(a,b,c,V,isovalue);
[faces1,verts1] = extractIsosurface(V,isovalue);
%% Gradient Plot
hold on
p = patch(co1);
isonormals(X,Y,Z,V,p)
view(3)
daspect([1 1 1])
colorbar
axis tight
camlight
lighting gouraud
box on
T = triangulation(double(faces1),double(verts1));
figure
trimesh(T)
%Export surface to .stl
stlwrite(T,'test.stl');
Accepted Answer
More Answers (0)
Categories
Find more on Scalar Volume Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
