int str_write_solution(double* x, double* lam_eq, double* lam_ieq,CallBackDataPtr cbd) { int row = cbd->row_node_id; int col = cbd->col_node_id; assert(row == col); MESSAGE("write_solution -- row " << row <<" col "<<col); if(row == 0) { PRINT_ARRAY("node = 0 - x ", x, 2); PRINT_ARRAY("node = 0 - eq ", lam_eq, 1); PRINT_ARRAY("node = 0 - ieq ", lam_ieq , 0); } else if(row == 1 || row == 2) { PRINT_ARRAY("node = "<<row<<" - x ", x, 2); PRINT_ARRAY("node = "<<row<<" - eq ", lam_eq, 0); PRINT_ARRAY("node = "<<row<<" - ieq ", lam_ieq , 1); } else { assert(false); } return 1; }
void apbconfig_save( apb_station_config_t* sc , const char* filename ) { //Assumes that filesystem has been initalized (mounted) uint8_t return_value = 0; uint32_t bytes_written = 0; FIL fout; MESSAGE("filename we are trying to open: %s\n\r", filename); return_value = f_open(&fout, filename, FA_WRITE|FA_CREATE_ALWAYS); //Overwrites old configuration if(return_value == FR_OK) { return_value = f_write(&fout, sc, sizeof(*sc), &bytes_written); if(return_value != FR_OK) { MESSAGE("f_write failed with %u\n\r", return_value); } if(bytes_written != sizeof(*sc)) MESSAGE("%d bytes written, should have been %d\n\r", bytes_written, sizeof(*sc)); return_value = f_close(&fout); if(return_value == FR_OK) { MESSAGE("apbconfig saved\n\r"); return; } else { MESSAGE("f_close failed with %u\n\r", return_value); } } else { MESSAGE("f_open in apbconfig_save failed, return value: %d\n\r", return_value); } }
GEOM_IOperations::~GEOM_IOperations() { delete _solver; MESSAGE("GEOM_IOperations::~GEOM_IOperations"); }
med_idt MEDouvrir(char *nom, med_mode_acces mode_acces) { med_idt fid=0; /* * On inhibe le gestionnaire d'erreur HDF */ _MEDmodeErreurVerrouiller(); /* * On ouvre le fichier MED sous HDF */ switch(mode_acces) { case MED_LECTURE : if (access(nom,F_OK)) { MESSAGE("Impossible d'accéder aux fichier :"); SSCRUTE(nom); return -1; } else { if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0) return -1; /*_MEDsetModeAcces(fid,MED_LECTURE);*/ }; break; case MED_LECTURE_ECRITURE : if (access(nom,F_OK)) { if ((fid = _MEDfichierCreer(nom,mode_acces)) < 0) return -1; } else if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0) return -1; break; case MED_LECTURE_AJOUT : if (access(nom,F_OK)) { if ((fid = _MEDfichierCreer(nom,mode_acces)) < 0) return -1; } else if ((fid = _MEDfichierOuvrir(nom,mode_acces)) < 0) return -1; break; case MED_CREATION : if ((fid = _MEDfichierCreer(nom,MED_LECTURE_ECRITURE)) < 0) return -1; break; default : return -1; } if (MEDcheckVersion(fid) < 0) { if (fid >0) _MEDfichierFermer(fid); return -1; } return fid; }
int Edit(DirEntry * dir_entry, char *file_path) { char *command_line; int result = -1; char *file_p_aux=NULL; char cwd[PATH_LENGTH + 1]; char path[PATH_LENGTH + 1]; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( -1 ); } if( access( file_path, R_OK ) ) { (void) sprintf( message, "Edit not possible!*\"%s\"*%s", file_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( ( file_p_aux = (char *)malloc( COMMAND_LINE_LENGTH ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } StrCp(file_p_aux, file_path); if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) strcpy( command_line, EDITOR ); (void) strcat( command_line, " \"" ); (void) strcat( command_line, file_p_aux ); (void) strcat( command_line, "\"" ); free( file_p_aux); /* result = SystemCall(command_line); --crb3 29apr02: perhaps finally eliminate the problem with jstar writing new files to the ytree starting cwd. new code grabbed from execute.c. --crb3 01oct02: move Getcwd operation within the IF DISKMODE stuff. */ if (mode == DISK_MODE) { if (Getcwd(cwd, PATH_LENGTH) == NULL) { WARNING("Getcwd failed*\".\"assumed"); (void) strcpy(cwd, "."); } if (chdir(GetPath(dir_entry, path))) { (void) sprintf(message, "Can't change directory to*\"%s\"", path); MESSAGE(message); }else{ result = SystemCall(command_line); } if(chdir(cwd)) { (void) sprintf(message, "Can't change directory to*\"%s\"", cwd); MESSAGE(message); } }else{ result = SystemCall(command_line); } free( command_line ); FNC_XIT: return( result ); }
SALOME_WNT_EXPORT TopoDS_Shape ImportIGES (const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatName, TCollection_AsciiString& theError, const TDF_Label& theShapeLabel) { IGESControl_Reader aReader; TopoDS_Shape aResShape; Interface_Static::SetCVal("xstep.cascade.unit","M"); try { IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); if (status == IFSelect_RetDone) { if( theFormatName == "IGES_UNIT" ) { Handle(IGESData_IGESModel) aModel = Handle(IGESData_IGESModel)::DownCast(aReader.Model()); gp_Pnt P(1.0,0.0,0.0); if(!aModel.IsNull()) { Handle(TCollection_HAsciiString) aUnitName = aModel->GlobalSection().UnitName(); //cout<<"aUnitName = "<<aUnitName->ToCString()<<endl; //cout<<"aUnitFlag = "<<aModel->GlobalSection().UnitFlag()<<endl; if( aUnitName->String()=="MM" ) { P = gp_Pnt(0.001,0.0,0.0); } else if( aUnitName->String()=="CM" ) { P = gp_Pnt(0.01,0.0,0.0); } } BRep_Builder B; TopoDS_Vertex V; B.MakeVertex(V,P,1.e-7); aResShape = V; return aResShape; } if( theFormatName == "IGES_SCALE" ) { //cout<<"need re-scale a model"<<endl; // set UnitFlag to 'meter' Handle(IGESData_IGESModel) aModel = Handle(IGESData_IGESModel)::DownCast(aReader.Model()); if(!aModel.IsNull()) { IGESData_GlobalSection aGS = aModel->GlobalSection(); aGS.SetUnitFlag(6); aModel->SetGlobalSection(aGS); } } MESSAGE("ImportIGES : all Geometry Transfer"); //OCC 5.1.2 porting // aReader.Clear(); // aReader.TransferRoots(false); aReader.ClearShapes(); aReader.TransferRoots(); MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes()); aResShape = aReader.OneShape(); // BEGIN: Store names of sub-shapes from file Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); if (!TR.IsNull()) { Handle(Transfer_TransientProcess) TP = /*TransientProcess();*/TR->TransientProcess(); Standard_Integer nb = Model->NbEntities(); for (Standard_Integer i = 1; i <= nb; i++) { Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(Model->Value(i)); if (ent.IsNull() || ! ent->HasName()) continue; // find target shape Handle(Transfer_Binder) binder = TP->Find(ent); if (binder.IsNull()) continue; TopoDS_Shape S = TransferBRep::ShapeResult(binder); if (S.IsNull()) continue; // create label and set shape TDF_Label L; TDF_TagSource aTag; L = aTag.NewChild(theShapeLabel); TNaming_Builder tnBuild (L); tnBuild.Generated(S); // set a name TCollection_AsciiString string = ent->NameValue()->String(); string.LeftAdjust(); string.RightAdjust(); TCollection_ExtendedString str (string); TDataStd_Name::Set(L, str); } } // END: Store names } else { // switch (status) { // case IFSelect_RetVoid: // theError = "Nothing created or No data to process"; // break; // case IFSelect_RetError: // theError = "Error in command or input data"; // break; // case IFSelect_RetFail: // theError = "Execution was run, but has failed"; // break; // case IFSelect_RetStop: // theError = "Execution has been stopped. Quite possible, an exception was raised"; // break; // default: // break; // } theError = "Wrong format of the imported file. Can't import file."; aResShape.Nullify(); } } catch(Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); theError = aFail->GetMessageString(); aResShape.Nullify(); } return aResShape; }
static void x_process_events(void *data) { XEvent event; XEvent last_event; struct graphics_device *gd; int last_was_mouse; #ifdef SC_DEBUG MESSAGE("x_process_event\n"); #endif last_was_mouse=0; while (XPending(x_display)) { XNextEvent(x_display,&event); if (last_was_mouse&&(event.type==ButtonPress||event.type==ButtonRelease)) /* this is end of mouse move block --- call mouse handler */ { int a,b; last_was_mouse=0; #ifdef X_DEBUG MESSAGE("(MotionNotify event)\n"); { unsigned char txt[256]; sprintf(txt,"x=%d y=%d\n",last_event.xmotion.x,last_event.xmotion.y); MESSAGE(txt); } #endif gd=x_find_gd(&(last_event.xmotion.window)); if (!gd)break; a=B_LEFT; b=B_MOVE; if ((last_event.xmotion.state)&Button1Mask) { a=B_LEFT; b=B_DRAG; #ifdef X_DEBUG MESSAGE("left button/drag\n"); #endif } if ((last_event.xmotion.state)&Button2Mask) { a=B_MIDDLE; b=B_DRAG; #ifdef X_DEBUG MESSAGE("middle button/drag\n"); #endif } if ((last_event.xmotion.state)&Button3Mask) { a=B_RIGHT; b=B_DRAG; #ifdef X_DEBUG MESSAGE("right button/drag\n"); #endif } x_clip_number(&(last_event.xmotion.x),gd->size.x1,gd->size.x2); x_clip_number(&(last_event.xmotion.y),gd->size.y1,gd->size.y2); gd->mouse_handler(gd,last_event.xmotion.x,last_event.xmotion.y,a|b); } switch(event.type) { case GraphicsExpose: /* redraw uncovered area during scroll */ { struct rect r; #ifdef X_DEBUG MESSAGE("(GraphicsExpose event)\n"); #endif gd=x_find_gd(&(event.xgraphicsexpose.drawable)); if (!gd)break; r.x1=event.xgraphicsexpose.x; r.y1=event.xgraphicsexpose.y; r.x2=event.xgraphicsexpose.x+event.xgraphicsexpose.width; r.y2=event.xgraphicsexpose.y+event.xgraphicsexpose.height; gd->redraw_handler(gd,&r); } break; case Expose: /* redraw part of the window */ { struct rect r; #ifdef X_DEBUG MESSAGE("(Expose event)\n"); #endif gd=x_find_gd(&(event.xexpose.window)); if (!gd)break; r.x1=event.xexpose.x; r.y1=event.xexpose.y; r.x2=event.xexpose.x+event.xexpose.width; r.y2=event.xexpose.y+event.xexpose.height; gd->redraw_handler(gd,&r); } break; case ConfigureNotify: /* resize window */ #ifdef X_DEBUG MESSAGE("(ConfigureNotify event)\n"); { unsigned char txt[256]; sprintf(txt,"width=%d height=%d\n",event.xconfigure.width,event.xconfigure.height); MESSAGE(txt); } #endif gd=x_find_gd(&(event.xconfigure.window)); if (!gd)break; /* when window only moved and size is the same, do nothing */ if (gd->size.x2==event.xconfigure.width&&gd->size.y2==event.xconfigure.height)break; gd->size.x2=event.xconfigure.width; gd->size.y2=event.xconfigure.height; x_update_driver_param(event.xconfigure.width, event.xconfigure.height); gd->resize_handler(gd); break; case KeyPress: /* a key was pressed */ { int f,k; #ifdef X_DEBUG MESSAGE("(KeyPress event)\n"); { unsigned char txt[256]; sprintf(txt,"keycode=%d state=%d\n",event.xkey.keycode,event.xkey.state); MESSAGE(txt); } #endif gd=x_find_gd(&(event.xkey.window)); if (!gd)break; if (x_translate_key((XKeyEvent*)(&event),&k,&f)) gd->keyboard_handler(gd,k,f); } break; case ClientMessage: if ( event.xclient.format!=32|| event.xclient.message_type!=x_wm_protocols_atom|| (Atom)event.xclient.data.l[0]!=x_delete_window_atom )break; /* This event is destroy window event from window manager */ case DestroyNotify: #ifdef X_DEBUG MESSAGE("(DestroyNotify event)\n"); #endif gd=x_find_gd(&(event.xkey.window)); if (!gd)break; gd->keyboard_handler(gd,KBD_CLOSE,0); break; case ButtonRelease: /* mouse button was released */ { int a; #ifdef X_DEBUG MESSAGE("(ButtonRelease event)\n"); { unsigned char txt[256]; sprintf(txt,"x=%d y=%d buttons=%d mask=%d\n",event.xbutton.x,event.xbutton.y,event.xbutton.button,event.xbutton.state); MESSAGE(txt); } #endif gd=x_find_gd(&(event.xbutton.window)); if (!gd)break; last_was_mouse=0; switch(event.xbutton.button) { case 1: a=B_LEFT; break; case 3: a=B_RIGHT; break; case 2: a=B_MIDDLE; break; default: goto r_xx; } x_clip_number(&(event.xmotion.x),gd->size.x1,gd->size.x2); x_clip_number(&(event.xmotion.y),gd->size.y1,gd->size.y2); gd->mouse_handler(gd,event.xbutton.x,event.xbutton.y,a|B_UP); r_xx:; } break; case ButtonPress: /* mouse button was pressed */ { int a; #ifdef X_DEBUG MESSAGE("(ButtonPress event)\n"); { unsigned char txt[256]; sprintf(txt,"x=%d y=%d buttons=%d mask=%d\n",event.xbutton.x,event.xbutton.y,event.xbutton.button,event.xbutton.state); MESSAGE(txt); } #endif gd=x_find_gd(&(event.xbutton.window)); if (!gd)break; last_was_mouse=0; switch(event.xbutton.button) { case 1: a=B_LEFT; break; case 3: a=B_RIGHT; break; case 2: a=B_MIDDLE; break; case 4: a=B_WHEELUP; break; case 5: a=B_WHEELDOWN; break; case 6: a=B_WHEELLEFT; break; case 7: a=B_WHEELRIGHT; break; default: goto p_xx; } x_clip_number(&(event.xmotion.x),gd->size.x1,gd->size.x2); x_clip_number(&(event.xmotion.y),gd->size.y1,gd->size.y2); gd->mouse_handler(gd,event.xbutton.x,event.xbutton.y,a|(a != B_WHEELDOWN && a != B_WHEELUP && a != B_WHEELLEFT && a != B_WHEELRIGHT ? B_DOWN : B_MOVE)); p_xx:; } break; case MotionNotify: /* pointer moved */ { #ifdef X_DEBUG MESSAGE("(MotionNotify event)\n"); { unsigned char txt[256]; sprintf(txt,"x=%d y=%d\n",event.xmotion.x,event.xmotion.y); MESSAGE(txt); } #endif /* just sign, that this was mouse event */ last_was_mouse=1; last_event=event; } break; /* read clipboard */ case SelectionNotify: #ifdef X_DEBUG MESSAGE("xselectionnotify\n"); #endif /* handled in x_get_clipboard_text */ break; /* This long code must be here in order to implement copying of stuff into the clipboard */ case SelectionRequest: { selection_request(&event); } break; case MapNotify: XFlush (x_display); break; default: #ifdef X_DEBUG { unsigned char txt[256]; sprintf(txt,"event=%d\n",event.type); MESSAGE(txt); } #endif break; } } if (last_was_mouse) /* lthat was end of mouse move block --- call mouse handler */ { int a,b; last_was_mouse=0; #ifdef X_DEBUG MESSAGE("(MotionNotify event)\n"); /* { unsigned char txt[256]; sprintf(txt,"x=%d y=%d\n",last_event.xmotion.x,last_event.xmotion.y); MESSAGE(txt); } */ #endif gd=x_find_gd(&(last_event.xmotion.window)); if (!gd)goto ret; a=B_LEFT; b=B_MOVE; if ((last_event.xmotion.state)&Button1Mask) { a=B_LEFT; b=B_DRAG; #ifdef X_DEBUG MESSAGE("left button/drag\n"); #endif } if ((last_event.xmotion.state)&Button2Mask) { a=B_MIDDLE; b=B_DRAG; #ifdef X_DEBUG MESSAGE("middle button/drag\n"); #endif } if ((last_event.xmotion.state)&Button3Mask) { a=B_RIGHT; b=B_DRAG; #ifdef X_DEBUG MESSAGE("right button/drag\n"); #endif } x_clip_number(&(last_event.xmotion.x),gd->size.x1,gd->size.x2); x_clip_number(&(last_event.xmotion.y),gd->size.y1,gd->size.y2); gd->mouse_handler(gd,last_event.xmotion.x,last_event.xmotion.y,a|b); } ret:; #ifdef SC_DEBUG MESSAGE("x_process_event end\n"); #endif }
static int Init(int argc, const char **argv) { int i; int fl1, nor1, noc1, fl2, nor2, noc2; char fn[LAT_MAXBASENAME+20]; /* Initialize global data ---------------------- */ memset(&TKInfo,0,sizeof(TKInfo)); memset(TkiName,0,sizeof(TkiName)); memset(CfIsLinked,0,sizeof(CfIsLinked)); /* Initialize the MeatAxe library ------------------------------ */ if ((App = AppAlloc(&AppInfo,argc,argv)) == NULL) return -1; opt_s = AppGetOption(App,"-s"); if (AppGetArguments(App,3,3) != 3) return -1; strcpy(TkiName,App->ArgV[0]); /* Read info files --------------- */ strncpy(TKInfo.NameM,App->ArgV[1],sizeof(TKInfo.NameM)); strncpy(TKInfo.NameN,App->ArgV[2],sizeof(TKInfo.NameN)); if (Lat_ReadInfo(&InfoM,App->ArgV[1]) != 0) { MTX_ERROR1("Error reading %s.cfinfo",App->ArgV[1]); return -1; } if (Lat_ReadInfo(&InfoN,App->ArgV[2]) != 0) { MTX_ERROR1("Error reading %s.cfinfo",App->ArgV[2]); return -1; } /* Initialize the TKInfo structure ------------------------------- */ TKInfo.NCf = 0; for (i = 0; i < LAT_MAXCF; ++i) TKInfo.CfIndex[0][i] = TKInfo.CfIndex[1][i] = -1; /* Some additional checks on input files ------------------------------------- */ if (InfoM.Field != InfoN.Field) { MTX_ERROR4("Incompatible representations: %s is over GF(%d), " "%s is over GF(%d)",InfoM.BaseName,InfoM.Field,InfoN.BaseName, InfoN.Field); return -1; } if (InfoM.NGen != InfoN.NGen) { MTX_ERROR4("Incompatible representations: %s has %d generators, " "%s has %d generators",InfoM.BaseName,InfoM.NGen,InfoN.BaseName, InfoN.NGen); return -1; } /* Print start message ------------------- */ sprintf(fn,"%s.1",InfoM.BaseName); fclose(FfReadHeader(fn,&fl1,&nor1,&noc1)); sprintf(fn,"%s.1",InfoN.BaseName); fclose(FfReadHeader(fn,&fl2,&nor2,&noc2)); MESSAGE(0,("Beginning pre-condensation of dimension %d x %d = %d\n", nor1,nor2,nor1*nor2)); return 0; }
struct irport_cb * irport_open(int i, unsigned int iobase, unsigned int irq) { struct net_device *dev; struct irport_cb *self; IRDA_DEBUG(1, "%s()\n", __FUNCTION__); /* Lock the port that we need */ if (!request_region(iobase, IO_EXTENT, driver_name)) { IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n", __FUNCTION__, iobase); goto err_out1; } /* * Allocate new instance of the driver */ dev = alloc_irdadev(sizeof(struct irport_cb)); if (!dev) { ERROR("%s(), can't allocate memory for " "irda device!\n", __FUNCTION__); goto err_out2; } self = dev->priv; spin_lock_init(&self->lock); /* Need to store self somewhere */ dev_self[i] = self; self->priv = self; self->index = i; /* Initialize IO */ self->io.sir_base = iobase; self->io.sir_ext = IO_EXTENT; self->io.irq = irq; self->io.fifo_size = 16; /* 16550A and compatible */ /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&self->qos); self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200; self->qos.min_turn_time.bits = qos_mtt_bits; irda_qos_bits_to_value(&self->qos); /* Bootstrap ZeroCopy Rx */ self->rx_buff.truesize = IRDA_SKB_MAX_MTU; self->rx_buff.skb = __dev_alloc_skb(self->rx_buff.truesize, GFP_KERNEL); if (self->rx_buff.skb == NULL) { ERROR("%s(), can't allocate memory for " "receive buffer!\n", __FUNCTION__); goto err_out3; } skb_reserve(self->rx_buff.skb, 1); self->rx_buff.head = self->rx_buff.skb->data; /* No need to memset the buffer, unless you are really pedantic */ /* Finish setup the Rx buffer descriptor */ self->rx_buff.in_frame = FALSE; self->rx_buff.state = OUTSIDE_FRAME; self->rx_buff.data = self->rx_buff.head; /* Specify how much memory we want */ self->tx_buff.truesize = 4000; /* Allocate memory if needed */ if (self->tx_buff.truesize > 0) { self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, GFP_KERNEL); if (self->tx_buff.head == NULL) { ERROR("%s(), can't allocate memory for " "transmit buffer!\n", __FUNCTION__); goto err_out4; } memset(self->tx_buff.head, 0, self->tx_buff.truesize); } self->tx_buff.data = self->tx_buff.head; self->netdev = dev; /* Keep track of module usage */ SET_MODULE_OWNER(dev); /* May be overridden by piggyback drivers */ self->interrupt = irport_interrupt; self->change_speed = irport_change_speed; /* Override the network functions we need to use */ dev->hard_start_xmit = irport_hard_xmit; dev->tx_timeout = irport_timeout; dev->watchdog_timeo = HZ; /* Allow time enough for speed change */ dev->open = irport_net_open; dev->stop = irport_net_close; dev->get_stats = irport_net_get_stats; dev->do_ioctl = irport_net_ioctl; /* Make ifconfig display some details */ dev->base_addr = iobase; dev->irq = irq; if (register_netdev(dev)) { ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); goto err_out5; } MESSAGE("IrDA: Registered device %s (irport io=0x%X irq=%d)\n", dev->name, iobase, irq); return self; err_out5: kfree(self->tx_buff.head); err_out4: kfree_skb(self->rx_buff.skb); err_out3: free_netdev(dev); dev_self[i] = NULL; err_out2: release_region(iobase, IO_EXTENT); err_out1: return NULL; }
int autoNumberRoman::getDigit(const char*& p) { int x = 0; switch ( p[0] ) { case 'I': case 'i': if ( p[1] != 0 && p[1] == 'V' ) { p++; x = 4; } else x = 1; break; case 'V': case 'v': x = 5; break; case 'X': case 'x': if ( p[1] != 0 && p[1] == 'I' ) { x = 9; p++; } else x = 10; break; case 'L': //50 case 'l': if ( p[1] != 0 && p[1] == 'X' ) { x = 40; p++; } else x = 50; break; case 'C': // 100 case 'c': if ( p[1] != 0 && p[1] == 'X' ) { x = 90; p++; } else x = 100; break; case 'D': // 500 case 'd': if ( p[1] != 0 && p[1] == 'C' ) { x = 400; p++; } else x = 500; break; case 'M': //1000 case 'm': if ( p[1] != 0 && p[1] == 'C' ) { x = 900; p++; } else x = 1000; break; default: MESSAGE(cerr, "unknown roman numeral letter"); throw(CASTHCREXCEPT hardCopyRendererException()); } p++; return x; }
void convertImages(Arguments* args){ char** mask = NULL; TwoPoints source, dest; FILE* eyeList; char line[ FILE_LINE_LENGTH ]; char filename[MAX_FILENAME_LENGTH]; char imagename[MAX_FILENAME_LENGTH]; char suffix[MAX_FILENAME_LENGTH]; int i; scaleArgs(args, args->scale); dest.x1 = args->eyeLx; dest.y1 = args->eyeLy; dest.x2 = args->eyeRx; dest.y2 = args->eyeRy; /* Prepare file suffix encoding preprocessing settings, blank if not requested */ if (args->configSuffix) { sprintf(suffix,"_%s", imageSuffix(args)); } else { suffix[0] = '\0'; } if(args->maskType == CL_YES){ MESSAGE("Creating Mask."); mask = generateMask(args->sizeWidth, args->sizeHeight, args->ellipseX, args->ellipseY, args->ellipseA, args->ellipseB); } eyeList = fopen(args->eyeFile,"r"); DEBUG_CHECK(eyeList,"Error opening eye coordinates file"); for(i = 1;;i++){ Image pgm; Image geo; Matrix transform; fgets(line, FILE_LINE_LENGTH, eyeList); if(feof(eyeList)) break; if(sscanf(line,"%s %lf %lf %lf %lf",filename, &(source.x1), &(source.y1), &(source.x2), &(source.y2)) != 5){ printf("Error parsing line %d of eye coordinate file. Exiting...",i); exit(1); } /* shift the eye coordinates if neccessary */ source.x1 += args->shiftX; source.y1 += args->shiftY; source.x2 += args->shiftX; source.y2 += args->shiftY; sprintf(imagename,"%s\\%s.pgm",args->inputDir,filename); MESSAGE1ARG("Processing image: %s",filename); pgm = readPGMImage(imagename); if(args->histType == HIST_PRE){ DEBUG(1," Performing Pre Histogram Equalization."); histEqual(pgm,256); } if(args->preNormType == CL_YES){ DEBUG(1," Performing Pre Pixel Normalization."); ZeroMeanOneStdDev(pgm); } if(args->preEdge){ smoothImageEdge(pgm, args->preEdge); } if(args->geoType == CL_YES){ DEBUG(1," Performing Geometric Normalization."); transform = generateTransform(&source,&dest,args->reflect); geo = transformImage(pgm,args->sizeWidth,args->sizeHeight,transform); } else{ transform = makeIdentityMatrix(3); geo = transformImage(pgm,args->sizeWidth,args->sizeHeight,transform); } if(args->noise != 0.0){ DEBUG(1," Adding Gausian Noise."); gaussianNoise(geo,args->noise); } if(args->histType == HIST_POST){ DEBUG(1," Performing Post Histogram Equalization."); histEqualMask(geo,256, (const char**) mask); } if(args->nrmType == CL_YES){ DEBUG(1," Performing final value normalization and Applying Mask."); ZeroMeanOneStdDevMasked(geo, (const char **) mask); } else{ DEBUG(1," No Value Normalization. Just Applying Mask."); applyMask(geo, (const char **) mask); } if(args->postEdge){ smoothImageEdge(geo, args->postEdge); } if(args->nrmDir){ sprintf(imagename,"%s\\%s%s.nrm", args->nrmDir, filename, suffix); DEBUG_STRING(1," Saving nrm: %s",imagename); writeFeretImage(geo,imagename); } if(args->pgmDir){ sprintf(imagename,"%s\\%s%s.pgm", args->pgmDir, filename, suffix); DEBUG_STRING(1," Saving pgm: %s",imagename); writePGMImage(geo,imagename,0); } if(args->sfiDir){ sprintf(imagename,"%s\\%s%s.sfi", args->sfiDir, filename, suffix); DEBUG_STRING(1," Saving sfi: %s",imagename); writeRawImage(geo,imagename); } freeImage(geo); freeImage(pgm); freeMatrix(transform); } fclose(eyeList); }
//========================================================================== bool SplineSurface::search_for_normal(bool interval_in_u, double fixed_parameter, double interval_start, // normal is not defined here double interval_end, Point& normal) const //========================================================================== { // We want to find the closest defined normal to the point on the surface with // the parameter values (interval_start, fixed_parameter) if interval_in_u = true, // or to the parameter values (fixed_parameter, interval_start) if interval_in_u = false. // We suppose that the normal for that point has been detected as undefined. const int INTERVAL_PARTITION = 10; double running_parameter = interval_start; double& u = interval_in_u ? running_parameter : fixed_parameter; double& v = interval_in_u ? fixed_parameter : running_parameter; // first a quick check - if we can find a normal in immediate vincinity to the // point (within the DEFAULT_PARAMETER_EPSILON value), we will return it. if (interval_end - interval_start > 0) { running_parameter += DEFAULT_PARAMETER_EPSILON; } else { running_parameter -= DEFAULT_PARAMETER_EPSILON; } bool normal_defined = false; try { normal_defined = normal_not_failsafe(normal, u, v); } catch ( ... ) { MESSAGE("Failed finding normal, trying a new method."); } if (normal_defined) { return true; } // if we got here, our little 'wiggling' of the moving parameter did not produce // a valid normal. We will do a more thorough search. // trying to locate a defined normal at some moderate distance from the // "difficult" point double stepsize = (interval_end - interval_start) / double(INTERVAL_PARTITION); int i; for (i = 1; i <= INTERVAL_PARTITION; ++i) { running_parameter = interval_start + i * stepsize; try { normal_defined = normal_not_failsafe(normal, u, v); } catch ( ... ) { MESSAGE("Failed finding normal, trying a new method."); } if (normal_defined) { break; } } if (i > INTERVAL_PARTITION) { // we didn't find any defined normal in this interval at all return false; } // restricting interval interval_end = running_parameter; // as detected in the above loop // trying to find the value of running_parameter that is as close as possible // to interval_start while still with a defined normal. Point tentative_normal; while (fabs(running_parameter - interval_start) > DEFAULT_PARAMETER_EPSILON) { running_parameter = (interval_start + interval_end) * 0.5; bool tentative_normal_defined = false; try { tentative_normal_defined = normal_not_failsafe(tentative_normal, u, v); } catch ( ... ) { MESSAGE("Failed finding normal, trying a new method."); } if (!tentative_normal_defined) { // we have gotten so close to the original point that the normal // has become undefined. Keep previous normal break; } else { interval_end = running_parameter; // shrinking interval normal = tentative_normal; // this normal was defined, and closer to orig. point } } // we have now found a defined normal that should be as close to the original point as // possible return true; }
SMESH_Exception::SMESH_Exception( void ): /*exception() ,*/ _text(0) { MESSAGE( "You must use the standard builder: SMESH_Exception::SMESH_Exception( const char *text )" ) ; INTERRUPTION(1) ; }
/*=======================================================================================*/ bool MakeWindow( bool *_FullScreenFlag , const int _nWinMode ) { WNDCLASSEX wc; // ウィンドウクラスの定義 // ウィンドウクラスの定義 wc.cbSize = sizeof(WNDCLASSEX); // 構造体のサイズ wc.style = CS_DBLCLKS; // スタイル wc.lpfnWndProc = WindowProc; // ウインドウ関数 wc.cbClsExtra = 0; // エキストラクラス情報 wc.cbWndExtra = 0; // エキストラウィンドウ情報 wc.hInstance = CAPP->hInst; // インスタンスハンドル wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // ラージアイコン wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO); // スモールアイコン wc.hCursor = LoadCursor(NULL, IDC_ARROW); // マウスカーソル wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // 背景色 wc.lpszMenuName = NULL; // メインメニュー名 wc.lpszClassName = WINDOW_NAME; // ウィンドウクラス名 // ウィンドウクラスの登録 if ( !RegisterClassEx( &wc ) ) { ErrorMessage( "ウィンドウの登録に失敗しました。\n" ); return false; } // スクリーンの解像度を取得 int ScreenSizeWidth = GetSystemMetrics( SM_CXSCREEN ); int ScreenSizeHeight = GetSystemMetrics( SM_CYSCREEN ); POINT WindowPos; WindowPos.x = ( ScreenSizeWidth - WINDOW_WIDTH ) / 2; WindowPos.y = ( ScreenSizeHeight - WINDOW_HEIGHT ) / 2; // ウィンドウの作成 CAPP->hWnd = CreateWindow( WINDOW_NAME, // 作成するウィンドウ名 GAME_TITLE.c_str(), // ウィンドウのタイトル WS_OVERLAPPEDWINDOW, // ウィンドウタイプを標準タイプに WindowPos.x + WINDOW_POSITION_X , // ウィンドウの位置(X座標) WindowPos.y + WINDOW_POSITION_Y , // ウィンドウの位置(Y座標) WINDOW_WIDTH, // ウィンドウの幅 WINDOW_HEIGHT, // ウィンドウの高さ NULL, // 親ウィンドウのハンドル NULL, // メニューのハンドル CAPP->hInst, // インスタンスハンドル NULL); // 追加情報 // ウィンドウの表示 #ifdef _DEBUG ShowWindow( CAPP->hWnd , bFullScreen ? ( SW_SHOW ) : ( _nWinMode ) ); #else int Select; Select = MESSAGE( "フルスクリーンで起動しますか?" ); *_FullScreenFlag = Select == IDYES ? ( true ) : ( false ); ShowWindow( CAPP->hWnd , Select == IDYES ? ( SW_SHOW ) : ( _nWinMode ) ); #endif // ウィンドウの更新 UpdateWindow( CAPP->hWnd ); return true; }
/** * rakia_codec_param_parse_generic: * @fmtp: a string value with the parameter description * @out: the parameter map to populate * * Parses parameters formatted as a semicolon separated list of * <replaceable>parameter</replaceable><literal>=</literal><replaceable>value</replaceable> * pairs, as recommended in IETF RFC 4855 Section 3. */ static void rakia_codec_param_parse_generic (const gchar *fmtp, TpMediaStreamType media_type, RakiaSipCodec *codec) { GMatchInfo *match = NULL; gint pos; gint value_start; gint value_end; if (fmtp == NULL) return; pos = 0; /* Fast path for trivial cases, not involving the regex engine */ while (g_ascii_isspace (fmtp[pos])) ++pos; if (!fmtp[pos]) return; g_assert (fmtp_attr_regex != NULL); g_regex_match_full (fmtp_attr_regex, fmtp, -1, pos, G_REGEX_MATCH_ANCHORED, &match, NULL); while (g_match_info_matches (match)) { gchar *name; gchar *value; name = g_match_info_fetch_named (match, FMTP_MATCH_NAME_PARAM); g_match_info_fetch_named_pos (match, FMTP_MATCH_NAME_VALUE, &value_start, &value_end); if (value_end - 1 > value_start && fmtp[value_start] == '\"' && fmtp[value_end - 1] == '\"') { value = rakia_unquote_string (fmtp + value_start, value_end - value_start); } else { value = g_strndup (fmtp + value_start, value_end - value_start); } rakia_sip_codec_add_param (codec, name, value); g_match_info_fetch_pos (match, 0, NULL, &pos); if (!fmtp[pos]) break; g_match_info_next (match, NULL); } g_match_info_free (match); if (fmtp[pos]) MESSAGE ("failed to parse part of format parameters" " as an attribute-value list: %s", &fmtp[pos]); }
/*********************************************************************** * thread_init * * Setup the initial thread. * * NOTES: The first allocated TEB on NT is at 0x7ffde000. */ HANDLE thread_init(void) { TEB *teb; void *addr; SIZE_T size, info_size; HANDLE exe_file = 0; LARGE_INTEGER now; NTSTATUS status; struct ntdll_thread_data *thread_data; static struct debug_info debug_info; /* debug info for initial thread */ virtual_init(); /* reserve space for shared user data */ addr = (void *)0x7ffe0000; size = 0x10000; status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE ); if (status) { MESSAGE( "wine: failed to map the shared user data: %08x\n", status ); exit(1); } user_shared_data = addr; /* allocate and initialize the PEB */ addr = NULL; size = sizeof(*peb); NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 1, &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ); peb = addr; peb->ProcessParameters = ¶ms; peb->TlsBitmap = &tls_bitmap; peb->TlsExpansionBitmap = &tls_expansion_bitmap; peb->FlsBitmap = &fls_bitmap; peb->LdrData = &ldr; params.CurrentDirectory.DosPath.Buffer = current_dir; params.CurrentDirectory.DosPath.MaximumLength = sizeof(current_dir); params.wShowWindow = 1; /* SW_SHOWNORMAL */ ldr.Length = sizeof(ldr); RtlInitializeBitMap( &tls_bitmap, peb->TlsBitmapBits, sizeof(peb->TlsBitmapBits) * 8 ); RtlInitializeBitMap( &tls_expansion_bitmap, peb->TlsExpansionBitmapBits, sizeof(peb->TlsExpansionBitmapBits) * 8 ); RtlInitializeBitMap( &fls_bitmap, peb->FlsBitmapBits, sizeof(peb->FlsBitmapBits) * 8 ); InitializeListHead( &peb->FlsListHead ); InitializeListHead( &ldr.InLoadOrderModuleList ); InitializeListHead( &ldr.InMemoryOrderModuleList ); InitializeListHead( &ldr.InInitializationOrderModuleList ); #ifdef __APPLE__ peb->Reserved[0] = get_dyld_image_info_addr(); #endif /* allocate and initialize the initial TEB */ signal_alloc_thread( &teb ); teb->Peb = peb; teb->Tib.StackBase = (void *)~0UL; teb->StaticUnicodeString.Buffer = teb->StaticUnicodeBuffer; teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer); thread_data = (struct ntdll_thread_data *)teb->SpareBytes1; thread_data->request_fd = -1; thread_data->reply_fd = -1; thread_data->wait_fd[0] = -1; thread_data->wait_fd[1] = -1; thread_data->debug_info = &debug_info; InsertHeadList( &tls_links, &teb->TlsLinks ); signal_init_thread( teb ); virtual_init_threading(); debug_info.str_pos = debug_info.strings; debug_info.out_pos = debug_info.output; debug_init(); /* setup the server connection */ server_init_process(); info_size = server_init_thread( peb ); /* create the process heap */ if (!(peb->ProcessHeap = RtlCreateHeap( HEAP_GROWABLE, NULL, 0, 0, NULL, NULL ))) { MESSAGE( "wine: failed to create the process heap\n" ); exit(1); } /* allocate user parameters */ if (info_size) { init_user_process_params( info_size, &exe_file ); } else { if (isatty(0) || isatty(1) || isatty(2)) params.ConsoleHandle = (HANDLE)2; /* see kernel32/kernel_private.h */ if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdInput ); if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdOutput ); if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdError ); } /* initialize time values in user_shared_data */ NtQuerySystemTime( &now ); user_shared_data->SystemTime.LowPart = now.u.LowPart; user_shared_data->SystemTime.High1Time = user_shared_data->SystemTime.High2Time = now.u.HighPart; user_shared_data->u.TickCountQuad = (now.QuadPart - server_start_time) / 10000; user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time; user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart; user_shared_data->TickCountMultiplier = 1 << 24; fill_cpu_info(); NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 ); return exe_file; }
static void MakePQ(int n, int mj, int nj) { MatRep_t *rep_m; Matrix_t *estar[MAXENDO], *endo[MAXENDO], *e, *ei; char fn[200]; int dim = InfoM.Cf[mj].dim; int spl = InfoM.Cf[mj].spl; int i; Matrix_t *p; MESSAGE(1,("Condensing %s%s x ",InfoM.BaseName,Lat_CfName(&InfoM,mj))); MESSAGE(1,("%s%s, [E:k]=%d\n",InfoN.BaseName,Lat_CfName(&InfoN,nj),spl)); /* Read the generators for the constituent of M and make the endomorphism ring. --------------------------------------------------------- */ rep_m = Lat_ReadCfGens(&InfoM,mj,InfoM.Cf[mj].peakword >= 0 ? LAT_RG_STD : 0); MESSAGE(2,("Calculating endomorphism ring\n")); MkEndo(rep_m,InfoM.Cf + mj,endo,MAXENDO); MrFree(rep_m); /* Calculate the Q matrix ---------------------- */ MESSAGE(2,("Calculating embedding of E\n")); MakeQ(n,spl,(const Matrix_t **)endo); /* Calculate the E* matrices Note: We should use the symmetry under i<-->k here! --------------------------------------------------- */ MESSAGE(2,("Calculating projection on E\n")); MESSAGE(2,(" E* matrices\n")); e = MatAlloc(FfOrder,spl,spl); for (i = 0; i < spl; ++i) { PTR pptr = MatGetPtr(e,i); int k; for (k = 0; k < spl; ++k) { FEL f; Matrix_t *x = MatDup(endo[i]); MatMul(x,endo[k]); f = MatTrace(x); FfInsert(pptr,k,f); MatFree(x); } } ei = MatInverse(e); MatFree(e); for (i = 0; i < spl; ++i) { int k; PTR p; estar[i] = MatAlloc(FfOrder,dim,dim); p = MatGetPtr(ei,i); for (k = 0; k < spl; ++k) MatAddMul(estar[i],endo[k],FfExtract(p,k)); } MatFree(ei); /* Transpose the E* matrices. This simplifies the calculation of tr(z E*) below. ----------------------------------------------- */ MESSAGE(2,(" Transposing E* matrices\n")); for (i = 0; i < spl; ++i) { Matrix_t *x = MatTransposed(estar[i]); MatFree(estar[i]); estar[i] = x; } /* Calculate the P matrix ---------------------- */ MESSAGE(2,(" P matrix\n")); p = MatAlloc(FfOrder,dim*dim,spl); for (i = 0; i < dim; ++i) { int j; for (j = 0; j < dim; ++j) { int r; PTR pptr = MatGetPtr(p,i*dim + j); Matrix_t *x = MatAlloc(FfOrder,dim,dim); MatCopyRegion(x,0,i,Trans[n],0,j,dim,1); for (r = 0; r < spl; ++r) { FEL f = MatProd(x,estar[r]); FfInsert(pptr,r,f); } MatFree(x); } } sprintf(fn,"%s.p.%d",TkiName,n+1); MESSAGE(2,("Writing %s\n",fn)); #if 0 if (InfoM.Cf[mj].peakword < 0) MatMulScalar(p,FF_ZERO); #endif MatSave(p,fn); /* Clean up -------- */ MatFree(p); for (i = 0; i < spl; ++i) MatFree(endo[i]); }
int main (int argc, char **argv) { med_idt fid; med_idt nfield, i, j; char meshname[MED_NAME_SIZE+1]=""; med_bool localmesh; char fieldname[MED_NAME_SIZE+1]=""; med_field_type fieldtype; char *componentname = NULL; char *componentunit = NULL; char dtunit[MED_SNAME_SIZE+1]=""; med_float *values = NULL; med_int nstep, nvalues; med_int ncomponent; med_int csit, numit, numdt, meshnumit, meshnumdt, it; med_float dt; med_geometry_type geotype; med_geometry_type *geotypes = MED_GET_CELL_GEOMETRY_TYPE; int k; int ret=-1; /* open file */ fid = MEDfileOpen("UsesCase_MEDfield_4.med",MED_ACC_RDONLY); if (fid < 0) { MESSAGE("ERROR : open file ..."); goto ERROR; } /* * generic approach : how many fields in the file and identification * of each field. */ if ((nfield = MEDnField(fid)) < 0) { MESSAGE("ERROR : How many fields in the file ..."); goto ERROR; } /* * read values for each field */ for (i=0; i<nfield; i++) { if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) { MESSAGE("ERROR : number of field component ..."); goto ERROR; } if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) { MESSAGE("ERROR : memory allocation ..."); goto ERROR; } if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) { MESSAGE("ERROR : memory allocation ..."); goto ERROR; } if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype, componentname, componentunit, dtunit, &nstep) < 0) { MESSAGE("ERROR : Field info ..."); free(componentname); free(componentunit); goto ERROR; } free(componentname); free(componentunit); /* * Read field values for each computing step */ for (csit=0; csit<nstep; csit++) { if (MEDfieldComputingStepMeshInfo(fid, fieldname, csit+1, &numdt, &numit, &dt, &meshnumdt, &meshnumit) < 0) { MESSAGE("ERROR : Computing step info ..."); goto ERROR; } /* * ... In our case, we suppose that the field values are only defined on cells ... */ for (it=1; it<=MED_N_CELL_FIXED_GEO; it++) { geotype = geotypes[it]; if ((nvalues = MEDfieldnValue(fid, fieldname, numdt, numit, MED_CELL, geotype)) < 0) { MESSAGE("ERROR : read number of values ..."); goto ERROR; } if (nvalues) { if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent)) == NULL) { MESSAGE("ERROR : memory allocation ..."); goto ERROR; } if (MEDfieldValueRd(fid, fieldname, numdt, numit, MED_CELL, geotype, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, (unsigned char*) values) < 0) { MESSAGE("ERROR : read fields values for cells ..."); free(values); goto ERROR; } free(values); } } } } ret=0; ERROR: /* close file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); ret=-1; } return ret; }
void LuaDatasetProxy::bind(Dataset* ds, shared_ptr<LuaScripting> ss) { if (mReg == NULL) throw LuaError("Unable to bind dataset, no class registration available."); mReg->clearProxyFunctions(); mDS = ds; if (ds != NULL) { // Register dataset functions using ds. string id; id = mReg->functionProxy(ds, &Dataset::GetDomainSize, "getDomainSize", "", false); id = mReg->functionProxy(ds, &Dataset::GetRange, "getRange", "", false); id = mReg->functionProxy(ds, &Dataset::GetLODLevelCount, "getLODLevelCount", "", false); id = mReg->functionProxy(ds, &Dataset::GetNumberOfTimesteps, "getNumberOfTimesteps", "", false); id = mReg->functionProxy(ds, &Dataset::GetMeshes, "getMeshes", "", false); // We do NOT want the return values from GetMeshes stuck in the provenance // system (Okay, so the provenance system doesn't store return values, just // function parameters. But it's best to be safe). ss->setProvenanceExempt(id); id = mReg->functionProxy(ds, &Dataset::GetBitWidth, "getBitWidth", "", false); id = mReg->functionProxy(ds, &Dataset::Get1DHistogram, "get1DHistogram", "", false); id = mReg->functionProxy(ds, &Dataset::Get2DHistogram, "get2DHistogram", "", false); id = mReg->functionProxy(ds, &Dataset::SaveRescaleFactors, "saveRescaleFactors", "", false); id = mReg->functionProxy(ds, &Dataset::GetRescaleFactors, "getRescaleFactors", "", false); id = mReg->functionProxy(ds, &Dataset::Clear, "clear", "clears cache data", false); // Attempt to cast the dataset to a file backed dataset. FileBackedDataset* fileDataset = dynamic_cast<FileBackedDataset*>(ds); if (fileDataset != NULL) { MESSAGE("Binding extra FileBackedDS functions."); id = mReg->functionProxy(fileDataset, &FileBackedDataset::Filename, "fullpath", "Full path to the dataset.", false); id = mReg->functionProxy(ds, &FileBackedDataset::Name, "name", "Dataset descriptive name.", false); } try { BrickedDataset& bds = dynamic_cast<BrickedDataset&>(*ds); id = mReg->functionProxy(&bds, &BrickedDataset::GetMaxUsedBrickSizes, "maxUsedBrickSize", "the size of the largest brick", false); } catch(const std::bad_cast&) { WARNING("Not binding BrickedDataset functions."); } try { UVFDataset& uvfDataset = dynamic_cast<UVFDataset&>(*ds); MESSAGE("Binding extra UVF functions."); mDatasetType = UVF; mReg->functionProxy(&uvfDataset, &UVFDataset::RemoveMesh, "removeMesh", "", true); mReg->functionProxy(&uvfDataset, &UVFDataset::AppendMesh, "appendMesh", "", false); id = mReg->functionProxy(&uvfDataset, &UVFDataset::GeometryTransformToFile, "geomTransformToFile", "", false ); ss->setProvenanceExempt(id); } catch(const std::bad_cast&) { WARNING("Not a uvf; not binding mesh functions."); } try { DynamicBrickingDS& dynDS = dynamic_cast<DynamicBrickingDS&>(*ds); MESSAGE("Binding dynamic bricking cache control functions"); id = mReg->functionProxy(&dynDS, &DynamicBrickingDS::SetCacheSize, "setCacheSize", "sets the size of the cache, in megabytes.", false); ss->addParamInfo(id, 0, "cacheMB", "cache size (megabytes)"); id = mReg->functionProxy(&dynDS, &DynamicBrickingDS::GetCacheSize, "getCacheSize", "gets the size of the cache, in megabytes.", false); } catch(const std::bad_cast&) { MESSAGE("Not dynamically bricked; not adding cache control functions."); } /// @todo Expose 1D/2D histogram? Currently, it is being transfered /// via shared_ptr. If lua wants to interpret this, the histogram /// will need to be placed in terms that lua can understand. /// Two approaches: /// 1) Add Grid1D to the LuaStrictStack. /// 2) Create a Histogram1D and Histogram2D proxy. /// /// The second solution would be more efficient, since there wouldn't /// be any time spent converting datatypes to and from Lua (and with /// histograms, that time wouldn't be negligible). } }
HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **ppObj) { MESSAGE("This program tried to use a XMLHTTPRequest object, but\n" "libxml2 support was not present at compile time.\n"); return E_NOTIMPL; }
/* initiate connection with X server */ static unsigned char * x_init_driver(unsigned char *param, unsigned char *display) { XGCValues gcv; XSetWindowAttributes win_attr; XVisualInfo vinfo; int misordered=-1; n_wins=0; #if defined(HAVE_SETLOCALE) && defined(LC_ALL) setlocale(LC_ALL,""); #endif #ifdef X_DEBUG { unsigned char txt[256]; sprintf(txt,"x_init_driver(%s, %s)\n",param, display); MESSAGE(txt); } #endif x_input_encoding=-1; #if defined(HAVE_NL_LANGINFO) && defined(HAVE_LANGINFO_H) && defined(CODESET) { unsigned char *cp; cp=nl_langinfo(CODESET); x_input_encoding=get_cp_index(cp); } #endif if (x_input_encoding<0)x_driver.flags|=GD_NEED_CODEPAGE; if (!display||!(*display))display=0; /* X documentation says on XOpenDisplay(display_name) : display_name Specifies the hardware display name, which determines the dis- play and communications domain to be used. On a POSIX-confor- mant system, if the display_name is NULL, it defaults to the value of the DISPLAY environment variable. But OS/2 has problems when display_name is NULL ... */ if (!display)display=getenv("DISPLAY"); #ifndef __linux__ /* on Linux, do not assume XWINDOW present if $DISPLAY is not set --- rather open links on svgalib or framebuffer console */ if (!display)display=":0.0"; /* needed for MacOS X */ #endif x_display=XOpenDisplay(display); if (!x_display) { unsigned char *err=init_str(); int l=0; add_to_str(&err,&l,"Can't open display \""); add_to_str(&err,&l,display?display:(unsigned char *)"(null)"); add_to_str(&err,&l,"\"\n"); return err; } x_hash_table_init(); x_bitmap_bit_order=BitmapBitOrder(x_display); x_fd=XConnectionNumber(x_display); x_screen=DefaultScreen(x_display); x_display_height=DisplayHeight(x_display,x_screen); x_display_width=DisplayWidth(x_display,x_screen); x_root_window=RootWindow(x_display,x_screen); x_default_window_width=x_display_width-50; x_default_window_height=x_display_height-50; x_driver_param=NULL; if (param) { char *p, *e, *f; int w,h; x_driver_param=stracpy(param); for (p=x_driver_param;(*p)&&(*p)!='x'&&(*p)!='X';p++); if (!(*p))goto done; *p=0; w=strtoul(x_driver_param,&e,10); h=strtoul(p+1,&f,10); if (!(*e)&&!(*f)&&w&&h){x_default_window_width=w;x_default_window_height=h;} *p='x'; done:; } /* find best visual */ { #define DEPTHS 5 #define CLASSES 2 int depths[DEPTHS]={24, 16, 15, 8, 4}; int classes[CLASSES]={TrueColor, PseudoColor}; /* FIXME: dodelat DirectColor */ int a,b; for (a=0;a<DEPTHS;a++) for (b=0;b<CLASSES;b++) { if (XMatchVisualInfo(x_display, x_screen,depths[a],classes[b], &vinfo)) { x_default_visual=vinfo.visual; x_depth=vinfo.depth; /* determine bytes per pixel */ { XPixmapFormatValues *pfm; int n,i; pfm=XListPixmapFormats(x_display,&n); for (i=0;i<n;i++) if (pfm[i].depth==x_depth) { x_bitmap_bpp=pfm[i].bits_per_pixel<8?1:((pfm[i].bits_per_pixel)>>3); x_bitmap_scanline_pad=(pfm[i].scanline_pad)>>3; XFree(pfm); goto bytes_per_pixel_found; } if(n) XFree(pfm); continue; } bytes_per_pixel_found: /* test misordered flag */ switch(x_depth) { case 4: case 8: if (x_bitmap_bpp!=1)break; if (vinfo.red_mask>=vinfo.green_mask&&vinfo.green_mask>=vinfo.blue_mask) { misordered=0; goto visual_found; } break; case 15: case 16: if (x_bitmap_bpp!=2)break; if (x_bitmap_bit_order==MSBFirst&&vinfo.red_mask>vinfo.green_mask&&vinfo.green_mask>vinfo.blue_mask) { misordered=256; goto visual_found; } if (x_bitmap_bit_order==MSBFirst)break; if (vinfo.red_mask>vinfo.green_mask&&vinfo.green_mask>vinfo.blue_mask) { misordered=0; goto visual_found; } break; case 24: if (x_bitmap_bpp!=3&&x_bitmap_bpp!=4) break; if (vinfo.red_mask<vinfo.green_mask&&vinfo.green_mask<vinfo.blue_mask) { misordered=256; goto visual_found; } if (x_bitmap_bit_order==MSBFirst&&vinfo.red_mask>vinfo.green_mask&&vinfo.green_mask>vinfo.blue_mask) { misordered=512; goto visual_found; } if (vinfo.red_mask>vinfo.green_mask&&vinfo.green_mask>vinfo.blue_mask) { misordered=0; goto visual_found; } break; } } }
int main (int argc, char **argv) { med_idt fid; const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh"; const med_int spacedim = 2; const med_int meshdim = 2; /* 12345678901234561234567890123456 */ const char axisname[2*MED_SNAME_SIZE+1] = "x y "; const char unitname[2*MED_SNAME_SIZE+1] = "cm cm "; const med_float coordinates[30] = { 2.,1., 7.,1., 12.,1., 17.,1., 22.,1., 2.,6., 7.,6., 12.,6., 17.,6., 22.,6., 2.,11., 7.,11., 12.,11., 17.,11., 22.,11.}; const med_int nnodes = 15; const med_int triaconnectivity[24] = { 1,7,6, 2,7,1, 3,7,2, 8,7,3, 13,7,8, 12,7,13, 11,7,12, 6,7,11 }; const med_int ntria3 = 8; const med_int quadconnectivity[16] = {3,4,9,8, 4,5,10,9, 15,14,9,10, 13,8,9,14}; const med_int nquad4 = 4; med_err ret=-1; /* open MED file */ fid = MEDfileOpen("UsesCase_MEDmesh_1.med",MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); goto ERROR; } /* write a comment in the file */ if (MEDfileCommentWr(fid,"A 2D unstructured mesh : 15 nodes, 12 cells") < 0) { MESSAGE("ERROR : write file description ..."); goto ERROR; } /* mesh creation : a 2D unstructured mesh */ if (MEDmeshCr(fid, meshname, spacedim, meshdim, MED_UNSTRUCTURED_MESH, "A 2D unstructured mesh","",MED_SORT_DTIT,MED_CARTESIAN, axisname, unitname) < 0) { MESSAGE("ERROR : mesh creation ..."); goto ERROR; } /* nodes coordinates in a cartesian axis in full interlace mode (X1,Y1, X2,Y2, X3,Y3, ...) with no iteration and computation step */ if (MEDmeshNodeCoordinateWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_FULL_INTERLACE, nnodes, coordinates) < 0) { MESSAGE("ERROR : nodes coordinates ..."); goto ERROR; } /* cells connectiviy is defined in nodal mode with no iteration and computation step */ if (MEDmeshElementConnectivityWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_TRIA3, MED_NODAL, MED_FULL_INTERLACE, ntria3, triaconnectivity) < 0) { MESSAGE("ERROR : triangular cells connectivity ..."); goto ERROR; } if (MEDmeshElementConnectivityWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_QUAD4, MED_NODAL, MED_FULL_INTERLACE, nquad4, quadconnectivity) < 0) { MESSAGE("ERROR : quadrangular cells connectivity ..."); goto ERROR; } /* create family 0 : by default, all mesh entities family number is 0 */ if (MEDfamilyCr(fid, meshname,MED_NO_NAME, 0, 0, MED_NO_GROUP) < 0) { MESSAGE("ERROR : family 0 creation ..."); goto ERROR; } ret = 0; ERROR : /* close MED file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); return -1; } return ret; }
void MAJ_236_300_champs(med_idt fid) { med_err lret,ret; /* med_idt _datagroup=0; */ med_field_type typcha; char nomcha [MED_NAME_SIZE+1]=""; char _meshname [MED_NAME_SIZE+1]=""; char _dtunit [MED_SNAME_SIZE+1]=""; char *comp= NULL, *unit= NULL; med_int ncomp,ncha; med_int _ncstp=0; med_bool _local=MED_FALSE; htri_t _datasetexist; char _pathi[MED_TAILLE_CHA+1+MED_NAME_SIZE+1]=MED_CHA; char _pathf[MED_TAILLE_CHA+2+MED_NAME_SIZE+1]="/CHA_/"; char _pathtmp[MED_TAILLE_CHA+3]="/CHA__/"; int i,j; char nomlien[MED_NAME_SIZE+1]=""; char * lien = NULL; med_int nln,nval; med_int _nloc,_intgeotype,_sdim; char _pathloc[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS; med_int _npar,_numdt,_numit; char _pathpari[MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+1]=MED_NUM_DATA; char _pathparf[MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+1]=MED_NUM_DATA; int _pathparlen; med_size _n=0; char _cpstnamei[2*MED_MAX_PARA+1]=""; char _cpstnamef[2*MED_MAX_PARA+1]=""; char _uniname[MED_SNAME_SIZE+1]=""; /* hid_t _lac_plist_id; */ hid_t _lcp_plist_id; hid_t _ocp_plist_id; med_bool _createunt = MED_TRUE; MAJ_version_num(fid,2,3,6); /* MAJ des varaibles scalaires */ _npar = MEDnParameter(fid); if (_npar > 0) { fprintf(stdout," >>> Normalisation des paramètres scalaires\n"); _pathparf[MED_TAILLE_NUM_DATA-2]='_'; /* _lac_plist_id = H5Pcreate( H5P_LINK_ACCESS ); */ _ocp_plist_id = H5Pcreate( H5P_OBJECT_COPY ); _lcp_plist_id = H5Pcreate( H5P_LINK_CREATE ); H5Pset_create_intermediate_group( _lcp_plist_id, 1 ); H5Pset_copy_object( _ocp_plist_id, H5O_COPY_SHALLOW_HIERARCHY_FLAG); } for (i=0 ; i < _npar ; i++ ) { MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathpari ,i, &_pathpari[MED_TAILLE_NUM_DATA]) < 0, MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathpari); strcpy(&_pathparf[MED_TAILLE_NUM_DATA],&_pathpari[MED_TAILLE_NUM_DATA]); /* SSCRUTE(_pathparf); */ /* SSCRUTE(_pathpari); */ /*Copie le group avec ses attributs et les objets de premier niveau.*/ ret = H5Ocopy(fid,_pathpari,fid,_pathparf,_ocp_plist_id,_lcp_plist_id); /* ret = H5Lcopy(fid,_pathpari,fid,_pathparf,_lcp_plist_id,_lac_plist_id); */ EXIT_IF(ret < 0,"Copie du datagroup",_pathpari); _pathparlen=strlen(_pathpari); _pathpari[_pathparlen]='/';_pathparf[_pathparlen]='/'; ++_pathparlen; _pathpari[_pathparlen]='\0';_pathparf[_pathparlen]='\0'; /* SSCRUTE(_pathparf); */ /* SSCRUTE(_pathpari); */ ret =_MEDnObjects(fid,_pathpari, &_n); MED_ERR_EXIT_IF( (ret == (MED_ERR_COUNT + MED_ERR_DATAGROUP)), MED_ERR_COUNT,MED_ERR_PARAMETER,_pathpari); for (j=0 ; j < _n ; ++j ) { MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathpari ,j, &_pathpari[_pathparlen]) < 0, MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathpari); MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathpari,MED_NOM_NOR, MED_INTERNAL_INT,(unsigned char * const ) &_numit) < 0, MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NOR); MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathpari,MED_NOM_NDT, MED_INTERNAL_INT,(unsigned char * const ) &_numdt) < 0, MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT); MED_ERR_EXIT_IF (_MEDattributeStringRdByName(fid,_pathpari,MED_NOM_UNI, MED_SNAME_SIZE,_uniname) < 0, MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT); _MEDgetComputationStepName(MED_SORT_DTIT,_numdt,_numit,&_pathparf[_pathparlen]); /* strcat(_pathpari,"/"); */ /* strcat(_pathparf,"/"); */ /* SSCRUTE(_pathparf); */ /* SSCRUTE(_pathpari); */ /* ret = H5Ocopy(fid,_pathpari,fid,_pathparf,_ocp_plist_id,_lcp_plist_id); */ /* ret = H5Lcopy(fid,_pathpari,fid,_pathparf,_lcp_plist_id,_lac_plist_id); */ /* H5Eprint1(stderr); */ /* EXIT_IF(ret < 0,"Copie d'une étape de calcul du paramètre scalaire ",_pathpari); */ /*On modifie temporairement _pathpari pour pointer dans _pathparf*/ _pathpari[MED_TAILLE_NUM_DATA-2]='_'; /* SSCRUTE(_pathparf); */ /* SSCRUTE(_pathpari); */ ret = H5Gmove(fid, _pathpari, _pathparf ); EXIT_IF(ret < 0,"Renommage de l'étape de calcul",_pathpari); _pathpari[MED_TAILLE_NUM_DATA-2]='A'; MED_ERR_EXIT_IF(H5Adelete_by_name( fid, _pathparf, MED_NOM_UNI, H5P_DEFAULT ) < 0, MED_ERR_DELETE,MED_ERR_ATTRIBUTE,_pathparf); _pathparf[_pathparlen]='\0'; _pathpari[_pathparlen]='\0'; if ( _createunt ) { MED_ERR_EXIT_IF (_MEDattributeStringWrByName(fid,_pathparf,MED_NOM_UNT, MED_SNAME_SIZE,_uniname) < 0, MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_UNT); _createunt = MED_FALSE; } } _createunt = MED_TRUE; _pathpari[MED_TAILLE_NUM_DATA]='\0'; } if ( _npar > 0 ) { _pathpari[MED_TAILLE_NUM_DATA]='\0'; _pathparf[MED_TAILLE_NUM_DATA]='\0'; MED_ERR_EXIT_IF ( H5Ldelete(fid,_pathpari,H5P_DEFAULT) < 0 , MED_ERR_DELETE,MED_ERR_LINK,_pathpari); ret = H5Gmove(fid, _pathparf, _pathpari ); EXIT_IF(ret < 0,"Renommage du group de paramètres scalaires",_pathparf); } /* MAJ des localisations */ _nloc = MEDnLocalization(fid); /* ISCRUTE(_nloc); */ if (_nloc > 0) fprintf(stdout," >>> Normalisation des localisations des points d'intégration\n"); for (i=0 ; i < _nloc ; i++ ) { /* SSCRUTE(_pathloc); */ MED_ERR_EXIT_IF (_MEDobjectGetName(fid, _pathloc ,i, &_pathloc[MED_TAILLE_GAUSS]) < 0, MED_ERR_ACCESS,MED_ERR_DATAGROUP,_pathloc); /* SSCRUTE(_pathloc); */ MED_ERR_EXIT_IF (_MEDattributeNumRdByName(fid,_pathloc,MED_NOM_GEO, MED_INTERNAL_INT,(unsigned char * const ) &_intgeotype) < 0, MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_GEO); _sdim = (_intgeotype/100); MED_ERR_EXIT_IF (_MEDattributeNumWrByName(fid,_pathloc,MED_NOM_DIM, MED_INTERNAL_INT,(const unsigned char * const) &_sdim) < 0, MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_DIM); MED_ERR_EXIT_IF ( _MEDattributeStringWrByName(fid,_pathloc,MED_NOM_INM,MED_NAME_SIZE,"") < 0, MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_INM); _pathloc[MED_TAILLE_GAUSS]='\0'; } /* MAJ des liens */ nln = MEDnLink(fid); if (nln > 0) fprintf(stdout," >>> Normalisation des liens\n"); for (i=1 ; i <= nln ; i++ ) { ret = MEDlinkInfo(fid, i, nomlien, &nval); EXIT_IF(ret,"Erreur a la demande d'information sur le lien",NULL); /* printf("\t- Lien n°%i de nom |%s| et de taille "IFORMAT"\n",i,nomlien,nval); */ lien = (char *) malloc((nval+1)*sizeof(char)); EXIT_IF(lien == NULL,NULL,NULL); ret = MEDlinkRd(fid, nomlien, lien ); EXIT_IF(ret,"Erreur a la lecture du lien : ",nomlien); MAJ_version_num(fid,3,0,8); ret = MED30linkWr(fid,nomlien,lien); EXIT_IF(ret,"Erreur a l'écrtiure du lien : ",nomlien); MAJ_version_num(fid,2,3,6); lien[nval] = '\0'; /* printf("\t\t|%s|\n\n",lien); */ free(lien); } /* combien de champs dans le fichier */ ncha = MEDnField(fid); EXIT_IF(ncha < 0,"lors de la lecture du nombre de champs",NULL); /* MAJ des champs */ for (i =0;i<ncha;i++) { lret = 0; /* Lecture du nombre de composantes */ ncomp = MEDfieldnComponent(fid,i+1); if (ncomp < 0) { MESSAGE("Erreur à la lecture du nombre de composantes : "); ISCRUTE(ncomp); exit(1); } /* Lecture du type du champ, des noms des composantes et du nom de l'unité*/ comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1); EXIT_IF(comp == NULL,NULL,NULL); unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1); EXIT_IF(unit == NULL,NULL,NULL); /* ret = MED231champInfoEtRen(fid,i+1,nomcha,&typcha,comp,unit,ncomp); */ ret = MEDfieldInfo(fid,i+1,nomcha,_meshname,&_local,&typcha,comp,unit,_dtunit,&_ncstp); MED_ERR_EXIT_IF(ret,MED_ERR_ACCESS,MED_ERR_FIELD,nomcha); /* creation du champ destination */ MAJ_version_num(fid,3,0,8); EXIT_IF( H5Gmove(fid, _pathi, _pathtmp ) < 0,"Switch to ",_pathtmp); _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT ); if (_datasetexist ) { EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathi); } MED_ERR_EXIT_IF( MEDfieldCr(fid,nomcha,typcha,ncomp,comp,unit,_dtunit,_meshname ) < 0, MED_ERR_CREATE,MED_ERR_FIELD,_pathf); EXIT_IF( H5Gmove(fid, _pathi , _pathf ) < 0,"Switch to ",_pathf); EXIT_IF( H5Gmove(fid, _pathtmp, _pathi ) < 0,"Switch to ",_pathi); MAJ_version_num(fid,2,3,6); free(comp); free(unit); lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_NODE,_ncstp, _pathi, _pathf); if (lret != 0) { MESSAGE("Erreur à la lecture des champs aux noeuds "); exit(1); } lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_CELL,_ncstp, _pathi, _pathf); if (lret != 0) { MESSAGE("Erreur à la lecture des champs aux mailles "); exit(1); } lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_DESCENDING_FACE,_ncstp, _pathi, _pathf); if (lret != 0) { MESSAGE("Erreur à la lecture des champs aux faces "); exit(1); } lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_DESCENDING_EDGE,_ncstp, _pathi, _pathf); if (lret != 0) { MESSAGE("Erreur à la lecture des champs aux aretes "); exit(1); } lret = MAJ_236_300_fieldOnEntity( fid, nomcha, _meshname, typcha, ncomp, MED_NODE_ELEMENT,_ncstp, _pathi, _pathf); if (lret != 0) { MESSAGE("Erreur à la lecture des champs aux aretes "); exit(1); } } _datasetexist=H5Lexists( fid, _pathf, H5P_DEFAULT ); if (_datasetexist ) { EXIT_IF( (H5Ldelete(fid,_pathi, H5P_DEFAULT) < 0) ,"Delete ",_pathi); EXIT_IF( (H5Gmove(fid, _pathf, _pathi ) < 0) ,"Switch to ",_pathf); } }
static BOOL load_gecko(void) { nsresult nsres; nsIObserver *pStartNotif; nsIComponentRegistrar *registrar = NULL; nsAString path; nsIFile *gre_dir; PRUnichar gre_path[MAX_PATH]; static BOOL tried_load = FALSE; TRACE("()\n"); if(tried_load) return pCompMgr != NULL; tried_load = TRUE; if(!load_wine_gecko(gre_path) && !load_mozctl(gre_path) && !load_mozilla(gre_path)) { install_wine_gecko(); if(!load_wine_gecko(gre_path)) { MESSAGE("Could not load Mozilla. HTML rendering will be disabled.\n"); return FALSE; } } NS_StringContainerInit(&path); NS_StringSetData(&path, gre_path, PR_UINT32_MAX); nsres = NS_NewLocalFile(&path, FALSE, &gre_dir); NS_StringContainerFinish(&path); if(NS_FAILED(nsres)) { ERR("NS_NewLocalFile failed: %08lx\n", nsres); FreeLibrary(hXPCOM); return FALSE; } nsres = NS_InitXPCOM2(&pServMgr, gre_dir, NULL); if(NS_FAILED(nsres)) { ERR("NS_InitXPCOM2 failed: %08lx\n", nsres); FreeLibrary(hXPCOM); return FALSE; } nsres = nsIServiceManager_QueryInterface(pServMgr, &IID_nsIComponentManager, (void**)&pCompMgr); if(NS_FAILED(nsres)) ERR("Could not get nsIComponentManager: %08lx\n", nsres); nsres = NS_GetComponentRegistrar(®istrar); if(NS_SUCCEEDED(nsres)) { nsres = nsIComponentRegistrar_AutoRegister(registrar, NULL); if(NS_FAILED(nsres)) ERR("AutoRegister(NULL) failed: %08lx\n", nsres); nsres = nsIComponentRegistrar_AutoRegister(registrar, gre_dir); if(NS_FAILED(nsres)) ERR("AutoRegister(gre_dir) failed: %08lx\n", nsres); init_nsio(pCompMgr, registrar); }else { ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres); } nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_APPSTARTUPNOTIFIER_CONTRACTID, NULL, &IID_nsIObserver, (void**)&pStartNotif); if(NS_SUCCEEDED(nsres)) { nsres = nsIObserver_Observe(pStartNotif, NULL, APPSTARTUP_TOPIC, NULL); if(NS_FAILED(nsres)) ERR("Observe failed: %08lx\n", nsres); nsIObserver_Release(pStartNotif); }else { ERR("could not get appstartup-notifier: %08lx\n", nsres); } set_profile(); nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_MEMORY_CONTRACTID, NULL, &IID_nsIMemory, (void**)&nsmem); if(NS_FAILED(nsres)) ERR("Could not get nsIMemory: %08lx\n", nsres); if(registrar) { register_nsservice(registrar, pServMgr); nsIComponentRegistrar_Release(registrar); } return TRUE; }
void stat_write(int outputnum) { stat.src_ray_count.total += stat.src_ray_count.subtotal; stat.rec_ray_count.total += stat.rec_ray_count.subtotal; stat.src_photon_count.total += stat.src_photon_count.subtotal; stat.rec_photon_count.total += stat.rec_photon_count.subtotal; MESSAGE("SRC(subtot): Ray %lu Photon %g ", stat.src_photon_count.subtotal, stat.src_ray_count.subtotal); MESSAGE("REC(subtot): Ray %lu Photon %g ", stat.rec_photon_count.subtotal, stat.rec_ray_count.subtotal); MESSAGE("REC(subtot): HII %g, HeII %g HeIII %g", stat.rec_photon_count.subtotalHII, stat.rec_photon_count.subtotalHeII, stat.rec_photon_count.subtotalHeIII); MESSAGE("PH EMISSION: Src %g Rec %g", stat.src_photon_count.total, stat.rec_photon_count.total); MESSAGE("PH STORAGE : Lost %g Rec %g ", stat.lost_photon_count_sum, stat.rec_photon_count_sum); MESSAGE("Deposit: saturated = %lu, disordered= %lu, total=%lu", stat.saturated_deposit_count, stat.disordered_count, stat.total_deposit_count); MESSAGE("First: %g %g %g", stat.first_ionization.HI, stat.first_ionization.HeI, stat.first_ionization.HeII); MESSAGE("Secondary: %g %g", stat.secondary_ionization.HI, stat.secondary_ionization.HeI); MESSAGE("Evolve : Error %lu FastRec %lu Total %lu", stat.gsl_error_count, stat.fast_recombination_count, stat.evolve_count); MESSAGE("Time : SpinLock %g", stat.spinlock_time); stat.src_ray_count.subtotal = 0; stat.rec_ray_count.subtotal = 0; stat.src_photon_count.subtotal = 0; stat.rec_photon_count.subtotal = 0; stat.rec_photon_count.subtotalHII = 0; stat.rec_photon_count.subtotalHeII = 0; stat.rec_photon_count.subtotalHeIII = 0; MESSAGE("Real Time: emit %g raytrace %g deposit %g update %g total %g", stat.emit_time, stat.raytrace_time, stat.deposit_time, stat.update_time, stat.total_time); stat.tick_subtotal = 0; char * basename; asprintf(&basename, psys.epoch->output.filename, outputnum); if(CFG_DUMP_HOTSPOTS) { fclose(stat.parlogfile); fclose(stat.hitlogfile); stat.parlogfile = fopen_printf("%s.par", "w", basename); stat.hitlogfile = fopen_printf("%s.hit", "w", basename); } if(CFG_PRINT_RAYS) { fclose(stat.raylogfile); stat.raylogfile = fopen_printf("%s.ray", "w", basename); } free(basename); }
int main (int argc, char **argv) { med_idt fid; med_int nse2 = 5; med_int se2[10] = {1,2,1,3,2,4,3,4,2,3}; /* 12345678901234561234567890123456123456789012345612345678901234561234567890123456 */ char nomse2[MED_TAILLE_PNOM*5+1]="se1 se2 se3 se4 se5 "; med_int numse2[5] = {1,2,3,4,5}; med_int nufase2[5] = {-1,-1,0,-2,-3}; med_int ntr3 = 2; med_int tr3[6] = {1,2,-5,-5,3,-4}; /* 1234567890123456123456789012345612345678901234561234567890123456 */ /* Erreur sur la taille de tr1, il manque deux blancs.*/ char nomtr3[MED_TAILLE_PNOM*2+1] = "tr1 tr2 "; med_int numtr3[2] = {4,5}; med_int nufatr3[2] = {0,-1}; char maa[MED_TAILLE_NOM+1] = "maa1"; med_int mdim = 2; /* Creation du fichier test16.med */ if ( (fid = MEDouvrir("test16.med",MODE_ACCES) ) < 0) { MESSAGE("Impossible de creer le fichier test16.med : "); return -1; } /* Creation du maillage */ if ( MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE, "un maillage pour test16") < 0 ) { MESSAGE("Impossible de creer le maillage : "); return -1; } /* Ecriture des aretes segments MED_SEG2 : - connectivite - noms (optionnel) - numeros (optionnel) - numeros des familles */ if ( MEDelementsEcr(fid,maa,mdim,se2,MED_NO_INTERLACE,nomse2,MED_VRAI,numse2,MED_VRAI, nufase2,nse2,MED_ARETE,MED_SEG2,MED_DESC)< 0 ) { MESSAGE("Impossible d'ecrire la connectivité des aretes : "); return -1; } /* Ecriture des mailles MED_TRIA3 : - Connectivite - Noms (optionnel) - Numeros (optionnel) - Numeros des familles */ if ( MEDelementsEcr(fid,maa,mdim,tr3,MED_NO_INTERLACE,nomtr3,MED_VRAI,numtr3,MED_VRAI, nufatr3,ntr3,MED_MAILLE,MED_TRIA3,MED_DESC) < 0 ) { MESSAGE("Impossible d'ecrire les éléments triangles : "); return -1; } /* Fermeture du fichier */ if ( MEDfermer(fid) < 0) { MESSAGE("Impossible de fermerle fichier : "); return -1; } return 0; }
med_int MEDjointnCorres (med_idt fid, char *maa, char *jn, med_entite_maillage type_ent_local, med_geometrie_element typ_geo_local, med_entite_maillage type_ent_distant, med_geometrie_element typ_geo_distant) { med_entite_maillage _type_ent_local = (med_entite_maillage) ( (int)(type_ent_local) % 10 ); med_entite_maillage _type_ent_distant = (med_entite_maillage) ( (int)(type_ent_distant) % 10 ); med_idt datagroup1=0,datagroup2=0; med_int n=0, ret=-1; char chemin[MED_TAILLE_MAA+MED_TAILLE_JNT+2*MED_TAILLE_NOM+1]; char nomdatagroup[MED_TAILLE_NOM_ENTITE*4+3+1]; char tmp[MED_TAILLE_NOM_ENTITE+1]; med_size dimd[1]; /* if (typ_geo_local == MED_TETRA4 || typ_geo_local == MED_TETRA10 || */ /* typ_geo_local == MED_HEXA8 || typ_geo_local == MED_HEXA20 || */ /* typ_geo_local == MED_PENTA6 || typ_geo_local == MED_PENTA15 || */ /* typ_geo_local == MED_PYRA5 || typ_geo_local == MED_PYRA13 || */ /* typ_geo_distant == MED_TETRA4 || typ_geo_distant == MED_TETRA10 || */ /* typ_geo_distant == MED_HEXA8 || typ_geo_distant == MED_HEXA20 || */ /* typ_geo_distant == MED_PENTA6 || typ_geo_distant == MED_PENTA15 || */ /* typ_geo_distant == MED_PYRA5 || typ_geo_distant == MED_PYRA13) */ /* return -1; */ /* * On inhibe le gestionnaire d'erreur HDF 5 */ _MEDmodeErreurVerrouiller(); if (MEDcheckVersion(fid) < 0) return -1; /* * Si le Data Group de "JNT/Corres" n'existe pas => erreur */ strcpy(chemin,MED_MAA); strcat(chemin,maa); strcat(chemin,MED_JNT); strcat(chemin,jn); if ((datagroup1 = _MEDdatagroupOuvrir(fid,chemin)) < 0) { MESSAGE("Impossible d'ouvrir le datagroup : "); SSCRUTE(chemin); goto ERREUR; } /* * Ecriture de la correspondance * construction du tag HDF "reperant" la correspondance * */ if ( _MEDnomEntite(nomdatagroup,_type_ent_local) < 0) goto ERREUR; if ((_type_ent_local != MED_NOEUD)) { if ( _MEDnomGeometrie30(tmp,typ_geo_local) < 0) goto ERREUR; strcat(nomdatagroup,"."); strcat(nomdatagroup,tmp); } if ( _MEDnomEntite(tmp,_type_ent_distant) < 0) goto ERREUR; strcat(nomdatagroup,"."); strcat(nomdatagroup,tmp); if ((_type_ent_distant != MED_NOEUD)) { if ( _MEDnomGeometrie30(tmp,typ_geo_distant) < 0) goto ERREUR; strcat(nomdatagroup,"."); strcat(nomdatagroup,tmp); } /* le couple d'entite n'existe pas, on renvoie 0 */ if ((datagroup2 = _MEDdatagroupOuvrir(datagroup1,nomdatagroup)) < 0 ) goto SORTIE; /* erreur : le couple d'entite existe mais on ne peut lire l'attribut NBR */ if ( _MEDattrEntierLire(datagroup2,MED_NOM_NBR,&n) < 0) { MESSAGE("Impossible de lire l'attribut NBR : "); SSCRUTE(chemin);SSCRUTE(MED_NOM_NBR); goto ERREUR; } /* * On ferme tout */ SORTIE: ret= n; ERREUR: if (datagroup2 > 0 ) if ( _MEDdatagroupFermer(datagroup2) < 0) { MESSAGE("Impossible de fermer le groupe : "); SSCRUTE(chemin);SSCRUTE(nomdatagroup);ret=-1; } if (datagroup1 > 0 ) if ( _MEDdatagroupFermer(datagroup1) < 0) { MESSAGE("Impossible de fermer le groupe : "); SSCRUTE(chemin);ret= -1; } return (med_int) ret; }
int main (int argc, char **argv) { med_idt fid; const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh"; const med_int spacedim = 2; const med_int meshdim = 2; const char axisname[2*MED_SNAME_SIZE+1] = "x y "; const char unitname[2*MED_SNAME_SIZE+1] = "cm cm "; const med_float initial_coordinates[30] = { 2.,1., 7.,1., 12.,1., 17.,1., 22.,1., 2.,6., 7.,6., 12.,6., 17.,6., 22.,6., 2.,11., 7.,11., 12.,11., 17.,11., 22.,11.}; const med_int nnodes = 15; const med_int triaconnectivity[24] = { 1,7,6, 2,7,1, 3,7,2, 8,7,3, 13,7,8, 12,7,13, 11,7,12, 6,7,11 }; const med_int ntria3 = 8; const med_int quadconnectivity[16] = {3,4,9,8, 4,5,10,9, 15,14,9,10, 13,8,9,14}; const med_int nquad4 = 4; /* matrix transformation (step 1) : rotation about the Y-axis : 45 degrees */ const med_float tansfMatrix_step1 [7] = { 0.0, 0.0, 0.0, 0.92388, 0.0, 0.38268, 0.0 }; /* matrix transformation (step 2) : rotation about the Y-axis : 90 degrees */ const med_float tansfMatrix_step2 [7] = { 0.0, 0.0, 0.0, 0.707, 0.0, 0.707, 0.0 }; int ret=-1; /* open MED file */ fid = MEDfileOpen("UsesCase_MEDmesh_9.med",MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); goto ERROR; } /* write a comment in the file */ if (MEDfileCommentWr(fid,"A 2D unstructured mesh : 15 nodes, 12 cells") < 0) { MESSAGE("ERROR : write file description ..."); goto ERROR; } /* mesh creation : a 2D unstructured mesh */ if (MEDmeshCr(fid, meshname, spacedim, meshdim, MED_UNSTRUCTURED_MESH, "A 2D structured mesh","",MED_SORT_DTIT,MED_CARTESIAN, axisname, unitname) < 0) { MESSAGE("ERROR : mesh creation ..."); goto ERROR; } /* nodes coordinates in a cartesian axis in full interlace mode (X1,Y1, X2,Y2, X3,Y3, ...) with no iteration and computation step */ if (MEDmeshNodeCoordinateWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nnodes, initial_coordinates) < 0) { MESSAGE("ERROR : nodes coordinates ..."); goto ERROR; } /* cells connectiviy is defined in nodal mode */ if (MEDmeshElementConnectivityWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_TRIA3, MED_NODAL, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, ntria3, triaconnectivity) < 0) { MESSAGE("ERROR : triangular cells connectivity ..."); goto ERROR; } if (MEDmeshElementConnectivityWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_QUAD4, MED_NODAL, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nquad4, quadconnectivity) < 0) { MESSAGE("ERROR : quadrangular cells connectivity ..."); goto ERROR; } /* * Mesh deformation (nodes coordinates) in 2 steps * A rotation by step for each node */ /* STEP 1 : dt1 = 5.5, it = 1*/ if ( MEDmeshNodeCoordinateTrsfWr(fid, meshname, 1, 1, 5.5, tansfMatrix_step1) < 0) { MESSAGE("Erreur a l'ecriture de la transformation géométrique n°1"); goto ERROR; } /* STEP 2 : dt2 = 8.9, it = 1*/ if ( MEDmeshNodeCoordinateTrsfWr(fid, meshname, 2, 2, 8.9, tansfMatrix_step2 ) < 0) { MESSAGE("Erreur a l'ecriture de la transformation géométrique n°1"); goto ERROR; } /* create family 0 : by default, all mesh entities family number is 0 */ if (MEDfamilyCr(fid, meshname,MED_NO_NAME, 0, 0, MED_NO_GROUP) < 0) { MESSAGE("ERROR : create family ..."); goto ERROR; } ret=0; ERROR: /* close MED file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); ret=-1; } return ret; }
int main (int argc, char **argv) { med_idt fid; const char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family"; med_geometry_type geotype =MED_NONE; med_bool cellnodes =MED_FALSE; med_int nbasisfunc =0; med_int nvariable =0; med_int maxdegree =0; med_int nmaxcoefficient =0; int basisfuncit =0; int powerit =0; med_int ncoefficient =0; med_int* power =NULL; med_float* coefficient =NULL; int coefficientit =0; int ret=-1; /* file creation */ fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY); if (fid < 0) { MESSAGE("ERROR : file creation ..."); goto ERROR; } /* with direct access by the family name */ if (MEDinterpInfoByName(fid,interpname,&geotype,&cellnodes,&nbasisfunc, &nvariable,&maxdegree,&nmaxcoefficient) < 0) { MESSAGE("ERROR : interpolation function information ..."); goto ERROR; } /* read each basis function */ for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) { if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) { MESSAGE("ERROR : read number of coefficient in the base function ..."); goto ERROR; } coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient); power = (med_int*) calloc(sizeof(med_int),nvariable*ncoefficient); if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) { MESSAGE("ERROR : read base function ..."); free(coefficient); free(power); goto ERROR; } free(coefficient); free(power); } ret=0; ERROR: /* close file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); ret=-1; } return ret; }
void convertImages(Arguments* args){ FILE* list; JetMasks masks; int x, y,i,j; char imagename[MAX_FILENAME_LENGTH]; char filename[MAX_FILENAME_LENGTH]; MESSAGE("Creating gabor masks."); masks = readMasksFile(args->maskFile); if(args->saveMasks){ for(y = 0; y < masks->size; y++){ char outname[MAX_FILENAME_LENGTH]; sprintf(outname, "mask%03d.pgm",y); writePGMImage(masks->masks[y],outname,0); } } list = fopen(args->imageList,"r"); if(!list){ printf("Error opening file: %s\n", args->imageList); exit(1); } while(fscanf(list, "%s", imagename) == 1){ Image im; Image grid; sprintf(filename, "%s/%s", args->inputDir, imagename); im = readRawImage(filename); MESSAGE1ARG("Processing file: %s",filename); /* Find the number of points in the grid */ i = 0; for( x = args->gridStartX; x < im->width; x += args->gridSpaceX){ for( y = args->gridStartY; y < im->height; y+= args->gridSpaceY){ i++; } } grid = makeImage(i,masks->size,1); /* Compute convolutions */ i = 0; for( x = args->gridStartX; x < im->width; x += args->gridSpaceX){ for( y = args->gridStartY; y < im->height; y+= args->gridSpaceY){ for(j = 0; j < masks->size; j++){ if( i < grid->width ) IE(grid,i,j,0) = convolvePoint(x, y, 0, im, masks->masks[j]); } i++; } } sprintf(filename, "%s/%s", args->sfiDir, imagename); writeRawImage(grid,filename); freeImage(grid); freeImage(im); } fclose(list); }