C++将坐标数据写入txt文件

记录一下写的txt文件,现在是将坐标数据写入到该文件中,具体的实现代码如下。

  ofstream outfile("D:\\TIF\\dem\\cesium_result_qinyan_qm_16\\data.txt", ios::trunc);
  outfile.setf(ios::fixed, ios::floatfield);
  outfile.precision(12);

  cartesianVertices.resize(mMesh.vertices.size());
  for (size_t i = 0, icount = mMesh.vertices.size(); i < icount; i++) {
    const CRSVertex &vertex = mMesh.vertices[i];

	outfile << mMesh.vertices[i].x << "," << mMesh.vertices[i].y <<","<< mMesh.vertices[i].z << "\n";

    cartesianVertices[i] = LLH2ECEF(vertex);
  }
  outfile.close();

注意上面ios::trunc是清零之前的数据。可以使用ios:app增加数据。

你可能感兴趣的:(C++)