From: <kin...@us...> - 2010-06-10 09:41:00
|
Revision: 4626 http://teem.svn.sourceforge.net/teem/?rev=4626&view=rev Author: kindlmann Date: 2010-06-10 09:40:54 +0000 (Thu, 10 Jun 2010) Log Message: ----------- added NrrdIoState->skipFormatURL to optionally turn off advertisement of URL for NRRD format info, also added nrrdSpaceVecExists and nrrdSpaceVecSetZero Modified Paths: -------------- teem/trunk/src/nrrd/formatNRRD.c teem/trunk/src/nrrd/methodsNrrd.c teem/trunk/src/nrrd/nrrd.h teem/trunk/src/nrrd/simple.c Modified: teem/trunk/src/nrrd/formatNRRD.c =================================================================== --- teem/trunk/src/nrrd/formatNRRD.c 2010-06-04 17:25:20 UTC (rev 4625) +++ teem/trunk/src/nrrd/formatNRRD.c 2010-06-10 09:40:54 UTC (rev 4626) @@ -551,17 +551,19 @@ } /* write the advertisement about where to get the file format */ - if (file) { - fprintf(file, "# %s\n", _nrrdFormatURLLine0); - fprintf(file, "# %s\n", _nrrdFormatURLLine1); - } else if (nio->headerStringWrite) { - sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); - strcat(nio->headerStringWrite, strbuf); - sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); - strcat(nio->headerStringWrite, strbuf); - } else { - nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); - nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); + if (!nio->skipFormatURL) { + if (file) { + fprintf(file, "# %s\n", _nrrdFormatURLLine0); + fprintf(file, "# %s\n", _nrrdFormatURLLine1); + } else if (nio->headerStringWrite) { + sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); + strcat(nio->headerStringWrite, strbuf); + sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); + strcat(nio->headerStringWrite, strbuf); + } else { + nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); + nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); + } } /* this is where the majority of the header printing happens */ Modified: teem/trunk/src/nrrd/methodsNrrd.c =================================================================== --- teem/trunk/src/nrrd/methodsNrrd.c 2010-06-04 17:25:20 UTC (rev 4625) +++ teem/trunk/src/nrrd/methodsNrrd.c 2010-06-10 09:40:54 UTC (rev 4626) @@ -89,6 +89,7 @@ nio->charsPerLine = nrrdDefaultWriteCharsPerLine; nio->valsPerLine = nrrdDefaultWriteValsPerLine; nio->skipData = AIR_FALSE; + nio->skipFormatURL = AIR_FALSE; nio->keepNrrdDataFileOpen = AIR_FALSE; nio->zlibLevel = -1; nio->zlibStrategy = nrrdZlibStrategyDefault; Modified: teem/trunk/src/nrrd/nrrd.h =================================================================== --- teem/trunk/src/nrrd/nrrd.h 2010-06-04 17:25:20 UTC (rev 4625) +++ teem/trunk/src/nrrd/nrrd.h 2010-06-10 09:40:54 UTC (rev 4626) @@ -387,6 +387,9 @@ datafiles). Warning: can result in broken noncomformant files. (be careful with this) */ + skipFormatURL, /* if non-zero for NRRD format ON WRITE: + skip the comment lines that document where + to find the NRRD file format specs */ keepNrrdDataFileOpen, /* ON READ: when there is only a single dataFile, don't close nio->dataFile when you otherwise would, when reading the @@ -849,7 +852,10 @@ const double vec[NRRD_SPACE_DIM_MAX]); NRRD_EXPORT double nrrdSpaceVecNorm(int sdim, const double vec[NRRD_SPACE_DIM_MAX]); +NRRD_EXPORT int nrrdSpaceVecExists(int sdim, + double vec[NRRD_SPACE_DIM_MAX]); NRRD_EXPORT void nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]); +NRRD_EXPORT void nrrdSpaceVecSetZero(double vec[NRRD_SPACE_DIM_MAX]); NRRD_EXPORT void nrrdZeroSet(Nrrd *nout); /******** comments related */ Modified: teem/trunk/src/nrrd/simple.c =================================================================== --- teem/trunk/src/nrrd/simple.c 2010-06-04 17:25:20 UTC (rev 4625) +++ teem/trunk/src/nrrd/simple.c 2010-06-10 09:40:54 UTC (rev 4626) @@ -374,6 +374,16 @@ return; } +void +nrrdSpaceVecSetZero(double vec[NRRD_SPACE_DIM_MAX]) { + int di; + + for (di=0; di<NRRD_SPACE_DIM_MAX; di++) { + vec[di] = 0; + } + return; +} + /* ** _nrrdContentGet ** @@ -556,6 +566,17 @@ } } +int +nrrdSpaceVecExists(int sdim, double vec[NRRD_SPACE_DIM_MAX]) { + int ii, exists; + + exists = AIR_EXISTS(vec[0]); + for (ii=1; ii<sdim; ii++) { + exists &= AIR_EXISTS(vec[ii]); + } + return exists; +} + /* ** asserts all the properties associated with orientation information ** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |