这篇教程C++ AlcMalloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AlcMalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ AlcMalloc函数的具体用法?C++ AlcMalloc怎么用?C++ AlcMalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AlcMalloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: WlzEffNodeEleFileNames/*!* /return Woolz error number.* /ingroup WlzExtFF* /brief Builds the node/ele file names from the given file name.* These strings should be free'd using AlcFree() when* no longer required.* /param fileBody Dest ptr for the file body.* /param nodeFileName Dest ptr for the '.node' file name.* /param eleFileName Dest ptr for the '.ele' file name.* /param gvnFileName Given file name with .node or no* extension.*/WlzErrorNum WlzEffNodeEleFileNames(char **fileBody, char **nodeFileName, char **eleFileName, const char *gvnFileName){ int tI0; WlzErrorNum errFlag = WLZ_ERR_MEM_ALLOC; tI0 = ((int )strlen(gvnFileName) + 5) * sizeof(char); if(((*fileBody = (char *)AlcMalloc(tI0)) != NULL) && ((*nodeFileName = (char *)AlcMalloc(tI0)) != NULL) && ((*eleFileName = (char *)AlcMalloc(tI0)) != NULL)) { (void )strcpy(*fileBody, gvnFileName); if((tI0 = (int )strlen(*fileBody) - 5) >= 0) { if((strcmp(*fileBody + tI0, ".node") == 0) || (strcmp(*fileBody + tI0, ".ele") == 0)) { *(*fileBody + tI0) = '/0'; } } (void )sprintf(*nodeFileName, "%s.node", *fileBody); (void )sprintf(*eleFileName, "%s.ele", *fileBody); errFlag = WLZ_ERR_NONE; } return(errFlag);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:40,
示例2: WlzEffAnlFileNames/*!* /return Woolz error code.* /ingroup WlzExtFF* /brief Builds the ANALYZE file names from the given file name.* These strings should be free'd using AlcFree() when* no longer required.* /param fileBody Dest ptr for the file body.* /param hdrFileName Dest ptr for the '.hdr' file* name.* /param imgFileName Dest ptr for the '.img' file* name.* /param gvnFileName Given file name with '.hdr',* '.img' or no extension.*/WlzErrorNum WlzEffAnlFileNames(char **fileBody, char **hdrFileName, char **imgFileName, const char *gvnFileName){ int tI0; WlzErrorNum errFlag = WLZ_ERR_MEM_ALLOC; tI0 = ((int )strlen(gvnFileName) + 5) * sizeof(char); if(((*fileBody = (char *)AlcMalloc(tI0)) != NULL) && ((*hdrFileName = (char *)AlcMalloc(tI0)) != NULL) && ((*imgFileName = (char *)AlcMalloc(tI0)) != NULL)) { (void )strcpy(*fileBody, gvnFileName); if((tI0 = (int )strlen(*fileBody) - 4) >= 0) { if((strcmp(*fileBody + tI0, ".hdr") == 0) || (strcmp(*fileBody + tI0, ".img") == 0)) { *(*fileBody + tI0) = '/0'; } } (void )sprintf(*hdrFileName, "%s.hdr", *fileBody); (void )sprintf(*imgFileName, "%s.img", *fileBody); errFlag = WLZ_ERR_NONE; } return(errFlag);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:42,
示例3: AlcPtr3Calloc/*!* /return Error code.* /ingroup AlcArray* /brief Allocates a 3 dimensional array of pointers to void.* /note Should be free'd using Alc3Free().* /note Array size is limited only by address space.* /param dest Destination for allocated array* pointer.* /param mElem Number of 2D arrays.* /param nElem Number of 1D arrays.* /param oElem Number of elements in each 1D* array.*/AlcErrno AlcPtr3Calloc(void *****dest, size_t mElem, size_t nElem, size_t oElem){ size_t index0, index1; void **dump0 = NULL, ***dump1 = NULL, ****dump2 = NULL; AlcErrno alcErrno = ALC_ER_NONE; if((dest) == NULL) { alcErrno = ALC_ER_NULLPTR; } else if((mElem < 1) || (nElem < 1) || (oElem < 1)) { alcErrno = ALC_ER_NUMELEM; } else if(((dump0 = (void **)AlcCalloc(mElem * nElem * oElem, sizeof(void *))) == NULL) || ((dump1 = (void ***)AlcMalloc(mElem * nElem * sizeof(void **))) == NULL) || ((dump2 = (void ****)AlcMalloc(mElem * sizeof(void ***))) == NULL)) { alcErrno = ALC_ER_ALLOC; } if(alcErrno == ALC_ER_NONE) { *(dest) = dump2; for(index0 = 0; index0 < mElem; ++index0) { for(index1=0; index1 < nElem; ++index1) { dump1[index1] = dump0; dump0 += oElem; } (*(dest))[index0] = dump1; dump1 += nElem; } } else { if(dest) { *(dest) = NULL; } AlcFree(dump2); AlcFree(dump1); AlcFree(dump0); } return(alcErrno);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:65,
示例4: AlcPtr2Malloc/*!* /return Error code.* /ingroup AlcArray* /brief Allocates a 2 dimensional non-zero'd array of pointers* to void.* /note Should be free'd using Alc2Free().* /note Array size is limited only by address space.* /param dest Destination for allocated array* pointer.* /param mElem Number of 1D arrays.* /param nElem Number of elements in each 1D* array.*/AlcErrno AlcPtr2Malloc(void ****dest, size_t mElem, size_t nElem){ size_t index; void **dump0 = NULL; void ***dump1 = NULL; AlcErrno alcErrno = ALC_ER_NONE; /* Template doesn't work for pointer types. */ if(dest == NULL) { alcErrno = ALC_ER_NULLPTR; } else if((mElem < 1) || (nElem < 1)) { alcErrno = ALC_ER_NUMELEM; } else if(((dump0 = (void **)AlcMalloc(mElem * nElem * sizeof(void *))) == NULL) || ((dump1 = (void ***)AlcMalloc(mElem * sizeof(void **))) == NULL)) { alcErrno = ALC_ER_ALLOC; } if(alcErrno == ALC_ER_NONE) { *dest = dump1; for(index = 0; index < mElem; ++index) { (*dest)[index] = dump0; dump0 += nElem; } } else { if(dest) { *dest = NULL; } if(dump0) { AlcFree(dump0); } if(dump1) { AlcFree(dump1); } } return(alcErrno);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:61,
示例5: AlcPtr1Malloc/*!* /return Error code.* /ingroup AlcArray* /brief Allocates a 1 dimensional non-zero'd array of pointers* to void.* /note Should be free'd using AlcFree().* /note Array size is limited only by address space.* /param dest Destination for allocated array* pointer.* /param mElem Number of elements in array.*/AlcErrno AlcPtr1Malloc(void ***dest, size_t mElem){ AlcErrno alcErrno = ALC_ER_NONE; /* Template doesn't work for pointer types. */ if(dest == NULL) { alcErrno = ALC_ER_NULLPTR; } else if(mElem < 1) { alcErrno = ALC_ER_NUMELEM; } else if((*dest = (void **)AlcMalloc(mElem * sizeof(void *))) == NULL) { alcErrno = ALC_ER_ALLOC; } if(alcErrno != ALC_ER_NONE) { if(dest) { *dest = NULL; } } return(alcErrno);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:37,
示例6: WlzTstReadVtxList/*!* /return Number of vertices read.* /ingroup binWlzTst* /brief Reads input vertices from file in the format:* <x> <y> <z>.* /param vtx Destination pointer for vertices.* /param fP Input file pointer.*/static int WlzTstReadVtxList(WlzDVertex3 **vtx, FILE *fP){ int ok = 1, inR = 0, inC = 0, nVtx = 0; double **inData = NULL; if((AlcDouble2ReadAsci(fP, &inData, (size_t *)&inR, (size_t *)&inC) != ALC_ER_NONE) || (inC != 3) || (inR < 1) || ((*vtx = AlcMalloc(inR * sizeof(WlzDVertex3))) == NULL)) { ok = 0; } if(ok) { int idx; nVtx = inR; for(idx = 0; idx < nVtx; ++idx) { (*vtx + idx)->vtX = inData[idx][0]; (*vtx + idx)->vtY = inData[idx][1]; (*vtx + idx)->vtZ = inData[idx][2]; } } AlcDouble2Free(inData); return(nVtx);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:39,
示例7: returnstatic WlzLLink *chainalloc(int flag, int n){ WlzLLink *chain; /* * memory allocation size determined by first allocation */ if (flag) n = allocthings.allocsize; else allocthings.allocsize = n; /* * allocate memory, chain to existing allocated memory */ if( (chain = (WlzLLink *) AlcMalloc((n+1) * sizeof(WlzLLink))) == NULL ){ return( NULL ); } chain->l_link = NULL; if (flag) { allocthings.chunk_base->l_link = chain; allocthings.chunk_base = chain; } else { allocthings.orig_base = allocthings.chunk_base = chain; } /* * retain first link for chaining allocated memory chunks */ return(chain+1);}
开发者ID:dscho,项目名称:Woolz,代码行数:29,
示例8: REC_DBG/*!* /return New registration section.* /ingroup Reconstruct* /brief Makes a registration section using the given member values.* /param index Section index.* /param iterations Number of iterations to find* section transform.* /param correlation Section correlation value.* /param imageFile Image file path, this is duplicated* so that the original may be freed* The image file path must not be NULL.* /param transform Section transform, if NULL an identity* transform is created.* /param obj Woolz object corresponding to the given* image file. This may be NULL without* causing the object to be read from the* associated file.*/RecSection *RecSecMake(int index, int iterations, double correlation, char *imageFile, WlzAffineTransform *transform, WlzObject *obj){ RecSection *sec = NULL; char *newImageFile = NULL; WlzAffineTransform *newTransform = NULL; WlzErrorNum wlzErr = WLZ_ERR_NONE; REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecMake FE %d %d %g 0x%lx 0x%lx 0x%lx/n", index, iterations, correlation, (unsigned long )imageFile, (unsigned long )transform, (unsigned long )obj)); if(imageFile) { newImageFile = AlcStrDup(imageFile); } if(newImageFile && (transform == NULL)) { newTransform = WlzAffineTransformFromPrimVal(WLZ_TRANSFORM_2D_AFFINE, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, &wlzErr); } if(newImageFile && (newTransform || transform) && (wlzErr == WLZ_ERR_NONE)) { sec = (RecSection *)AlcMalloc(sizeof(RecSection)); } if(sec == NULL) { if(newImageFile) { AlcFree(newImageFile); } if(newTransform) { WlzFreeAffineTransform(newTransform); } } else { sec->linkcount = 0; sec->index = index; sec->iterations = iterations; sec->correl = correlation; sec->obj = WlzAssignObject(obj, NULL); sec->imageFile = newImageFile; sec->transform = WlzAssignAffineTransform(transform? transform: newTransform, NULL); sec->transObj = NULL; sec->cumTransform = NULL; sec->cumTransObj = NULL; } REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecMake FX 0x%lx/n", (unsigned long )sec)); return(sec);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:77,
示例9: WlzMakeMain/*!* /return Integer array with values and coordinates from 3D object.* /ingroup WlzValueUtils* /brief Allocates a new array (4 ints per value: 0 = value,* 1 = x coordinate, 2 = y coordinate and 3 = z coordinate.* /param obj Given object which must be a valid* 3D domain object with integer values.* /param dstNAry Destination pointer for the number of* values, must not be NULL.* /param dstErr Destination error pointer, may be NULL.*/static int *WlzCompDispMakeValAry3D(WlzObject *obj, int *dstNAry, WlzErrorNum *dstErr){ int idO, idP, nAry; int *ary, *array = NULL; WlzObject *obj2D; WlzPlaneDomain *pDom; WlzErrorNum errNum = WLZ_ERR_NONE; if((nAry = WlzVolume(obj, &errNum)) <= 0) { errNum = WLZ_ERR_DOMAIN_DATA; } if(errNum == WLZ_ERR_NONE) { if((array = AlcMalloc(nAry * 4 * sizeof(int))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { ary = array; pDom = obj->domain.p; for(idP = pDom->plane1; (errNum == WLZ_ERR_NONE) && (idP <= pDom->lastpl); ++idP) { idO = idP - pDom->plane1; obj2D = WlzMakeMain(WLZ_2D_DOMAINOBJ, *(obj->domain.p->domains + idO), *(obj->values.vox->values + idO), NULL, NULL, &errNum); if(errNum == WLZ_ERR_NONE) { errNum = WlzCompDispSetAry(&ary, obj2D, idP, 3); WlzFreeObj(obj2D); } } } if(errNum != WLZ_ERR_NONE) { AlcFree(ary); ary = NULL; } else { *dstNAry = nAry; if(dstErr != NULL) { *dstErr = errNum; } } return(array);}
开发者ID:dscho,项目名称:Woolz,代码行数:68,
示例10: HGU_XmFileListAddFileWlzErrorNum HGU_XmFileListAddFile( AlcDLPList *fileList, String file, WlzEffFormat format){ HGU_XmFileListCallbackStruct *cbs; AlcDLPItem *item; WlzErrorNum errNum=WLZ_ERR_NONE; AlcErrno alcErr; /* check inputs */ if((fileList == NULL) || (file == NULL)){ errNum = WLZ_ERR_PARAM_NULL; } /* create new item and add to head of the list */ if( errNum == WLZ_ERR_NONE ){ /* check if already in the list, in which case bring it to the top */ item = fileList->head; while( item ){ cbs = (HGU_XmFileListCallbackStruct *) item->entry; if( !strcmp(file, cbs->file) ){ break; } if( item->next == fileList->head ){ item = NULL; } else { item = item->next; } } /* move or create new list item */ if( item ){ AlcDLPItemUnlink(fileList, item, 0, &alcErr); AlcDLPItemInsert(fileList, NULL, item); } else { cbs = (HGU_XmFileListCallbackStruct *) AlcMalloc(sizeof(HGU_XmFileListCallbackStruct)); cbs->file = AlcStrDup(file); cbs->format = format; AlcDLPListEntryInsert(fileList, NULL, (void *) cbs, HGU_XmFileListItemFree); } } while( AlcDLPListCount(fileList, &alcErr) > HGU_XMFILELIST_MAXNUMITEMS ){ AlcDLPItemUnlink( fileList, fileList->head->prev, 1, &alcErr); } return errNum;}
开发者ID:ma-tech,项目名称:HGUX,代码行数:55,
示例11: AlcDLPListNewAlcDLPList *HGU_XmFileListCreateList( String resourceFile, WlzErrorNum *dstErr){ AlcDLPList *list=NULL; FILE *fp; HGU_XmFileListCallbackStruct *cbs; int index; WlzErrorNum errNum=WLZ_ERR_NONE; AlcErrno alcErrno; /* check input parameters */ if( resourceFile == NULL ){ errNum = WLZ_ERR_PARAM_NULL; } /* create list */ list = AlcDLPListNew(&alcErrno); /* read file to get menu items */ if( errNum == WLZ_ERR_NONE ){ if( (fp = fopen(resourceFile, "r")) ){ BibFileRecord *bibfileRecord; BibFileError bibFileErr; /* search for file list entry */ bibFileErr = BibFileRecordRead(&bibfileRecord, NULL, fp); while( bibFileErr == BIBFILE_ER_NONE ){ /* create items and add to list */ if( !strncmp(bibfileRecord->name, "HGU_XmFileListFileRecord", 23) ){ cbs = (HGU_XmFileListCallbackStruct *) AlcMalloc(sizeof(HGU_XmFileListCallbackStruct)); errNum = WlzEffBibParseFileRecord(bibfileRecord, &index, &(cbs->file), &(cbs->format)); AlcDLPListEntryAppend(list, NULL, (void *) cbs, HGU_XmFileListItemFree); } BibFileRecordFree(&bibfileRecord); bibFileErr = BibFileRecordRead(&bibfileRecord, NULL, fp); } } else { errNum = WLZ_ERR_FILE_OPEN; } } if( dstErr ){ *dstErr = errNum; } return list;}
开发者ID:ma-tech,项目名称:HGUX,代码行数:53,
示例12: WlzBoundaryToPolyObjArray/*!* /return Woolz error code.* /ingroup WlzBoundary* /brief decomposes a boundary into it's component polygons.* /param bndObj Given boundary.* /param dstNumObjs Destination pointer for the number of polygons.* /param dstObjArray Destination pointer for the array of polygons.*/WlzErrorNum WlzBoundaryToPolyObjArray( WlzObject *bndObj, int *dstNumObjs, WlzObject ***dstObjArray){ WlzErrorNum errNum=WLZ_ERR_NONE; WlzDomain domain; WlzValues values; WlzObject *obj, **objs; WlzPolygonDomain **polyArray; int i, numPolys; /* check inputs */ if( bndObj == NULL ){ errNum = WLZ_ERR_OBJECT_NULL; } else if((dstNumObjs == NULL) || (dstObjArray == NULL)){ errNum = WLZ_ERR_PARAM_NULL; } else { /* generate array of poly domains */ errNum = WlzBoundObjToPolyDomArray(bndObj, &numPolys, &polyArray); } /* convert to polygon objects */ if( errNum == WLZ_ERR_NONE ){ if((objs = (WlzObject **) AlcMalloc(sizeof(WlzObject *)*numPolys)) == NULL){ errNum = WLZ_ERR_MEM_ALLOC; for(i=0; i < numPolys; i++){ WlzFreePolyDmn(polyArray[i]); } AlcFree(polyArray); numPolys = 0; } else { for(i=0; i < numPolys; i++){ domain.poly = polyArray[i]; values.core = NULL; obj = WlzMakeMain(WLZ_2D_POLYGON, domain, values, NULL, NULL, &errNum); objs[i] = WlzAssignObject(obj, NULL); WlzFreePolyDmn(polyArray[i]); } AlcFree(polyArray); } } *dstNumObjs = numPolys; *dstObjArray = objs; return errNum;}
开发者ID:dscho,项目名称:Woolz,代码行数:59,
示例13: AlgDPTotalCosts/*!* /return zero* /ingroup AlgDPSearch* /brief* /param imax number of points on the path* /param jmax number of locations per path point* /param optimal_cost return for optimal path cost through each point* /param optimal_path return for optimal path through each point.* /param non_local_cost non-local cost function calculated in terms*/int AlgDPTotalCosts( int imax, int jmax, double **optimal_cost, int **optimal_path, double (*non_local_cost)(int, int, int, int **)){ int i, j, jp; double cost, min_cost, *tmp; /* now determine the total optimal-costs for each point */ tmp = (double *) AlcMalloc(sizeof(double) * jmax); for(i=imax-1; i > 0; i--) { for(j=0; j < jmax; j++) { cost = optimal_cost[i][0] - optimal_cost[i-1][optimal_path[i][0]] + (*non_local_cost)(i,0,j,optimal_path) - (*non_local_cost)(i,0,optimal_path[i][0], optimal_path); min_cost = cost; for(jp=1; jp < jmax; jp++) { cost = optimal_cost[i][jp] - optimal_cost[i-1][optimal_path[i][jp]] + (*non_local_cost)(i,jp,j,optimal_path) - (*non_local_cost)(i,jp, optimal_path[i][jp], optimal_path); if( cost < min_cost ) { min_cost = cost; } } tmp[j] = min_cost; } for(j=0; j < jmax; j++) { optimal_cost[i-1][j] += tmp[j]; } } AlcFree( tmp ); return( 0 );}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:56,
示例14: WlzBoundObjToPolyDomArray/*!* /return Array of polygon domains.* /ingroup WlzBoundary* /brief Given a boundary list object returns a simple array of* polygon domains.* /param bndObj Given boundary list object.* /param dstArySz Destination ptr for array size.* /param dstPolyAry Destination ptr for the array.*/WlzErrorNum WlzBoundObjToPolyDomArray(WlzObject *bndObj, int *dstArySz, WlzPolygonDomain ***dstPolyAry){ int idx, polyCnt; WlzPolygonDomain **polyAry = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; if(bndObj == NULL) { errNum = WLZ_ERR_OBJECT_NULL; } else if(bndObj->type != WLZ_BOUNDLIST) { errNum = WLZ_ERR_OBJECT_TYPE; } else if(bndObj->domain.b == NULL) { errNum = WLZ_ERR_DOMAIN_NULL; } else if((dstArySz == NULL) || (dstPolyAry == NULL)) { errNum = WLZ_ERR_PARAM_NULL; } /* Count number of polydomains in the boundary list. */ polyCnt = WlzBoundPolyCount(bndObj->domain.b, &errNum); /* Allocate array for polygon domain pointers. */ if(errNum == WLZ_ERR_NONE) { if((polyAry = (WlzPolygonDomain **)AlcMalloc(sizeof(WlzPolygonDomain *) * polyCnt)) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } /* Fill in the Array. */ if(errNum == WLZ_ERR_NONE) { idx = 0; WlzBoundObjToPolyFillArray(bndObj->domain.b, polyAry, &idx); *dstArySz = polyCnt; *dstPolyAry = polyAry; } return(errNum);}
开发者ID:dscho,项目名称:Woolz,代码行数:54,
示例15: addToBndListvoid addToBndList( AlcDLPList *list, char *name, WlzBoundList *bnd){ AlcDLPItem *bndItem; NamedBndItem *namedBndItem; WlzBoundList *tmpBnd; /* check if name exists */ bndItem = list->head; namedBndItem = NULL; while( bndItem ){ namedBndItem = (NamedBndItem *) bndItem->entry; if( strcmp(name, namedBndItem->name) == 0 ){ break; } namedBndItem = NULL; bndItem = bndItem->next; if( bndItem == list->head ){ break; } } if( namedBndItem ){ tmpBnd = namedBndItem->bnd; while(tmpBnd->next){ tmpBnd = tmpBnd->next; } tmpBnd->next = WlzAssignBoundList(bnd, NULL); } else { /* create a NamedBndItem */ namedBndItem = (NamedBndItem *) AlcMalloc(sizeof(NamedBndItem)); namedBndItem->name = name; namedBndItem->bnd = bnd; /* add to the list */ AlcDLPListEntryAppend(list, NULL, (void *) namedBndItem, NULL); } return;}
开发者ID:dscho,项目名称:Woolz,代码行数:43,
示例16: HGU_XmFileListResetMenuWlzErrorNum HGU_XmFileListResetMenu( AlcDLPList *fileList, Widget cascade, XtCallbackProc callbackProc){ WlzErrorNum errNum=WLZ_ERR_NONE; Widget menu=NULL, widget; MenuItem *items; HGU_XmFileListCallbackStruct *cbs; int i; char *strbuf; if( cascade ){ XtVaGetValues(cascade, XmNsubMenuId, &menu, NULL); if( menu ){ XtDestroyWidget(menu); } items = HGU_XmFileListCreateMenuItems(fileList, callbackProc, NULL); menu = HGU_XmBuildPulldownMenu(cascade, XmTEAR_OFF_DISABLED, False, False, items); /* add tool-tips */ for(i=0; items[i].name != NULL; i++){ if( (cbs = (HGU_XmFileListCallbackStruct *) items[i].callback_data) ){ if(strcmp(items[i].name, "separator") && strcmp(items[i].name, "Clear list")){ strbuf = AlcMalloc(sizeof(char)*(strlen(cbs->file)+4)); sprintf(strbuf, "*%s", cbs->file); if((widget = XtNameToWidget(menu, strbuf))){ HGU_XmAddToolTip(HGU_XmGetTopShell(cascade), widget, cbs->file); } AlcFree(strbuf); } } } HGU_XmFileListDestroyMenuItems(items); } return errNum;}
开发者ID:ma-tech,项目名称:HGUX,代码行数:41,
示例17: AlgMatrixRSEigen/*!* /return Error code.* /ingroup AlgMatrix* /brief Determines the eigenvalues and eigenvectors of a* real symmetric matrix by calling AlgMatrixRSTDiag()* to create a tridiagonal symmetric matrix and then* AlgMatrixTDiagQLI() to compute its eigenvalues and* eigenvectors. The eigenvectors and eigenvalues * are returned in descending eigenvalue order.* For efficiency, the eigenvectors should only be* computed if required.* /param aM Given real symmetric matrix* which contains the eigenvectors* in it's columns on return if* required.* /param vM Given vector for the return of the* eigenvalues.* /param reqEV Non zero if the eigenvectors are* required.*/AlgError AlgMatrixRSEigen(AlgMatrix aM, double *vM, int reqEV){ double *oM = NULL; AlgError errCode = ALG_ERR_NONE; if((aM.core == NULL) || (aM.core->type != ALG_MATRIX_RECT) || (aM.core->nR <= 0) || (aM.core->nR != aM.core->nC) || (vM == NULL)) { errCode = ALG_ERR_FUNC; } else { if((oM = (double *)AlcMalloc(sizeof(double) * aM.core->nR)) == NULL) { errCode = ALG_ERR_MALLOC; } if(errCode == ALG_ERR_NONE) { if((errCode = AlgMatrixRSTDiag(aM, vM, oM)) == ALG_ERR_NONE) { AlgMatrix rM; rM.core = (reqEV == 0)? NULL: aM.core; errCode = AlgMatrixTDiagQLI(vM, oM, aM.core->nR, rM); } } if(errCode == ALG_ERR_NONE) { AlgMatrixRSEigenSort(aM.rect->array, vM, aM.core->nR, reqEV); } if(oM) { AlcFree(oM); } } return(errCode);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:58,
示例18: RecSecListToStrList/*!* /return Error code.* /ingroup Reconstruct* /brief Creates a list of strings from a registration serial* section list and a bit mask for the fields required.* This is NOT intended to be used for output to a file* (RecFileSecWrite() should be used). This function was* written to allow a user to be presented with a simple* list of serial sections within a GUI application.* /param strList Destination pointer for list of* strings.* /param secList Given section list.* /param numSec Number of sections in secList.* /param eMsg Destination pointer for messages.* /param reqFields Bit mask for fields required* in the strings.*/RecError RecSecListToStrList(char ***strList, HGUDlpList *secList, int numSec, char **eMsg, unsigned int reqFields){ int secIdx = 0; HGUDlpListItem *secItem; RecSection *sec; RecError errFlag = REC_ERR_NONE; REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecListToStrList FE 0x%lx 0x%lx %d 0x%lx %d/n", (unsigned long )strList, (unsigned long )secList, numSec, (unsigned long )eMsg, reqFields)); if((*strList = (char **)AlcMalloc(sizeof(char **) * numSec)) != NULL) /* Allocate string list */ { secItem = HGUDlpListHead(secList); while(secItem && ((sec = HGUDlpListEntryGet(secList, secItem)) != NULL) && (secIdx < numSec) && (errFlag == REC_ERR_NONE)) { if((*(*strList + secIdx) = RecSecToStr(sec, reqFields, eMsg)) == NULL) { errFlag = REC_ERR_MALLOC; } else { secItem = HGUDlpListNext(secList, secItem); ++secIdx; } } } REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecListToStrList FX %d/n", errFlag)); return(errFlag);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:54,
示例19: WlzEffAmReadArray3D/*!* /return Woolz error code.* /ingroup WlzExtFF* /brief Read the block of data at the current file position into the* given Alc style array which has already been allocated.* /param fP File pointer at ready to read * first datum.* /param data Alc style 3D array.* /param head Amira lattice file header.* /param gType Grey type to be read.*/static WlzErrorNum WlzEffAmReadArray3D(FILE *fP, void ***data, WlzEffAmHead *head, WlzGreyType gType){ int nDst; size_t datumSz; void *buf = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; switch(gType) { case WLZ_GREY_UBYTE: datumSz = sizeof(WlzUByte); break; case WLZ_GREY_SHORT: datumSz = sizeof(short); break; default: errNum = WLZ_ERR_READ_INCOMPLETE; break; } if(errNum == WLZ_ERR_NONE) { switch(head->latComp) { case WLZEFF_AM_LATCOMP_NONE: if(fread(**data, datumSz, head->latBytes, fP) != head->latBytes) { errNum = WLZ_ERR_READ_INCOMPLETE; } if((errNum == WLZ_ERR_NONE) && (gType == WLZ_GREY_SHORT) && (head->endian = WLZEFF_AM_ENDIAN_LITTLE)) { WlzEffAmSwapBytes(buf, head->latBytes); } break; case WLZEFF_AM_LATCOMP_HXBYTERLE: if((buf = AlcMalloc(datumSz * head->latBytes)) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } else if(fread(buf, datumSz, head->latBytes, fP) != head->latBytes) { errNum = WLZ_ERR_MEM_ALLOC; } else { if((gType == WLZ_GREY_SHORT) && (head->endian = WLZEFF_AM_ENDIAN_LITTLE)) { WlzEffAmSwapBytes(buf, head->latBytes); } nDst = head->latSize.vtX * head->latSize.vtY * head->latSize.vtZ; switch(gType) { case WLZ_GREY_UBYTE: WlzEffAmBufDecodeHXByteRLEUByte(**(WlzUByte ***)data, (WlzUByte *)buf, nDst, head->latBytes); break; case WLZ_GREY_SHORT: WlzEffAmBufDecodeHXByteRLEShort(**(short ***)data, (short *)buf, nDst, head->latBytes); break; default: break; } } AlcFree(buf); break; default: errNum = WLZ_ERR_READ_INCOMPLETE; break; } } return(errNum);}
开发者ID:dscho,项目名称:Woolz,代码行数:88,
示例20: D//.........这里部分代码省略......... s = (double )(u[1]) / (double )u01; } break; case WLZ_RCC_ENC: /* |/Omega_0 /cup /Omega_1^{/circ}|/|/Omega_0| = * v_0 / u_0 */ if(u[1] >= 0) { s = (double )(v[0]) / (double )(u[0]); } break; case WLZ_RCC_ENCI: /* |/Omega_0^{/circ} /cup /Omega_1|/|/Omega_1| = * v_1 / u_1 */ if(v[1] >= 0) { s = (double )(v[1]) / (double )(u[1]); } break; default: break; } if(errNum == WLZ_ERR_NONE) { stats[i] = s; } } } } /* If offset is required check for it and add to both the classification * mask and statistics. */ if((errNum == WLZ_ERR_NONE) && (noOst == 0) && ((cls & WLZ_RCC_EQ) == 0)) { int ostQ[3]; errNum = WlzRCCOffset(o, t, maxOstDist, &(ostQ[0]), &(ostQ[1]), &(ostQ[2])); if(errNum == WLZ_ERR_NONE) {#ifdef WLZ_RCC_DEBUG_OST (void )fprintf(stderr, "WLZ_RCC_DEBUG_OST %d %d %d/n", ostQ[0], ostQ[1], ostQ[2]);#endif if((ostQ[1] > 0) && (ostQ[1] < maxOstDist) && (ostQ[2] >= ostQ[0])) { const double eps = 1.0e-06; if(ostQ[2] > ostQ[0]) { stats[WLZ_RCCIDX_OST] = (double )ostQ[1] / (double )(ostQ[2] + ostQ[1] - ostQ[0]); } else { stats[WLZ_RCCIDX_OST] = 1.0; } if(stats[WLZ_RCCIDX_OST] > (0.5 - eps)) { cls |= WLZ_RCC_OST; } } } } /* Free objects. */ for(i = 0; i < WLZ_RCCTOIDX_CNT; ++i) { (void )WlzFreeObj(t[i]); } for(i = 0; i <= 8; ++i) { (void )WlzFreeObj(c[i]); } for(i = 0; i < 2; ++i) { (void )WlzFreeObj(o[i]); } if((errNum == WLZ_ERR_NONE) && (dstStatAry != NULL)) { if((*dstStatAry = (double *) AlcMalloc(sizeof(double) * WLZ_RCCIDX_CNT)) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } else { (void )memcpy(*dstStatAry, stats, sizeof(double) * WLZ_RCCIDX_CNT); if(dstStatCnt) { *dstStatCnt = WLZ_RCCIDX_CNT; } } } if(dstErr) { *dstErr = errNum; } return(cls);}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
示例21: mainint main(int argc, char **argv){ WlzObject *obj1, *obj, **objlist; WlzObjectType type = (WlzObjectType) -1; int n, nmax; FILE *inFile; char optList[] = "n:h"; int option; const char *errMsg; WlzErrorNum errNum = WLZ_ERR_NONE; /* read the argument list and check for an input file */ opterr = 0; nmax = 100; while( (option = getopt(argc, argv, optList)) != EOF ) { switch( option ) { case 'n': nmax = atoi(optarg); if( nmax < 1 ) { fprintf(stderr, "%s: nmax = %d is invalid/n", argv[0], nmax); usage(argv[0]); return( 1 ); } break; case 'h': default: usage(argv[0]); return( 1 ); } } inFile = stdin; if( optind < argc ) { if( (inFile = fopen(*(argv+optind), "r")) == NULL ) { fprintf(stderr, "%s: can't open file %s/n", argv[0], *(argv+optind)); usage(argv[0]); return( 1 ); } } /* allocate space for the object pointers */ if( (objlist = (WlzObject **) AlcMalloc(sizeof(WlzObject *) * nmax)) == NULL ) { (void )fprintf(stderr, "%s: memory allocation failed./n", argv[0]); return( 1 ); } /* read objects accumulating compatible types */ n = 0; while(((obj = WlzReadObj(inFile, NULL)) != NULL) && (n < nmax) ) { if( type == -1 && (obj->type == WLZ_2D_DOMAINOBJ || obj->type == WLZ_3D_DOMAINOBJ) ) { type = obj->type; } if( (obj->type == type) || (obj->type == WLZ_EMPTY_OBJ) ) { objlist[n++] = WlzAssignObject(obj, NULL); } else { WlzFreeObj( obj ); } } if((obj1 = WlzUnionN(n, objlist, 1, &errNum)) == NULL) { (void )WlzStringFromErrorNum(errNum, &errMsg); (void )fprintf(stderr, "%s: failed to perform union (%s)./n", argv[0], errMsg); return(1); } else { if((errNum = WlzWriteObj(stdout, obj1)) != WLZ_ERR_NONE) { (void )WlzStringFromErrorNum(errNum, &errMsg); (void )fprintf(stderr, "%s: failed to write union object (%s)./n", argv[0], errMsg); } } /* freespace so purify can check for leaks */ WlzFreeObj(obj1); while( n-- ) { WlzFreeObj(objlist[n]); } AlcFree((void *) objlist); return( 0 );}
开发者ID:omsai,项目名称:Woolz,代码行数:93,
示例22: WlzEffWriteObjCM2D5Stl/*!* /return Woolz error number.* /ingroup WlzExtFF* /brief Writes the given Woolz object (which is known to be a* WLZ_CMESH_2D5) object to the given file stream using the* stereolithography stl file format, see WlzEffReadObjStl().* /param fP Output file stream.* /param obj Given woolz object (must not be NULL).*/static WlzErrorNum WlzEffWriteObjCM2D5Stl(FILE *fP, WlzObject *obj){ int *nodTbl = NULL; WlzCMesh2D5 *mesh; WlzErrorNum errNum = WLZ_ERR_NONE; if(obj->domain.core == NULL) { errNum = WLZ_ERR_DOMAIN_NULL; } else { mesh = obj->domain.cm2d5; if(mesh->type != WLZ_CMESH_2D5) { errNum = WLZ_ERR_DOMAIN_TYPE; } } if(errNum == WLZ_ERR_NONE) { if((nodTbl = (int *)AlcMalloc(mesh->res.nod.maxEnt * sizeof(int))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { if(fprintf(fP, "solid ascii/n") <= 0) { errNum = WLZ_ERR_WRITE_INCOMPLETE; } } /* Output the elements. */ if(errNum == WLZ_ERR_NONE) { int idE; WlzDVertex3 nrm; WlzCMeshElm2D5 *elm; WlzCMeshNod2D5 *nod[3]; for(idE = 0; idE < mesh->res.elm.maxEnt; ++idE) { elm = (WlzCMeshElm2D5 *)AlcVectorItemGet(mesh->res.elm.vec, idE); if(elm->idx >= 0) { WlzCMeshElmGetNodes2D5(elm, nod + 0, nod + 1, nod + 2); nrm = WlzGeomTriangleNormal(nod[0]->pos, nod[1]->pos, nod[2]->pos); if(fprintf(fP, " facet normal %g %g %g/n" " outer loop/n" " vertex %g %g %g/n" " vertex %g %g %g/n" " vertex %g %g %g/n" " endloop/n" " endfacet/n", nrm.vtX, nrm.vtY, nrm.vtZ, nod[0]->pos.vtX, nod[0]->pos.vtY, nod[0]->pos.vtZ, nod[1]->pos.vtX, nod[1]->pos.vtY, nod[1]->pos.vtZ, nod[2]->pos.vtX, nod[2]->pos.vtY, nod[2]->pos.vtZ) <= 0) { errNum = WLZ_ERR_WRITE_INCOMPLETE; break; } } } } if(errNum == WLZ_ERR_NONE) { if(fprintf(fP, "endsolid/n") <= 0) { errNum = WLZ_ERR_WRITE_INCOMPLETE; } } return(errNum);}
开发者ID:dscho,项目名称:Woolz,代码行数:84,
示例23: file_menu_initvoid file_menu_init( Widget topl){ Widget rc, form, toggle; Visual *visual; Arg arg[1]; char fileStr[128]; FILE *fp; WlzEffFormat image_type=WLZEFF_FORMAT_WLZ; /* set the top-level title */ set_topl_title(NULL); /* get the visual explicitly */ visual = HGU_XmWidgetToVisual(topl); XtSetArg(arg[0], XmNvisual, visual); /* create the read-model file selection dialog */ read_model_dialog = XmCreateFileSelectionDialog(topl, "read_model_dialog", arg, 1); XtAddCallback(read_model_dialog, XmNokCallback, read_reference_object_cb, (XtPointer) WLZEFF_FORMAT_WLZ); XtAddCallback(read_model_dialog, XmNokCallback, PopdownCallback, NULL); XtAddCallback( read_model_dialog, XmNcancelCallback, PopdownCallback, NULL); XtAddCallback(read_model_dialog, XmNmapCallback, FSBPopupCallback, NULL); XtManageChild( read_model_dialog ); /* create the read-obj file selection dialog */ read_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "read_obj_dialog", read_reference_object_cb, NULL); if((rc = XtNameToWidget(read_obj_dialog, "*.formatFormRC"))){ /* add a form to include file type and fill-blanks toggle */ form = XtVaCreateManagedWidget("read_file_form", xmFormWidgetClass, rc, XmNborderWidth, 0, NULL); /* add a fill-blanks toggles */ toggle = XtVaCreateManagedWidget("fill_blanks", xmToggleButtonGadgetClass, form, XmNindicatorOn, True, XmNindicatorType, XmN_OF_MANY, XmNset, False, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, NULL); toggle = XtVaCreateManagedWidget("min_domain", xmToggleButtonGadgetClass, form, XmNindicatorOn, True, XmNindicatorType, XmN_OF_MANY, XmNset, True, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, toggle, NULL); } HGU_XmExtFFObjectFSBSetType(read_obj_dialog, WLZEFF_FORMAT_WLZ); XtManageChild( read_obj_dialog ); /* add to the save restore list */ HGU_XmSaveRestoreAddWidget( read_obj_dialog, HGU_XmFSD_SaveFunc, (XtPointer) XtName(topl), NULL, NULL ); /* create the write-obj file selection dialog */ write_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "write_obj_dialog", write_reference_object_cb, NULL); HGU_XmExtFFObjectFSBSetType(write_obj_dialog, WLZEFF_FORMAT_WLZ); /* initialise the reference file list pulldown */ if( !globals.sectViewFlg ){ Widget cascade; if((cascade = XtNameToWidget(globals.topl, "*file_menu*_pulldown*Recent"))){ globals.resourceFile = (String) AlcMalloc(sizeof(char) * (strlen(getenv("HOME")) + 16)); sprintf(globals.resourceFile, "%s/%s", getenv("HOME"), ".maRecentFiles"); globals.fileList = HGU_XmFileListCreateList(globals.resourceFile, NULL); HGU_XmFileListResetMenu(globals.fileList, cascade, referenceFileListCb); } } /* add to the save restore list */ HGU_XmSaveRestoreAddWidget( write_obj_dialog, HGU_XmFSD_SaveFunc, (XtPointer) XtName(topl), NULL, NULL ); /* create the object properties dialog */ obj_props_dialog_init( topl ); globals.file = NULL; globals.obj = NULL; globals.orig_obj = NULL; globals.fb_obj = NULL;//.........这里部分代码省略.........
开发者ID:ma-tech,项目名称:MAPaint,代码行数:101,
示例24: WlzDistMetricDirVertex3D/*!* /return Woolz error code.* /ingroup WlzFeatures* /brief Computes any combination of the directed Hausdorff, mean* nearest neighbour, median nearest neighbour and* minimum nearest neighbour distances* between the given sets of vertices.* See WlzDistMetricDirVertex2D() for an explaination of the* distance metrics.* /param n0 Number of vertices in the first* array.* /param vx0 First array of vertices.* /param n1 Number of vertices in the second* array.* /param vx1 Second array of vertices.* /param dstDistH Destination pointer for the directed* Hausdorff distance, may be NULL.* /param dstDistM Destination pointer for the directed* mean nearest neighbour distance, may* be NULL.* /param dstDistN Destination pointer for the directed* median nearest neighbour distance, may* be NULL.* /param dstDistI Destination pointer for the minimum* nearest neighbour distance, may* be NULL.*/WlzErrorNum WlzDistMetricDirVertex3D(int n0, WlzDVertex3 *vx0, int n1, WlzDVertex3 *vx1, double *dstDistH, double *dstDistM, double *dstDistN, double *dstDistI){ int id0, cCnt; double cDist, mDist, sDist, iDist; int *iWSp = NULL; double *nnDist = NULL; double vxD3[3]; WlzVertexP tVP; AlcKDTNode *tNode; AlcKDTTree *tTree = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; if((vx0 == NULL) || (vx1 == NULL)) { errNum = WLZ_ERR_PARAM_NULL; } else if((n0 <= 0) || (n1 <= 0)) { errNum = WLZ_ERR_PARAM_DATA; } else if((iWSp = (int *)AlcMalloc(n1 * sizeof(int))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } else { if(dstDistN) { if((nnDist = (double *)AlcMalloc(n0 * sizeof(double))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } } if(errNum == WLZ_ERR_NONE) { tVP.d3 = vx1; tTree = WlzVerticesBuildTree(WLZ_VERTEX_D3, n1, tVP, iWSp, &errNum); } if(errNum == WLZ_ERR_NONE) { cCnt = 0; iDist = DBL_MAX; sDist = mDist = 0.0; for(id0 = 0; id0 < n0; ++id0) { vxD3[0] = (vx0 + id0)->vtX; vxD3[1] = (vx0 + id0)->vtY; vxD3[2] = (vx0 + id0)->vtZ; tNode = AlcKDTGetNN(tTree, vxD3, DBL_MAX, &cDist, NULL); if(tNode) { sDist += cDist; if(cDist > mDist) { mDist = cDist; } if(nnDist) { *(nnDist + cCnt) = cDist; } if(cDist < iDist) { iDist = cDist; } ++cCnt;//.........这里部分代码省略.........
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
示例25: if/*!* /return Object read from file.* /ingroup WlzExtFF* /brief Reads a Woolz object from the given stream using the* GRUMMP vmesh tetrahedral mesh file format.* /param fP Input file stream.* /param dstErr Destination error number ptr, may be* NULL.*/WlzObject *WlzEffReadObjEMT(FILE *fP, WlzErrorNum *dstErr){ int nElm = 0, nNod = 0; char *str; WlzDVertex3 *vBuf = NULL; WlzCMesh3D *mesh = NULL; WlzObject *obj = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; char cBuf[256]; if(fP == NULL) { errNum = WLZ_ERR_PARAM_NULL; } else { int idC = 0; /* Optional records may be comments starting with a '#' but apart * from these the first line should have a single integer specifying * the number of nodes. */ do { if((str = WlzEffReadObjEMTRec(fP, cBuf, 256)) == NULL) { errNum = WLZ_ERR_READ_INCOMPLETE; } else if(*str != '#') { if((idC = sscanf(str, "%d", &nNod)) != 1) { errNum = WLZ_ERR_READ_INCOMPLETE; } } } while((errNum == WLZ_ERR_NONE) && (idC != 1)); } /* Check for reasonable number of nodes. */ if(errNum == WLZ_ERR_NONE) { if(nNod <= 0) { errNum = WLZ_ERR_READ_INCOMPLETE; } } /* Create a new 3D constrained mesh. */ if(errNum == WLZ_ERR_NONE) { mesh = WlzCMeshNew3D(&errNum); } /* Read in the node positions into a temporary buffer computing their * bounding box and then create the nodes. */ if(errNum == WLZ_ERR_NONE) { if((vBuf = AlcMalloc(sizeof(WlzDVertex3) * nNod)) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { int idN = 0; while(idN < nNod) { if((str = WlzEffReadObjEMTRec(fP, cBuf, 256)) == NULL) { errNum = WLZ_ERR_READ_INCOMPLETE; break; } else if(*str != '#') { if(sscanf(str, "%lg %lg %lg", &(vBuf[idN].vtX), &(vBuf[idN].vtY), &(vBuf[idN].vtZ)) != 3) { errNum = WLZ_ERR_READ_INCOMPLETE; break; } ++idN; } } } if(errNum == WLZ_ERR_NONE) { mesh->bBox = WlzBoundingBoxVtx3D(nNod, vBuf, NULL); if(AlcVectorExtendAndGet(mesh->res.nod.vec, nNod) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE)//.........这里部分代码省略.........
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
示例26: WlzEffWriteObjEMT/*!* /return Woolz error number.* /ingroup WlzExtFF* /brief Writes the given Woolz object to the given stream using the* Netgen neutral mesh file format.* /param fP Output file stream.* /param obj Given woolz object.*/WlzErrorNum WlzEffWriteObjEMT(FILE *fP, WlzObject *obj){ int nBFce = 0, nElm = 0, nNod = 0; int *nodTbl = NULL; WlzCMesh3D *mesh; WlzErrorNum errNum = WLZ_ERR_NONE; if(fP == NULL) { errNum = WLZ_ERR_PARAM_NULL; } else if(obj == NULL) { errNum = WLZ_ERR_OBJECT_NULL; } else if(obj->type != WLZ_CMESH_3D) { errNum = WLZ_ERR_OBJECT_TYPE; } else if(obj->domain.core == NULL) { errNum = WLZ_ERR_DOMAIN_NULL; } else { mesh = obj->domain.cm3; if(mesh->type != WLZ_CMESH_3D) { errNum = WLZ_ERR_DOMAIN_TYPE; } } if(errNum == WLZ_ERR_NONE) { if((nodTbl = (int *) AlcMalloc(mesh->res.nod.maxEnt * sizeof(int))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } /* Compute the number of boundary faces while building an element table to * avoid deleted elements. */ if(errNum == WLZ_ERR_NONE) { int idE; nNod = mesh->res.nod.numEnt; for(idE = 0; idE < mesh->res.elm.maxEnt; ++idE) { WlzCMeshElm3D *elm; elm = (WlzCMeshElm3D *)AlcVectorItemGet(mesh->res.elm.vec, idE); if(elm->idx >= 0) { int idF; for(idF = 0; idF < 4; ++idF) { if((elm->face[idF].opp == NULL) || (elm->face[idF].opp == &(elm->face[idF]))) { ++nBFce; } } ++nElm; } } } /* Output the number of nodes. */ if(errNum == WLZ_ERR_NONE) { if(fprintf(fP, "%d/n", nNod) <= 0) { errNum = WLZ_ERR_WRITE_INCOMPLETE; } } /* Output the node positions while building a node table to avoid deleted * nodes. */ if(errNum == WLZ_ERR_NONE) { int idC = 0, idN; for(idN = 0; idN < mesh->res.nod.maxEnt; ++idN) { WlzCMeshNod3D *nod; nod = (WlzCMeshNod3D *)AlcVectorItemGet(mesh->res.nod.vec, idN); if(nod->idx >= 0) {//.........这里部分代码省略.........
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
示例27: WlzLabel/*! * /ingroup WlzBinaryOps* /brief Segment a domain into connected parts. Connectivity is defined by the connect parameter and can be 4- or 8-connected for 2D objects and 6-, 18- or 26-connected for 3D objects. Note this version requires that there is sufficient space in the objects array defined by maxNumObjs and this is not extended. This should be changed in future so that the array is extended as required.** /return Error number.* /param obj input object to be segmented* /param mm number of objects return* /param dstArrayObjs object array return, allocated in the procedure.* /param maxNumObjs maximum number of object to return (determines the size of the array)* /param ignlns ignore objects with num lines <= ignlns* /param connect connectivity to determine connected regions* /par Source:* WlzLabel.c*/WlzErrorNum WlzLabel( WlzObject *obj, int *mm, WlzObject ***dstArrayObjs, int maxNumObjs, int ignlns, WlzConnectType connect){ WlzIntervalDomain *jdp; WlzRagRValues *jvp; WlzIntervalWSpace iwsp; WlzInterval *itvl; WlzInterval *jtvl; WlzLAllocBuf *crntal, *altemp; WlzLAllocBuf *al, *crntst, *crlast; WlzLAllocBuf *precal, *precst, *prlast; int nints, mkl; int maxinline,nob,line,ended,lend,chainlistsize; WlzLLink *freechain, *alprec, *alloc, *link1, *link2; int lftcrn, lftprc, rtcrn, rtprec; int jrtcrn, mxkl, jl, jr; int oll, ofl, jjj; WlzDomain domain; WlzValues values; int jdqt; WlzErrorNum errNum=WLZ_ERR_NONE; WlzObject **objlist; /* see HISTORY for comments from the FORTRAN version */ /* now we allocate space for the objects */ if( (objlist = (WlzObject **)AlcMalloc(sizeof(WlzObject *) * maxNumObjs)) == NULL ){ errNum = WLZ_ERR_MEM_ALLOC; } else { *dstArrayObjs = objlist; } /* check object note *mm is always set to zero on error return because the "Too many objects" error can return nobj valid objects therefore if *mm != 0 there are valid objects in objlist which must be freed */ if( obj == NULL ){ *mm = 0; return WLZ_ERR_OBJECT_NULL; } /* check types */ switch( obj->type ){ case WLZ_2D_DOMAINOBJ: if( obj->domain.core == NULL ){ *mm = 0; return WLZ_ERR_DOMAIN_NULL; } switch( obj->domain.core->type ){ case WLZ_INTERVALDOMAIN_INTVL: break; case WLZ_INTERVALDOMAIN_RECT: if( (obj->domain.i->lastln - obj->domain.i->line1) < ignlns ){ *mm = 0; return( WLZ_ERR_NONE ); } if( maxNumObjs < 1 ){ *mm = 0; return( WLZ_ERR_INT_DATA ); } objlist[0] = WlzAssignObject( WlzMakeMain(obj->type, obj->domain, obj->values, NULL, NULL, &errNum), NULL); *mm = 1; return WLZ_ERR_NONE;//.........这里部分代码省略.........
开发者ID:dscho,项目名称:Woolz,代码行数:101,
示例28: WlzBoundingBox2I//.........这里部分代码省略......... WlzPixelV zeroBgd; const int samFacStep = 4, maxSam = 16, minSamSz = 100; zeroBgd.type = WLZ_GREY_INT; zeroBgd.v.inv = 0; gV[0].type = gV[1].type = gV[2].type = gV[3].type = WLZ_GREY_DOUBLE; /* Compute the number of x4 subsampling operations to use. */ sBox = WlzBoundingBox2I(sObj, &errNum); if(errNum == WLZ_ERR_NONE) { tBox = WlzBoundingBox2I(tObj, &errNum); } if(errNum == WLZ_ERR_NONE) { tIV0.vtX = sBox.xMax - sBox.xMin + 1; tIV0.vtY = sBox.yMax - sBox.yMin + 1; tIV1.vtX = tBox.xMax - tBox.xMin + 1; tIV1.vtY = tBox.yMax - tBox.yMin + 1; tIV0.vtX = WLZ_MIN(tIV0.vtX, tIV1.vtX); tIV0.vtY = WLZ_MIN(tIV0.vtY, tIV1.vtY); nSam = 1; tI1 = WLZ_MIN(tIV0.vtX, tIV0.vtY); while((nSam < maxSam) && (tI1 > minSamSz)) { ++nSam; tI1 /= samFacStep; } } /* Allocate space for subsampled objects. */ if(errNum == WLZ_ERR_NONE) { if(((samFac = (int *)AlcMalloc(nSam * sizeof(int))) == NULL) || ((sTObj = (WlzObject **)AlcCalloc(nSam, sizeof(WlzObject *))) == NULL) || ((sSObj = (WlzObject **)AlcCalloc(nSam, sizeof(WlzObject *))) == NULL)) { errNum = WLZ_ERR_MEM_ALLOC; } } /* Compute subsampled objects and make sure the background value is zero. */ if(errNum == WLZ_ERR_NONE) { samIdx = 0; *samFac = 1; samFacV.vtX = samFacV.vtY = samFacStep; *(sTObj + 0) = WlzAssignObject(tObj, NULL); *(sSObj + 0) = WlzAssignObject(sObj, NULL); while((errNum == WLZ_ERR_NONE) && (++samIdx < nSam)) { *(samFac + samIdx) = *(samFac + samIdx - 1) * samFacStep; *(sTObj + samIdx) = WlzAssignObject( WlzSampleObj(*(sTObj + samIdx - 1), samFacV, WLZ_SAMPLEFN_GAUSS, &errNum), NULL); if(errNum == WLZ_ERR_NONE) { (void )WlzSetBackground(*(sTObj + samIdx), zeroBgd); *(sSObj + samIdx) = WlzAssignObject( WlzSampleObj(*(sSObj + samIdx - 1), samFacV, WLZ_SAMPLEFN_GAUSS, &errNum), NULL); } if(errNum == WLZ_ERR_NONE) { (void )WlzSetBackground(*(sSObj + samIdx), zeroBgd);
开发者ID:dscho,项目名称:Woolz,代码行数:67,
示例29: mainint main(int argc, char *argv[]){ int idC, idO, idP, option, ok = 1, usage = 0, mean = 0, stddev = 0, nObjs = 0, maxObjs = 0; FILE *fP = NULL; char *fStr, *outObjFileStr; const char *errMsgStr; WlzObject *inObj = NULL, *outObj = NULL; WlzObject **objs = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; static char optList[] = "hmso:"; const char fileStrDef[] = "-"; const int stepObjs = 1024; opterr = 0; outObjFileStr = (char *)fileStrDef; while(ok && ((option = getopt(argc, argv, optList)) != EOF)) { switch(option) { case 'o': outObjFileStr = optarg; break; case 'm': mean = 1; break; case 's': stddev = 1; break; case 'h': default: usage = 1; break; } } ok = !usage; if(ok) { if((outObjFileStr == NULL) || (*outObjFileStr == '/0')) { ok = 0; usage = 1; } } if(ok) { maxObjs += stepObjs; if((objs = AlcMalloc(maxObjs * sizeof(WlzObject *))) == NULL) { ok = 0; errNum = WLZ_ERR_MEM_ALLOC; } } /* Read objects from the command line. */ if(ok) { int nFiles; idO = 0; nFiles = argc - optind; while((errNum == WLZ_ERR_NONE) && (idO < nFiles)) { if(nObjs >= maxObjs) { maxObjs += stepObjs; if((objs = AlcRealloc(objs, stepObjs * sizeof(WlzObject *))) == NULL) { ok = 0; errNum = WLZ_ERR_MEM_ALLOC; break; } } if(ok) { fStr = *(argv + optind + idO); if((fP = (strcmp(fStr, "-")? fopen(fStr, "rb"): stdin)) == NULL) { errNum = WLZ_ERR_READ_EOF; } else { objs[nObjs] = WlzAssignObject( WlzReadObj(fP, &errNum), NULL); if(errNum == WLZ_ERR_NONE) { ++nObjs; } if(strcmp(fStr, "-")) { (void )fclose(fP);//.........这里部分代码省略.........
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
示例30: WlzAssignObject/*! * /ingroup WlzValuesFilters* /brief Gaussian filter of grey-level 2D woolz object. x- and y-coordinate width parameters and derivative degree can be independently specified. For derivative zero, i.e. Gaussian smoothing, the filter is normalised. Derivatives are derivative of the normalised filter. RGB data will only return values for smoothing, higher derivatives are not implemented. The width parameter is the full-width half-height of the Gaussian distribution. Note RGB pixel types are converted to a compound object with each channel returned with WLZ_GREY_SHORT pixel type.** /return Pointer to transformed object* /param obj Input object* /param wx x-direction width parameter* /param wy y-direction width parameter* /param x_deriv x-direction derivative* /param y_deriv y-direction derivative* /param wlzErr error return* /par Source:* WlzGauss.c*/WlzObject *WlzGauss2( WlzObject *obj, double wx, double wy, int x_deriv, int y_deriv, WlzErrorNum *wlzErr){ WlzObject *newobj=NULL; Wlz1DConvMask x_params, y_params; float alpha, sum; int i, n, value; WlzErrorNum errNum=WLZ_ERR_NONE; /* check object, don't need to check type etc. because WlzSepTrans does it */ if( obj == NULL ) { errNum = WLZ_ERR_OBJECT_NULL; } /* do need to check for rgb grey type */ if( errNum == WLZ_ERR_NONE ){ if( (obj->type == WLZ_2D_DOMAINOBJ) && (WlzGreyTypeFromObj(obj, &errNum) == WLZ_GREY_RGBA) ){ if( (x_deriv != 0) || (y_deriv != 0) ){ /* implement this using a compond object since the result should be a vector value */ WlzCompoundArray *cobj; if((cobj = WlzRGBAToCompound(obj, WLZ_RGBA_SPACE_RGB, &errNum)) != NULL){ /* need to convert each to short for gradient calc */ for(i=0; i < 3; i++){ WlzObject *tmpObj; tmpObj = cobj->o[i]; cobj->o[i] = WlzAssignObject(WlzConvertPix(tmpObj, WLZ_GREY_SHORT, &errNum), NULL); WlzFreeObj(tmpObj); } newobj = WlzGauss2((WlzObject *) cobj, wx, wy, x_deriv, y_deriv, &errNum); WlzFreeObj((WlzObject *) cobj); if( wlzErr ){ *wlzErr = errNum; } return newobj; } } } } /* now start work */ if( errNum == WLZ_ERR_NONE ){ alpha = (float )(4.0 * log((double )2.0)); /* set up x function parameters */ x_params.mask_size = (((int) wx * 4)/2)*2 + 1; if( (x_params.mask_values = (int *) AlcMalloc(sizeof(int) * x_params.mask_size)) == NULL){ errNum = WLZ_ERR_MEM_ALLOC; } else { n = x_params.mask_size / 2; switch( x_deriv ){ case 0: for(i=0, sum = -AFACTOR; i <= n; i++){ value = (int )(AFACTOR * exp(((double) -alpha*i*i/wx/wx))); *(x_params.mask_values+n-i) = value; *(x_params.mask_values+n+i) = value; sum += 2 * value; } x_params.norm_factor = sum; break; case 1://.........这里部分代码省略.........
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,
注:本文中的AlcMalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AlignLo函数代码示例 C++ AlcFree函数代码示例 |