,怎么将txt文本中的数据点提取出来,并保存到数组里
求助,如何将txt文本中的数据点提取出来,并保存到数组里
solid data
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 7.460438e+002 1.019743e+002 3.140000e+002
vertex 7.233645e+002 1.246536e+002 3.140000e+002
vertex 7.049680e+002 1.509265e+002 3.140000e+002
endloop
endfacet
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 7.049680e+002 1.509265e+002 3.140000e+002
vertex 1.023665e+003 3.349265e+002 3.140000e+002
vertex 1.037220e+003 3.058582e+002 3.140000e+002
endloop
endfacet
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 8.013850e+002 4.158300e+002 3.140000e+002
vertex 7.049680e+002 1.509265e+002 3.140000e+002
vertex 6.914133e+002 1.799948e+002 3.140000e+002
endloop
endfacet
在一个data.txt文本中读取vertex 之后的三个数据,分别保存到x(),y(),z()数组中去要如何实现啊,各位大神求指导!相邻的三个vertex是一个三角形面饼。是由stl文件保存的asc码
这只是txt文本中的一小段,一共有24798个vertex
------解决方案--------------------
定义一个类模块vertex,它只包含三个数据成员,使用类保存顶点,可以动态的创建对象
public x as single
public y as single
public z as sing
窗口模块中:
假设你已经将solid data读入到一个字符串sData中
solid data
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 7.460438e+002 1.019743e+002 3.140000e+002
vertex 7.233645e+002 1.246536e+002 3.140000e+002
vertex 7.049680e+002 1.509265e+002 3.140000e+002
endloop
endfacet
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 7.049680e+002 1.509265e+002 3.140000e+002
vertex 1.023665e+003 3.349265e+002 3.140000e+002
vertex 1.037220e+003 3.058582e+002 3.140000e+002
endloop
endfacet
facet normal 0.000000e+000 0.000000e+000 -1.000000e+000
outer loop
vertex 8.013850e+002 4.158300e+002 3.140000e+002
vertex 7.049680e+002 1.509265e+002 3.140000e+002
vertex 6.914133e+002 1.799948e+002 3.140000e+002
endloop
endfacet
在一个data.txt文本中读取vertex 之后的三个数据,分别保存到x(),y(),z()数组中去要如何实现啊,各位大神求指导!相邻的三个vertex是一个三角形面饼。是由stl文件保存的asc码
这只是txt文本中的一小段,一共有24798个vertex
------解决方案--------------------
定义一个类模块vertex,它只包含三个数据成员,使用类保存顶点,可以动态的创建对象
public x as single
public y as single
public z as sing
窗口模块中:
假设你已经将solid data读入到一个字符串sData中
- VB code
dim s() as string dim x as vertex dim C as new collection '将所有的顶点使用集合收集 dim d() as string s=split(sData,vbcrlf) '把每行数据装入到s数组中,每个单元对应于一行 for i=0 to ubound(s) if instr(1,s(i),"vertex")>0 then '如果行包含关键字vertex d=split(s(i)," ") set x=new vertex if isnumeric(d(1)) then x.x=val(d(1)) if isnumeric(d(2)) then x.y=val(d(2)) if isnumeric(d(3)) then x.z=val(d(3)) c.add x end if next
------解决方案--------------------
童鞋们和谐啊,新手就该多照顾照顾啊~~~~~