/*----------------------------------------------------------------------- | MAIN | -----------------------------------------------------------------------*/ int main () { FILE *ostream; ostream = fopen("orientation", "r"); errorf(ostream); FILE *estream; estream = fopen("export1.xyzi", "r"); errorf(estream); int i = linesoffilex(estream); points *cloud; cloud = malloc((sizeof(double) * i)* 3 + (sizeof(int) * i)); if (cloud == NULL) {error();} cloud = loadxyzi(estream, i); info orient; orient = orientation(ostream); values *real; real = malloc((sizeof(double) * i)* 3 + (sizeof(int) * i)* 4); if (real == NULL) {error();} real = project(cloud, i, orient); values *sort; sort = malloc((sizeof(double) * i)* 3 + (sizeof(int) * i)* 4); if (sort == NULL) {error();} sort = sorttod(real, i); int j = threshold(sort,i, orient); free(cloud); FILE *istream; istream = fopen("exportx", "r"); errorf(istream); values *project; project = malloc(sizeof(double) *i* 3 + sizeof(int) * 3* i); if (project == NULL) {error();} project = loadt(istream, j); saveimage(project, orient); printf("finished\n"); free(project); fclose(ostream); fclose(estream); fclose(istream); return 0; }
bool io::read(const char* url, io::reader& e) { auto pp = io::plugin::find(szext(url)); if(!pp) return false; const char* source = loadt(url); if(!source || source[0] == 0) return false; pp->read(source, e); delete source; return true; }
//自动切分纹理产生纹理数组的方法 static void generateTexCoor(){ int bw = (int)(360/angleSpan); int bh = (int)(180/angleSpan); float *result= pTexture; float sizew=1.0f/bw;//列数 float sizeh=1.0f/bh;//行数 int c=0; int i,j; for(i=0;i<bh;i++){ for(j=0;j<bw;j++){ //每行列一个矩形,由两个三角形构成,共六个点,12个纹理坐标 float s=j*sizew; float t=i*sizeh; #define loads(x) (result[c++]= 1.0 - (x)) #define loadt(x) (result[c++]= (x)) loads(s); loadt(t); loads(s); loadt(t+sizeh); loads(s+sizew); loadt(t); loads(s+sizew); loadt(t); loads(s); loadt(t+sizeh); loads(s+sizew); loadt(t+sizeh); } } }
bsfile(const char* url, const bsfile* parent = 0) : parent(0), url(url), start(loadt(url)) { }