void MainWindow::compareSides() { SparseMatrix *first = buildModel(*imageSteps1.at(currentStep1)); SparseMatrix *second = buildModel(*imageSteps2.at(currentStep2)); double angle = first->compareTo(*second); ui->timingLabel->setText(QString("Abs(Error) = %1").arg(angle)); }
AlgPuLP(const RCP<const Environment> &env__, const RCP<const Comm<int> > &problemComm__, const RCP<const MatrixAdapter<user_t,userCoord_t> > &adapter__) : env(env__), problemComm(problemComm__), adapter(adapter__) { modelFlag_t flags; flags.reset(); const ParameterList &pl = env->getParameters(); const Teuchos::ParameterEntry *pe; std::string defString("default"); std::string objectOfInterest(defString); pe = pl.getEntryPtr("objects_to_partition"); if (pe) objectOfInterest = pe->getValue<std::string>(&objectOfInterest); if (objectOfInterest == defString || objectOfInterest == std::string("matrix_rows") ) flags.set(VERTICES_ARE_MATRIX_ROWS); else if (objectOfInterest == std::string("matrix_columns")) flags.set(VERTICES_ARE_MATRIX_COLUMNS); else if (objectOfInterest == std::string("matrix_nonzeros")) flags.set(VERTICES_ARE_MATRIX_NONZEROS); buildModel(flags); }
AlgPuLP(const RCP<const Environment> &env__, const RCP<const Comm<int> > &problemComm__, const RCP<const MeshAdapter<user_t> > &adapter__) : env(env__), problemComm(problemComm__), adapter(adapter__) { modelFlag_t flags; flags.reset(); const ParameterList &pl = env->getParameters(); const Teuchos::ParameterEntry *pe; std::string defString("default"); std::string objectOfInterest(defString); pe = pl.getEntryPtr("objects_to_partition"); if (pe) objectOfInterest = pe->getValue<std::string>(&objectOfInterest); if (objectOfInterest == defString || objectOfInterest == std::string("mesh_nodes") ) flags.set(VERTICES_ARE_MESH_NODES); else if (objectOfInterest == std::string("mesh_elements")) flags.set(VERTICES_ARE_MESH_ELEMENTS); buildModel(flags); }
void Maze::generate() { // set starting (exit) point int randX = (int)ofRandom(NUM_CELLS_X); int randY = (int)ofRandom(NUM_CELLS_Y); currentCell = cells[randX][randY]; currentCell->visit(); currentCell->mazeExit = true; cellStack.push(currentCell); exitCell = currentCell; finishedGenerating = false; // generate the maze while (!finishedGenerating) { generateStep(); } buildModel(); // create moving balls with paths for (int i=0; i<settings->numberOfBalls; i++) { int sx = (int)ofRandom(60, NUM_CELLS_X-60); int sy = (int)ofRandom(10, 500); ofxSimpleSpline* spline = createSimpleSpline(sx, sy, 100); balls.push_back(new MovingBall(spline, settings)); } }
// http://tfc.duke.free.fr/old/models/md2.htm Assets::EntityModel* Md2Parser::doParseModel() { const char* cursor = m_begin; const int ident = readInt<int32_t>(cursor); const int version = readInt<int32_t>(cursor); if (ident != Md2Layout::Ident) throw AssetException() << "Unknown MD2 model ident: " << ident; if (version != Md2Layout::Version) throw AssetException() << "Unknown MD2 model version: " << version; /*const size_t skinWidth =*/ readSize<int32_t>(cursor); /*const size_t skinHeight =*/ readSize<int32_t>(cursor); /*const size_t frameSize =*/ readSize<int32_t>(cursor); const size_t skinCount = readSize<int32_t>(cursor); const size_t frameVertexCount = readSize<int32_t>(cursor); /* const size_t texCoordCount =*/ readSize<int32_t>(cursor); /* const size_t triangleCount =*/ readSize<int32_t>(cursor); const size_t commandCount = readSize<int32_t>(cursor); const size_t frameCount = readSize<int32_t>(cursor); const size_t skinOffset = readSize<int32_t>(cursor); /* const size_t texCoordOffset =*/ readSize<int32_t>(cursor); /* const size_t triangleOffset =*/ readSize<int32_t>(cursor); const size_t frameOffset = readSize<int32_t>(cursor); const size_t commandOffset = readSize<int32_t>(cursor); const Md2SkinList skins = parseSkins(m_begin + skinOffset, skinCount); const Md2FrameList frames = parseFrames(m_begin + frameOffset, frameCount, frameVertexCount); const Md2MeshList meshes = parseMeshes(m_begin + commandOffset, commandCount); return buildModel(skins, frames, meshes); }
/** * This function secures calls to glpk with an error hook. * @param forceError force error if bit 0 = 1 * @return ok code: 1 failure, 2 out of memory */ int runOptimizer(int forceError) { int ret = 0; INFO *info; info = (INFO*) malloc(sizeof(INFO)); if (info == NULL) { return 2; } info->env = (jmp_buf *) malloc(sizeof(jmp_buf)); if (info->env == NULL) { free(info); return 2; } info->text = "This information was passed to the hook function."; if (setjmp(*(info->env))) { printf("Post treatment of error.\n"); ret = 1; } else { glp_error_hook(errorHook, info); buildModel(forceError); } glp_error_hook(NULL, NULL); free(info->env); free(info); return ret; }
void EditorApplication::createSkybox(string skybox_name) { LibGens::Model *skybox_model=current_level->getModelLibrary()->getModel(skybox_name); if (skybox_model) { Ogre::SceneNode *scene_node = scene_manager->getRootSceneNode()->createChildSceneNode(); buildModel(scene_node, skybox_model, skybox_model->getName(), "", scene_manager, current_level->getMaterialLibrary(), 0, GENERAL_MESH_GROUP, false); unsigned short attached_objects=scene_node->numAttachedObjects(); for (unsigned short i=0; i<attached_objects; i++) { Ogre::Entity *entity=static_cast<Ogre::Entity *>(scene_node->getAttachedObject(i)); entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_SKIES_EARLY); unsigned int attached_entities=entity->getNumSubEntities(); Ogre::AxisAlignedBox aabb; aabb.setInfinite(); entity->getMesh()->_setBounds(aabb, false); for (unsigned int j=0; j<attached_entities; j++) { Ogre::SubEntity *sub_entity=entity->getSubEntity(j); Ogre::MaterialPtr material=sub_entity->getMaterial(); Ogre::Pass *pass=material->getTechnique(0)->getPass(0); pass->setDepthWriteEnabled(false); } } } }
void TreeModel::buildSampleModel(){ Employee* manager1=new Employee("manager1","cologne",12345); Employee* manager2=new Employee("manager2","Berlin",12345); Company* c=new Company("Google"); Department*d1=new Department("dep1"); Department*d2=new Department("dep2"); Department*d3=new Department("dep3"); Department*d4=new Department("dep4"); Employee* emp1=new Employee("Joe","malibu",123); Employee* emp2=new Employee("Jack","Koblenz",1234); Employee* emp3=new Employee("Dexter","Miami",1234); Employee* emp4=new Employee("Walter","Boston",1234); c->addDepartment(d1); c->addDepartment(d2); d1->addSubDepartment(d3); d3->addSubDepartment(d4); d1->addEmployee(manager1); d1->addEmployee(emp1); d1->addEmployee(emp2); d2->addEmployee(manager2); d2->addEmployee(emp3); d1->setManager(manager1); d2->setManager(manager2); d3->addEmployee(emp4); d3->setManager(emp4); buildModel(c); }
void NetworkPlan::createModel(vector<char*> lines) { vector<NodeInfo> nodes; if (parse(lines, nodes)) { buildModel(nodes); calculate(); } }
AlgPuLP(const RCP<const Environment> &env__, const RCP<const Comm<int> > &problemComm__, const RCP<const GraphAdapter<user_t,userCoord_t> > &adapter__) : env(env__), problemComm(problemComm__), adapter(adapter__) { modelFlag_t flags; flags.reset(); buildModel(flags); }
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow){ ui->setupUi(this); setWindowIcon(QIcon("/Users/nick102795/Desktop/favicon.ico")); // build all initial backend structures & load the appropriate data from files setInitialState(); // Set Up the top 8 Most Popular Playlists QListView *listView = ui->mostPopularPlaylistListView; QAbstractItemModel *model = buildModel(); // make the buildModel() func to intake the new most-popular PL strings listView->setModel(model); listView->show(); }
IloEdgeValMap CPLEX_LP_MSTSolverIF::resolveRAW() throw (ModelExceptions::GeneralConcertException) { IloEdgeValMap solution { }; buildModel(); try { solution = LP_RAW_Solve(); } catch (IloException& e) { ERROR(logger, LogBundleKey::CPLPMSTIF_SOLVER_ERROR, e.getMessage()); throw ModelExceptions::GeneralConcertException(); } return solution; }
void LaTeXCompletionModel::completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) { if(!range.isValid() || (invocationType == AutomaticInvocation && !KileConfig::completeAuto())) { m_completionList.clear(); reset(); return; } Q_UNUSED(invocationType); m_currentView = view; KILE_DEBUG() << "building model..."; buildModel(view, range); }
CSVSettings::View::View(CSMSettings::Setting *setting, Page *parent) : mDataModel(0), mParentPage (parent), mHasFixedValues (!setting->declaredValues().isEmpty()), mIsMultiValue (setting->isMultiValue()), mViewKey (setting->page() + '/' + setting->name()), mSerializable (setting->serializable()), Frame(true, setting->name(), parent) { setObjectName (setting->name()); buildView(); buildModel (setting); }
int main (int argc,char* argv[]){ if (argc != 2 && argc != 3){ printf("usage:\n %s /path/to/recoding/filename.oni\n",argv[0]); return 0; } Xn_sensor sensor(WIDTH,HEIGHT); sensor.play(argv[1],false); cvNamedWindow( "Model Extractor Viewer", 1 ); IplImage* rgb_image = cvCreateImageHeader(cvSize(WIDTH,HEIGHT), 8, 3); IplImage* test = cvCreateImageHeader(cvSize(WIDTH,HEIGHT), 8, 3); IplImage* gray = cvCreateImage(cvSize(WIDTH,HEIGHT), 8, 1); Mat img; pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr model (new pcl::PointCloud<pcl::PointXYZRGB>); //pcl::visualization::CloudViewer viewer("Model Extractor Viewer"); //Read Fiducial from file Fiducial fiducial("fiducial.yml"); Pose pose; while(/*!viewer.wasStopped() && */!sensor.endPlaying()){ //Get the frame sensor.update(); sensor.getPCL(cloud); cvSetData(rgb_image,sensor.rgb,rgb_image->widthStep); //Estimate Camera Pose from fiducial cvCvtColor(rgb_image,gray,CV_BGR2GRAY); if (fiducial.find(gray,true)){ pose.estimate(gray,fiducial); //fiducial.draw(rgb_image); } if (pose.isFound()){ printf("Rotation"); printMat<double>(pose.getR()); printf("Translation"); printMat<double>(pose.getT()); //Segment volume around the fiducial boxFilter(cloud,pose); //Create 3D model buildModel(cloud,model); } //viewer.showCloud (model); } pcl::io::savePCDFileBinary ("model.pcd", *model); sensor.shutdown(); return 0; }
int main(void) { double code; printf("\n\nИзходно съобщение: %s",MESSAGE); getStatistics(MESSAGE); buildModel(MESSAGE); #ifdef SHOW_MORE printModel(); printf("\nНатиснете <<ENTER>>"); getchar(); #endif code = arithmeticEncode(MESSAGE); printf("\nКодът на съобщението е: %1.8f",code); printf("\nДекодиране: "); arithmeticDecode(code,strlen(MESSAGE)); return 0; }
void Scene::buildNode(Json::Value node) { string type = node["type"].asString(); if(type.compare("group") == 0) { buildGroup(node); } else if(type.compare("model") == 0) { models.push_back(buildModel(node)); } /*if(node.isMember("children")) { Json::Value children = node["children"]; for(int i=0; i<children.size(); i++) { buildNode(children[i]); } }*/ }
GrassField::GrassField(int size) { fieldsize = size; //create array with grasscut info grasscut[size+1][size+1]; totalsquares = (size+1)*(size+1); squaresremaining = totalsquares; grasscut = new int*[fieldsize+1]; for(int i = 0; i <=fieldsize+1;i++) grasscut[i] = new int[fieldsize+1]; fmodelid = glGenLists(1); buildModel(); growGrass(); }
EdgeSetIF * CPLEX_LP_MSTSolverIF::resolve(VertexIF * const initialVertex) throw (ModelExceptions::GeneralConcertException) { EdgeSetIF* solution { }; buildModel(); try { solution = LP_Solve(); } catch (IloException& e) { ERROR(logger, LogBundleKey::CPLPMSTIF_SOLVER_ERROR, e.getMessage()); throw ModelExceptions::GeneralConcertException(); } INFO(logger, LogBundleKey::CPLPMSTIF_SOLUTION, LogStringUtils::edgeSetVisualization(solution, "\t").c_str(), solution->getTotalEdgeCost()); return solution; }
Sun::Sun(int screenWidth, int screenHeight) : program(nullptr), depthTestProgram(nullptr), radialBlurProgram(nullptr), sunPosition(glm::vec3(3000, -500, 0)), position(sunPosition) { buildModel(); buildRect(); //generate id glGenFramebuffers(1, &fboId); glGenTextures(2, texIdDepth); glGenTextures(2, texIdColor); Resize(screenWidth, screenHeight); }
vector<int> ListModel::solve(SolverParams params) { Utils::Tracer *tr = nullptr; TraceCallback *cback = nullptr; buildModel(); applyParams(params); if(params.traceobj) { tr = new Utils::Tracer(traceFilenameForListModel(params.outPath, params.solverIx, p.instanceName)); cback = new TraceCallback(*tr); //ls.addCallback(CT_TimeTicked, cback); decoder->setTracer(tr); } ls.solve(); auto sol = ls.getSolution(); if(cback != nullptr) delete cback; if(tr != nullptr) delete tr; return parseScheduleFromSolution(sol); }
// single playlist adding void MainWindow::on_pushButton_3_clicked(){ ui->textEdit_3->setStyleSheet("color:black; background-color:white"); playlistName = ui->textEdit_3->toPlainText(); playlistPopularity = ui->textEdit_4->toPlainText(); string sPlaylistName = playlistName.toLatin1().data(); string sPlaylistPopularity = playlistPopularity.toLatin1().data(); //test single playlist input: Friend Of God, Your Great Name, Collide, September 63 bool is_legal_pop = true; bool is_legal_ss = is_legal_input_str_stream(sPlaylistName); int dec = playlistPopularity.toInt(&is_legal_pop, 10); // some general console error logs if(!is_legal_ss && !is_legal_pop){ std::cout << "illegal stream & illegal popularity inputs" << std::endl; } else if(!is_legal_ss){ std::cout << "illegal stream input" << std::endl; } else if(!is_legal_pop){ std::cout << "illegal popularity input" << std::endl; } if(is_legal_ss && is_legal_pop){ string song_id_stream = convTitleStream2StrNumStream(sPlaylistName); std::cout << "Single Playlist Submitted: " << (sPlaylistName + " " + sPlaylistPopularity) << std::endl; Playlist* new_pl = new Playlist(song_id_stream,playlistPopularity.toInt()); // add a new playlist pl_c->add(new_pl); // add this playlists popularity to the song's pop for(int ii = 0; ii < new_pl->my_songs->size(); ii++){ std::string member_song_id = new_pl->my_songs->at(ii); // sng_c->query(member_song_id)->set_song_popularity(sng_c->query(member_song_id)->getPopularity() + new_pl->getPopularity()); sng_c->query((member_song_id))->song_add_playlist(new_pl->my_id); } // refine is required to maintain the backend storage and so-on pl_c->refine(); QListView *listView = ui->mostPopularPlaylistListView; QAbstractItemModel *model = buildModel(); // make the buildModel() func to intake the new most-popular PL strings listView->setModel(model); listView->show(); } }
void buildFullModel(){ gROOT->SetBatch(1); TFile *fin = TFile::Open("Output_skimtrees.root"); // Set up categories and cut-strings std::vector<std::string> cut_selections; //cut_selections.push_back(" metRaw > 200 "); cut_selections.push_back(" !( jet1mprune > 60 && jet1tau2o1 <0.45 && jet1pt>250) "); cut_selections.push_back(" ( jet1mprune > 60 && jet1tau2o1 <0.45 && jet1pt>250) "); TFile *fout = new TFile(outfilename.c_str(),"RECREATE"); int nselections = cut_selections.size(); for (int sel_i=0;sel_i<nselections;sel_i++){ TDirectory *fdir = fout->mkdir(Form("category_%d",sel_i)); cutstring = cut_selections[sel_i]; buildModel(sel_i,fin,fdir); TNamed cstr(Form("cuts_category_%d",sel_i), cut_selections[sel_i].c_str()); fdir->cd(); cstr.Write(); } }
void EarthWidget::initializeGL() { makeCurrent(); buildModel(); }
pModel BuilderModelManual::build() { return buildModel(mEngine, mProgram, mShapePath, mDiffuseMap, mNormalMap, mSpecularMap, mMaterial); }
static int processModel(const char *file, glhckObject *object, glhckObject *current, const struct aiScene *sc, const struct aiNode *nd, glhckGeometryIndexType itype, glhckGeometryVertexType vtype, const glhckImportModelParameters *params) { unsigned int m, f; unsigned int numVertices = 0, numIndices = 0; unsigned int ioffset, voffset; glhckImportIndexData *indices = NULL; glhckImportVertexData *vertexData = NULL; glhckMaterial *material = NULL; glhckTexture **textureList = NULL, *texture = NULL; glhckAtlas *atlas = NULL; const struct aiMesh *mesh; const struct aiFace *face; int canFreeCurrent = 0; int hasTexture = 0; assert(file); assert(object && current); assert(sc && nd); /* combine && atlas loading path */ if (params->flatten) { /* prepare atlas for texture combining */ if (!(atlas = glhckAtlasNew())) goto assimp_no_memory; /* texturelist for offseting coordinates */ if (!(textureList = _glhckCalloc(nd->mNumMeshes, sizeof(_glhckTexture*)))) goto assimp_no_memory; /* gather statistics */ for (m = 0; m != nd->mNumMeshes; ++m) { mesh = sc->mMeshes[nd->mMeshes[m]]; if (!mesh->mVertices) continue; for (f = 0; f != mesh->mNumFaces; ++f) { face = &mesh->mFaces[f]; if (!face) goto fail; numIndices += face->mNumIndices; } numVertices += mesh->mNumVertices; if ((texture = textureFromMaterial(file, sc->mMaterials[mesh->mMaterialIndex]))) { glhckAtlasInsertTexture(atlas, texture); glhckTextureFree(texture); textureList[m] = texture; hasTexture = 1; } } /* allocate vertices */ if (!(vertexData = _glhckCalloc(numVertices, sizeof(glhckImportVertexData)))) goto assimp_no_memory; /* allocate indices */ if (!(indices = _glhckMalloc(numIndices * sizeof(glhckImportIndexData)))) goto assimp_no_memory; /* pack combined textures */ if (hasTexture) { if (glhckAtlasPack(atlas, GLHCK_RGBA, 1, 0, glhckTextureDefaultParameters()) != RETURN_OK) goto fail; } else { NULLDO(glhckAtlasFree, atlas); NULLDO(_glhckFree, textureList); } /* join vertex data */ for (m = 0, ioffset = 0, voffset = 0; m != nd->mNumMeshes; ++m) { mesh = sc->mMeshes[nd->mMeshes[m]]; if (!mesh->mVertices) continue; if (textureList) texture = textureList[m]; else texture = NULL; joinMesh(mesh, voffset, indices+ioffset, vertexData+voffset, atlas, texture); for (f = 0; f != mesh->mNumFaces; ++f) { face = &mesh->mFaces[f]; if (!face) goto fail; ioffset += face->mNumIndices; } voffset += mesh->mNumVertices; } /* create material */ if (hasTexture && !(material = glhckMaterialNew(texture))) goto assimp_no_memory; /* finally build the model */ if (buildModel(current, numIndices, numVertices, indices, vertexData, itype, vtype) == RETURN_OK) { _glhckObjectFile(current, nd->mName.data); if (material) glhckObjectMaterial(current, material); if (!(current = glhckObjectNew())) goto fail; glhckObjectAddChild(object, current); glhckObjectFree(current); canFreeCurrent = 1; } /* free stuff */ IFDO(glhckAtlasFree, atlas); IFDO(glhckMaterialFree, material); IFDO(_glhckFree, textureList); NULLDO(_glhckFree, vertexData); NULLDO(_glhckFree, indices); } else { /* default loading path */ for (m = 0, ioffset = 0, voffset = 0; m != nd->mNumMeshes; ++m) { mesh = sc->mMeshes[nd->mMeshes[m]]; if (!mesh->mVertices) continue; /* gather statistics */ numIndices = 0; for (f = 0; f != mesh->mNumFaces; ++f) { face = &mesh->mFaces[f]; if (!face) goto fail; numIndices += face->mNumIndices; } numVertices = mesh->mNumVertices; // FIXME: create materialFromAssimpMaterial // that returns glhckMaterial with correct stuff /* get texture */ hasTexture = 0; if ((texture = textureFromMaterial(file, sc->mMaterials[mesh->mMaterialIndex]))) hasTexture = 1; /* create material */ if (hasTexture && !(material = glhckMaterialNew(texture))) goto assimp_no_memory; /* allocate vertices */ if (!(vertexData = _glhckCalloc(numVertices, sizeof(glhckImportVertexData)))) goto assimp_no_memory; /* allocate indices */ if (!(indices = _glhckMalloc(numIndices * sizeof(glhckImportIndexData)))) goto assimp_no_memory; /* fill arrays */ joinMesh(mesh, 0, indices, vertexData, NULL, NULL); /* build model */ if (buildModel(current, numIndices, numVertices, indices, vertexData, itype, vtype) == RETURN_OK) { /* FIXME: UGLY */ char pointer[16]; snprintf(pointer, sizeof(pointer), "%p", mesh); _glhckObjectFile(current, pointer); if (material) glhckObjectMaterial(current, material); if (!(current = glhckObjectNew())) goto fail; glhckObjectAddChild(object, current); glhckObjectFree(current); canFreeCurrent = 1; } /* free stuff */ NULLDO(_glhckFree, vertexData); NULLDO(_glhckFree, indices); IFDO(glhckTextureFree, texture); IFDO(glhckMaterialFree, material); } } /* process childrens */ for (m = 0; m != nd->mNumChildren; ++m) { if (processModel(file, object, current, sc, nd->mChildren[m], itype, vtype, params) == RETURN_OK) { if (!(current = glhckObjectNew())) goto fail; glhckObjectAddChild(object, current); glhckObjectFree(current); canFreeCurrent = 1; } } /* we din't do anything to the next * allocated object, so free it */ if (canFreeCurrent) glhckObjectRemoveFromParent(current); return RETURN_OK; assimp_no_memory: DEBUG(GLHCK_DBG_ERROR, "Assimp not enough memory."); fail: IFDO(_glhckFree, vertexData); IFDO(_glhckFree, indices); IFDO(_glhckFree, textureList); IFDO(glhckTextureFree, texture); IFDO(glhckMaterialFree, material); IFDO(glhckAtlasFree, atlas); if (canFreeCurrent) glhckObjectRemoveFromParent(current); return RETURN_FAIL; }
char *openModel(char *Alas, char *Adb, char *Bdb, int first, int last, int nolink, int nolap, int elim, int max_comp, int max_expn) { static char buffer[2*MAX_NAME+100]; static DAZZ_DB _db1; static DAZZ_DB _db2; FILE *dbfile; if (FIRSTCALL) { FIRSTCALL = 0; Prog_Name = Strdup("DaViewer",""); } if ( ! UNDEFINED) { Close_DB(MODEL.db1); if (MODEL.db1 != MODEL.db2) Close_DB(MODEL.db2); fclose(MODEL.input); free(MODEL.local); free(MODEL.pile+MODEL.first); free(MODEL.tbuf); } UNDEFINED = 1; { int i, nfiles, nblocks, cutoff, all, oindx; int64 size; int la_first, la_last; int db_first, db_last; FILE *input; input = fopen(Alas,"r"); if (input == NULL) { if (rindex(Alas,'/') != NULL) Alas = rindex(Alas,'/')+1; EPRINTF(EPLACE,"%s: Cannot open file %s\n",Prog_Name,Alas); return (Ebuffer); } if (scanLAS(input,&la_first,&la_last)) { if (rindex(Alas,'/') != NULL) Alas = rindex(Alas,'/')+1; EPRINTF(EPLACE,"%s: LAS file %s has no overlaps !\n",Prog_Name,Alas); fclose(input); return (Ebuffer); } fclose(input); dbfile = Fopen(Adb,"r"); if (dbfile == NULL) return (Ebuffer); if (fscanf(dbfile,DB_NFILE,&nfiles) != 1) goto junk; for (i = 0; i < nfiles; i++) if (fgets(buffer,2*MAX_NAME+100,dbfile) == NULL) goto junk; if (fscanf(dbfile,DB_NBLOCK,&nblocks) != 1) { if (feof(dbfile)) { EPRINTF(EPLACE,"%s: Database has not been split!",Prog_Name); goto error; } goto junk; } if (fscanf(dbfile,DB_PARAMS,&size,&cutoff,&all) != 3) goto junk; for (i = 0; i <= nblocks; i++) { if (fscanf(dbfile,DB_BDATA,&oindx,&db_last) != 2) goto junk; if (la_first >= db_last) db_first = db_last; if (la_last < db_last) break; } fclose(dbfile); if (first >= 0) { if (first >= db_last) { EPRINTF(EPLACE,"First requested read %d is > last read in las block %d\n", first+1,db_last); return (Ebuffer); } else if (first > db_first) db_first = first; } if (last >= 0) { if (last <= db_first) { EPRINTF(EPLACE,"Last requested read %d is < first read in las block %d\n", last,db_first+1); return (Ebuffer); } else if (last < db_last) db_last = last; } MODEL.first = db_first; MODEL.last = db_last; } MODEL.db1 = &_db1; if (Open_DB(Adb,MODEL.db1) < 0) return (Ebuffer); if (Bdb == NULL) MODEL.db2 = MODEL.db1; else { MODEL.db2 = &_db2; if (Open_DB(Bdb,MODEL.db2) < 0) { Close_DB(MODEL.db1); return (Ebuffer); } Trim_DB(MODEL.db2); } Trim_DB(MODEL.db1); if (List_DB_Files(Adb,OPEN_MASKS)) return (Ebuffer); { int i, n; DAZZ_READ *read = MODEL.db2->reads; n = MODEL.db2->nreads; for (i = 0; i < n; i++) read[i].flags &= (DB_CSS | DB_BEST); } { int kind; if (Check_Track(MODEL.db1,"prof",&kind) > -2) { MODEL.prf = Load_Track(MODEL.db1,"prof"); if (MODEL.prf == NULL) { Close_DB(MODEL.db1); if (MODEL.db2 != MODEL.db1) Close_DB(MODEL.db2); return (Ebuffer); } } else MODEL.prf = NULL; if (Check_Track(MODEL.db1,"qual",&kind) > -2) { MODEL.qvs = Load_Track(MODEL.db1,"qual"); if (MODEL.qvs == NULL) { Close_DB(MODEL.db1); if (MODEL.db2 != MODEL.db1) Close_DB(MODEL.db2); return (Ebuffer); } } else MODEL.qvs = NULL; } MODEL.input = fopen(Alas,"r"); if (buildModel(nolink,nolap,elim,max_comp,max_expn)) { fclose(MODEL.input); Close_DB(MODEL.db1); if (MODEL.db2 != MODEL.db1) Close_DB(MODEL.db2); return (Ebuffer); } { DAZZ_TRACK *t, *u, *v; int j; int64 *anno; u = NULL; for (t = MODEL.db1->tracks; t != NULL; t = v) { v = t->next; t->next = u; u = t; } MODEL.db1->tracks = u; for (t = MODEL.db1->tracks; t != MODEL.qvs && t != MODEL.prf; t = t->next) { anno = (int64 *) (t->anno); for (j = 0; j <= MODEL.db1->nreads; j++) anno[j] >>= 2; } } UNDEFINED = 0; return (NULL); junk: if (rindex(Adb,'/') != NULL) Adb = rindex(Adb,'/')+1; EPRINTF(EPLACE,"%s: Stub file %s is junk!\n",Prog_Name,Adb); error: fclose(dbfile); return (Ebuffer); }
void ObjectNode::createEntities(Ogre::SceneNode *target_node, Ogre::SceneManager *scene_manager, LibGens::ModelLibrary *model_library, LibGens::MaterialLibrary *material_library, LibGens::ObjectProduction *object_production, string slot_id_name) { string model_name=object->queryEditorModel(slot_id_name, OBJECT_NODE_UNKNOWN_MESH); string skeleton_name=object->queryEditorSkeleton(slot_id_name, ""); string animation_name=object->queryEditorAnimation(slot_id_name, ""); string preview_box_x=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_X, ""); string preview_box_y=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_Y, ""); string preview_box_z=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_Z, ""); string preview_box_x_scale=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_X_SCALE, ""); string preview_box_y_scale=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_Y_SCALE, ""); string preview_box_z_scale=object->queryExtraName(OBJECT_NODE_EXTRA_PREVIEW_BOX_Z_SCALE, ""); if ((preview_box_x.size()) || (preview_box_y.size()) || (preview_box_z.size())) { LibGens::ObjectElementFloat *p_x = (LibGens::ObjectElementFloat *) object->getElement(preview_box_x); LibGens::ObjectElementFloat *p_y = (LibGens::ObjectElementFloat *) object->getElement(preview_box_y); LibGens::ObjectElementFloat *p_z = (LibGens::ObjectElementFloat *) object->getElement(preview_box_z); Ogre::Vector3 new_scale = preview_box_node->getScale(); float scale_f=0.0f; float scale_x = 1.0f; float scale_y = 1.0f; float scale_z = 1.0f; if (preview_box_x_scale.size()) FromString<float>(scale_x, preview_box_x_scale, std::dec); if (preview_box_y_scale.size()) FromString<float>(scale_y, preview_box_y_scale, std::dec); if (preview_box_z_scale.size()) FromString<float>(scale_z, preview_box_z_scale, std::dec); // Check if elements were found. If not, try reading the float value from the string if (p_x) new_scale.x = p_x->value; else { FromString<float>(scale_f, preview_box_x, std::dec); new_scale.x = scale_f; } if (p_y) new_scale.y = p_y->value; else { FromString<float>(scale_f, preview_box_y, std::dec); new_scale.y = scale_f; } if (p_z) new_scale.z = p_z->value; else { FromString<float>(scale_f, preview_box_z, std::dec); new_scale.z = scale_f; } new_scale.x = new_scale.x * scale_x; new_scale.y = new_scale.y * scale_y; new_scale.z = new_scale.z * scale_z; // Check for valid scaling values if (new_scale.x <= 0.0) new_scale.x = 0.1; if (new_scale.y <= 0.0) new_scale.y = 0.1; if (new_scale.z <= 0.0) new_scale.z = 0.1; preview_box_node->setScale(new_scale); } if ((object->getName() == OBJECT_NODE_OBJECT_PHYSICS) && object_production) { bool found_model=false; LibGens::ObjectElement *element=object->getElement(OBJECT_NODE_OBJECT_PHYSICS_ELEMENT_TYPE); if (element) { string type_name=static_cast<LibGens::ObjectElementString *>(element)->value; if (type_name != current_type_name) { current_type_name = type_name; destroyAllAttachedMovableObjects(target_node); } else { return; } LibGens::ObjectPhysics *object_physics = object_production->getObjectPhysics(type_name); if (object_physics) { vector<string> models=object_physics->getModels(); vector<string> motions=object_physics->getMotions(); vector<string> motion_skeletons=object_physics->getMotionSkeletons(); for (size_t i=0; i<models.size(); i++) { string model_id=models[i]; string skeleton_id = ""; string animation_id = ""; LibGens::Model *model=model_library->getModel(model_id); if (i < motions.size()) { animation_id = motions[i]; } if (i < motion_skeletons.size()) { skeleton_id = motion_skeletons[i]; } if (model) { prepareSkeletonAndAnimation(skeleton_id, animation_id); buildModel(target_node, model, model->getName(), skeleton_id, scene_manager, material_library, EDITOR_NODE_QUERY_OBJECT, GENERAL_MESH_GROUP, false); createAnimationState(animation_id); found_model = true; } } } } if (found_model) { return; } else { current_model_name = ""; } } if ((model_name != current_model_name) || (skeleton_name != current_skeleton_name) || (animation_name != current_animation_name)) { current_model_name = model_name; current_skeleton_name = skeleton_name; current_animation_name = animation_name; destroyAllAttachedMovableObjects(target_node); } else { return; } string model_id=model_name; model_id.resize(model_id.size() - ((string)OBJECT_NODE_MODEL_EXTENSION).size()); string skeleton_id=""; if (skeleton_name.size()) { skeleton_id=skeleton_name; skeleton_id.resize(skeleton_id.size() - ((string)OBJECT_NODE_SKELETON_EXTENSION).size()); } string animation_id=""; if (animation_name.size()) { animation_id=animation_name; animation_id.resize(animation_id.size() - ((string)OBJECT_NODE_ANIMATION_EXTENSION).size()); } if (model_name.find(OBJECT_NODE_MODEL_EXTENSION) != string::npos) { LibGens::Model *model=model_library->getModel(model_id); if (model) { prepareSkeletonAndAnimation(skeleton_id, animation_id); buildModel(target_node, model, model->getName(), skeleton_id, scene_manager, material_library, EDITOR_NODE_QUERY_OBJECT, GENERAL_MESH_GROUP, false); } else { Ogre::Entity *entity = scene_manager->createEntity(OBJECT_NODE_UNKNOWN_MESH); entity->setQueryFlags(EDITOR_NODE_QUERY_OBJECT); target_node->attachObject(entity); } } else if (model_name.find(OBJECT_NODE_MESH_EXTENSION) != string::npos) { Ogre::Entity *entity = scene_manager->createEntity(model_name); entity->setQueryFlags(EDITOR_NODE_QUERY_OBJECT); target_node->attachObject(entity); } createAnimationState(animation_id); // Create PreviewBox if necessary if ((preview_box_x.size()) || (preview_box_y.size()) || (preview_box_z.size())) { preview_box_entity = scene_manager->createEntity("preview_box.mesh"); preview_box_entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAX); preview_box_entity->setQueryFlags(EDITOR_NODE_QUERY_PREVIEW_BOX); preview_box_node->attachObject(preview_box_entity); } }
// upload playlists from a file void MainWindow::on_pushButton_2_clicked(){ QString fileName = ui->textEdit_2->toPlainText(); string sFileName = fileName.toLatin1().data(); std::cout << "Attempting to Upload: " + sFileName << std::endl; // test url: /Users/nick102795/Desktop/main/School/College/year3/EC504/playlist/uploads/day01.txt int line_counter = 1; QFile inputFile(fileName); if (inputFile.open(QIODevice::ReadOnly)){ QTextStream in(&inputFile); srand(time(NULL)); while (!in.atEnd()){ if(line_counter > 128){ // one is only allowed to upload 128 lines break; } QString line_temp = in.readLine(); string line = line_temp.toUtf8().constData(); string deliminator = " "; //make sure there is at least one '\t' on that line int up_to = line.find(deliminator); if(up_to <= 0){ // There is no tab deliminator to be found std::cout << "Tab Deliminator Error" << endl << "Exited due to error in the file." << endl <<"Successfully uploaded " << (line_counter - 1) << " playlists." << endl; break; } string str_of_song_ids = ""; for(int ii = 0; ii < up_to; ii++){ str_of_song_ids += line[ii]; } line = line.substr(line.find(deliminator)+1,line.length()-line.find(deliminator)+1); string pl_pop = line; int pl_popularity = atoi(pl_pop.c_str()); // was stoi but this version of C++ is bad std::cout << "Playlists Uploaded: " << (line_counter - 1) << std::endl; // std::cout << pl_pop << std::endl; if(!is_legal_id_stream(str_of_song_ids)){ std::cout << "Exited due to error in the file." << endl <<"Successfully uploaded " << (line_counter - 1) << " playlists." << endl; break; } // pl_popularity, str_of_song_ids are set at this point Playlist* new_pl = new Playlist(str_of_song_ids, pl_popularity); //std::cout << "ID: " << temp_str << " title: " << str_of_song_ids << " popularity: "<< pl_popularity << std::endl; pl_c->add(new_pl); // add this playlists popularity to the song's pop for(int ii = 0; ii < new_pl->my_songs->size(); ii++){ std::string member_song_id = new_pl->my_songs->at(ii); // sng_c->query(member_song_id)->set_song_popularity(sng_c->query(member_song_id)->getPopularity() + new_pl->getPopularity()); sng_c->query((member_song_id))->song_add_playlist(new_pl->my_id); } line_counter++; } pl_c->refine(); inputFile.close(); QListView *listView = ui->mostPopularPlaylistListView; QAbstractItemModel* model = buildModel(); // make the buildModel() func to intake the new most-popular PL strings listView->setModel(model); listView->show(); } else{ std::cout << "Failed to open: " << sFileName << std::endl; } ui->textEdit_2->setText(""); }