int main(int argc, char *argv[]) { Nrrd *map, *ppm; NrrdRange *range; AIR_UNUSED(argc); me = argv[0]; if (limnEnvMapFill(map=nrrdNew(), cb, limnQN16checker, NULL)) { fprintf(stderr, "%s: trouble:\n%s", me, biffGet(LIMN)); exit(1); } range = nrrdRangeNew(0, 1); if (nrrdQuantize(ppm=nrrdNew(), map, range, 8)) { fprintf(stderr, "%s: trouble:\n%s", me, biffGet(NRRD)); exit(1); } if (nrrdSave("map.ppm", ppm, NULL)) { fprintf(stderr, "%s: trouble:\n%s", me, biffGet(NRRD)); exit(1); } nrrdNuke(map); nrrdNuke(ppm); nrrdRangeNix(range); exit(0); }
/* vector pp of parameters is as follows: ** pp[0]: principal eigenvalue ** pp[1]: fraction of 1st tensor ** pp[2]: phi for 1st tensor ** pp[3]: phi for 2nd tensor */ void _tenLevmarPeledCB(double *pp, double *xx, int mm, int nn, void *_pvlData) { /* char me[]="_tenLevmarPeledCB"; */ double tenA[7], tenB[7]; int ii; tenDwiGagePvlData *pvlData; double *egrad; AIR_UNUSED(mm); pvlData = AIR_CAST(tenDwiGagePvlData *, _pvlData); /* Form the tensors using the estimated parms */ _tenPeledRotate2D(tenA, pp[0], pvlData->ten1Eval[2], pp[2]); _tenPeledRotate2D(tenB, pp[0], pvlData->ten1Eval[2], pp[3]); egrad = AIR_CAST(double *, pvlData->nten1EigenGrads->data); /* skip past b0 gradient, HEY: not general purpose */ egrad += 3; for (ii=0; ii<nn; ii++) { double argA, argB, sigA, sigB; argA = -pvlData->tec2->bValue*TEN_T3V_CONTR(tenA, egrad + 3*ii); argB = -pvlData->tec2->bValue*TEN_T3V_CONTR(tenB, egrad + 3*ii); if (pvlData->levmarUseFastExp) { sigA = airFastExp(argA); sigB = airFastExp(argB); } else { sigA = exp(argA); sigB = exp(argB); } xx[ii] = pvlData->tec2->knownB0*(pp[1]*sigA + (1-pp[1])*sigB); } return; }
int _nrrdFormatPNM_contentStartsLike(NrrdIoState *nio) { AIR_UNUSED(nio); return AIR_FALSE; }
static char * parmSprint(char str[AIR_STRLEN_MED], const double *parm) { AIR_UNUSED(parm); sprintf(str, "constant 0"); return str; }
double _pullEnergyGaussEval(double *frc, double dist, const double *parm) { AIR_UNUSED(parm); *frc = _DGAUSS(dist, 0.25, 4); return _GAUSS(dist, 0.25, 4); }
int _baneClipAnswer_Absolute(int *countP, Nrrd *hvol, double *clipParm) { AIR_UNUSED(hvol); *countP = (int)(clipParm[0]); return 0; }
static int _nrrdEncodingZRL_read(FILE *file, void *data, size_t elementNum, Nrrd *nrrd, NrrdIoState *nio) { AIR_UNUSED(nio); unsigned char *output_buffer = (unsigned char *) data; size_t toread = elementNum*nrrdElementSize(nrrd); /* static const char me[]="_nrrdEncodingZRL_read"; printf("!%s: looking for %u values (%u bytes) of type %s\n", me, (unsigned int)elementNum, (unsigned int)toread, airEnumStr(nrrdType, nrrd->type)); */ int cc, dd; unsigned int j = 0; while (j < toread) { cc = fgetc(file); if (cc == 0) { dd = fgetc(file); if (dd == 0) { dd = fgetc(file); j += dd + fgetc(file)*256; } else { j += (unsigned char)dd; } } else { output_buffer[j] = (unsigned char)cc; j++; } } return 0; }
static int _nrrdEncodingUnknown_write(FILE *file, const void *data, size_t elementNum, const Nrrd *nrrd, struct NrrdIoState_t *nio) { static const char me[]="_nrrdEncodingUnknown_write"; /* insert code here, and remove error handling below */ AIR_UNUSED(file); AIR_UNUSED(data); AIR_UNUSED(elementNum); AIR_UNUSED(nrrd); AIR_UNUSED(nio); biffAddf(NRRD, "%s: ERROR!!! trying to write unknown encoding", me); return 1; }
int main(int argc, char *argv[]) { char *me, *err; FILE *file; limnPolyData *lmpd; AIR_UNUSED(argc); me = argv[0]; lmpd = limnPolyDataNew(); file = fopen("in.lmpd", "r"); if (limnPolyDataReadLMPD(lmpd, file)) { err = biffGetDone(LIMN), fprintf(stderr, "%s: trouble:\n%s\n", me, err); return 1; } fclose(file); file = fopen("out.vtk", "w"); if (limnPolyDataWriteVTK(file, lmpd)) { err = biffGetDone(LIMN); fprintf(stderr, "%s: trouble:\n%s\n", me, err); return 1; } fclose(file); return 0; }
void _tenDwiGageAnswer(gageContext *ctx, gagePerVolume *pvl) { AIR_UNUSED(ctx); AIR_UNUSED(pvl); #if 0 char me[]="_tenDwiGageAnswer"; unsigned int dwiIdx; tenDwiGageKindData *kindData; gage_t *dwiAll, dwiMean=0; kindData = AIR_CAST(tenDwiGageKindData *, pvl->kind->data); dwiAll = pvl->directAnswer[tenDwiGageAll]; if (GAGE_QUERY_ITEM_TEST(pvl->query, tenDwiGageAll)) { /* done if doV */ if (ctx->verbose) { for (dwiIdx=0; dwiIdx<kindData->num; dwiIdx++) { fprintf(stderr, "%s: dwi[%u] = %g\n", me, dwiIdx, dwiAll[dwiIdx]); } } } /* if (GAGE_QUERY_ITEM_TEST(pvl->query, tenDwiGageB0)) { done if doV } */ if (GAGE_QUERY_ITEM_TEST(pvl->query, tenDwiGageMeanDwiValue)) { dwiMean = 0; for (dwiIdx=1; dwiIdx<kindData->num; dwiIdx++) { dwiMean += dwiAll[dwiIdx]; } dwiMean /= 1.0f/(kindData->num - 1); pvl->directAnswer[tenDwiGageMeanDwiValue][0] = dwiMean; } if (GAGE_QUERY_ITEM_TEST(pvl->query, tenDwiGageTensorLLS)) { #if GAGE_TYPE_FLOAT tenEstimateLinearSingle_f #else tenEstimateLinearSingle_d #endif (pvl->directAnswer[tenDwiGageTensorLLS], NULL, dwiAll, AIR_CAST(double *, kindData->nemat->data), /* pvlData->vbuf */ NULL, kindData->num, AIR_TRUE, kindData->dwiConfThresh, kindData->dwiConfSoft, kindData->bval); }
int _nrrdFormatUnknown_nameLooksLike(const char *filename) { /* insert code here */ AIR_UNUSED(filename); return AIR_FALSE; }
double _pushEnergyUnknownSupport(const double *parm) { char me[]="_pushEnergyUnknownSupport"; AIR_UNUSED(parm); fprintf(stderr, "%s: ERROR- using unknown energy.\n", me); return AIR_NAN; }
/* ** the bin loses track of the point, caller responsible for ownership, ** even though caller never identifies it by pointer, which is weird */ void _pullBinPointRemove(pullContext *pctx, pullBin *bin, int loseIdx) { AIR_UNUSED(pctx); bin->point[loseIdx] = bin->point[bin->pointNum-1]; airArrayLenIncr(bin->pointArr, -1); return; }
/* ** _gageStandardNixer() ** ********************************************************* ** as of about Wed Apr 20 19:32:54 EDT 2005, this is moot ********************************************************* ** ** the usual/default nixer used in gage, which is a simple wrapper ** around nrrdNuke at this point, although other things could be ** implemented later ... ** ** The "kind" and "_info" pointers are ignored. ** ** Nixers must gracefully handle being handed a NULL npad. ** ** The intention is that nixers cannot generate errors, so the return ** is void, and no nixer should accumulate errors in biff. This nixer ** is a shining example of this. */ void _gageStandardNixer (Nrrd *npad, gageKind *kind, gagePerVolume *pvl) { AIR_UNUSED(kind); if (npad != pvl->nin) { nrrdNuke(npad); } }
double _nrrdWindSincInt(const double *parm) { AIR_UNUSED(parm); /* This isn't true, but there aren't good accurate, closed-form approximations for these integrals ... */ return 1.0; }
int _nrrdEncodingUnknown_read(FILE *file, void *data, size_t elementNum, Nrrd *nrrd, struct NrrdIoState_t *nio) { char me[]="_nrrdEncodingUnknown_read", err[BIFF_STRLEN]; /* insert code here, and remove error handling below */ AIR_UNUSED(file); AIR_UNUSED(data); AIR_UNUSED(elementNum); AIR_UNUSED(nrrd); AIR_UNUSED(nio); sprintf(err, "%s: ERROR!!! trying to read unknown encoding", me); biffAdd(NRRD, err); return 1; }
void _coilKind7TensorTangents(coil_t traceGrad[6], coil_t varianceGrad[6], coil_t skewGrad[6], coil_t rot0Grad[6], coil_t rot1Grad[6], coil_t rot2Grad[6], coil_t tensor[7]) { AIR_UNUSED(traceGrad); AIR_UNUSED(varianceGrad); AIR_UNUSED(skewGrad); AIR_UNUSED(rot0Grad); AIR_UNUSED(rot1Grad); AIR_UNUSED(rot2Grad); AIR_UNUSED(tensor); /* coil_t a, b, c, d, e, f; a = tensor[1]; b = tensor[2]; c = tensor[3]; d = tensor[4]; e = tensor[5]; f = tensor[6]; ELL_6V_SET(traceGrad, 1, 0, 0, 1, 0, 1); */ }
int miteRayBegin(miteThread *mtt, miteRender *mrr, miteUser *muu, int uIndex, int vIndex, double rayLen, double rayStartWorld[3], double rayStartIndex[3], double rayDirWorld[3], double rayDirIndex[3]) { airPtrPtrUnion appu; AIR_UNUSED(mrr); AIR_UNUSED(rayStartWorld); AIR_UNUSED(rayStartIndex); AIR_UNUSED(rayDirIndex); mtt->ui = uIndex; mtt->vi = vIndex; mtt->rayStep = (muu->rayStep*rayLen / (muu->hctx->cam->vspFaar - muu->hctx->cam->vspNeer)); if (!uIndex) { fprintf(stderr, "%d/%d ", vIndex, muu->hctx->imgSize[1]); fflush(stderr); } mtt->verbose = (uIndex == muu->verbUi && vIndex == muu->verbVi); mtt->skip = (muu->verbUi >= 0 && muu->verbVi >= 0 && !mtt->verbose); if (mtt->verbose) { /* create muu->ndebug */ muu->ndebug = nrrdNew(); /* we want to store the value and index for each txf domain variable, plus the RGBAZ computed for that sample */ muu->ndebug->axis[0].size = 2*mtt->stageNum + 5; /* we really do want to associate ndebug with the miteUser's mop, because the information stored in it has to persist for as long as the user wants: mite itself doesn't call miteUserNix */ airMopAdd(muu->umop, muu->ndebug, (airMopper)nrrdNuke, airMopAlways); /* but the scope of the debug array allocation is within this ray */ muu->debugArr = airArrayNew((appu.d = &(muu->debug), appu.v), NULL, sizeof(double), 128); } mtt->raySample = 0; mtt->RR = mtt->GG = mtt->BB = 0.0; mtt->TT = 1.0; mtt->ZZ = AIR_NAN; ELL_3V_SCALE(mtt->V, -1, rayDirWorld); return 0; }
/* ** this makes the bin the owner of the point */ void _pullBinPointAdd(pullContext *pctx, pullBin *bin, pullPoint *point) { int pntI; AIR_UNUSED(pctx); pntI = airArrayLenIncr(bin->pointArr, 1); bin->point[pntI] = point; return; }
int _nrrdReadNrrdParse_encoding (FILE *file, Nrrd *nrrd, NrrdIoState *nio, int useBiff) { char me[]="_nrrdReadNrrdParse_encoding", err[BIFF_STRLEN]; char *info; int etype; AIR_UNUSED(file); AIR_UNUSED(nrrd); info = nio->line + nio->pos; if (!(etype = airEnumVal(nrrdEncodingType, info))) { sprintf(err, "%s: couldn't parse encoding \"%s\"", me, info); biffMaybeAdd(NRRD, err, useBiff); return 1; } nio->encoding = nrrdEncodingArray[etype]; return 0; }
int _nrrdReadNrrdParse_nonfield (FILE *file, Nrrd *nrrd, NrrdIoState *nio, int useBiff) { AIR_UNUSED(file); AIR_UNUSED(nrrd); AIR_UNUSED(nio); AIR_UNUSED(useBiff); /* char c; c= 10; write(2,&c,1); c= 69; write(2,&c,1); c=108; write(2,&c,1); c= 32; write(2,&c,1); c= 67; write(2,&c,1); c=104; write(2,&c,1); c=101; write(2,&c,1); c= 32; write(2,&c,1); c= 86; write(2,&c,1); c=105; write(2,&c,1); c=118; write(2,&c,1); c=101; write(2,&c,1); c= 33; write(2,&c,1); c= 10; write(2,&c,1); c= 10; write(2,&c,1); */ return 0; }
int _nrrdReadNrrdParse_line_skip (FILE *file, Nrrd *nrrd, NrrdIoState *nio, int useBiff) { char me[]="_nrrdReadNrrdParse_line_skip", err[BIFF_STRLEN]; char *info; AIR_UNUSED(file); AIR_UNUSED(nrrd); info = nio->line + nio->pos; _PARSE_ONE_VAL(nio->lineSkip, "%u", "unsigned int"); /* now that its unsigned, what error checking can I do? if (!(0 <= nio->lineSkip)) { sprintf(err, "%s: lineSkip value %d invalid", me, nio->lineSkip); biffMaybeAdd(NRRD, err, useBiff); return 1; } */ return 0; }
void plotEpilog(plotPS *pps, plotParm *pparm) { AIR_UNUSED(pparm); fprintf(pps->file, "grestore\n"); fprintf(pps->file, "grestore\n"); fprintf(pps->file, "%%%%Trailer\n"); return; }
void plotLine(plotPS *pps, plotParm *pparm, double x0, double y0, double x1, double y1) { AIR_UNUSED(pparm); fprintf(pps->file, "%g %g M\n", PPS_X(x0), PPS_Y(y0)); fprintf(pps->file, "%g %g L S\n", PPS_X(x1), PPS_Y(y1)); return; }
double _nrrdApplyDomainMin(const Nrrd *nmap, int ramps, int mapAxis) { double ret; AIR_UNUSED(ramps); ret = nmap->axis[mapAxis].min; ret = AIR_EXISTS(ret) ? ret : 0; return ret; }
/* ******** gageQuerySet() ** ** sets a query in a pervolume. Does recursive expansion of query ** to cover all prerequisite measures. ** ** Sets: pvl->query ** ** the gageContext is not actually used here, but I'm cautiously ** including it in case its used in the future. */ int gageQuerySet(gageContext *ctx, gagePerVolume *pvl, gageQuery query) { char me[]="gageQuerySet", err[BIFF_STRLEN]; gageQuery lastQuery; int pi, ii; AIR_UNUSED(ctx); if (!( pvl )) { sprintf(err, "%s: got NULL pointer", me); biffAdd(GAGE, err); return 1; } GAGE_QUERY_COPY(pvl->query, query); if (pvl->verbose) { fprintf(stderr, "%s: original ", me); gageQueryPrint(stderr, pvl->kind, pvl->query); } /* recursive expansion of prerequisites */ do { GAGE_QUERY_COPY(lastQuery, pvl->query); ii = pvl->kind->itemMax+1; do { ii--; if (GAGE_QUERY_ITEM_TEST(pvl->query, ii)) { for (pi=0; pi<GAGE_ITEM_PREREQ_MAXNUM; pi++) { if (0 != pvl->kind->table[ii].prereq[pi]) { GAGE_QUERY_ITEM_ON(pvl->query, pvl->kind->table[ii].prereq[pi]); } } } } while (ii); } while (!GAGE_QUERY_EQUAL(pvl->query, lastQuery)); if (pvl->verbose) { fprintf(stderr, "%s: expanded ", me); gageQueryPrint(stderr, pvl->kind, pvl->query); } /* doing this kind of error checking here is not really the way gage should work-- it should be done at the time of gageUpdate()-- but the novelty of pvl->data encourages putting new smarts at superficial levels instead of deeper levels */ if (!pvl->data) { for (ii=1; ii<=pvl->kind->itemMax; ii++) { if (GAGE_QUERY_ITEM_TEST(pvl->query, ii) && pvl->kind->table[ii].needData) { sprintf(err, "%s: item %d (%s) needs data, but pvl->data is NULL", me, ii, airEnumStr(pvl->kind->enm, ii)); biffAdd(GAGE, err); return 1; } } } pvl->flag[gagePvlFlagQuery] = AIR_TRUE; return 0; }
int _nrrdEncodingAscii_read(FILE *file, void *_data, size_t elNum, Nrrd *nrrd, NrrdIoState *nio) { static const char me[]="_nrrdEncodingAscii_read"; char numbStr[AIR_STRLEN_HUGE]; /* HEY: fix this */ char *nstr; size_t I; char *data; int tmp; AIR_UNUSED(nio); if (nrrdTypeBlock == nrrd->type) { biffAddf(NRRD, "%s: can't read nrrd type %s from %s", me, airEnumStr(nrrdType, nrrdTypeBlock), nrrdEncodingAscii->name); return 1; } data = (char*)_data; I = 0; while (I < elNum) { if (1 != fscanf(file, "%s", numbStr)) { biffAddf(NRRD, "%s: couldn't parse element " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV, me, I+1, elNum); return 1; } if (!strcmp(",", numbStr)) { /* its an isolated comma, not a value, pass over this */ continue; } /* get past any commas prefixing a number (without space) */ nstr = numbStr + strspn(numbStr, ","); if (nrrd->type >= nrrdTypeInt) { /* sscanf supports putting value directly into this type */ if (1 != airSingleSscanf(nstr, nrrdTypePrintfStr[nrrd->type], (void*)(data + I*nrrdElementSize(nrrd)))) { biffAddf(NRRD, "%s: couln't parse %s " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " (\"%s\")", me, airEnumStr(nrrdType, nrrd->type), I+1, elNum, nstr); return 1; } } else { /* sscanf value into an int first */ if (1 != airSingleSscanf(nstr, "%d", &tmp)) { biffAddf(NRRD, "%s: couln't parse element " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " (\"%s\")", me, I+1, elNum, nstr); return 1; } nrrdIInsert[nrrd->type](data, I, tmp); } I++; } return 0; }
int airThreadCondBroadcast(airThreadCond *cond) { char me[]="airThreadCondBroadcast"; AIR_UNUSED(cond); if (airThreadNoopWarning) { fprintf(stderr, "%s: WARNING: all cond usage is a no-op!\n", me); } return 0; }
int airThreadMutexUnlock(airThreadMutex *mutex) { char me[]="airThreadMutexUnlock"; AIR_UNUSED(mutex); if (airThreadNoopWarning) { fprintf(stderr, "%s: WARNING: all mutex usage is a no-op!\n", me); } return 0; }
int _echoRayIntx_Triangle(RAYINTX_ARGS(Triangle)) { echoPos_t pvec[3], qvec[3], tvec[3], det, t, u, v, edge0[3], edge1[3], tmp; AIR_UNUSED(parm); AIR_UNUSED(tstate); ELL_3V_SUB(edge0, obj->vert[1], obj->vert[0]); ELL_3V_SUB(edge1, obj->vert[2], obj->vert[0]); TRI_INTX(ray, obj->vert[0], edge0, edge1, pvec, qvec, tvec, det, t, u, v, (v < 0.0 || u + v > 1.0), return AIR_FALSE); intx->t = t; intx->u = u; intx->v = v; ELL_3V_CROSS(intx->norm, edge0, edge1); ELL_3V_NORM(intx->norm, intx->norm, tmp); intx->obj = (echoObject *)obj; /* DOES set u, v */ return AIR_TRUE; }