export – STL-file Contains Mesh Defects
I want to make a piece of “curve object” for 3D printing.
I made a mesh region using points along a curve and exported it to a stl-file.
I verified the stl-file and found the result containing some mesh errors.
Here is a minimal sample.
$Version
14.1.0 for Microsoft Windows (64-bit) (July 16, 2024)
curve
Clear[fn, pts]
fn = Min[2, 1.8 - 3.6 x + x^3];
pts = Join[{#[[1]] /. {x_, _} -> {x, -2}}, #, {#[[-1]] /. {x_, _} -> {x, -2}}] &@(Join @@Cases[Plot[fn, {x, -1.8, 1.8}], Line[pts_] -> pts, \[Infinity]]);
Graphics[Line[pts]]
helper function
makemesh[pts_, thick_] := Module[{p = Join[pts /. {x_, y_} -> {-(thick/2), x, y}, pts /. {x_, y_} -> {thick/2, x, y}], n = Length[pts], index1, index2},
index1 = Range[n];
MeshRegion[p, {Polygon[Join[{index1, Reverse[index2 =n+index1]},
Join[#[[1]], Reverse[#[[2]]]]&/@Partition[Transpose[{index1, index2}], 2, 1, 1]]]}]]
result
thick = 1.;
samplemesh = makemesh[pts, thick]
FindMeshDefects[samplemesh]
The mesh region contains no error.
verify
file = Export["sample.stl", samplemesh]
FindMeshDefects[Import[file]]
But there are severeal errors in the imported STL-file.
Read more here: Source link




