我找到了几种工具,可以将MATLAB中的isosurface
- 类或meshgrid
数据转换为STL格式。示例包括stlwrite和surf2stl。我无法弄清楚的是如何获取一个delaunayTriangulation对象,并使用它创建一个STL文件或将其转换为等值面对象。
根本问题是我从不规则多边形的N-by-2边界点数组开始,所以我没有任何简单的方法来生成xyz meshgrid。如果有办法将边界列表转换为内部区域的等值面(恒定的Z高度是我所需要的),那也可以解决我的问题。
否则,我需要一些方法将delaunayTriangulation
对象转换为引用的MATLAB FEX工具可以处理的东西。
我确认我在MATLAB中的三角形集是一个圆的二维扇区。但是,当我将数据提供给stlwrite
并导入Cura
时,我会遇到灾难 - 三角形呈直角或从所需的角度旋转pi,或者更糟。这是stlwrite
的错误,Cura对某些意外的价值是敏感的,还是我无法分辨的。什么是最初的光盘:
例如,这是一组定义圆的扇区的点。我可以从这些数据中成功创建delaunayTriangulation对象。
>> [fcx1',fcy1']
ans =
100.4563 26.9172
99.9712 28.6663
99.4557 30.4067
98.9099 32.1378
98.3339 33.8591
97.7280 35.5701
97.0924 37.2703
96.4271 38.9591
95.7325 40.6360
95.0087 42.3006
94.2560 43.9523
93.4746 45.5906
92.6647 47.2150
91.8265 48.8250
90.9604 50.4202
90.0666 52.0000
89.1454 53.5640
88.1970 55.1116
87.2217 56.6425
86.2199 58.1561
85.1918 59.6519
84.1378 61.1297
83.0581 62.5888
81.9531 64.0288
80.8232 65.4493
79.6686 66.8499
78.4898 68.2301
77.2871 69.5896
76.0608 70.9278
74.8113 72.2445
73.5391 73.5391
72.2445 74.8113
70.9278 76.0608
69.5896 77.2871
68.2301 78.4898
66.8499 79.6686
65.4493 80.8232
64.0288 81.9531
62.5888 83.0581
61.1297 84.1378
59.6519 85.1918
58.1561 86.2199
56.6425 87.2217
55.1116 88.1970
53.5640 89.1454
52.0000 90.0666
50.4202 90.9604
48.8250 91.8265
47.2150 92.6647
45.5906 93.4746
43.9523 94.2560
42.3006 95.0087
40.6360 95.7325
38.9591 96.4271
37.2703 97.0924
35.5701 97.7280
33.8591 98.3339
32.1378 98.9099
30.4067 99.4557
28.6663 99.9712
26.9172 100.4563
25.1599 100.9108
23.3949 101.3345
21.6228 101.7274
19.8441 102.0892
18.0594 102.4200
16.2692 102.7196
14.4740 102.9879
12.6744 103.2248
10.8710 103.4303
9.0642 103.6042
7.2547 103.7467
5.4429 103.8575
3.6295 103.9366
1.8151 103.9842
0 104.0000
-1.8151 103.9842
-3.6295 103.9366
-5.4429 103.8575
-7.2547 103.7467
-9.0642 103.6042
-10.8710 103.4303
-12.6744 103.2248
-14.4740 102.9879
-16.2692 102.7196
-18.0594 102.4200
-19.8441 102.0892
-21.6228 101.7274
-23.3949 101.3345
-25.1599 100.9108
-26.9172 100.4563
0 0
答案 0 :(得分:0)
STL只是一种存储在内存网格信息中的格式,因此如果你有网格就有数据,你只需要用正确的格式将它写入内存。
您似乎将stlwrite
函数的顶点和面输入为
stlwrite(FILE, FACES, VERTICES);
delaunayTriangulation
输出为您提供了一个对象,可以轻松访问此数据,对象是对象DT
,DT.Points
是顶点,DT.ConnectivityList
是面。
您可以在链接的文档中阅读更多相关信息。
答案 1 :(得分:0)
Building on Ander B's answer, here is the complete sequence. These steps ensure that even concave polygons are properly handled.
Start with two vectors containing all the x
and the y
coordinates. Then:
% build the constraint list
constr=[ (1:(numel(x)-1))' (2:numel(x))' ; numel(x) 1;];
foodel = delaunayTriangulation(x',y',constr);
% get logical indices of interior triangles
inout = isInterior(foodel);
% if desired, plot the triangles and the original points to verify.
% triplot(foodel.ConnectivityList(inout, :),...
foodel.Points(:,1),foodel.Points(:,2), 'r')
% hold on
% plot(fooa.Points(:,1),fooa.Points(:,2),'g')
% now solidify
% need to create dummy 3rd column of points for a solid
point3 = [foodel.Points,ones(numel(foodel.Points(:,1)),1)];
% pick any negative 'elevation' to make the area into a solid
[solface,solvert] = surf2solid(foodel.ConnectivityList(inout,:),...
point3, 'Elevation', -10);
stlwrite('myfigure.stl',solface,solvert);
I've successfully turned some 'ugly' concave polygons into STLs that Cura is happy to turn into gCode.