public void WriteOFF(vtkPolyData polydata)
{
string offfilename = MyClass.StaticAppInfo.yagenyajingoff;
IntPtr X = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);
double[] xx = new double[3];
FileStream fs = new FileStream(offfilename, FileMode.Create);
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write("OFF" + "\r\n");
sw.Write(polydata.GetNumberOfPoints() + " " + polydata.GetNumberOfCells() + " 0\r\n");
for (int ww = 0; ww < polydata.GetNumberOfPoints(); ww++)
{
polydata.GetPoint(ww, X);
Marshal.Copy(X, xx, 0, 3);
sw.Write(xx[0] + " " + xx[1] + " " + xx[2] + "\r\n");
}
for (int ww = 0; ww < polydata.GetNumberOfCells(); ww++)
{
sw.Write("3 ");
for (int i = 0; i < polydata.GetCell(ww).GetNumberOfPoints(); i++)
{
sw.Write(polydata.GetCell(ww).GetPointId(i) + " ");
}
sw.Write("\r\n");
}
sw.Flush();
sw.Close();
fs.Close();
}
}
vtk转OFF格式
最新推荐文章于 2022-09-22 11:22:18 发布