📄 filemanager.h
字号:
#include "stdafx.h"
#include <stdio.h>
#include "RBFcore\PointSet.h"
class FileManager{
public:
FileManager() {}
~FileManager() {}
bool ReadPointFile(PointSet * ps, CString file_name)
{
FILE* in = fopen(file_name, "r");
if(in == NULL)
return false;
//read #points
int N;
fscanf(in, "%d", &N);
ps->setPointSize(N);
//read points
for(int i=0; i<N; i++)
{
float x,y,z;
fscanf(in, "%f %f %f", &x, &y, &z);
ps->setPoint(i, x, y, z);
}
//read normals
int count = 0;
float (*point)[3] = ps->_point;
for(i=0; i<N; i++){
float x,y,z;
fscanf(in, "%f %f %f", &x, &y, &z);
if(x == 0 && y == 0 && z == 0)
continue;
float len = (float)sqrt(x*x + y*y + z*z);
x /= len;
y /= len;
z /= len;
//ps->setPoint(count, point[i][0], point[i][1], point[i][2]);
ps->setNormal(count, -x, -y, -z);
count++;
}
ps->_pointN = count;
fclose(in);
return true;
}
bool WritePointFile(PointSet * ps, CString file_name)
{
FILE* out = fopen(file_name, "w");
if(out == NULL)
return false;
int N = ps->_pointN;
fprintf(out, "%d\n", N);
for(int i=0; i<N; i++)
{
float *p = ps->_point[i];
fprintf(out, "%f %f %f \n", p[0], p[1], p[2]);
}
for(i=0; i<N; i++)
{
float *p = ps->_normal[i];
fprintf(out, "%f %f %f \n", -p[0], -p[1], -p[2]);
}
fclose(out);
return true;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -