#ifndef FILEMANAGER #define FILEMANAGER #include "EvaluationTreeD.h" #include "PointSet.h" #include #include #define PI 3.1415926535897932385 class FileManager{ public: static PointSet* readMeshFile(char* name){ ifstream in(name); printf("File read is started. (Mesh file)\n"); int N; in >> N; int fN; in >> fN; printf("%d points.\n", N); printf("%d faces.\n", fN); PointSet* ps = new PointSet; ps->setPointSize(N); double a = 0.25*PI; double b = 0.25*PI; int i; for(i=0; i> x; in >> y; in >> z; //float xt = cos(a)*x - sin(a)*cos(b)*y - sin(a)*sin(b)*z; //float yt = sin(a)*x + cos(a)*cos(b)*y + cos(a)*sin(b)*z; //float zt = -sin(b)*y + cos(b)*z; //ps->setPoint(i, xt, yt, zt); ps->setPoint(i, x, y, z); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d points are read.", i); } float (*vertex)[3] = ps->_point; float (*normal)[3] = ps->_normal; for(i=0; i> dummy; in >> f0; in >> f1; in >> f2; float* p0 = vertex[f0]; float* p1 = vertex[f1]; float* p2 = vertex[f2]; float v1x = p1[0] - p0[0]; float v1y = p1[1] - p0[1]; float v1z = p1[2] - p0[2]; float v2x = p2[0] - p0[0]; float v2y = p2[1] - p0[1]; float v2z = p2[2] - p0[2]; float nx = v1y*v2z - v1z*v2y; float ny = v1z*v2x - v1x*v2z; float nz = v1x*v2y - v1y*v2x; normal[f0][0] += nx; normal[f0][1] += ny; normal[f0][2] += nz; normal[f1][0] += nx; normal[f1][1] += ny; normal[f1][2] += nz; normal[f2][0] += nx; normal[f2][1] += ny; normal[f2][2] += nz; } for(i=0; i> N; printf("%d points.\n", N); PointSet* ps = new PointSet; ps->setPointSize(N); int i; for(i=0; i> x; in >> y; in >> z; ps->setPoint(i, x, y, z); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d points are read.", i); } for(i=0; i> x; in >> y; in >> z; ps->setNormal(i, -x, -y, -z); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d normals are read.", i); } printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFile read is done. \n\n"); in.close(); return ps; } static PointSet* readPwvFile(char* name){ ifstream in(name); printf("File read is started.\n"); int N; in >> N; printf("%d points.\n", N); PointSet* ps = new PointSet; ps->setPointSize(N); int i; for(i=0; i> x; in >> y; in >> z; ps->setPoint(i, x, y, z); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d points are read.", i); } for(i=0; i> v; ps->setValue(i, v); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d values are read.", i); } printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFile read is done. \n\n"); in.close(); return ps; } static void writePwvFile(PointSet* ps, char* name){ ofstream out(name); printf("File write is started.\n"); int N = ps->_pointN; out << N << endl; printf("%d points.\n", N); float (*point)[3] = ps->_point; int i; for(i=0; i_value; for(i=0; i_pointN; fprintf(out, "%d\n", N); printf("%d points.\n", N); float (*point)[3] = ps->_point; int i; for(i=0; i_normal; for(i=0; imin[0], tree->min[1], tree->min[2]); fprintf(out, "%f %f %f\n", tree->max[0], tree->max[1], tree->max[2]); int N; BasisFunction** bfs; tree->getBFS(bfs, N); fprintf(out, "%d\n", N); fprintf(out, "%f\n", tree->out); printf("%d basis functions.\n", N); for(int i=0; icenterX, bfi->centerY, bfi->centerZ, bfi->cXX, bfi->cYY, bfi->cZZ, bfi->cXY, bfi->cYZ, bfi->cZX, bfi->cX, bfi->cY, bfi->cZ, bfi->c0, bfi->support, bfi->level); if(i%10000 == 0) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %d functions are written.", i); } fclose(out); printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bFile write is done. \n\n"); delete[] bfs; } }; #endif