/** * 结果等于: * 前缀+模式的目录(比如retina)+文件名前缀(season1_)+文件名(比如test)+地域标记(_zh)+模式的后缀(比如@2x,ipadhd)+后缀名(.png) * season/retina/[email protected] * 我们这里处理过程如下: * * 这里实际获得的是: * test.png (本身数据) ----> * season/retina/season1_test_zh.png (Manager返回数据) ----> * season/retina/season1_test_zh-ipadhd.png (cocos2dx真正的数据) * * 版本1.1: * 处理情况(由于实现统一目录了,所以就不在套很多目录了): * 这里使用默认的语系:Locale_default,就没有后缀了 * test.png (本身数据) ----> * retina/test_zh.png (Manager返回数据) ----> * retina/test_zh-ipadhd.png (cocos2dx真正的数据) */ string ResourcePathManager::getPath(string fileName) { return getPath(fileName,Locale_Ignore); }
bool Model::parseMeshes(FS::IFile& file) { int object_count = 0; file.read(&object_count, sizeof(object_count)); if (object_count <= 0) return false; m_meshes.reserve(object_count); char model_dir[MAX_PATH_LENGTH]; PathUtils::getDir(model_dir, MAX_PATH_LENGTH, getPath().c_str()); for (int i = 0; i < object_count; ++i) { int32 str_size; file.read(&str_size, sizeof(str_size)); char material_name[MAX_PATH_LENGTH]; file.read(material_name, str_size); if (str_size >= MAX_PATH_LENGTH) return false; material_name[str_size] = 0; char material_path[MAX_PATH_LENGTH]; copyString(material_path, model_dir); catString(material_path, material_name); catString(material_path, ".mat"); auto* material_manager = m_resource_manager.get(ResourceManager::MATERIAL); Material* material = static_cast<Material*>(material_manager->load(Path(material_path))); int32 attribute_array_offset = 0; file.read(&attribute_array_offset, sizeof(attribute_array_offset)); int32 attribute_array_size = 0; file.read(&attribute_array_size, sizeof(attribute_array_size)); int32 indices_offset = 0; file.read(&indices_offset, sizeof(indices_offset)); int32 mesh_tri_count = 0; file.read(&mesh_tri_count, sizeof(mesh_tri_count)); file.read(&str_size, sizeof(str_size)); if (str_size >= MAX_PATH_LENGTH) { material_manager->unload(*material); return false; } char mesh_name[MAX_PATH_LENGTH]; mesh_name[str_size] = 0; file.read(mesh_name, str_size); bgfx::VertexDecl def; parseVertexDef(file, &def); m_meshes.emplace(def, material, attribute_array_offset, attribute_array_size, indices_offset, mesh_tri_count * 3, mesh_name, m_allocator); addDependency(*material); } return true; }
PathNode* Astar::findPath( INT a_iSx, INT a_iSy, INT a_iEx, INT a_iEy ) { PathNode* path = NULL; // 타겟 위치와 같은 위치면 탐색 중지 if( a_iSx == a_iEx && a_iSy == a_iEy ) { return NULL; } // 타겟 위치가 가지 못하는 곳이거나 // 타겟 위치 기준 8방향이 가지 못하는 곳이면 탐색 중지 if( m_Map[a_iEx][a_iEy].map == 1 || ( m_Map[a_iEx+0][a_iEy-1].map == 1 && m_Map[a_iEx+1][a_iEy-1].map == 1 && m_Map[a_iEx+1][a_iEy+0].map == 1 && m_Map[a_iEx+1][a_iEy+1].map == 1 && m_Map[a_iEx+0][a_iEy+1].map == 1 && m_Map[a_iEx-1][a_iEy-1].map == 1 && m_Map[a_iEx-1][a_iEy+0].map == 1 && m_Map[a_iEx-1][a_iEy-1].map == 1 ) ) { return NULL; } m_Start[0] = a_iSx; m_Start[1] = a_iSy; m_End[0] = a_iEx; m_End[1] = a_iEy; INT x = a_iSx; INT y = a_iSy; m_Map[x][y].visit = TRUE; m_Map[x][y].cameX = -1; m_Map[x][y].cameY = -1; m_Map[x][y].g = 0; m_Map[x][y].h = getDistH( x,y ); m_Map[x][y].f = getDistF( x,y ); insert( m_pOpen, createNode( x,y ) ); INT v[2]; while( getminimum( v ) ) { x = v[0]; y = v[1]; m_Map[x][y].map = 4; if( x == m_End[0] && y == m_End[1] ) { break; } for( INT i=0; i<8; ++i ) { openMap( x, y, x + m_Dir[i][0], y + m_Dir[i][1] ); } } m_Map[a_iSx][a_iSy].map = 10; m_Map[a_iEx][a_iEy].map = 20; removeTree( m_pOpen ); m_pOpen->root = NULL; return getPath( m_Start[0], m_Start[1], m_End[0], m_End[1] ); }
int main(){ FILE *fp = fopen("graph.in", "r"); FILE *fRand = fopen("graph2.in", "r"); int y, tests ,source, count=0, cnt=0, destination; int distance[N] = {0}, predecesor[N] = {0}; int distanceSimple[N], distanceMinHeap[N], distanceBruteForce[N]; bool ok; clock_t beginSD,endSD,beginDMH, endDMH, beginDBF, endDBF; struct Graph* G = (Graph*) malloc(sizeof(Graph)); struct MinHeap *mh = (MinHeap*) malloc(sizeof(MinHeap)); Init(mh); do{ puts("________________________________\n"); puts("Choose an option: \n"); puts("1. Load the Graph\n2. 2. Print the Graph\n3. Distance between two nodes\n4. Path between two nodes\n5. Dijkstra\n6. Dijkstra with Min Heap\n7. Brute Force Dijkstra\n8. Compare results\n9. Exit"); puts("________________________________\n"); scanf("%d", &y); switch(y){ case 1: G = loadGraph(fp); system("cls"); break; case 2: printGraph(G); system("cls"); break; case 3://Get shortest distance between two nodes puts("Give the source node: "); scanf("%d", &source); printf("Give the destination node: "); scanf("%d", &destination); getDistance(G, source, destination , mh, distance, predecesor); for(int i = 0; i <= G->V; i ++){ predecesor[i] = 0; distance[i] = 0; } system("cls"); break; case 4://Get shortest path between two nodes puts("Give the source node: "); scanf("%d", &source); printf("Give the destination node: "); scanf("%d", &destination); if( !hasNegativeCosts(G)){//preprocessing puts("\nThe Graph is valid for applying Dijkstra."); DijkstraMH(G, source, mh, distance, predecesor); getPath(G, source, destination, mh, distance, predecesor); for(int i = 0; i <= G->V; i ++){ predecesor[i] = 0; distance[i] = 0; } } else puts("\nThe Graph is invalid for applying Dijkstra.\nOne or more of the edges has negative cost."); getch(); system("cls"); break; case 5://Simple Dijkstra puts("Give the source: "); scanf("%d", &source); if( !hasNegativeCosts(G)){//preprocessing puts("\nThe Graph is valid for applying Dijkstra."); Dijkstra(G, source, distance, predecesor); printResult(G, distance, source); for(int i = 0;i <= G->V; i ++){ predecesor[i] = 0; distance[i] = 0; } } else puts("\nThe Graph is invalid for applying Dijkstra.\nOne or more of the edges has negative cost."); getch(); system("cls"); break; case 6://Dijkstra with Min Heap puts("Give the source: "); scanf("%d", &source); if( !hasNegativeCosts(G)){//preprocessing puts("\nThe Graph is valid for applying Dijkstra."); DijkstraMH(G, source, mh, distance, predecesor); printResult(G, distance, source); for(int i = 0;i <= G->V; i ++){ predecesor[i] = 0; distance[i] = 0; } } else puts("\nThe Graph is invalid for applying Dijkstra.\nOne or more of the edges has negative cost."); getch(); system("cls"); break; case 7://brute force Dijkstra puts("Give the source: "); scanf("%d", &source); if( !hasNegativeCosts(G)){//preprocessing puts("\nThe Graph is valid for applying Dijkstra."); bruteForceDijkstra(source, G, mh, 0, 0, 0, count, distance, predecesor); printResult(G, distance, source); } for(int i = 0; i <= G->V; i ++){ predecesor[i] = 0; distance[i] = 0; } getch(); system("cls"); break; case 8://compare results puts("Give the source: "); scanf("%d", &source); assert((beginSD = clock())!=-1); Dijkstra(G, source, distanceSimple, predecesor); endSD = clock(); beginDMH = clock(); DijkstraMH(G, source, mh, distanceMinHeap, predecesor); endDMH = clock(); beginDBF = clock(); bruteForceDijkstra(source, G, mh, 0, 0, 0, count, distanceBruteForce, predecesor); endDBF = clock(); if(compare(G, distanceSimple, distanceMinHeap, distanceBruteForce)){ puts("\nThe three algorithms provided the same results that are:"); printf("\nSimple Dijkstra:\n"); printResult(G, distanceSimple, source); printf("\nDijkstra with Min Heap:\n"); printResult(G, distanceMinHeap, source); printf("\nBrute Force Dijkstra:\n"); printResult(G, distanceBruteForce, source); } getch(); case 9: return 0; } }while(y != 9); return (0); }
void File::initializeMediaProperties() { #ifdef HAVE_AVFORMAT av_register_all(); AVFormatContext* ctx; if ((av_open_input_file(&ctx, getPath(), NULL, 0, NULL) == 0) && (av_find_stream_info(ctx) >= 0)) { // duration if (ctx->duration != AV_NOPTS_VALUE) duration = strdup(Utils::timeToString(ctx->duration / AV_TIME_BASE).c_str()); // bitrate if (ctx->bit_rate > 0) bitrate = ctx->bit_rate / 8; for (unsigned int i = 0; i < ctx->nb_streams; i++) { // samplerate if(samplerate <= 0) samplerate = ctx->streams[i]->codec->sample_rate; // channels if(channels <= 0) channels = ctx->streams[i]->codec->channels; // width if(width <= 0) width = ctx->streams[i]->codec->width; // height if(height <= 0) height = ctx->streams[i]->codec->height; if ((samplerate > 0) && (channels > 0) && (width > 0) && (height > 0)) i = ctx->nb_streams; } #if LIBAVFORMAT_VERSION_INT < (53<<16) // title if(ctx->title != NULL) title = strdup(ctx->title); // artist if(ctx->author != NULL) author = strdup(ctx->author); // album if(ctx->album != NULL) album = strdup(ctx->album); // genre if(ctx->genre != NULL) genre = strdup(ctx->genre); // description / comment if(ctx->comment != NULL) comment = strdup(ctx->comment); // track number if(ctx->track > 0) track = ctx->track; // date / year if(ctx->year > 0) year = ctx->year; #else av_metadata_conv(ctx, NULL, ctx->iformat->metadata_conv); AVMetadataTag *mtitle, *mauthor, *malbum, *mgenre, *mcomment, *mtrack, *myear; mtitle = av_metadata_get(ctx->metadata, "title", NULL, 0); mauthor = av_metadata_get(ctx->metadata, "author", NULL, 0); malbum = av_metadata_get(ctx->metadata, "album", NULL, 0); mgenre = av_metadata_get(ctx->metadata, "genre", NULL, 0); mcomment = av_metadata_get(ctx->metadata, "comment", NULL, 0); mtrack = av_metadata_get(ctx->metadata, "track", NULL, 0); myear = av_metadata_get(ctx->metadata, "year", NULL, 0); // title if(mtitle != NULL) title = strdup(mtitle->value); // artist if(mauthor != NULL) author = strdup(mauthor->value); // album if(malbum != NULL) album = strdup(malbum->value); // genre if(mgenre != NULL) genre = strdup(mgenre->value); // description / comment if(mcomment != NULL) comment = strdup(mcomment->value); // track number if(mtrack != NULL) track = Utils::stringToInteger(mtrack->value); // date / year if(myear != NULL) year = Utils::stringToInteger(myear->value); #endif //LIBAVFORMAT_VERSION_INT } av_close_input_file(ctx); #endif //HAVE_AVFORMAT }
bool HIDDeviceManager::Enumerate(HIDEnumerateVisitor* enumVisitor) { if (!initializeManager()) { return false; } CFSetRef deviceSet = IOHIDManagerCopyDevices(HIDManager); if (!deviceSet) return false; CFIndex deviceCount = CFSetGetCount(deviceSet); // Allocate a block of memory and read the set into it. IOHIDDeviceRef* devices = (IOHIDDeviceRef*) OVR_ALLOC(sizeof(IOHIDDeviceRef) * deviceCount); CFSetGetValues(deviceSet, (const void **) devices); // Iterate over devices. for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) { IOHIDDeviceRef hidDev = devices[deviceIndex]; if (!hidDev) { continue; } HIDDeviceDesc devDesc; if (getPath(hidDev, &(devDesc.Path)) && initVendorProductVersion(hidDev, &devDesc) && enumVisitor->MatchVendorProduct(devDesc.VendorId, devDesc.ProductId) && initUsage(hidDev, &devDesc)) { initStrings(hidDev, &devDesc); initSerialNumber(hidDev, &devDesc); // Look for the device to check if it is already opened. Ptr<DeviceCreateDesc> existingDevice = DevManager->FindHIDDevice(devDesc, true); // if device exists and it is opened then most likely the CreateHIDFile // will fail; therefore, we just set Enumerated to 'true' and continue. if (existingDevice && existingDevice->pDevice) { existingDevice->Enumerated = true; continue; } // open the device temporarily for startup communication if (IOHIDDeviceOpen(hidDev, kIOHIDOptionsTypeSeizeDevice) == kIOReturnSuccess) { // Construct minimal device that the visitor callback can get feature reports from. OSX::HIDDevice device(this, hidDev); enumVisitor->Visit(device, devDesc); IOHIDDeviceClose(hidDev, kIOHIDOptionsTypeSeizeDevice); } } } OVR_FREE(devices); CFRelease(deviceSet); return true; }
// add parameter string to tree Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, int ww, int hh, Fl_Tree_Item *n, bool highlight, Fl_Color c) { char *path = strdup(getPath(n).c_str()); _treeStrings.push_back(path); // macro button if(p.getAttribute("Macro") == "Gmsh"){ Fl_Button *but = new Fl_Button(1, 1, ww / _widgetLabelRatio, hh); but->box(FL_FLAT_BOX); but->color(_tree->color()); but->selection_color(_tree->color()); but->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); //TODO but->callback(onelab_string_button_cb, (void*)path); if(highlight) but->color(c); return but; } // non-editable value if(p.getReadOnly()){ Fl_Output *but = new Fl_Output(1, 1, ww, hh); but->value(p.getValue().c_str()); but->align(FL_ALIGN_RIGHT); if(highlight) but->color(c); return but; } // simple string (no menu) if(p.getChoices().empty() && p.getKind() != "file"){ Fl_Input *but = new Fl_Input(1, 1, ww, hh); but->value(p.getValue().c_str()); //TODO but->callback(onelab_string_input_cb, (void*)path); but->when(FL_WHEN_ENTER_KEY); but->align(FL_ALIGN_RIGHT); if(highlight) but->color(c); return but; } // general string input Fl_Input_Choice *but = new Fl_Input_Choice(1, 1, ww, hh); std::string multipleSelection = p.getAttribute("MultipleSelection"); if(multipleSelection.size()) ;//but->menubutton()->callback(multiple_selection_menu_cb, but); std::vector<Fl_Menu_Item> menu; for(unsigned int j = 0; j < p.getChoices().size(); j++){ char *str = strdup(p.getChoices()[j].c_str()); _treeStrings.push_back(str); bool divider = (p.getKind() == "file" && j == p.getChoices().size() - 1); int choice = multipleSelection.size() ? FL_MENU_TOGGLE : 0; if(multipleSelection.size() > j && multipleSelection[j] == '1') choice |= FL_MENU_VALUE; Fl_Menu_Item it = {str, 0, 0, 0, divider ? FL_MENU_DIVIDER : choice}; menu.push_back(it); } //if(p.getKind() == "file"){ // Fl_Menu_Item it = {"Choose...", 0, onelab_input_choice_file_chooser_cb, (void*)n}; // menu.push_back(it); // Fl_Menu_Item it2 = {"Edit...", 0, onelab_input_choice_file_edit_cb, (void*)n}; // menu.push_back(it2); // if(GuessFileFormatFromFileName(p.getValue()) >= 0){ // Fl_Menu_Item it3 = {"Merge...", 0, onelab_input_choice_file_merge_cb, (void*)n}; // menu.push_back(it3); // } //} Fl_Menu_Item it = {0}; menu.push_back(it); but->menubutton()->copy(&menu[0]); but->value(p.getValue().c_str()); but->callback(onelab_string_input_choice_cb, (void*)path); but->input()->when(FL_WHEN_ENTER_KEY); but->align(FL_ALIGN_RIGHT); if(highlight) but->input()->color(c); return but; }
Field* Grid::createField(QGraphicsItem * parent) { return new Field(getPath(), parent); }
//uint64_t spIndex=0; int generateSP(void **arg) { char *bin=(char *)arg[0]; uint64_t THREAD_NUM=(uint64_t )arg[1]; spSplit=(uint64_t *)calloc(THREAD_NUM,sizeof(uint64_t)); spSplitCapacity=(uint64_t *)calloc(THREAD_NUM,sizeof(uint64_t)); fusionNode=(uint64_t *)calloc(THREAD_NUM,sizeof(uint64_t)); fusionMod=(uint64_t *)calloc(THREAD_NUM,sizeof(uint64_t)); tempSP=(uint64_t **)calloc(THREAD_NUM,sizeof(uint64_t*)); printf("the case3num is %lu\n", case3num); printf("the blueBoundNum is %lu\n", blueBoundNum); printf("the redCapacity is %lu\n", redCapacity); printf("the blueCapacity is %lu\n", blueCapacity); redSeq=(uint64_t *)calloc(redCapacity,sizeof(uint64_t)); redPoint=(uint64_t *)calloc(redCapacity,sizeof(uint64_t)); blueTable=(uint64_t *)calloc(blueCapacity,sizeof(uint64_t)); char *redSeqPath=getPath(bin,"/redSeq"); FILE *fpredSeq=fopen(redSeqPath,"rb"); char *redPointPath=getPath(bin,"/redPoint"); FILE *fpredPoint=fopen(redPointPath,"rb"); if(fpredSeq==NULL||fpredPoint==NULL) { printf("fail to open the red file!\n"); exit(1); } fread(redSeq,sizeof(uint64_t),redCapacity,fpredSeq); fread(redPoint,sizeof(uint64_t),redCapacity,fpredPoint); fclose(fpredSeq); fclose(fpredPoint); remove(redPointPath); remove(redSeqPath); free(redPointPath); free(redSeqPath); uint64_t i; for(i=1;i<BLACKCAPACITY;i++) { if(blackTable[i]==0) { blackTable[i]=blackTable[i-1]; } } //////////////////////////////go through reference//////////////////////////////////// char *refPath=getPath(bin,"/reference"); FILE *fpRef=fopen(refPath,"rb"); if(fpRef==NULL) { printf("fail to open the ref file\n"); exit(1); } reference=(uint64_t *)calloc(compress_length,sizeof(uint64_t)); fread(reference,sizeof(uint64_t),compress_length,fpRef); fclose(fpRef); remove(refPath); free(refPath); //////////////////////////////////////////////////////////////////////////////////////////////// char *specialBranchPath=getPath(bin,"/specialBranch"); FILE *fpSB=fopen(specialBranchPath,"rb"); specialBranch=(uint64_t *)calloc(specialBranchNum,sizeof(uint64_t)); if(fpSB==NULL) { printf("fail to open the specialBranch file\n"); exit(1); } /* replaced by binary file for(i=0;i<specialBranchNum;i++) { fscanf(fpSB,"%lu",&specialBranch[i]); } */ fread(specialBranch,sizeof(uint64_t),specialBranchNum,fpSB); fclose(fpSB); remove(specialBranchPath); free(specialBranchPath); qsort(specialBranch,specialBranchNum,sizeof(uint64_t),ascend); specialSA=(uint64_t *)calloc(countRead,sizeof(uint64_t)); char *specialSAPath=getPath(bin,"/specialSA"); FILE *fpSpecialSA=fopen(specialSAPath,"rb"); if(fpSpecialSA==NULL) { printf("fail to open the specialBranch file\n"); exit(1); } fread(specialSA,sizeof(uint64_t),countRead,fpSpecialSA); fclose(fpSpecialSA); remove(specialSAPath); free(specialSAPath); ///////////////////////////////////split the ref first////////////////////////////////////////// splitIndex=(uint64_t *)calloc(THREAD_NUM+1,sizeof(uint64_t)); splitIndex[0]=0; splitIndex[THREAD_NUM]=BWTLEN; pthread_t myThread[THREAD_NUM]; for(i=1;i<THREAD_NUM;i++) { void **tt=(void **)calloc(2,sizeof(void *)); tt[0]=(void *)i; tt[1]=(void *)THREAD_NUM; int check=pthread_create( &myThread[i-1], NULL, multiGenerateSplit, (void*)tt); if(check) { fprintf(stderr,"threadNum:%lu, Error - pthread_create() return code: %d\n",i,check); exit(EXIT_FAILURE); } } for(i=1;i<THREAD_NUM;i++) { pthread_join( myThread[i-1], NULL); } //////////////////////////////////multi-thread generate spcode//////////////////////////////////// rwlockRed=(pthread_rwlock_t*)calloc(redCapacity,sizeof(pthread_rwlock_t)); for(i=0;i<redCapacity;i++) { if(pthread_rwlock_init(&rwlockRed[i], NULL)) { printf("fail to create rwlock %lu\n",i); exit(1); } } for(i=0;i<THREAD_NUM;i++) { void **tt=(void **)calloc(2,sizeof(void *)); tt[0]=(void *)i; tt[1]=(void *)bin; int check=pthread_create( &myThread[i], NULL, multiGenerateSP, (void*)tt); if(check) { fprintf(stderr,"threadNum:%lu, Error - pthread_create() return code: %d\n",i,check); exit(EXIT_FAILURE); } } for(i=0;i<THREAD_NUM;i++) { pthread_join( myThread[i], NULL); } spSplitCapacity[0]=spSplit[0]; for(i=1;i<THREAD_NUM;i++) { spSplitCapacity[i]=spSplit[i]; spSplit[i]=spSplit[i]+spSplit[i-1]; } free(rwlockRed); free(reference); free(specialSA); free(specialBranch); free(redSeq); free(redPoint); free(blackTable); /////////////////////////////////add seg to the blue table and special sp index//////////////////// for(i=1;i<THREAD_NUM;i++) { void **tt=(void **)calloc(2,sizeof(void *)); tt[0]=(void *)i; tt[1]=(void *)bin; int check=pthread_create( &myThread[i], NULL, multiAddSeg, (void*)tt); if(check) { fprintf(stderr,"threadNum:%lu, Error - pthread_create() return code: %d\n",i,check); exit(EXIT_FAILURE); } //pthread_join( myThread[i], NULL); } for(i=1;i<THREAD_NUM;i++) { pthread_join( myThread[i], NULL); } char *spSpecialIndexPath=getPath(bin,"/spSpecialIndex"); FILE *fpspSpecial=fopen(spSpecialIndexPath,"wb"); free(spSpecialIndexPath); spSpecialIndexPath=getPath(bin,"/spSpecialIndex0"); FILE *fpspSpecial0=fopen(spSpecialIndexPath,"rb"); uint64_t *readBuf=(uint64_t *)calloc(BUFFERSIZE,sizeof(uint64_t)),bufReadNum; while((bufReadNum=fread(readBuf,sizeof(uint64_t),BUFFERSIZE,fpspSpecial0))>0) { fwrite(readBuf,sizeof(uint64_t),bufReadNum,fpspSpecial); } remove(spSpecialIndexPath); free(spSpecialIndexPath); fclose(fpspSpecial0); for(i=1;i<THREAD_NUM;i++) { char cNum[4]; sprintf(cNum,"%lu",i); char spSpecialName[30]="/spSpecialIndexAdded"; strcat(spSpecialName,cNum); spSpecialIndexPath=getPath(bin,spSpecialName); fpspSpecial0=fopen(spSpecialIndexPath,"rb"); while((bufReadNum=fread(readBuf,sizeof(uint64_t),BUFFERSIZE,fpspSpecial0))>0) { fwrite(readBuf,sizeof(uint64_t),bufReadNum,fpspSpecial); } remove(spSpecialIndexPath); free(spSpecialIndexPath); fclose(fpspSpecial0); } fclose(fpspSpecial); free(readBuf); //////////////////////////connect the sp codes/////////////////////////////////////////////// spCodeLen=spSplit[THREAD_NUM-1]; spCodeLen+=32; uint64_t spCodeSpace=spCodeLen>>5; uint64_t spLenMod=spCodeLen&MOD32; if(spLenMod) spCodeSpace++; spCode=(uint64_t *)calloc(spCodeSpace,sizeof(uint64_t)); spSpecialIndexPath=getPath(bin,"/SPcode0"); fpspSpecial=fopen(spSpecialIndexPath,"rb");//just used as temp paramater. uint64_t capacity0=spSplitCapacity[0]; uint64_t space0=capacity0>>5; if((capacity0&MOD32)!=0) space0++; bufReadNum=fread(spCode,sizeof(uint64_t),space0,fpspSpecial); remove(spSpecialIndexPath); free(spSpecialIndexPath); if(bufReadNum!=space0) fprintf(stderr,"alert! bufReadNum=%lu, space0=%lu\n",bufReadNum,space0 ),exit(1); fclose(fpspSpecial); fusionNode[0]=spCode[space0-1]; fusionMod[0]=capacity0&MOD32; for(i=1;i<THREAD_NUM;i++) { void **tt=(void **)calloc(2,sizeof(void *)); tt[0]=(void *)i; tt[1]=(void *)bin; int check=pthread_create( &myThread[i], NULL, multiCatSP, (void*)tt); if(check) { fprintf(stderr,"threadNum:%lu, Error - pthread_create() return code: %d\n",i,check); exit(EXIT_FAILURE); } } for(i=1;i<THREAD_NUM;i++) { pthread_join( myThread[i], NULL); } for(i=1;i<THREAD_NUM;i++) { void **tt=(void **)calloc(2,sizeof(void *)); tt[0]=(void *)i; tt[1]=(void *)bin; int check=pthread_create( &myThread[i], NULL, multiConnect, (void*)tt); if(check) { fprintf(stderr,"threadNum:%lu, Error - pthread_create() return code: %d\n",i,check); exit(EXIT_FAILURE); } } for(i=1;i<THREAD_NUM;i++) { pthread_join( myThread[i], NULL); } uint64_t space=spSplit[THREAD_NUM-1]>>5; spCode[space]=fusionNode[THREAD_NUM-1]; free(spSplit); free(spSplitCapacity); free(fusionNode); free(fusionMod); return 1; }
void addLineEndingToItem(QGraphicsPathItem* item, const CLLineEnding* ending, const CLGroup* group, const CLRenderResolver* resolver, QPointF point, QPointF second, QGraphicsItemGroup* itemGroup) { const CLGroup* lineGroup = ending->getGroup(); for (size_t i = 0; i < lineGroup->getNumElements(); ++i) { const CLPolygon* poly = dynamic_cast<const CLPolygon*>(lineGroup->getElement(i)); const CLRenderCurve* rcurve = dynamic_cast<const CLRenderCurve*>(lineGroup->getElement(i)); const CLEllipse* ellipse = dynamic_cast<const CLEllipse*>(lineGroup->getElement(i)); const CLRectangle* rect = dynamic_cast<const CLRectangle*>(lineGroup->getElement(i)); if (rcurve != NULL) { QPainterPath path = item->path(); QPainterPath& linePath = *getPath(rcurve, ending->getBoundingBox()); applyRotationalMapping(linePath, ending, point, second); linePath.translate(point); path.addPath(linePath); item->setPath(path); } else if (poly != NULL) { QPainterPath path = item->path(); QPainterPath& linePath = *getPath(poly, ending->getBoundingBox()); applyRotationalMapping(linePath, ending, point, second); linePath.translate(point); path.addPath(linePath); item->setPath(path); if (poly->isSetFill() || group->isSetFill()) { QBrush* brush = getBrush(poly, ending->getGroup(), resolver, ending->getBoundingBox()); QPen* pen = getPen(poly, ending->getGroup(), resolver, ending->getBoundingBox()); linePath.setFillRule(Qt::WindingFill); if (poly->isSetFillRule()) { switch (poly->getFillRule()) { case CLGraphicalPrimitive2D::EVENODD: linePath.setFillRule(Qt::OddEvenFill); break; case CLGraphicalPrimitive2D::NONZERO: default: linePath.setFillRule(Qt::WindingFill); break; } } if (group->isSetFillRule()) { switch (group->getFillRule()) { case CLGraphicalPrimitive2D::EVENODD: linePath.setFillRule(Qt::OddEvenFill); break; case CLGraphicalPrimitive2D::NONZERO: default: linePath.setFillRule(Qt::WindingFill); break; } } QGraphicsPathItem* outline = new QGraphicsPathItem(linePath); outline->setPen(*pen); outline->setBrush(*brush); itemGroup->addToGroup(outline); } } else if (ellipse != NULL) { QPainterPath path = item->path(); QPainterPath& linePath = *getPath(ellipse, ending->getBoundingBox()); applyRotationalMapping(linePath, ending, point, second); linePath.translate(point); path.addPath(linePath); item->setPath(path); if (ellipse->isSetFill() || group->isSetFill()) { QBrush* brush = getBrush(ellipse, ending->getGroup(), resolver, ending->getBoundingBox()); QPen* pen = getPen(ellipse, ending->getGroup(), resolver, ending->getBoundingBox()); QGraphicsPathItem* outline = new QGraphicsPathItem(linePath); outline->setPen(*pen); outline->setBrush(*brush); itemGroup->addToGroup(outline); } } else if (rect != NULL) { QPainterPath path = item->path(); QPainterPath& linePath = *getPath(rect, ending->getBoundingBox()); applyRotationalMapping(linePath, ending, point, second); linePath.translate(point); path.addPath(linePath); item->setPath(path); if (rect->isSetFill() || group->isSetFill()) { QBrush* brush = getBrush(rect, ending->getGroup(), resolver, ending->getBoundingBox()); QPen* pen = getPen(rect, ending->getGroup(), resolver, ending->getBoundingBox()); QGraphicsPathItem* outline = new QGraphicsPathItem(linePath); outline->setPen(*pen); outline->setBrush(*brush); itemGroup->addToGroup(outline); } } } }
bool DebugIR::runOnModule(Module &M, std::string &Path) { bool result = runOnModule(M); Path = getPath(); return result; }
/* * The main function implements a loader for applications which use UNO. * * <p>This code runs on the Windows platform only.</p> * * <p>The main function detects a UNO installation on the system and adds the * program directory of the UNO installation to the PATH environment variable. * After that, the application process is loaded and started, whereby the * new process inherits the environment of the calling process, including * the modified PATH environment variable. The application's executable name * must be the same as the name of this executable, prefixed by '_'.</p> * * <p>A UNO installation can be specified by the user by setting the UNO_PATH * environment variable to the program directory of the UNO installation. * If no installation is specified by the user, the default installation on * the system will be taken. The default installation is read from the * default value of the key "Software\LibreOffice\UNO\InstallPath" from the * root key HKEY_CURRENT_USER in the Windows Registry. If this key is missing, * the key is read from the root key HKEY_LOCAL_MACHINE.</p> */ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { const char* ENVVARNAME = "PATH"; const char* PATHSEPARATOR = ";"; char const* path = NULL; char path2[MAX_PATH]; char* value = NULL; char* envstr = NULL; char* cmdline = NULL; size_t size; STARTUPINFO startup_info; PROCESS_INFORMATION process_info; BOOL bCreate; (void) hInstance; /* unused */ (void) hPrevInstance; /* unused */ (void) nCmdShow; /* unused */ /* get the path of the UNO installation */ path = getPath(); if ( path != NULL ) { wchar_t cmd[ MY_LENGTH(L"\"") + MAX_PATH + MY_LENGTH(L"\\unoinfo.exe\" c++")]; /* hopefully does not overflow */ int pathsize; SECURITY_ATTRIBUTES sec; HANDLE temp; HANDLE stdoutRead; HANDLE stdoutWrite; STARTUPINFOW startinfo; PROCESS_INFORMATION procinfo; int ret; cmd[0] = L'"'; pathsize = MultiByteToWideChar(CP_ACP, 0, path, -1, cmd + 1, MAX_PATH); if (pathsize == 0) { writeError("Error: MultiByteToWideChar failed!\n"); closeErrorFile(); return 1; } if (wcschr(cmd + 1, L'"') != NULL) { writeError("Error: bad characters in UNO installation path!\n"); closeErrorFile(); return 1; } wcscpy( cmd + pathsize, (L"\\unoinfo.exe\" c++" + (pathsize == 1 || cmd[pathsize - 1] != L'\\' ? 0 : 1))); sec.nLength = sizeof (SECURITY_ATTRIBUTES); sec.lpSecurityDescriptor = NULL; sec.bInheritHandle = TRUE; if (CreatePipe(&temp, &stdoutWrite, &sec, 0) == 0 || DuplicateHandle( GetCurrentProcess(), temp, GetCurrentProcess(), &stdoutRead, 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) == 0) { writeError("Error: CreatePipe/DuplicateHandle failed!\n"); closeErrorFile(); return 1; } memset(&startinfo, 0, sizeof (STARTUPINFOW)); startinfo.cb = sizeof (STARTUPINFOW); startinfo.lpDesktop = L""; startinfo.dwFlags = STARTF_USESTDHANDLES; startinfo.hStdOutput = stdoutWrite; ret = CreateProcessW( NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startinfo, &procinfo); if (ret != 0) { char * buf = NULL; char * tmp; DWORD n = 1000; DWORD k = 0; DWORD exitcode; int path2size; CloseHandle(stdoutWrite); CloseHandle(procinfo.hThread); for (;;) { DWORD m; tmp = realloc(buf, n); if (tmp == NULL) { free(buf); writeError( "Error: out of memory reading unoinfo output!\n"); closeErrorFile(); return 1; } buf = tmp; if (!ReadFile(stdoutRead, buf + k, n - k, &m, NULL)) { DWORD err = GetLastError(); if (err == ERROR_HANDLE_EOF || err == ERROR_BROKEN_PIPE) { break; } writeError("Error: cannot read unoinfo output!\n"); closeErrorFile(); return 1; } if (m == 0) { break; } k += m; if (k >= n) { if (n >= MAXDWORD / 2) { writeError( "Error: out of memory reading unoinfo output!\n"); closeErrorFile(); return 1; } n *= 2; } } if ((k & 1) == 1) { writeError("Error: bad unoinfo output!\n"); closeErrorFile(); return 1; } CloseHandle(stdoutRead); if (!GetExitCodeProcess(procinfo.hProcess, &exitcode) || exitcode != 0) { writeError("Error: executing unoinfo failed!\n"); closeErrorFile(); return 1; } if (k == 0) { path2size = 0; } else { path2size = WideCharToMultiByte( CP_ACP, 0, (wchar_t *) buf, k / 2, path2, MAX_PATH - 1, NULL, NULL); if (path2size == 0) { writeError("Error: converting unoinfo output failed!\n"); closeErrorFile(); return 1; } } path2[path2size] = '\0'; path = path2; } else { if (GetLastError() != ERROR_FILE_NOT_FOUND) { writeError("Error: calling unoinfo failed!\n"); closeErrorFile(); return 1; } CloseHandle(stdoutRead); CloseHandle(stdoutWrite); } /* get the value of the PATH environment variable */ value = getenv( ENVVARNAME ); /* * add the UNO installation path to the PATH environment variable; * note that this only affects the environment variable of the current * process, the command processor's environment is not changed */ size = strlen( ENVVARNAME ) + strlen( "=" ) + strlen( path ) + 1; if ( value != NULL ) size += strlen( PATHSEPARATOR ) + strlen( value ); envstr = (char*) malloc( size ); strcpy( envstr, ENVVARNAME ); strcat( envstr, "=" ); strcat( envstr, path ); if ( value != NULL ) { strcat( envstr, PATHSEPARATOR ); strcat( envstr, value ); } _putenv( envstr ); free( envstr ); } else { writeError( "Warning: no UNO installation found!\n" ); } /* create the command line for the application process */ cmdline = createCommandLine( lpCmdLine ); if ( cmdline == NULL ) { writeError( "Error: cannot create command line!\n" ); closeErrorFile(); return 1; } /* create the application process */ memset( &startup_info, 0, sizeof( STARTUPINFO ) ); startup_info.cb = sizeof( STARTUPINFO ); bCreate = CreateProcess( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup_info, &process_info ); free( cmdline ); if ( !bCreate ) { writeError( "Error: cannot create process!\n" ); closeErrorFile(); return 1; } /* close the error file */ closeErrorFile(); return 0; }
bool SkDrawPath::draw(SkAnimateMaker& maker) { SkPath& path = getPath(); SkBoundableAuto boundable(this, maker); maker.fCanvas->drawPath(path, *maker.fPaint); return false; }
string ResourcePathManager::getPath_locale(string fileName) { return getPath(fileName,currentLocale); }
void parseCmd(const char **strptr) { // Parse Executable Filename char exe[MAX_CMD_SIZE + 1] = ""; char path[MAX_CMD_SIZE + 1] = ""; bool exeValid; PARSE_ASSERT(getToken(exe, strptr) == IDENTIFIER); exeValid = getPath(path, exe); if (!exeValid) { char msg[MAX_CMD_SIZE + 30]; sprintf(msg, "Unknown command: [%s].", exe); throw std::string(msg); } // Parse Arguments int num_arg = 0; char *arg[16]; while (peekToken(*strptr) == IDENTIFIER) { arg[num_arg] = new char[MAX_CMD_SIZE + 1]; getToken(arg[num_arg++], strptr); } // Parse Pipe to File bool pipeToFile = false; char file[MAX_CMD_SIZE + 1]; if (peekToken(*strptr) == OUT) { pipeToFile = true; getToken(NULL, strptr); // '>' PARSE_ASSERT(getToken(file, strptr) == IDENTIFIER); } // Parse Pipe bool pipe = false; bool pipenum = false; int pipenumCount; if (peekToken(*strptr) == PIPE) { getToken(NULL, strptr); // '|' /* // Test whether this is the last process char nextCmdName[MAX_CMD_SIZE + 1]; Token token; char temp[MAX_CMD_SIZE + 1]; token = peekToken(*strptr, nextCmdName); if (token == END || token == IDENTIFIER && !getPath(temp, nextCmdName)) { // Consider '|' as '|1' pipenum = true; pipenumCount = 1; } else { */ pipe = true; //} } // Parse Pipenum if (peekToken(*strptr) == PIPENUM) { char temp[MAX_CMD_SIZE + 1]; pipenum = true; getToken(temp, strptr); // '|?' pipenumCount = atoi(temp + 1); } // Parse Pipeerrnum bool pipeerrnum = false; int pipeerrnumCount; if (peekToken(*strptr) == PIPEERRNUM) { char temp[MAX_CMD_SIZE + 1]; pipeerrnum = true; getToken(temp, strptr); // '!?' pipeerrnumCount = atoi(temp + 1); } // Parse Pipenum again if !? exists if (!pipenum && pipeerrnum) { if (peekToken(*strptr) == PIPENUM) { char temp[MAX_CMD_SIZE + 1]; pipenum = true; getToken(temp, strptr); // '|?' pipeerrnumCount = atoi(temp + 1); } } // Some assertions PARSE_ASSERT(pipeToFile + pipe + pipenum <= 1); // No multiple outputs // Execute executeCmd(exe, path, num_arg, (const char **)arg, pipeToFile, file, pipe, pipenum, pipenumCount, pipeerrnum, pipeerrnumCount); // Release Argument List for (int i = 0; i < num_arg; i++) { delete [] arg[i]; } }
//-------------------------------------------------------------- void Parameter::readFromXml(ofxXmlSettings &xml, bool bFullSchema) { ofLogVerbose("ofxMSAControlFreak") << "msa::controlfreak::Parameter::readFromXml: " << getPath(); if(_paramValue) _paramValue->readFromXml(xml, bFullSchema); if(bFullSchema) { setTooltip(xml.getAttribute(_xmlTag, "tooltip", "", _xmlTagId)); } }
void Resources::loadXML(const string &xml_name, LoadResourcesContext *load_context, bool load_completely, bool use_load_counter, const string &prebuilt_folder_) { _name = xml_name; string path; for (int i = xml_name.size() - 1; i >= 0; --i) { char c = xml_name[i]; if (c == '\\' || c == '/') { path = xml_name.substr(0, i + 1); } } FS_LOG("step0"); file::buffer fb; file::read(xml_name.c_str(), fb); FS_LOG("step1"); char destHead[255]; char destTail[255]; path::split(xml_name.c_str(), destHead, destTail); string xml_only_name = destTail; string prebuilt_folder = prebuilt_folder_ + "/" + destTail + ".ox/"; if (prebuilt_folder[0] == '/') { prebuilt_folder.erase(prebuilt_folder.begin()); } file::buffer fb_meta; pugi::xml_document doc_meta; string ox = prebuilt_folder + "meta.xml"; const char *ox_file = ox.c_str(); FS_LOG("step2"); if (file::exists(ox_file)) { file::read(ox_file, fb_meta, ep_ignore_error); if (fb_meta.getSize()) doc_meta.load_buffer_inplace(&fb_meta.data[0], fb_meta.data.size()); } if (!fb.data.size()) { OX_ASSERT(fb.data.size() && "can't find xml file"); return; } pugi::xml_document *doc = new pugi::xml_document(); _docs.push_back(doc); bool loaded = doc->load_buffer(&fb.data[0], fb.data.size()); OX_ASSERT(loaded); pugi::xml_node resources = doc->first_child(); pugi::xml_node resources_meta = doc_meta.first_child(); pugi::xml_node meta_node = resources_meta.first_child(); int i = 0; string id; //string file; string rect_str; FS_LOG("loading xml resources"); float scaleFactor = 1.0f; pugi::xml_node child = resources.first_child(); while (!child.empty()) { const char *name = child.name(); pugi::xml_attribute attr; if (!strcmp(name, "set")) { pugi::xml_attribute attr = child.first_attribute(); while (attr) { if (!strcmp(attr.name(), "path")) { path = getPath(path.c_str(), attr.value()); path += "/"; } if (!strcmp(attr.name(), "load")) { load_completely = attr.as_bool(); } if (!strcmp(attr.name(), "scale_factor")) { scaleFactor = attr.as_float(scaleFactor); } attr = attr.next_attribute(); } } else/* if (!strcmp(name, "atlas")) { loadAtlas(path, child, meta_node); meta_node = meta_node.next_sibling(); } else*/ { bool load = child.attribute("load").as_bool(load_completely); registeredResources::iterator i = lower_bound(_registeredResources.begin(), _registeredResources.end(), name); if (i != _registeredResources.end()) { registeredResource &r = *i; if (!strcmp(r.id, name)) { CreateResourceContext context; context.xml_name = &xml_name; context.node = child; context.meta = meta_node; context.folder = &path; context.resources = this; context.scale_factor = scaleFactor; string prebuilt_xml_folder = prebuilt_folder + "/" + name + "/"; context.prebuilt_folder = &prebuilt_xml_folder; FS_LOG("resource: %s ", name); Resource *res = r.cb(context); OX_ASSERT(res); res->setUseLoadCounter(use_load_counter); meta_node = context.meta; if (res) { //res-> = child; if (load) res->load(load_context); _resources.push_back(res); } } else { log::error("unknown resource. type: '%s' id: '%s'", name, Resource::extractID(child, "", "").c_str()); OX_ASSERT(!"unknown resource type"); } } } child = child.next_sibling(); } sort(_resources.begin(), _resources.end(), comparePred); FS_LOG("xml loaded"); //print(); }
//-------------------------------------------------------------- Parameter::~Parameter() { ofLogVerbose("ofxMSAControlFreak") << "msa::controlfreak::Parameter::~Parameter(): " << getPath(); if(_paramValue) delete _paramValue; // TODO }
// add a parameter number to the tree Fl_Widget *onelabGroup::_addParameterWidget(onelab::number &p, int ww, int hh, Fl_Tree_Item *n, bool highlight, Fl_Color c) { char *path = strdup(getPath(n).c_str()); _treeStrings.push_back(path); // enumeration (display choices as value labels, not numbers) if(p.getChoices().size() && p.getChoices().size() == p.getValueLabels().size()){ Fl_Choice *but = new Fl_Choice(1, 1, ww, hh); std::vector<Fl_Menu_Item> menu; std::map<double, std::string> labels(p.getValueLabels()); for(std::map<double, std::string>::iterator it = labels.begin(); it != labels.end(); it++){ char *str = strdup(it->second.c_str()); _treeStrings.push_back(str); Fl_Menu_Item menuItem = {str, 0, 0, 0, 0}; if(highlight) menuItem.labelcolor(c); menu.push_back(menuItem); } Fl_Menu_Item it = {0}; menu.push_back(it); but->copy(&menu[0]); for(unsigned int i = 0; i < p.getChoices().size(); i++){ if(p.getValue() == p.getChoices()[i]){ but->value(i); break; } } but->callback(onelab_number_choice_cb, (void*)path); but->align(FL_ALIGN_RIGHT); if(p.getReadOnly()) but->deactivate(); return but; } // check box (boolean choice) if(p.getChoices().size() == 2 && p.getChoices()[0] == 0 && p.getChoices()[1] == 1){ n->labelsize(FL_NORMAL_SIZE + 2); Fl_Check_Button *but = new Fl_Check_Button(1, 1, ww / _widgetLabelRatio, hh); but->box(FL_FLAT_BOX); but->color(_tree->color()); but->value(p.getValue()); but->callback(onelab_number_check_button_cb, (void*)path); if(highlight) but->color(c); if(p.getReadOnly()) but->deactivate(); return but; } // non-editable value if(p.getReadOnly()){ outputRange *but = new outputRange(1, 1, ww, hh); //TODO but->callback(onelab_number_output_range_cb, (void*)path); but->value(p.getValue()); but->align(FL_ALIGN_RIGHT); but->graph(p.getAttribute("Graph")); if(highlight) but->color(c); return but; } // general number input inputRange *but = new inputRange(1, 1, ww, hh, onelab::parameter::maxNumber(), p.getAttribute("ReadOnlyRange") == "1"); but->value(p.getValue()); but->minimum(p.getMin()); but->maximum(p.getMax()); but->step(p.getStep()); but->choices(p.getChoices()); but->loop(p.getAttribute("Loop")); but->graph(p.getAttribute("Graph")); but->callback(onelab_number_input_range_cb, (void*)path); but->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY); but->align(FL_ALIGN_RIGHT); if(highlight) but->color(c); return but; }
//-------------------------------------------------------------- void Parameter::setParent(ParameterGroup *parent) { ofLogVerbose("ofxMSAControlFreak") << "msa::controlfreak::Parameter::setParent: '" << getPath() << "' to '" << (parent ? parent->getName(): "NULL") << "'"; _pparent = parent; }
FontTex *ftxLoadFont(const char *filename) { char *path; file_handle file; char buf[100]; int i; int len; FontTex *ftx; path = getPath(PATH_DATA, filename); if(path == NULL) { fprintf(stderr, FTX_ERR "can't load font file '%s'\n", filename); return NULL; } file = file_open(path, "r"); free(path); /* TODO(5): check for EOF errors in the following code */ /* nTextures, texture width, char width */ ftx = (FontTex*) malloc(sizeof(FontTex)); getLine(buf, sizeof(buf), file); sscanf(buf, "%d %d %d ", &(ftx->nTextures), &(ftx->texwidth), &(ftx->width)); /* lowest character, highest character */ getLine(buf, sizeof(buf), file); sscanf(buf, "%d %d ", &(ftx->lower), &(ftx->upper)); /* font name */ getLine(buf, sizeof(buf), file); len = strlen(buf) + 1; ftx->fontname = (char*)malloc(len); memcpy(ftx->fontname, buf, len); /* prepare space for texture IDs */ ftx->texID = (GLint*) malloc(ftx->nTextures * sizeof(unsigned int)); glGenTextures(ftx->nTextures, (GLuint *)ftx->texID); /* the individual textures */ for(i = 0; i < ftx->nTextures; i++) { char *texname; getLine(buf, sizeof(buf), file); len = strlen(buf) + 1; if(buf[len - 2] == '\n') buf[len - 2] = 0; texname = (char*)malloc(len); memcpy(texname, buf, len); glBindTexture(GL_TEXTURE_2D, ftx->texID[i]); loadTexture(texname, GL_RGBA); free(texname); //TODO: Changed the i to X need to check it glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); */ /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ /*glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);*/ //TODO: check this code glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_NEAREST); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST); } file_close(file); return ftx; }
Common::SeekableReadStream *Ps2FilesystemNode::createReadStream() { Common::SeekableReadStream *ss = PS2FileStream::makeFromPath(getPath(), false); return ss; }
void SSearchTest::searchTest() { #if !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_FILE_IO UErrorCode status = U_ZERO_ERROR; char path[PATH_BUFFER_SIZE]; const char *testFilePath = getPath(path, "ssearch.xml"); if (testFilePath == NULL) { return; /* Couldn't get path: error message already output. */ } LocalPointer<UXMLParser> parser(UXMLParser::createParser(status)); TEST_ASSERT_SUCCESS(status); LocalPointer<UXMLElement> root(parser->parseFile(testFilePath, status)); TEST_ASSERT_SUCCESS(status); if (U_FAILURE(status)) { return; } const UnicodeString *debugTestCase = root->getAttribute("debug"); if (debugTestCase != NULL) { // setenv("USEARCH_DEBUG", "1", 1); } const UXMLElement *testCase; int32_t tc = 0; while((testCase = root->nextChildElement(tc)) != NULL) { if (testCase->getTagName().compare("test-case") != 0) { errln("ssearch, unrecognized XML Element in test file"); continue; } const UnicodeString *id = testCase->getAttribute("id"); *testId = 0; if (id != NULL) { id->extract(0, id->length(), testId, sizeof(testId), US_INV); } // If debugging test case has been specified and this is not it, skip to next. if (id!=NULL && debugTestCase!=NULL && *id != *debugTestCase) { continue; } // // Get the requested collation strength. // Default is tertiary if the XML attribute is missing from the test case. // const UnicodeString *strength = testCase->getAttribute("strength"); UColAttributeValue collatorStrength = UCOL_PRIMARY; if (strength==NULL) { collatorStrength = UCOL_TERTIARY;} else if (*strength=="PRIMARY") { collatorStrength = UCOL_PRIMARY;} else if (*strength=="SECONDARY") { collatorStrength = UCOL_SECONDARY;} else if (*strength=="TERTIARY") { collatorStrength = UCOL_TERTIARY;} else if (*strength=="QUATERNARY") { collatorStrength = UCOL_QUATERNARY;} else if (*strength=="IDENTICAL") { collatorStrength = UCOL_IDENTICAL;} else { // Bogus value supplied for strength. Shouldn't happen, even from // typos, if the XML source has been validated. // This assert is a little deceiving in that strength can be // any of the allowed values, not just TERTIARY, but it will // do the job of getting the error output. TEST_ASSERT(*strength=="TERTIARY") } // // Get the collator normalization flag. Default is UCOL_OFF. // UColAttributeValue normalize = UCOL_OFF; const UnicodeString *norm = testCase->getAttribute("norm"); TEST_ASSERT (norm==NULL || *norm=="ON" || *norm=="OFF"); if (norm!=NULL && *norm=="ON") { normalize = UCOL_ON; } // // Get the alternate_handling flag. Default is UCOL_NON_IGNORABLE. // UColAttributeValue alternateHandling = UCOL_NON_IGNORABLE; const UnicodeString *alt = testCase->getAttribute("alternate_handling"); TEST_ASSERT (alt == NULL || *alt == "SHIFTED" || *alt == "NON_IGNORABLE"); if (alt != NULL && *alt == "SHIFTED") { alternateHandling = UCOL_SHIFTED; } const UnicodeString defLocale("en"); char clocale[100]; const UnicodeString *locale = testCase->getAttribute("locale"); if (locale == NULL || locale->length()==0) { locale = &defLocale; }; locale->extract(0, locale->length(), clocale, sizeof(clocale), NULL); UnicodeString text; UnicodeString target; UnicodeString pattern; int32_t expectedMatchStart = -1; int32_t expectedMatchLimit = -1; const UXMLElement *n; int32_t nodeCount = 0; n = testCase->getChildElement("pattern"); TEST_ASSERT(n != NULL); if (n==NULL) { continue; } text = n->getText(FALSE); text = text.unescape(); pattern.append(text); nodeCount++; n = testCase->getChildElement("pre"); if (n!=NULL) { text = n->getText(FALSE); text = text.unescape(); target.append(text); nodeCount++; } n = testCase->getChildElement("m"); if (n!=NULL) { expectedMatchStart = target.length(); text = n->getText(FALSE); text = text.unescape(); target.append(text); expectedMatchLimit = target.length(); nodeCount++; } n = testCase->getChildElement("post"); if (n!=NULL) { text = n->getText(FALSE); text = text.unescape(); target.append(text); nodeCount++; } // Check that there weren't extra things in the XML TEST_ASSERT(nodeCount == testCase->countChildren()); // Open a collator and StringSearch based on the parameters // obtained from the XML. // status = U_ZERO_ERROR; LocalUCollatorPointer collator(ucol_open(clocale, &status)); ucol_setStrength(collator.getAlias(), collatorStrength); ucol_setAttribute(collator.getAlias(), UCOL_NORMALIZATION_MODE, normalize, &status); ucol_setAttribute(collator.getAlias(), UCOL_ALTERNATE_HANDLING, alternateHandling, &status); LocalUStringSearchPointer uss(usearch_openFromCollator(pattern.getBuffer(), pattern.length(), target.getBuffer(), target.length(), collator.getAlias(), NULL, // the break iterator &status)); TEST_ASSERT_SUCCESS(status); if (U_FAILURE(status)) { continue; } int32_t foundStart = 0; int32_t foundLimit = 0; UBool foundMatch; // // Do the search, check the match result against the expected results. // foundMatch= usearch_search(uss.getAlias(), 0, &foundStart, &foundLimit, &status); TEST_ASSERT_SUCCESS(status); if ((foundMatch && expectedMatchStart<0) || (foundStart != expectedMatchStart) || (foundLimit != expectedMatchLimit)) { TEST_ASSERT(FALSE); // ouput generic error position infoln("Found, expected match start = %d, %d \n" "Found, expected match limit = %d, %d", foundStart, expectedMatchStart, foundLimit, expectedMatchLimit); } // In case there are other matches... // (should we only do this if the test case passed?) while (foundMatch) { expectedMatchStart = foundStart; expectedMatchLimit = foundLimit; foundMatch = usearch_search(uss.getAlias(), foundLimit, &foundStart, &foundLimit, &status); } uss.adoptInstead(usearch_openFromCollator(pattern.getBuffer(), pattern.length(), target.getBuffer(), target.length(), collator.getAlias(), NULL, &status)); // // Do the backwards search, check the match result against the expected results. // foundMatch= usearch_searchBackwards(uss.getAlias(), target.length(), &foundStart, &foundLimit, &status); TEST_ASSERT_SUCCESS(status); if ((foundMatch && expectedMatchStart<0) || (foundStart != expectedMatchStart) || (foundLimit != expectedMatchLimit)) { TEST_ASSERT(FALSE); // ouput generic error position infoln("Found, expected backwards match start = %d, %d \n" "Found, expected backwards match limit = %d, %d", foundStart, expectedMatchStart, foundLimit, expectedMatchLimit); } } #endif }
Common::WriteStream *Ps2FilesystemNode::createWriteStream() { return PS2FileStream::makeFromPath(getPath(), true); }
bool Model::parseBones(FS::IFile& file) { int bone_count; file.read(&bone_count, sizeof(bone_count)); if (bone_count < 0) { return false; } m_bones.reserve(bone_count); for (int i = 0; i < bone_count; ++i) { Model::Bone& b = m_bones.emplace(m_allocator); int len; file.read(&len, sizeof(len)); char tmp[MAX_PATH_LENGTH]; if (len >= MAX_PATH_LENGTH) { return false; } file.read(tmp, len + 1); tmp[len] = 0; b.name = tmp; m_bone_map.insert(crc32(b.name.c_str()), m_bones.size() - 1); file.read(&len, sizeof(len)); if (len >= MAX_PATH_LENGTH) { return false; } if(len > 0) { file.read(tmp, len); tmp[len] = 0; b.parent = tmp; } else { b.parent = ""; } file.read(&b.position.x, sizeof(float) * 3); file.read(&b.rotation.x, sizeof(float) * 4); } m_first_nonroot_bone_index = -1; for (int i = 0; i < bone_count; ++i) { Model::Bone& b = m_bones[i]; if (b.parent.length() == 0) { b.parent_idx = -1; } else { b.parent_idx = getBoneIdx(b.parent.c_str()); if (b.parent_idx > i || b.parent_idx < 0) { g_log_error.log("renderer") << "Invalid skeleton in " << getPath().c_str(); return false; } if (m_first_nonroot_bone_index == -1) { m_first_nonroot_bone_index = i; } } } for (int i = 0; i < m_bones.size(); ++i) { m_bones[i].rotation.toMatrix(m_bones[i].inv_bind_matrix); m_bones[i].inv_bind_matrix.translate(m_bones[i].position); } for (int i = 0; i < m_bones.size(); ++i) { m_bones[i].inv_bind_matrix.fastInverse(); } return true; }
Common::SeekableReadStream *RoninCDFileNode::createReadStream() { return StdioStream::makeFromPath(getPath().c_str(), false); }
void* map_run(void *junk){ int start = clock() / CLOCKS_PER_SEC; while (ros::ok()) { //ROS_INFO("start"); if (feedbackKey || goalKey || getKey || mapKey ) continue; if (clock() / CLOCKS_PER_SEC - start < 2) { /* if (mapDataInit[Now.y*width+Now.x] == -1) { start = clock() / CLOCKS_PER_SEC; if (getKey) continue; ROS_INFO("get again"); int pathLen = getPath(); while (getKey); if (pathLen == 0) { ROS_INFO("I can't get there!!!"); } else if (pathLen == 1) { printf("now Point is %d\n", nowPoint); bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = goalData.z; ret.say = goalData.say; goalPoint_pub.publish(ret); } else { printf("now Point is %d\n", nowPoint); bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = euler_angles[PATH[nowPoint].ddir]; ret.say = ""; goalPoint_pub.publish(ret); } } */ //ROS_INFO("<100000"); //printf("clock is %d", clock() / CLOCKS_PER_SEC - start); if (abs(Now.x - PATH[nowPoint].x) < 5 && abs(Now.y - PATH[nowPoint].y) < 5 && !getKey) { //printf("now Point is %d\n", nowPoint); if (nowPoint + 1 >= PATH.size() && !getKey) { continue; } else if (nowPoint + 2 == PATH.size() && !getKey) { printf("now Point is %d\n", nowPoint); nowPoint ++; bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = goalData.z; ret.say = goalData.say; goalPoint_pub.publish(ret); } else if (!getKey){ printf("now Point is %d\n", nowPoint); nowPoint ++; bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = euler_angles[PATH[nowPoint].ddir]; ret.say = ""; goalPoint_pub.publish(ret); } } } else { start = clock() / CLOCKS_PER_SEC; if (getKey) continue; //bitathome_navigation_control::MyPoint ret; //ret.x = feedbackData.position.x; //ret.y = feedbackData.position.y; //double z[3]; //tf::Quaternion q(feedbackData.orientation.x, feedbackData.orientation.y, feedbackData.orientation.z, feedbackData.orientation.w); //tf::Matrix3x3 m(q); //m.getRPY(z[0], z[1], z[2]); //ret.z = z[2]; //ret.say = ""; //goalPoint_pub.publish(ret); ROS_INFO("get again"); int pathLen = getPath(); while (getKey); if (pathLen == 0) { ROS_INFO("I can't get there!!!"); } else if (pathLen == 1) { printf("now Point is %d\n", nowPoint); bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = goalData.z; ret.say = goalData.say; goalPoint_pub.publish(ret); } else { printf("now Point is %d\n", nowPoint); bitathome_navigation_control::MyPoint ret; ret.x = (PATH[nowPoint].x - Start.x) * pointSize; ret.y = (PATH[nowPoint].y - Start.y) * pointSize; ret.z = euler_angles[PATH[nowPoint].ddir]; ret.say = ""; goalPoint_pub.publish(ret); } } } }
bool ConnectedShortcut::computeIsConnected() const { return !getLArgs().empty() && (_tcsicmp(getSelfPath().data(), getPath().data()) == 0); }
void DecimalFormatTest::DataDrivenTests() { char tdd[2048]; const char *srcPath; UErrorCode status = U_ZERO_ERROR; int32_t lineNum = 0; // // Open and read the test data file. // srcPath=getPath(tdd, "dcfmtest.txt"); if(srcPath==NULL) { return; /* something went wrong, error already output */ } int32_t len; UChar *testData = ReadAndConvertFile(srcPath, len, status); if (U_FAILURE(status)) { return; /* something went wrong, error already output */ } // // Put the test data into a UnicodeString // UnicodeString testString(FALSE, testData, len); RegexMatcher parseLineMat(UnicodeString( "(?i)\\s*parse\\s+" "\"([^\"]*)\"\\s+" // Capture group 1: input text "([ild])\\s+" // Capture group 2: expected parsed type "\"([^\"]*)\"\\s+" // Capture group 3: expected parsed decimal "\\s*(?:#.*)?"), // Trailing comment 0, status); RegexMatcher formatLineMat(UnicodeString( "(?i)\\s*format\\s+" "(\\S+)\\s+" // Capture group 1: pattern "(ceiling|floor|down|up|halfeven|halfdown|halfup|default)\\s+" // Capture group 2: Rounding Mode "\"([^\"]*)\"\\s+" // Capture group 3: input "\"([^\"]*)\"" // Capture group 4: expected output "\\s*(?:#.*)?"), // Trailing comment 0, status); RegexMatcher commentMat (UNICODE_STRING_SIMPLE("\\s*(#.*)?$"), 0, status); RegexMatcher lineMat(UNICODE_STRING_SIMPLE("(?m)^(.*?)$"), testString, 0, status); if (U_FAILURE(status)){ dataerrln("Construct RegexMatcher() error."); delete [] testData; return; } // // Loop over the test data file, once per line. // while (lineMat.find()) { lineNum++; if (U_FAILURE(status)) { errln("File dcfmtest.txt, line %d: ICU Error \"%s\"", lineNum, u_errorName(status)); } status = U_ZERO_ERROR; UnicodeString testLine = lineMat.group(1, status); // printf("%s\n", UnicodeStringPiece(testLine).data()); if (testLine.length() == 0) { continue; } // // Parse the test line. Skip blank and comment only lines. // Separate out the three main fields - pattern, flags, target. // commentMat.reset(testLine); if (commentMat.lookingAt(status)) { // This line is a comment, or blank. continue; } // // Handle "parse" test case line from file // parseLineMat.reset(testLine); if (parseLineMat.lookingAt(status)) { execParseTest(lineNum, parseLineMat.group(1, status), // input parseLineMat.group(2, status), // Expected Type parseLineMat.group(3, status), // Expected Decimal String status ); continue; } // // Handle "format" test case line // formatLineMat.reset(testLine); if (formatLineMat.lookingAt(status)) { execFormatTest(lineNum, formatLineMat.group(1, status), // Pattern formatLineMat.group(2, status), // rounding mode formatLineMat.group(3, status), // input decimal number formatLineMat.group(4, status), // expected formatted result status); continue; } // // Line is not a recognizable test case. // errln("Badly formed test case at line %d.\n%s\n", lineNum, UnicodeStringPiece(testLine).data()); } delete [] testData; }
//查找路径 //isEnding:为真表示curNode是路径的结束点(4个方向不通,不能往回走) bool NDFindPath::getPath(unsigned int uiTileX, unsigned int uiTileY, NDPathNode* curNode, bool isEnding) { if (!m_mapGraph) return false; if (0 != curNode) { //路径判定:点数匹配 if (m_uiRollNumber == curNode->stepNumber) { TilePath kPaths; NDPathNode* tmpNode = curNode; while (0 != tmpNode) { kPaths.push(tmpNode); tmpNode = tmpNode->preNode; } m_vecPath.push_back(kPaths); return true; } //路径判定:经过出口 if (curNode->bExit && 0 != curNode->stepNumber) { TilePath kPaths; NDPathNode* tmpNode = curNode; while (0 != tmpNode) { kPaths.push(tmpNode); tmpNode = tmpNode->preNode; } m_vecPath.push_back(kPaths); //这里不return,接着寻路... } } //获取当前坐标的GraphNode const GRAPH_NODE* pkGraphNode = m_mapGraph->getGraphNode_Const(uiTileX, uiTileY); if (!pkGraphNode) return false; //新建一个路径节点 NDPathNode* pathNode = new NDPathNode; { int stepNumber = (curNode ? curNode->stepNumber + 1 : 0); //起点为0! pathNode->init(uiTileX, uiTileY, pkGraphNode->isExit, stepNumber, curNode); } //尝试4个方向的寻路 if (!isEnding) { bool bhasWay = false; //左 if (pkGraphNode->left) { if (0 == curNode) { getPath(uiTileX - 1, uiTileY, pathNode); bhasWay = true; } else if (curNode->x != uiTileX - 1 || curNode->y != uiTileY) //不允许回退! { getPath(uiTileX - 1, uiTileY, pathNode); bhasWay = true; } } //上 if (pkGraphNode->up) { if (0 == curNode) { getPath(uiTileX, uiTileY - 1, pathNode); bhasWay = true; } else if (curNode->x != uiTileX || curNode->y != uiTileY - 1) { getPath(uiTileX, uiTileY - 1, pathNode); bhasWay = true; } } //右 if (pkGraphNode->right) { if (0 == curNode) { getPath(uiTileX + 1, uiTileY, pathNode); bhasWay = true; } else if (curNode->x != uiTileX + 1 || curNode->y != uiTileY) { getPath(uiTileX + 1, uiTileY, pathNode); bhasWay = true; } } //下 if (pkGraphNode->down) { if (0 == curNode) { getPath(uiTileX, uiTileY + 1, pathNode); bhasWay = true; } else if (curNode->x != uiTileX || curNode->y != uiTileY + 1) { getPath(uiTileX, uiTileY + 1, pathNode); bhasWay = true; } } //4个方向都不通(不允许回退) if (!bhasWay) { if (curNode && curNode == pathNode) { } else { getPath(uiTileX, uiTileY, pathNode, true); } } } return true; }