bool ObjReader::readFile2(char* name) { fstream file; string line; vector<string> data; Model *mod = new ModelAdv(); scPtr->models.push_back(mod); modPtr = mod; modPtr->implicit= false; Material *mat1= new MaterialPhong; mat1->setDiffuse(ColourRGB(0.5,0.5,0.5)); mat1->setAmbientC(ColourRGB(0.2,0.2,0.2)); mat1->setSpecular(ColourRGB(0.5,0.5,0.5)); mat1->setSpecularExp(2); scPtr->materials.push_back(mat1); modPtr->material = mat1; file.open(name); while(! file.eof()) { getline (file,line); data = getWords(line); if(data.size() >0) { if(data[0] == "v") { storeVertex(data); } if(data[0] == "vt") { storeVertexUV(data); } if(data[0] == "vn") { storeVertexNormal(data); } if(data[0] == "f") { storeModel(data); } } } //invertPolygons(); clear(); file.close(); return true; }
int main(int argc, char** argv) { //srand(getpid()); //srand48(getpid()); srand(0); srand48(0); properties props = TrainParameters(&argc, &argv); if (argc != 3) { printInstructions(); return 4; } char * data_file = argv[1]; char * data_model = argv[2]; svm_dataset dataset = readTrainFile(data_file); printf("\nDataset Loaded from file: %s\n\nTraining samples: %d\nNumber of features: %d\n\n",data_file, dataset.l,dataset.maxdim); struct timeval tiempo1, tiempo2; omp_set_num_threads(props.Threads); printf("Running IRWLS\n"); gettimeofday(&tiempo1, NULL); initMemory(props.Threads,(props.MaxSize+1)); double * W = trainFULL(dataset,props); gettimeofday(&tiempo2, NULL); printf("\nWeights calculated in %ld\n\n",((tiempo2.tv_sec-tiempo1.tv_sec)*1000+(tiempo2.tv_usec-tiempo1.tv_usec)/1000)); model modelo = calculateModel(props, dataset, W); printf("Saving model in file: %s\n\n",data_model); FILE *Out = fopen(data_model, "w+"); storeModel(&modelo, Out); fclose(Out); return 0; }