static void initializeLdbPattern(const int& nlevels, const int& patchSize) { if(!generateCoordFlag){ int patch_size = patchSize; rotated_X_.clear(); rotated_Y_.clear(); generateRotatedPatterns(patch_size, 30, rotated_X_, rotated_Y_); computeCoordinates(coordinates2by2_, (int)(patch_size/2), patch_size); computeCoordinates(coordinates3by3_, (int)(patch_size/3), patch_size); computeCoordinates(coordinates4by4_, (int)(patch_size/4), patch_size); computeCoordinates(coordinates5by5_, (int)(patch_size/5), patch_size); generateCoordFlag = true; } if(randomSequence_.empty()) generateRandSequence(randomSequence_); n_levels = nlevels; }
void SpecificWorker::compute( ) { static int fps = 0; static QTime reloj = QTime::currentTime(); readFrame(); computeCoordinates(); if (reloj.elapsed() > 1000) { qDebug()<<"Grabbing at:"<<fps<<"fps"; reloj.restart(); fps=0; } fps++; }
/** * Generates asyncronously queries for each files. * Makes encrypted of 0 or 1. **/ void PIRQueryGenerator::generateQuery() { double start = omp_get_wtime(); coord = new unsigned int[pirParams.d](); computeCoordinates(); for (unsigned int j = 0 ; j < pirParams.d ; j++) { for (unsigned int i = 0 ; i < pirParams.n[j] ; i++) { if (i == coord[j]) queryBuffer.push(cryptoMethod.encrypt(1, j + 1 )); else queryBuffer.push(cryptoMethod.encrypt(0, j + 1)); } std::cout << "PIRQueryGenerator: Generated a " << pirParams.n[j] << " element query" << std::endl; } double end = omp_get_wtime(); std::cout << "PIRQueryGenerator: All the queries have been generated, total time is " << end - start << " seconds" << std::endl; }
/* * To be done: refactoring with NgonGridData, as these two classes' * setGridSize methods are almost identical. */ int NgonGridMatplotData::setGridSize(int const* gridSize) { int newXSize = 0; int newYSize = 0; int xModified = 0; int yModified = 0; int zModified = 0; int result = 0; int formerGridSize = 0; double* newXCoordinates = NULL; double* newYCoordinates = NULL; double* newZCoordinates = NULL; result = 1; xModified = 0; yModified = 0; zModified = 0; if ((gridSize[0] != 1) && (gridSize[1] != 1)) { return 0; } if ((gridSize[2] != 1) && (gridSize[3] != 1)) { return 0; } newXSize = gridSize[0] * gridSize[1]; newYSize = gridSize[2] * gridSize[3]; if (newXSize != xSize) { xModified = 1; try { newXCoordinates = new double[newXSize]; } catch (const std::exception& e) { e.what(); result = 0; } } if (newYSize != ySize) { yModified = 1; try { newYCoordinates = new double[newYSize]; } catch (const std::exception& e) { e.what(); result = 0; } } if (xSize > 0 && ySize > 0) { formerGridSize = (xSize - 1) * (ySize - 1); } else { formerGridSize = 0; } if ((newXSize - 1) * (newYSize - 1) != formerGridSize) { zModified = 1; try { newZCoordinates = new double[(newXSize - 1) * (newYSize - 1)]; } catch (const std::exception& e) { e.what(); result = 0; } } if (result) { if (xModified) { if (xSize > 0) { delete [] xCoordinates; } xCoordinates = newXCoordinates; xSize = newXSize; } xDimensions[0] = gridSize[0]; xDimensions[1] = gridSize[1]; if (yModified) { if (ySize > 0) { delete [] yCoordinates; } yCoordinates = newYCoordinates; ySize = newYSize; } yDimensions[0] = gridSize[2]; yDimensions[1] = gridSize[3]; if (zModified) { if (formerGridSize > 0) { delete [] zCoordinates; } zCoordinates = newZCoordinates; numGons_f = (xSize - 1) * (ySize - 1); } if (xModified || yModified) { computeCoordinates(); } } else { /* Failed allocation(s) */ if (xModified && (newXCoordinates != NULL)) { delete [] newXCoordinates; } if (yModified && (newYCoordinates != NULL)) { delete [] newYCoordinates; } if (zModified && (newZCoordinates != NULL)) { delete [] newZCoordinates; } } return result; }
void PlanarDrawLayout::doCall( const Graph &G, adjEntry adjExternal, GridLayout &gridLayout, IPoint &boundingBox, bool fixEmbedding) { // require to have a planar graph without multi-edges and self-loops; // planarity is checked below OGDF_ASSERT(isSimple(G) && isLoopFree(G)); // handle special case of graphs with less than 3 nodes if(G.numberOfNodes() < 3) { node v1, v2; switch(G.numberOfNodes()) { case 0: boundingBox = IPoint(0,0); return; case 1: v1 = G.firstNode(); gridLayout.x(v1) = gridLayout.y(v1) = 0; boundingBox = IPoint(0,0); return; case 2: v1 = G.firstNode(); v2 = G.lastNode (); gridLayout.x(v1) = gridLayout.y(v1) = gridLayout.y(v2) = 0; gridLayout.x(v2) = 1; boundingBox = IPoint(1,0); return; } } // we make a copy of G since we use planar biconnected augmentation GraphCopySimple GC(G); if(fixEmbedding) { PlanarAugmentationFix augmenter; augmenter.call(GC); } else { // augment graph planar biconnected m_augmenter.get().call(GC); // embed augmented graph PlanarModule pm; bool isPlanar = pm.planarEmbed(GC); if(isPlanar == false) OGDF_THROW_PARAM(PreconditionViolatedException, pvcPlanar); } // compute shelling order m_computeOrder.get().baseRatio(m_baseRatio); ShellingOrder order; m_computeOrder.get().call(GC,order,adjExternal); // compute grid coordinates for GC NodeArray<int> x(GC), y(GC); computeCoordinates(GC,order,x,y); boundingBox.m_x = x[order(1,order.len(1))]; boundingBox.m_y = 0; node v; forall_nodes(v,GC) if(y[v] > boundingBox.m_y) boundingBox.m_y = y[v]; // copy coordinates from GC to G forall_nodes(v,G) { node vCopy = GC.copy(v); gridLayout.x(v) = x[vCopy]; gridLayout.y(v) = y[vCopy]; }
void PlanarStraightLayout::doCall( const Graph &G, adjEntry adjExternal, GridLayout &gridLayout, IPoint &boundingBox, bool fixEmbedding) { // require to have a planar graph without multi-edges and self-loops; // planarity is checked below OGDF_ASSERT(isSimple(G) && isLoopFree(G)); // handle special case of graphs with less than 3 nodes if(G.numberOfNodes() < 3) { node v1, v2; switch(G.numberOfNodes()) { case 0: boundingBox = IPoint(0,0); return; case 1: v1 = G.firstNode(); gridLayout.x(v1) = gridLayout.y(v1) = 0; boundingBox = IPoint(0,0); return; case 2: v1 = G.firstNode(); v2 = G.lastNode (); gridLayout.x(v1) = gridLayout.y(v1) = gridLayout.y(v2) = 0; gridLayout.x(v2) = 1; boundingBox = IPoint(1,0); return; } } // we make a copy of G since we use planar biconnected augmentation GraphCopySimple GC(G); if(fixEmbedding) { // determine adjacency entry on external face of GC (if required) if(adjExternal != 0) { edge eG = adjExternal->theEdge(); edge eGC = GC.copy(eG); adjExternal = (adjExternal == eG->adjSource()) ? eGC->adjSource() : eGC->adjTarget(); } PlanarAugmentationFix augmenter; augmenter.call(GC); } else { adjExternal = 0; // augment graph planar biconnected m_augmenter.get().call(GC); // embed augmented graph m_embedder.get().call(GC,adjExternal); } // compute shelling order with shelling order module m_computeOrder.get().baseRatio(m_baseRatio); ShellingOrder order; m_computeOrder.get().callLeftmost(GC,order,adjExternal); // compute grid coordinates for GC NodeArray<int> x(GC), y(GC); computeCoordinates(GC,order,x,y); boundingBox.m_x = x[order(1,order.len(1))]; boundingBox.m_y = 0; node v; forall_nodes(v,GC) if(y[v] > boundingBox.m_y) boundingBox.m_y = y[v]; // copy coordinates from GC to G forall_nodes(v,G) { node vCopy = GC.copy(v); gridLayout.x(v) = x[vCopy]; gridLayout.y(v) = y[vCopy]; }
void FPPLayout::doCall( const Graph &G, adjEntry adjExternal, GridLayout &gridLayout, IPoint &boundingBox, bool fixEmbedding) { // check for double edges & self loops OGDF_ASSERT(isSimple(G)); // handle special case of graphs with less than 3 nodes if (G.numberOfNodes() < 3) { node v1, v2; switch (G.numberOfNodes()) { case 0: boundingBox = IPoint(0, 0); return; case 1: v1 = G.firstNode(); gridLayout.x(v1) = gridLayout.y(v1) = 0; boundingBox = IPoint(0, 0); return; case 2: v1 = G.firstNode(); v2 = G.lastNode(); gridLayout.x(v1) = gridLayout.y(v1) = gridLayout.y(v2) = 0; gridLayout.x(v2) = 1; boundingBox = IPoint(1, 0); return; } } // make a copy for triangulation GraphCopy GC(G); // embed if (!fixEmbedding) { if (planarEmbed(GC) == false) { OGDF_THROW_PARAM(PreconditionViolatedException, pvcPlanar); } } triangulate(GC); // get edges for outer face (triangle) adjEntry e_12; if (adjExternal != 0) { edge eG = adjExternal->theEdge(); edge eGC = GC.copy(eG); e_12 = (adjExternal == eG->adjSource()) ? eGC->adjSource() : eGC->adjTarget(); } else { e_12 = GC.firstEdge()->adjSource(); } adjEntry e_2n = e_12->faceCycleSucc(); NodeArray<int> num(GC); NodeArray<adjEntry> e_wp(GC); // List of predecessors on circle C_k NodeArray<adjEntry> e_wq(GC); // List of successors on circle C_k computeOrder(GC, num , e_wp, e_wq, e_12, e_2n, e_2n->faceCycleSucc()); computeCoordinates(GC, boundingBox, gridLayout, num, e_wp, e_wq); }
int main(int argc, char* argv[]) { //process commandline arguments int argFile=0, argTransformation=0; char *argFileName; int i, j, tmp; j=argc-1; //tracking, if all the arguments were processed for (i=1; i<argc; i++) { //skipping argv[0] - program name if (strcmp(argv[i], "--help")==0 || strcmp(argv[i], "-h")==0) { fprintf(stderr, "usage: %s [options]\n", argv[0]); //fprintf(stderr, ""); fprintf(stderr, "\t-h\n\t--help\n"); fprintf(stderr, "\t\tthis help message\n"); fprintf(stderr, "\t-d\n\t--debug\n"); fprintf(stderr, "\t\tprint debug messages\n"); fprintf(stderr, "\t-f <file_name>\n\t--file <file_name>\n"); fprintf(stderr, "\t\tload this map file\n"); fprintf(stderr, "\t-t <0|1|2>\n\t--transformation <0|1|2>\n"); fprintf(stderr, "\t\tdefine, how coordinate transformation should happen\n"); exit(1); } else if (strcmp(argv[i], "--debug")==0 || strcmp(argv[i], "-d")==0) { argDebug=1; j--; } else if (strcmp(argv[i], "--file")==0 || strcmp(argv[i], "-f")==0) { argFile=1; j--; if (i<argc) { i++; //preventing loop from reading this argument again argFileName=argv[i]; } j--; } else if (strcmp(argv[i], "--transformation")==0 || strcmp(argv[i], "-t")==0) { // j--; if (i<argc) { i++; //preventing loop from reading this argument again argTransformation=atoi(argv[i]); } j--; } } if (j!=0) { //if all the arguments were processed sucessfully, j should be 0 fprintf(stderr, "error: wrong parameters, exiting"); exit(1); } // load map file if (argFile==1) { tmp=readPolishFile(argFileName); //read the map file to datastructure objects } else { tmp=readPolishFile("sample_map.mp"); //read the map file to datastructure objects } if (tmp==1) { //there was an error with reading the map file fprintf(stderr, "error: couldn't load map file, exiting"); exit(1); } computeCoordinates(); //compute world coordinates from lon/lat data // printAll(); //Init glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); //glutInitWindowSize(300, 300); glutCreateWindow("Map GL"); //create the display lists displayNet(); //printf("************debug: pm"); displayPolishMap(); // << Init // >> Callback fuggvenyek //glutReshapeFunc(ChangeSizeOrtho); // Parhuzamos vetites glutReshapeFunc(ChangeSizePerspective); // Perspektiv vetites glutDisplayFunc(Display); glutSpecialFunc(SpecialKeys); glutKeyboardFunc(Keyboard); glutTimerFunc(1000, Timer, 1); // 1 mp mulva meghivodik a Timer() fuggveny //glutIdleFunc(Idle); // Idle(), ha nem tortenik semmi // << Callback fuggvenyek // >> Menu IdleMenu = glutCreateMenu(ProcessMenu); glutAddMenuEntry("Idle kiiratas bekapcsolasa", 3); glutAddMenuEntry("Idle kiiratas kikapcsolasa", 4); MenuID = glutCreateMenu(ProcessMenu); glutAddMenuEntry("1. menupont", 1); glutAddMenuEntry("2. menupont", 2); glutAddSubMenu("Idle fuggveny", IdleMenu); glutAddMenuEntry("Kilepes", 5); glutAttachMenu(GLUT_RIGHT_BUTTON); // << Menu SetupRC(); glutMainLoop(); return 0; }