Graphics 写入四边形的最简单网格文件格式?
我有1024 x 1024 x 1024的体素贴图,超过10亿个体素,我正在从XYZ轴遍历它们,以找到其中的扫描轮廓 每次碰到体素边界时,我都要为遇到的面创建一个四边形参照,该参照由4个顶点和一个三角形/四边形参照索引组成 因为结果是5000-6000万个四边形,我不认为我可以将数组写入内存并使用循环合并顶点,这会占用太多内存,我可以使用Meshlab删除重复的顶点 所以每次我发现我穿过一个边界时,只写4个顶点和对它们的引用是很简单的 A/我可以使用其他方法吗 B/什么样的文件格式允许我对以下行进行文件流处理:Graphics 写入四边形的最简单网格文件格式?,graphics,3d,polygon,mesh,vertex,Graphics,3d,Polygon,Mesh,Vertex,我有1024 x 1024 x 1024的体素贴图,超过10亿个体素,我正在从XYZ轴遍历它们,以找到其中的扫描轮廓 每次碰到体素边界时,我都要为遇到的面创建一个四边形参照,该参照由4个顶点和一个三角形/四边形参照索引组成 因为结果是5000-6000万个四边形,我不认为我可以将数组写入内存并使用循环合并顶点,这会占用太多内存,我可以使用Meshlab删除重复的顶点 所以每次我发现我穿过一个边界时,只写4个顶点和对它们的引用是很简单的 A/我可以使用其他方法吗 B/什么样的文件格式允许我对以下行
FORMAT= .EASY
vtxA: (2.0 , 5.0, 2,0) nml(-1,0,0)
vtxB: (2.0 , 6.0, 2,0) nml(-1,0,0)
vtxC: (2.0 , 5.0, 3,0) nml(-1,0,0)
vtxD: (2.0 , 6.0, 3,0) nml(-1,0,0)
QUAD: ABCD
vtxC: (1002.0 , 5.0, 2,0) nml(1,0,0)
vtxD: (1002.0 , 6.0, 2,0) nml(1,0,0)
vtxE: (1002.0 , 5.0, 3,0) nml(1,0,0)
vtxF: (1002.0 , 6.0, 3,0) nml(1,0,0)
QUAD: CDEF
我一直在研究obj、ply和stl文件格式,将四边形直接写入磁盘的最简单的格式似乎是stl,即使它是三角形,因为您可以将stram写入磁盘,无需阵列,非常适合在实验室快速修复 以下是一个多维数据集示例:
solid cube
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 0 1 0
vertex 1 1 0
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 1 1 0
vertex 1 0 0
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 0 0 1
vertex 0 1 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 0 1 1
vertex 0 1 0
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 1 0 0
vertex 1 0 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 0
vertex 1 0 1
vertex 0 0 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 1
vertex 1 0 1
vertex 1 1 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 0 1
vertex 1 1 1
vertex 0 1 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1 0 0
vertex 1 1 0
vertex 1 1 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1 0 0
vertex 1 1 1
vertex 1 0 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 1 0
vertex 0 1 1
vertex 1 1 1
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0 1 0
vertex 1 1 1
vertex 1 1 0
endloop
endfacet
endsolid cube
c类代码编写上述代码:
function Xquad( X:float , Y:float , Z:float , cnt:float){
//based on stl cube
qstr+="facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X) +" "+ st(Y+1) +" "+ st(Z)+ "\n"+
"vertex "+st(X) +" "+ st(Y+1) +" "+ st(Z+1)+ "\n"+
"endloop\n" +
"endfacet\n"+
"facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X) +" "+ st(Y+1)+" "+ st(Z+1)+ "\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z+1)+ "\n"+
"endloop\n"+
"endfacet\n";
}
function Yquad( X:float , Y:float , Z:float , cnt:float){
qstr+="facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1)+" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1)+" "+ st(Y) +" "+ st(Z+1)+ "\n"+
"endloop\n" +
"endfacet\n"+
"facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1)+" "+ st(Y) +" "+ st(Z+1)+ "\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z+1)+ "\n"+
"endloop\n"+
"endfacet\n";
}
function Zquad( X:float , Y:float , Z:float , cnt:float){
qstr+="facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X) +" "+ st(Y+1) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1)+" "+ st(Y+1) +" "+ st(Z)+ "\n"+
"endloop\n" +
"endfacet\n"+
"facet normal " +"0 0 0"+ "\n"+
"outer loop\n"+
"vertex "+st(X) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1) +" "+ st(Y+1) +" "+ st(Z)+ "\n"+
"vertex "+st(X+1) +" "+ st(Y) +" "+ st(Z)+ "\n"+
"endloop\n"+
"endfacet\n";
}
我会使用二进制STL,每个四元体两个tringle。此处的更多信息:可能可以存储所需信息。对于您的方法,只需要存储在以前某个四边形中使用的顶点的信息。不需要将四边形存储在内存中,因为它们可以写入文件
网格中有1025x1025x1025(~=1G)个顶点,可以使用三组网格坐标来标识顶点
(x,y,z)
,其中0为什么不从切片进行网格划分。您需要记住最后一个和实际切片周长多边形。切片i-th
多边形完成后,在(i-1)-th
多边形中查找匹配项以形成四边形并将其添加到网格中。您可以将顶点和索引存储在单独的文件中,当整个网格完成合并/打包并保存为您支持的三维格式时。。。可能更好的方法是在每个切片上使用三角形而不是四边形。这是一个非常好的主意,我倾向于逻辑结果,它肯定更简单。看看相关的QA,你的切片应该非常相似,所以解决方案可能会比那简单得多。可能是缠绕规则。。。如果您所说的fn
是指最后一个f5 14 8
如果有帮助,请尝试将其更改为f8 4 1 5
。。。顺便说一句,不确定是否所有波前obj加载程序都支持混合的v
和f
行,但在所有操作完成后,您始终可以对这两行进行后期处理以将其分开。。。但我会从一开始创建两个文件,一个用于f
,另一个用于v
,当整个网格合并后,两个文件不会使用索引,使巨大的网格变得更大。。。另一方面,二进制STL版本可以更快地加载(如果不是太大的话)