C# 读取并导入一个带C的图层
您好,我想知道是否有任何方法可以读取.ply文件,并且只取X-Y-Z位置。ply文件格式为:C# 读取并导入一个带C的图层,c#,file,import,C#,File,Import,您好,我想知道是否有任何方法可以读取.ply文件,并且只取X-Y-Z位置。ply文件格式为: ply format ascii 1.0 element vertex 303943 property float x property float y property float z property uchar red property uchar green property uchar blue end_header 1.955 1.647 -1.359 182 185 1
ply
format ascii 1.0
element vertex 303943
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
1.955 1.647 -1.359 182 185 182
0.87 1.532 -1.453 152 160 153
0.843 1.548 -1.484 153 161 154
0.832 1.539 -1.472 151 159 152
除了在Matlab中找到一种方法外,我还没有找到任何其他方法。试试这个
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication93
{
class Program
{
const string FILENAME = @"c:\temp\test.txt";
static void Main(string[] args)
{
List<List<double>> data = new List<List<double>>();
StreamReader reader = new StreamReader(FILENAME);
string inputLine = "";
Boolean endHeader = false;
while ((inputLine = reader.ReadLine()) != null)
{
inputLine = inputLine.Trim();
if (inputLine.Length > 0)
{
if(endHeader)
{
List<double> newRow = inputLine.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToList();
data.Add(newRow);
}
else
{
if(inputLine.Contains("end_header"))
{
endHeader = true;
}
}
}
}
}
}
}
是什么阻止你写一些c代码来解析这种格式并得到x,y和z?你似乎误解了StackOverflow的概念。你不描述你想要什么,人们给你发代码。您提供了自己的代码,并告诉我们哪些代码不起作用。如果你正在寻找一个现有的库来为你做这件事-这也是离题的。注意,该脚本还将阅读“面列表”。。如果您只需要顶点,应该从PLY头读取顶点计数,并仅读取该数量的线。或在inputLine.Split提供3个以上的值时停止读取。层格式: